Add missing package-info file for new test.context.web.socket package
Issue: SPR-14420
This commit is contained in:
parent
a6e4b64c23
commit
080dcad218
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.websocket.ClientEndpointConfig;
|
import javax.websocket.ClientEndpointConfig;
|
||||||
import javax.websocket.DeploymentException;
|
import javax.websocket.DeploymentException;
|
||||||
import javax.websocket.Endpoint;
|
import javax.websocket.Endpoint;
|
||||||
|
@ -30,8 +29,7 @@ import javax.websocket.server.ServerContainer;
|
||||||
import javax.websocket.server.ServerEndpointConfig;
|
import javax.websocket.server.ServerEndpointConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock implementation of the {@link javax.websocket.server.ServerContainer}
|
* Mock implementation of the {@link javax.websocket.server.ServerContainer} interface.
|
||||||
* interface.
|
|
||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @since 4.3.1
|
* @since 4.3.1
|
||||||
|
@ -107,17 +105,20 @@ class MockServerContainer implements ServerContainer {
|
||||||
@Override
|
@Override
|
||||||
public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path)
|
public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path)
|
||||||
throws DeploymentException, IOException {
|
throws DeploymentException, IOException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"MockServerContainer does not support connectToServer(Endpoint, ClientEndpointConfig, URI)");
|
"MockServerContainer does not support connectToServer(Endpoint, ClientEndpointConfig, URI)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path)
|
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path)
|
||||||
throws DeploymentException, IOException {
|
throws DeploymentException, IOException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"MockServerContainer does not support connectToServer(Class, ClientEndpointConfig, URI)");
|
"MockServerContainer does not support connectToServer(Class, ClientEndpointConfig, URI)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- ServerContainer -----------------------------------------------------
|
// --- ServerContainer -----------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,7 +129,7 @@ class MockServerContainer implements ServerContainer {
|
||||||
@Override
|
@Override
|
||||||
public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException {
|
public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"MockServerContainer does not support addEndpoint(ServerEndpointConfig)");
|
"MockServerContainer does not support addEndpoint(ServerEndpointConfig)");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,14 +40,8 @@ class MockServerContainerContextCustomizer implements ContextCustomizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object that) {
|
public boolean equals(Object other) {
|
||||||
if (this == that) {
|
return (this == other || (other != null && getClass() == other.getClass()));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (that == null || this.getClass() != that.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,15 +35,15 @@ import org.springframework.util.ClassUtils;
|
||||||
*/
|
*/
|
||||||
class MockServerContainerContextCustomizerFactory implements ContextCustomizerFactory {
|
class MockServerContainerContextCustomizerFactory implements ContextCustomizerFactory {
|
||||||
|
|
||||||
private static final boolean webSocketPresent = ClassUtils.isPresent("javax.websocket.server.ServerContainer",
|
|
||||||
MockServerContainerContextCustomizerFactory.class.getClassLoader());
|
|
||||||
|
|
||||||
private static final String WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME =
|
private static final String WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME =
|
||||||
"org.springframework.test.context.web.WebAppConfiguration";
|
"org.springframework.test.context.web.WebAppConfiguration";
|
||||||
|
|
||||||
private static final String MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME =
|
private static final String MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME =
|
||||||
"org.springframework.test.context.web.socket.MockServerContainerContextCustomizer";
|
"org.springframework.test.context.web.socket.MockServerContainerContextCustomizer";
|
||||||
|
|
||||||
|
private static final boolean webSocketPresent = ClassUtils.isPresent("javax.websocket.server.ServerContainer",
|
||||||
|
MockServerContainerContextCustomizerFactory.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||||
|
@ -52,12 +52,12 @@ class MockServerContainerContextCustomizerFactory implements ContextCustomizerFa
|
||||||
if (webSocketPresent && isAnnotatedWithWebAppConfiguration(testClass)) {
|
if (webSocketPresent && isAnnotatedWithWebAppConfiguration(testClass)) {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = ClassUtils.forName(MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME,
|
Class<?> clazz = ClassUtils.forName(MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME,
|
||||||
getClass().getClassLoader());
|
getClass().getClassLoader());
|
||||||
return (ContextCustomizer) BeanUtils.instantiateClass(clazz);
|
return (ContextCustomizer) BeanUtils.instantiateClass(clazz);
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
throw new IllegalStateException("Failed to enable WebSocket test support; could not load class: "
|
throw new IllegalStateException("Failed to enable WebSocket test support; could not load class: " +
|
||||||
+ MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME, ex);
|
MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ class MockServerContainerContextCustomizerFactory implements ContextCustomizerFa
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAnnotatedWithWebAppConfiguration(Class<?> testClass) {
|
private static boolean isAnnotatedWithWebAppConfiguration(Class<?> testClass) {
|
||||||
return AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
|
return (AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
|
||||||
WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME, false, false) != null;
|
WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME, false, false) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* WebSocket support classes for the <em>Spring TestContext Framework</em>.
|
||||||
|
*/
|
||||||
|
package org.springframework.test.context.web.socket;
|
Loading…
Reference in New Issue