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.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.Endpoint;
|
||||
|
@ -30,8 +29,7 @@ import javax.websocket.server.ServerContainer;
|
|||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.websocket.server.ServerContainer}
|
||||
* interface.
|
||||
* Mock implementation of the {@link javax.websocket.server.ServerContainer} interface.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.3.1
|
||||
|
@ -107,17 +105,20 @@ class MockServerContainer implements ServerContainer {
|
|||
@Override
|
||||
public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path)
|
||||
throws DeploymentException, IOException {
|
||||
|
||||
throw new UnsupportedOperationException(
|
||||
"MockServerContainer does not support connectToServer(Endpoint, ClientEndpointConfig, URI)");
|
||||
"MockServerContainer does not support connectToServer(Endpoint, ClientEndpointConfig, URI)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path)
|
||||
throws DeploymentException, IOException {
|
||||
|
||||
throw new UnsupportedOperationException(
|
||||
"MockServerContainer does not support connectToServer(Class, ClientEndpointConfig, URI)");
|
||||
"MockServerContainer does not support connectToServer(Class, ClientEndpointConfig, URI)");
|
||||
}
|
||||
|
||||
|
||||
// --- ServerContainer -----------------------------------------------------
|
||||
|
||||
@Override
|
||||
|
@ -128,7 +129,7 @@ class MockServerContainer implements ServerContainer {
|
|||
@Override
|
||||
public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException {
|
||||
throw new UnsupportedOperationException(
|
||||
"MockServerContainer does not support addEndpoint(ServerEndpointConfig)");
|
||||
"MockServerContainer does not support addEndpoint(ServerEndpointConfig)");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,14 +40,8 @@ class MockServerContainerContextCustomizer implements ContextCustomizer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null || this.getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other != null && getClass() == other.getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,15 +35,15 @@ import org.springframework.util.ClassUtils;
|
|||
*/
|
||||
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 =
|
||||
"org.springframework.test.context.web.WebAppConfiguration";
|
||||
|
||||
private static final String MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME =
|
||||
"org.springframework.test.context.web.socket.MockServerContainerContextCustomizer";
|
||||
|
||||
private static final boolean webSocketPresent = ClassUtils.isPresent("javax.websocket.server.ServerContainer",
|
||||
MockServerContainerContextCustomizerFactory.class.getClassLoader());
|
||||
|
||||
|
||||
@Override
|
||||
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||
|
@ -52,12 +52,12 @@ class MockServerContainerContextCustomizerFactory implements ContextCustomizerFa
|
|||
if (webSocketPresent && isAnnotatedWithWebAppConfiguration(testClass)) {
|
||||
try {
|
||||
Class<?> clazz = ClassUtils.forName(MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME,
|
||||
getClass().getClassLoader());
|
||||
getClass().getClassLoader());
|
||||
return (ContextCustomizer) BeanUtils.instantiateClass(clazz);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Failed to enable WebSocket test support; could not load class: "
|
||||
+ MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME, ex);
|
||||
throw new IllegalStateException("Failed to enable WebSocket test support; could not load class: " +
|
||||
MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,8 @@ class MockServerContainerContextCustomizerFactory implements ContextCustomizerFa
|
|||
}
|
||||
|
||||
private static boolean isAnnotatedWithWebAppConfiguration(Class<?> testClass) {
|
||||
return AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
|
||||
WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME, false, false) != null;
|
||||
return (AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
|
||||
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