Convert assertThat(x instanceof X).isTrue() to assertThat(x).isInstanceOf()

Search:  assertThat\((.+?) instanceof (.+?)\)(.*?)\.isTrue\(\)

Replace: assertThat($1)$3.isInstanceOf($2.class)

See gh-36504
This commit is contained in:
Sam Brannen
2026-03-20 10:54:23 +01:00
parent 4357bbd31b
commit a40ec44cb7
70 changed files with 176 additions and 175 deletions
@@ -66,7 +66,7 @@ class BeanNamePointcutAtAspectTests {
@Test
void matchingBeanName() {
assertThat(testBean1 instanceof Advised).as("Expected a proxy").isTrue();
assertThat(testBean1).as("Expected a proxy").isInstanceOf(Advised.class);
// Call two methods to test for SPR-3953-like condition
testBean1.setAge(20);
@@ -94,7 +94,7 @@ class BeanNamePointcutAtAspectTests {
ITestBean proxyTestBean = factory.getProxy();
assertThat(proxyTestBean instanceof Advised).as("Expected a proxy").isTrue();
assertThat(proxyTestBean).as("Expected a proxy").isInstanceOf(Advised.class);
proxyTestBean.setAge(20);
assertThat(myCounterAspect.count).as("Programmatically created proxy shouldn't match bean()").isEqualTo(0);
}
@@ -75,7 +75,7 @@ class BeanNamePointcutTests {
@Test
void matchingBeanName() {
assertThat(this.testBean1 instanceof Advised).as("Matching bean must be advised (proxied)").isTrue();
assertThat(this.testBean1).as("Matching bean must be advised (proxied)").isInstanceOf(Advised.class);
// Call two methods to test for SPR-3953-like condition
this.testBean1.setAge(20);
this.testBean1.setName("");
@@ -96,7 +96,7 @@ class BeanNamePointcutTests {
@Test
void matchingFactoryBeanObject() {
assertThat(this.testFactoryBean1 instanceof Advised).as("Matching bean must be advised (proxied)").isTrue();
assertThat(this.testFactoryBean1).as("Matching bean must be advised (proxied)").isInstanceOf(Advised.class);
assertThat(this.testFactoryBean1.get("myKey")).isEqualTo("myValue");
assertThat(this.testFactoryBean1.get("myKey")).isEqualTo("myValue");
assertThat(this.counterAspect.getCount()).as("Advice not executed: must have been").isEqualTo(2);
@@ -108,7 +108,7 @@ class BeanNamePointcutTests {
void matchingFactoryBeanItself() {
assertThat((this.testFactoryBean2 instanceof Advised)).as("Matching bean must *not* be advised (proxied)").isFalse();
FactoryBean<?> fb = (FactoryBean<?>) ctx.getBean("&testFactoryBean2");
assertThat(fb instanceof Advised).as("FactoryBean itself must be advised").isTrue();
assertThat(fb).as("FactoryBean itself must be advised").isInstanceOf(Advised.class);
assertThat(Map.class.isAssignableFrom(fb.getObjectType())).isTrue();
assertThat(Map.class.isAssignableFrom(fb.getObjectType())).isTrue();
assertThat(this.counterAspect.getCount()).as("Advice not executed: must have been").isEqualTo(2);
@@ -116,7 +116,7 @@ class BeanNamePointcutTests {
@Test
void pointcutAdvisorCombination() {
assertThat(this.interceptThis instanceof Advised).as("Matching bean must be advised (proxied)").isTrue();
assertThat(this.interceptThis).as("Matching bean must be advised (proxied)").isInstanceOf(Advised.class);
assertThat(this.dontInterceptThis instanceof Advised).as("Non-matching bean must *not* be advised (proxied)").isFalse();
interceptThis.setAge(20);
assertThat(testInterceptor.interceptionCount).isEqualTo(1);
@@ -61,7 +61,7 @@ class PropertyDependentAspectTests {
private void checkXmlAspect(String appContextFile) {
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
ICounter counter = (ICounter) context.getBean("counter");
assertThat(counter instanceof Advised).as("Proxy didn't get created").isTrue();
assertThat(counter).as("Proxy didn't get created").isInstanceOf(Advised.class);
counter.increment();
JoinPointMonitorAspect callCountingAspect = (JoinPointMonitorAspect)context.getBean("monitoringAspect");
@@ -72,7 +72,7 @@ class PropertyDependentAspectTests {
private void checkAtAspectJAspect(String appContextFile) {
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
ICounter counter = (ICounter) context.getBean("counter");
assertThat(counter instanceof Advised).as("Proxy didn't get created").isTrue();
assertThat(counter).as("Proxy didn't get created").isInstanceOf(Advised.class);
counter.increment();
JoinPointMonitorAtAspectJAspect callCountingAspect = (JoinPointMonitorAtAspectJAspect)context.getBean("monitoringAspect");
@@ -97,7 +97,7 @@ class MethodLocatingFactoryBeanTests {
factory.setBeanFactory(beanFactory);
Object result = factory.getObject();
assertThat(result).isNotNull();
assertThat(result instanceof Method).isTrue();
assertThat(result).isInstanceOf(Method.class);
Method method = (Method) result;
assertThat(method.invoke("Bingo")).isEqualTo("Bingo");
}
@@ -121,11 +121,11 @@ class CommonsPool2TargetSourceTests {
void proxySerializableWithoutConfigMixin() throws Exception {
Person pooled = (Person) beanFactory.getBean("pooledPerson");
assertThat(((Advised) pooled).getTargetSource() instanceof CommonsPool2TargetSource).isTrue();
assertThat(((Advised) pooled).getTargetSource()).isInstanceOf(CommonsPool2TargetSource.class);
//((Advised) pooled).setTargetSource(new SingletonTargetSource(new SerializablePerson()));
Person serialized = SerializationTestUtils.serializeAndDeserialize(pooled);
assertThat(((Advised) serialized).getTargetSource() instanceof SingletonTargetSource).isTrue();
assertThat(((Advised) serialized).getTargetSource()).isInstanceOf(SingletonTargetSource.class);
serialized.setAge(25);
assertThat(serialized.getAge()).isEqualTo(25);
}
@@ -204,8 +204,8 @@ class CommonsPool2TargetSourceTests {
Object first = targetSource.getTarget();
Object second = targetSource.getTarget();
assertThat(first instanceof SerializablePerson).isTrue();
assertThat(second instanceof SerializablePerson).isTrue();
assertThat(first).isInstanceOf(SerializablePerson.class);
assertThat(second).isInstanceOf(SerializablePerson.class);
assertThat(second).isEqualTo(first);
targetSource.releaseTarget(first);
@@ -79,7 +79,7 @@ class ClassPathFactoryBeanDefinitionScannerTests {
Object bean = context.getBean("requestScopedInstance"); //5
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
assertThat(bean instanceof ScopedObject).isTrue();
assertThat(bean).isInstanceOf(ScopedObject.class);
QualifiedClientBean clientBean = context.getBean("clientBean", QualifiedClientBean.class);
assertThat(clientBean.testBean).isSameAs(context.getBean("publicInstance"));
@@ -401,7 +401,7 @@ class CommonAnnotationBeanPostProcessorTests {
bf.getBean("annotatedBean2");
}
catch (BeanCreationException ex) {
assertThat(ex.getRootCause() instanceof NoSuchBeanDefinitionException).isTrue();
assertThat(ex.getRootCause()).isInstanceOf(NoSuchBeanDefinitionException.class);
NoSuchBeanDefinitionException innerEx = (NoSuchBeanDefinitionException) ex.getRootCause();
assertThat(innerEx.getBeanName()).isEqualTo("testBean9");
}
@@ -457,7 +457,7 @@ class ConfigurationClassPostProcessorTests {
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean(Foo.class);
assertThat(foo instanceof ExtendedFoo).isTrue();
assertThat(foo).isInstanceOf(ExtendedFoo.class);
Bar bar = beanFactory.getBean(Bar.class);
assertThat(bar.foo).isSameAs(foo);
}
@@ -472,7 +472,7 @@ class ConfigurationClassPostProcessorTests {
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean(Foo.class);
assertThat(foo instanceof ExtendedAgainFoo).isTrue();
assertThat(foo).isInstanceOf(ExtendedAgainFoo.class);
Bar bar = beanFactory.getBean(Bar.class);
assertThat(bar.foo).isSameAs(foo);
}
@@ -502,7 +502,7 @@ class ConfigurationClassPostProcessorTests {
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean(Foo.class);
assertThat(foo instanceof ExtendedFoo).isTrue();
assertThat(foo).isInstanceOf(ExtendedFoo.class);
Bar bar = beanFactory.getBean(Bar.class);
assertThat(bar.foo).isSameAs(foo);
}
@@ -516,7 +516,7 @@ class ConfigurationClassPostProcessorTests {
beanFactory.addBeanPostProcessor(new AutowiredAnnotationBeanPostProcessor());
Foo foo = beanFactory.getBean(Foo.class);
assertThat(foo instanceof ExtendedFoo).isTrue();
assertThat(foo).isInstanceOf(ExtendedFoo.class);
Bar bar = beanFactory.getBean(Bar.class);
assertThat(bar.foo).isSameAs(foo);
}
@@ -532,7 +532,7 @@ class ConfigurationClassPostProcessorTests {
pp.postProcessBeanFactory(beanFactory);
ITestBean injected = beanFactory.getBean("consumer", ScopedProxyConsumer.class).testBean;
assertThat(injected instanceof ScopedObject).isTrue();
assertThat(injected).isInstanceOf(ScopedObject.class);
assertThat(injected).isSameAs(beanFactory.getBean("scopedClass"));
assertThat(injected).isSameAs(beanFactory.getBean(ITestBean.class));
}
@@ -91,7 +91,7 @@ class LazyAutowiredAnnotationBeanPostProcessorTests {
tb.setName("tb");
assertThat(bean.getTestBean().getName()).isSameAs("tb");
assertThat(bean.getTestBeans() instanceof Advised).isTrue();
assertThat(bean.getTestBeans()).isInstanceOf(Advised.class);
TargetSource targetSource = ((Advised) bean.getTestBeans()).getTargetSource();
assertThat(targetSource.getTarget()).isSameAs(targetSource.getTarget());
@@ -44,7 +44,7 @@ class SimpleConfigTests {
assertThat(value).isEqualTo("bar");
Future<?> future = fooService.asyncFoo(1);
assertThat(future instanceof FutureTask).isTrue();
assertThat(future).isInstanceOf(FutureTask.class);
assertThat(future.get()).isEqualTo("bar");
assertThat(serviceInvocationCounter.getCount()).isEqualTo(2);
@@ -160,7 +160,7 @@ class ScopingTests {
void scopedProxyConfiguration() {
TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedInterfaceDep");
ITestBean spouse = singleton.getSpouse();
assertThat(spouse instanceof ScopedObject).as("scoped bean is not wrapped by the scoped-proxy").isTrue();
assertThat(spouse).as("scoped bean is not wrapped by the scoped-proxy").isInstanceOf(ScopedObject.class);
String beanName = "scopedProxyInterface";
@@ -192,7 +192,7 @@ class ScopingTests {
void scopedProxyConfigurationWithClasses() {
TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedClassDep");
ITestBean spouse = singleton.getSpouse();
assertThat(spouse instanceof ScopedObject).as("scoped bean is not wrapped by the scoped-proxy").isTrue();
assertThat(spouse).as("scoped bean is not wrapped by the scoped-proxy").isInstanceOf(ScopedObject.class);
String beanName = "scopedProxyClass";
@@ -92,14 +92,14 @@ class LocaleContextHolderTests {
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+1"));
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.getDefault());
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isNull();
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+2"));
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.getDefault());
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isNull();
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
@@ -125,14 +125,14 @@ class LocaleContextHolderTests {
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+1"));
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMANY);
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMANY);
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
LocaleContextHolder.setLocale(Locale.GERMAN);
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN);
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMAN);
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
@@ -145,14 +145,14 @@ class LocaleContextHolderTests {
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+2"));
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN);
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMAN);
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
LocaleContextHolder.setLocale(null);
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.getDefault());
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isTrue();
assertThat(LocaleContextHolder.getLocaleContext()).isInstanceOf(TimeZoneAwareLocaleContext.class);
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isNull();
assertThat(((TimeZoneAwareLocaleContext) LocaleContextHolder.getLocaleContext()).getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+2"));
@@ -53,19 +53,19 @@ class JeeNamespaceHandlerEventTests {
@Test
void jndiLookupComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
assertThat(component instanceof BeanComponentDefinition).isTrue();
assertThat(component).isInstanceOf(BeanComponentDefinition.class);
}
@Test
void localSlsbComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
assertThat(component instanceof BeanComponentDefinition).isTrue();
assertThat(component).isInstanceOf(BeanComponentDefinition.class);
}
@Test
void remoteSlsbComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
assertThat(component instanceof BeanComponentDefinition).isTrue();
assertThat(component).isInstanceOf(BeanComponentDefinition.class);
}
}
@@ -86,7 +86,7 @@ class ModelMBeanNotificationPublisherTests {
publisher.sendNotification(notification);
assertThat(mbean.getActualNotification()).isNotNull();
assertThat(mbean.getActualNotification() instanceof AttributeChangeNotification).isTrue();
assertThat(mbean.getActualNotification()).isInstanceOf(AttributeChangeNotification.class);
assertThat(mbean.getActualNotification()).as("The exact same Notification is not being passed through from the publisher to the mbean.").isSameAs(notification);
assertThat(mbean.getActualNotification().getSource()).as("The 'source' property of the Notification is not being set to the ObjectName of the associated MBean.").isSameAs(objectName);
}
@@ -101,7 +101,7 @@ class ModelMBeanNotificationPublisherTests {
publisher.sendNotification(notification);
assertThat(mbean.getActualNotification()).isNotNull();
assertThat(mbean.getActualNotification() instanceof AttributeChangeNotification).isTrue();
assertThat(mbean.getActualNotification()).isInstanceOf(AttributeChangeNotification.class);
assertThat(mbean.getActualNotification()).as("The exact same Notification is not being passed through from the publisher to the mbean.").isSameAs(notification);
assertThat(mbean.getActualNotification().getSource()).as("The 'source' property of the Notification is *wrongly* being set to the ObjectName of the associated MBean.").isSameAs(this);
}
@@ -210,7 +210,7 @@ class JndiObjectFactoryBeanTests {
jof.setJndiName("foo");
jof.setProxyInterface(ITestBean.class);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getAge()).isEqualTo(0);
proxy.setAge(99);
@@ -246,7 +246,7 @@ class JndiObjectFactoryBeanTests {
jof.setProxyInterface(ITestBean.class);
jof.setLookupOnStartup(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getName()).isNull();
assertThat(tb.getAge()).isEqualTo(0);
@@ -274,7 +274,7 @@ class JndiObjectFactoryBeanTests {
jof.setProxyInterface(ITestBean.class);
jof.setCache(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getName()).isEqualTo("tb");
assertThat(tb.getAge()).isEqualTo(1);
@@ -304,7 +304,7 @@ class JndiObjectFactoryBeanTests {
jof.setLookupOnStartup(false);
jof.setCache(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getName()).isNull();
assertThat(tb.getAge()).isEqualTo(0);
@@ -343,7 +343,7 @@ class JndiObjectFactoryBeanTests {
jof.setExpectedType(TestBean.class);
jof.setProxyInterface(ITestBean.class);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getAge()).isEqualTo(0);
proxy.setAge(99);
@@ -379,7 +379,7 @@ class JndiObjectFactoryBeanTests {
jof.setProxyInterface(ITestBean.class);
jof.setExposeAccessContext(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() instanceof ITestBean).isTrue();
assertThat(jof.getObject()).isInstanceOf(ITestBean.class);
ITestBean proxy = (ITestBean) jof.getObject();
assertThat(tb.getAge()).isEqualTo(0);
proxy.setAge(99);
@@ -331,7 +331,7 @@ class ScheduledAnnotationBeanPostProcessorTests {
assertThat(task.getExpression()).isEqualTo("0 0 0-4,6-23 * * ?");
Trigger trigger = task.getTrigger();
assertThat(trigger).isNotNull();
assertThat(trigger instanceof CronTrigger).isTrue();
assertThat(trigger).isInstanceOf(CronTrigger.class);
CronTrigger cronTrigger = (CronTrigger) trigger;
ZonedDateTime dateTime = ZonedDateTime.of(2013, 4, 15, 4, 0, 0, 0, ZoneId.of("GMT+10"));
Instant lastScheduledExecution = dateTime.toInstant();
@@ -223,7 +223,7 @@ class GroovyScriptFactoryTests {
Messenger messenger = (Messenger) ctx.getBean("messenger");
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
assertThat(messenger instanceof Refreshable).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);
@@ -242,7 +242,7 @@ class GroovyScriptFactoryTests {
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
assertThat(AopUtils.isAopProxy(messenger)).as("Should be a proxy for refreshable scripts").isTrue();
assertThat(messenger instanceof Refreshable).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!");
@@ -399,7 +399,7 @@ class GroovyScriptFactoryTests {
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
assertThat(messenger instanceof Refreshable).isTrue();
assertThat(messenger).isInstanceOf(Refreshable.class);
assertThat(countingAspect.getCalls()).isEqualTo(0);
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
assertThat(countingAspect.getCalls()).isEqualTo(1);
@@ -416,7 +416,7 @@ class GroovyScriptFactoryTests {
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
assertThat(messenger instanceof Refreshable).isTrue();
assertThat(messenger).isInstanceOf(Refreshable.class);
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
assertThat(ctx.getBeansOfType(ConcreteMessenger.class)).containsValue((ConcreteMessenger) messenger);
@@ -467,7 +467,7 @@ class GroovyScriptFactoryTests {
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger");
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
assertThat(messenger instanceof Refreshable).isTrue();
assertThat(messenger).isInstanceOf(Refreshable.class);
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
@@ -530,7 +530,7 @@ class GroovyScriptFactoryTests {
void factoryBean() {
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
Object factory = context.getBean("&factory");
assertThat(factory instanceof FactoryBean).isTrue();
assertThat(factory).isInstanceOf(FactoryBean.class);
Object result = context.getBean("factory");
assertThat(result).isEqualTo("test");
}
@@ -539,7 +539,7 @@ class GroovyScriptFactoryTests {
void refreshableFactoryBean() {
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
Object factory = context.getBean("&refreshableFactory");
assertThat(factory instanceof FactoryBean).isTrue();
assertThat(factory).isInstanceOf(FactoryBean.class);
Object result = context.getBean("refreshableFactory");
assertThat(result).isEqualTo("test");
}