Apply and enforce spring-javaformat
This commit is contained in:
committed by
Dave Syer
parent
ad60397400
commit
7254dc8be7
@@ -24,25 +24,24 @@ public class ScopingTests {
|
||||
|
||||
@Test
|
||||
public void verifyScopes() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ScopingTestsConfig.class);
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScopingTestsConfig.class);
|
||||
SomeSingletonDependency someSingletonDependency1 = context.getBean(SomeSingletonDependency.class);
|
||||
SomeSingletonDependency someSingletonDependency2 = context.getBean(SomeSingletonDependency.class);
|
||||
|
||||
|
||||
assertNotNull(someSingletonDependency1);
|
||||
assertNotNull(someSingletonDependency2);
|
||||
assertEquals(someSingletonDependency1, someSingletonDependency2);
|
||||
|
||||
|
||||
SomeNoScopeDependency someNoScopeDependency1 = context.getBean(SomeNoScopeDependency.class);
|
||||
SomeNoScopeDependency someNoScopeDependency2 = context.getBean(SomeNoScopeDependency.class);
|
||||
|
||||
|
||||
assertNotNull(someNoScopeDependency1);
|
||||
assertNotNull(someNoScopeDependency2);
|
||||
assertNotEquals(someNoScopeDependency1, someNoScopeDependency2);
|
||||
|
||||
|
||||
SomeCustomScopeDependency someCustomScopeDependency1 = context.getBean(SomeCustomScopeDependency.class);
|
||||
SomeCustomScopeDependency someCustomScopeDependency2 = context.getBean(SomeCustomScopeDependency.class);
|
||||
|
||||
|
||||
assertNotNull(someCustomScopeDependency1);
|
||||
assertNotNull(someCustomScopeDependency2);
|
||||
assertNotEquals(someCustomScopeDependency1, someCustomScopeDependency2);
|
||||
@@ -52,16 +51,30 @@ public class ScopingTests {
|
||||
context.close();
|
||||
}
|
||||
|
||||
public static class SomeSingletonDependency {}
|
||||
public static class SomeNoScopeDependency {}
|
||||
public static class SomeCustomScopeDependency {
|
||||
String value;
|
||||
public SomeCustomScopeDependency() {}
|
||||
public SomeCustomScopeDependency(String value) {
|
||||
this.value=value;
|
||||
}
|
||||
public static class SomeSingletonDependency {
|
||||
|
||||
}
|
||||
|
||||
public static class SomeNoScopeDependency {
|
||||
|
||||
}
|
||||
|
||||
public static class SomeCustomScopeDependency {
|
||||
|
||||
String value;
|
||||
|
||||
public SomeCustomScopeDependency() {
|
||||
}
|
||||
|
||||
public SomeCustomScopeDependency(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface CustomScope extends Scope {
|
||||
|
||||
}
|
||||
public interface CustomScope extends Scope {}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,17 +87,19 @@ class ScopingTestsConfig {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
CustomScope customScope = new CustomScope(){
|
||||
CustomScope customScope = new CustomScope() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
|
||||
Provider<?> provider = () -> new SomeCustomScopeDependency("custom");
|
||||
return (Provider<T>) provider;
|
||||
}};
|
||||
}
|
||||
};
|
||||
bind(SomeSingletonDependency.class).asEagerSingleton();
|
||||
bind(SomeNoScopeDependency.class);
|
||||
bind(SomeCustomScopeDependency.class).in(customScope);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user