Skip to content

Commit f4f7f40

Browse files
committed
Test for actual HttpInvokerProxyFactoryBean usage with plain FactoryBean return type
Issue: SPR-12141
1 parent 50846e3 commit f4f7f40

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerFactoryBeanIntegrationTests.java

+40-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.context.annotation.ComponentScan;
2828
import org.springframework.context.annotation.Configuration;
2929
import org.springframework.context.annotation.Lazy;
30+
import org.springframework.core.env.Environment;
3031
import org.springframework.remoting.support.RemoteInvocation;
3132
import org.springframework.remoting.support.RemoteInvocationResult;
3233
import org.springframework.scheduling.annotation.Async;
@@ -60,6 +61,17 @@ public void testNonLoadedConfigClass() {
6061
myBean.myService.handleAsync();
6162
}
6263

64+
@Test
65+
public void withConfigurationClassWithPlainFactoryBean() {
66+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
67+
context.register(ConfigWithPlainFactoryBean.class);
68+
context.refresh();
69+
MyBean myBean = context.getBean("myBean", MyBean.class);
70+
assertSame(context.getBean("myService"), myBean.myService);
71+
myBean.myService.handle();
72+
myBean.myService.handleAsync();
73+
}
74+
6375

6476
public interface MyService {
6577

@@ -93,7 +105,6 @@ public HttpInvokerProxyFactoryBean myService() {
93105
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
94106
factory.setServiceUrl("/svc/dummy");
95107
factory.setServiceInterface(MyService.class);
96-
Thread thread = Thread.currentThread();
97108
factory.setHttpInvokerRequestExecutor(new HttpInvokerRequestExecutor() {
98109
@Override
99110
public RemoteInvocationResult executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation) {
@@ -109,4 +120,32 @@ public FactoryBean<String> myOtherService() {
109120
}
110121
}
111122

123+
124+
@Configuration
125+
static class ConfigWithPlainFactoryBean {
126+
127+
@Autowired
128+
Environment env;
129+
130+
@Bean
131+
public MyBean myBean() {
132+
return new MyBean();
133+
}
134+
135+
@Bean
136+
public FactoryBean myService() {
137+
String name = env.getProperty("testbean.name");
138+
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
139+
factory.setServiceUrl("/svc/" + name);
140+
factory.setServiceInterface(MyService.class);
141+
factory.setHttpInvokerRequestExecutor(new HttpInvokerRequestExecutor() {
142+
@Override
143+
public RemoteInvocationResult executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation) {
144+
return new RemoteInvocationResult(null);
145+
}
146+
});
147+
return factory;
148+
}
149+
}
150+
112151
}

0 commit comments

Comments
 (0)