mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Polish integration tests
This commit is contained in:
+2
-2
@@ -380,7 +380,7 @@ class UtilNamespaceHandlerTests {
|
||||
|
||||
|
||||
// For DependencyDescriptor resolution
|
||||
private Map<String, TestBean> mapWithRef;
|
||||
private Map<String, TestBean> mapWithTypes;
|
||||
Map<String, TestBean> mapWithRef;
|
||||
Map<String, TestBean> mapWithTypes;
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -134,20 +134,15 @@ class ResourceElementResolverMethodTests {
|
||||
|
||||
private String one;
|
||||
|
||||
private String test;
|
||||
|
||||
private Integer count;
|
||||
|
||||
public void setOne(String one) {
|
||||
this.one = one;
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
public void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ class PeriodicTriggerTests {
|
||||
void equalsVerification() {
|
||||
PeriodicTrigger trigger1 = new PeriodicTrigger(Duration.ofMillis(3000));
|
||||
PeriodicTrigger trigger2 = new PeriodicTrigger(Duration.ofMillis(3000));
|
||||
assertThat(trigger1.equals(new String("not a trigger"))).isFalse();
|
||||
assertThat(trigger1).isNotEqualTo(new String("not a trigger"));
|
||||
assertThat(trigger1).isNotEqualTo(null);
|
||||
assertThat(trigger1).isEqualTo(trigger1);
|
||||
assertThat(trigger2).isEqualTo(trigger2);
|
||||
|
||||
+15
-29
@@ -60,18 +60,13 @@ class BshScriptFactoryTests {
|
||||
Calculator calc = (Calculator) ctx.getBean("calculator");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
|
||||
boolean condition3 = calc instanceof Refreshable;
|
||||
assertThat(condition3).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
boolean condition2 = messenger instanceof Refreshable;
|
||||
assertThat(condition2).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(calc).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(calc).isEqualTo(calc);
|
||||
assertThat(messenger).isEqualTo(messenger);
|
||||
boolean condition1 = !messenger.equals(calc);
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
|
||||
boolean condition = !messenger.toString().equals(calc.toString());
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger.toString()).isNotEqualTo(calc.toString());
|
||||
|
||||
assertThat(calc.add(2, 3)).isEqualTo(5);
|
||||
|
||||
@@ -144,8 +139,7 @@ class BshScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(messenger2).isNotSameAs(messenger);
|
||||
assertThat(messenger2.getClass()).isSameAs(messenger.getClass());
|
||||
@@ -164,8 +158,7 @@ class BshScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Should be an instance of Refreshable").isTrue();
|
||||
assertThat(messenger).as("Should be an instance of Refreshable").isInstanceOf(Refreshable.class);
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -185,8 +178,7 @@ class BshScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Should be an instance of Refreshable").isTrue();
|
||||
assertThat(messenger).as("Should be an instance of Refreshable").isInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
assertThat(messenger2.getMessage()).isEqualTo("Hello World!");
|
||||
@@ -206,9 +198,9 @@ class BshScriptFactoryTests {
|
||||
|
||||
@Test
|
||||
void scriptCompilationException() {
|
||||
assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml"))
|
||||
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
||||
assertThatExceptionOfType(NestedRuntimeException.class)
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml"))
|
||||
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,20 +219,17 @@ class BshScriptFactoryTests {
|
||||
|
||||
@Test
|
||||
void ctorWithNullScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new BshScriptFactory(null, Messenger.class));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new BshScriptFactory(null, Messenger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ctorWithEmptyScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new BshScriptFactory("", Messenger.class));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new BshScriptFactory("", Messenger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ctorWithWhitespacedScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new BshScriptFactory("\n ", Messenger.class));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new BshScriptFactory("\n ", Messenger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -255,8 +244,7 @@ class BshScriptFactoryTests {
|
||||
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).isFalse();
|
||||
assertThat(messenger).isNotInstanceOf(Refreshable.class);
|
||||
|
||||
Messenger messengerImpl = (Messenger) ctx.getBean("messengerImpl");
|
||||
assertThat(messengerImpl.getMessage()).isEqualTo("Hello World!");
|
||||
@@ -305,8 +293,7 @@ class BshScriptFactoryTests {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||
Calculator calculator = (Calculator) ctx.getBean("calculator");
|
||||
assertThat(calculator).isNotNull();
|
||||
boolean condition = calculator instanceof Refreshable;
|
||||
assertThat(condition).isFalse();
|
||||
assertThat(calculator).isNotInstanceOf(Refreshable.class);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@@ -315,8 +302,7 @@ class BshScriptFactoryTests {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Messenger should be Refreshable").isTrue();
|
||||
assertThat(messenger).as("Messenger should be Refreshable").isInstanceOf(Refreshable.class);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
+26
-53
@@ -78,18 +78,14 @@ public class GroovyScriptFactoryTests {
|
||||
assertThat(AopUtils.isAopProxy(calc)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
|
||||
boolean condition3 = calc instanceof Refreshable;
|
||||
assertThat(condition3).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
boolean condition2 = messenger instanceof Refreshable;
|
||||
assertThat(condition2).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(calc instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
assertThat(calc).isEqualTo(calc);
|
||||
assertThat(messenger).isEqualTo(messenger);
|
||||
boolean condition1 = !messenger.equals(calc);
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(messenger).isNotEqualTo(calc);
|
||||
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
|
||||
boolean condition = !messenger.toString().equals(calc.toString());
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger.toString()).isNotEqualTo(calc.toString());
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -111,18 +107,14 @@ public class GroovyScriptFactoryTests {
|
||||
assertThat(AopUtils.isAopProxy(calc)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
|
||||
boolean condition3 = calc instanceof Refreshable;
|
||||
assertThat(condition3).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
boolean condition2 = messenger instanceof Refreshable;
|
||||
assertThat(condition2).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(calc instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
assertThat(calc).isEqualTo(calc);
|
||||
assertThat(messenger).isEqualTo(messenger);
|
||||
boolean condition1 = !messenger.equals(calc);
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(messenger).isNotEqualTo(calc);
|
||||
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
|
||||
boolean condition = !messenger.toString().equals(calc.toString());
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger.toString()).isNotEqualTo(calc.toString());
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -138,8 +130,7 @@ public class GroovyScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
assertThat(messenger2).isNotSameAs(messenger);
|
||||
assertThat(messenger2.getClass()).isSameAs(messenger.getClass());
|
||||
@@ -158,8 +149,7 @@ public class GroovyScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
assertThat(messenger2).isNotSameAs(messenger);
|
||||
assertThat(messenger2.getClass()).isSameAs(messenger.getClass());
|
||||
@@ -178,8 +168,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -193,8 +182,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -208,8 +196,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -223,8 +210,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -237,8 +223,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Should be an instance of Refreshable").isTrue();
|
||||
assertThat(messenger instanceof Refreshable).as("Should be an instance of Refreshable").isTrue();
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -257,8 +242,7 @@ public class GroovyScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).as("Should be an instance of Refreshable").isTrue();
|
||||
assertThat(messenger instanceof Refreshable).as("Should be an instance of Refreshable").isTrue();
|
||||
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
assertThat(messenger2.getMessage()).isEqualTo("Hello World!");
|
||||
@@ -371,8 +355,7 @@ public class GroovyScriptFactoryTests {
|
||||
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).isFalse();
|
||||
assertThat(messenger instanceof Refreshable).isFalse();
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(0);
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(1);
|
||||
@@ -404,8 +387,7 @@ public class GroovyScriptFactoryTests {
|
||||
assertThat(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")).isTrue();
|
||||
Calculator calculator = (Calculator) ctx.getBean("calculator");
|
||||
assertThat(calculator).isNotNull();
|
||||
boolean condition = calculator instanceof Refreshable;
|
||||
assertThat(condition).isFalse();
|
||||
assertThat(calculator instanceof Refreshable).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -417,8 +399,7 @@ public class GroovyScriptFactoryTests {
|
||||
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger instanceof Refreshable).isTrue();
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(0);
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(1);
|
||||
@@ -435,8 +416,7 @@ public class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger instanceof Refreshable).isTrue();
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
|
||||
assertThat(ctx.getBeansOfType(ConcreteMessenger.class)).containsValue((ConcreteMessenger) messenger);
|
||||
@@ -487,8 +467,7 @@ public class GroovyScriptFactoryTests {
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger");
|
||||
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
||||
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
|
||||
boolean condition = messenger instanceof Refreshable;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(messenger instanceof Refreshable).isTrue();
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
}
|
||||
|
||||
@@ -542,20 +521,17 @@ public class GroovyScriptFactoryTests {
|
||||
// expect the exception we threw in the custom metaclass to show it got invoked
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile);
|
||||
Calculator calc = (Calculator) ctx.getBean("delegatingCalculator");
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
calc.add(1, 2))
|
||||
.withMessage("Gotcha");
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> calc.add(1, 2))
|
||||
.withMessage("Gotcha");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFactoryBean() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
Object factory = context.getBean("&factory");
|
||||
boolean condition1 = factory instanceof FactoryBean;
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(factory instanceof FactoryBean).isTrue();
|
||||
Object result = context.getBean("factory");
|
||||
boolean condition = result instanceof String;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(result).isEqualTo("test");
|
||||
}
|
||||
|
||||
@@ -563,11 +539,8 @@ public class GroovyScriptFactoryTests {
|
||||
void testRefreshableFactoryBean() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
Object factory = context.getBean("&refreshableFactory");
|
||||
boolean condition1 = factory instanceof FactoryBean;
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(factory instanceof FactoryBean).isTrue();
|
||||
Object result = context.getBean("refreshableFactory");
|
||||
boolean condition = result instanceof String;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(result).isEqualTo("test");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user