Reimplemented ServerEndpointExporter to avoid BeanPostProcessor role

Issue: SPR-12340
(cherry picked from commit 10328f1)
This commit is contained in:
Juergen Hoeller
2014-10-22 01:05:19 +02:00
parent a1c0905a7c
commit 7507560e75
3 changed files with 69 additions and 73 deletions

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -67,7 +67,7 @@ public class ServerEndpointExporterTests {
@Test
public void addAnnotatedEndpointBeans() throws Exception {
public void addAnnotatedEndpointClasses() throws Exception {
this.exporter.setAnnotatedEndpointClasses(AnnotatedDummyEndpoint.class);
this.exporter.setApplicationContext(this.webAppContext);
this.exporter.afterPropertiesSet();
@@ -77,7 +77,7 @@ public class ServerEndpointExporterTests {
}
@Test
public void addAnnotatedEndpointBeansWithServletContextOnly() throws Exception {
public void addAnnotatedEndpointClassesWithServletContextOnly() throws Exception {
this.exporter.setAnnotatedEndpointClasses(AnnotatedDummyEndpoint.class, AnnotatedDummyEndpointBean.class);
this.exporter.setServletContext(this.servletContext);
this.exporter.afterPropertiesSet();
@@ -87,7 +87,7 @@ public class ServerEndpointExporterTests {
}
@Test
public void addAnnotatedEndpointBeansWithServerContainerOnly() throws Exception {
public void addAnnotatedEndpointClassesWithExplicitServerContainerOnly() throws Exception {
this.exporter.setAnnotatedEndpointClasses(AnnotatedDummyEndpoint.class, AnnotatedDummyEndpointBean.class);
this.exporter.setServerContainer(this.serverContainer);
this.exporter.afterPropertiesSet();
@@ -98,31 +98,37 @@ public class ServerEndpointExporterTests {
@Test
public void addServerEndpointConfigBean() throws Exception {
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.webAppContext.getBeanFactory().registerSingleton("dummyEndpoint", endpointRegistration);
this.exporter.setApplicationContext(this.webAppContext);
this.exporter.afterPropertiesSet();
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.exporter.postProcessAfterInitialization(endpointRegistration, "dummyEndpoint");
verify(this.serverContainer).addEndpoint(endpointRegistration);
}
@Test
public void addServerEndpointConfigBeanWithServletContextOnly() throws Exception {
public void addServerEndpointConfigBeanWithExplicitServletContext() throws Exception {
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.webAppContext.getBeanFactory().registerSingleton("dummyEndpoint", endpointRegistration);
this.exporter.setServletContext(this.servletContext);
this.exporter.setApplicationContext(this.webAppContext);
this.exporter.afterPropertiesSet();
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.exporter.postProcessAfterInitialization(endpointRegistration, "dummyEndpoint");
verify(this.serverContainer).addEndpoint(endpointRegistration);
}
@Test
public void addServerEndpointConfigBeanWithServerContainerOnly() throws Exception {
public void addServerEndpointConfigBeanWithExplicitServerContainer() throws Exception {
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.webAppContext.getBeanFactory().registerSingleton("dummyEndpoint", endpointRegistration);
this.servletContext.removeAttribute("javax.websocket.server.ServerContainer");
this.exporter.setServerContainer(this.serverContainer);
this.exporter.setApplicationContext(this.webAppContext);
this.exporter.afterPropertiesSet();
ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint());
this.exporter.postProcessAfterInitialization(endpointRegistration, "dummyEndpoint");
verify(this.serverContainer).addEndpoint(endpointRegistration);
}