Author: richard.opalka(a)jboss.com
Date: 2009-10-02 06:11:35 -0400 (Fri, 02 Oct 2009)
New Revision: 10825
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServer.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerConfig.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyInvocationHandler.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
Log:
[JBWS-2674][JBWS-2754] providing test cases (WIP)
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -177,7 +177,10 @@
if (context instanceof HttpContext)
{
serverContext = (HttpContext)context;
- //address = getAddressFromConfigAndContext(serverContext); // TODO: is it
necessary?
+ if (address == null)
+ {
+ address = getAddressFromConfigAndContext(serverContext); // TODO: is it
necessary?
+ }
HttpServer httpServer = serverContext.getHttpServer();
httpServer.publish(serverContext, this);
isPublished = true;
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServer.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServer.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServer.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -102,19 +102,22 @@
// TODO: should we use archive deployment - see META-INF/services ???
final ArchiveDeployment dep = (ArchiveDeployment)
this.deploymentModelFactory.newDeployment(contextRoot, loader);
final org.jboss.wsf.spi.deployment.Endpoint endpoint =
this.deploymentModelFactory.newEndpoint(endpointClass.getName());
- endpoint.setShortName(epImpl.getName());
+ endpoint.setShortName(epImpl.getName() + "-port-" + epImpl.getPort()); //
we need to distinguish ports in endpoints registry
endpoint.setURLPattern(epImpl.getName()); // TODO: rename method
dep.getService().addEndpoint(endpoint);
dep.setRootFile(new ResourceLoaderAdapter(loader));
dep.setRuntimeClassLoader(loader);
dep.setType(DeploymentType.JAXWS_JSE);
dep.getService().setContextRoot(contextRoot);
+ // TODO: remove this properties hack
+ dep.getService().setProperty("protocol", "http");
+ dep.getService().setProperty("host", "127.0.0.1");
+ dep.getService().setProperty("port", epImpl.getPort());
DeploymentAspectManagerImpl daManager = new DeploymentAspectManagerImpl();
daManager.setDeploymentAspects(getDeploymentAspects());
daManager.deploy(dep);
epImpl.setDeployment(dep);
- // TODO: call DAManager.undeploy()
RealNettyHttpServer server = RealNettyHttpServer.getInstance("http",
"localhost", epImpl.getPort());
NettyCallbackHandler callback = new NettyCallbackHandler(epImpl.getPath(),
contextRoot, endpoint.getShortName());
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerConfig.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerConfig.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerConfig.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -82,17 +82,19 @@
public int getWebServicePort()
{
- return 8878;
+ throw new UnsupportedOperationException();
+ //return 8878;
}
public int getWebServiceSecurePort()
{
- return 8879;
+ throw new UnsupportedOperationException();
+ //return 8879;
}
public boolean isModifySOAPAddress()
{
- return true;
+ return false;
}
public void setModifySOAPAddress(boolean flag)
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyInvocationHandler.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyInvocationHandler.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyInvocationHandler.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -137,9 +137,11 @@
for (NettyCallbackHandler handler : this.callbacks)
{
handledPath = truncateHostName(handler.getHandledPath());
+ /*
System.out.println("---");
System.out.println("Request path 2: " + requestPath);
System.out.println("Handled path 2: " + handledPath);
+ */
if (requestPath.equals(handledPath))
{
handlerExists = true;
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -214,14 +214,14 @@
URL orgURL = new URL(orgLocation);
String protocol = orgURL.getProtocol();
String host = orgURL.getHost();
- int port = getPortForProtocol(protocol);
- String path = orgURL.getPath();
final boolean rewriteLocation =
ServerConfig.UNDEFINED_HOSTNAME.equals(host) ||
this.config.isModifySOAPAddress();
if (rewriteLocation)
{
+ int port = getPortForProtocol(protocol);
+ String path = orgURL.getPath();
String newLocation = new URL(protocol, wsdlHost, port,
path).toString();
if (!newLocation.equals(orgLocation))
{
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -139,14 +139,16 @@
// Get the URL pattern from the endpoint
String linkName = sepMetaData.getLinkName();
+ Endpoint endpoint = null;
if (linkName != null)
{
- Endpoint endpoint = dep.getService().getEndpointByName(linkName);
+ endpoint = dep.getService().getEndpointByName(linkName);
if (endpoint != null)
urlPattern = endpoint.getURLPattern();
}
// If not, derive the context root from the deployment
+ Integer port = (Integer)dep.getService().getProperty("port");
if (contextRoot == null)
{
String simpleName = dep.getSimpleName();
@@ -161,6 +163,10 @@
}
}
}
+ if (port == null)
+ {
+ port = -1;
+ }
// Default to "/*"
if (urlPattern == null)
@@ -175,7 +181,7 @@
sepMetaData.setURLPattern(urlPattern);
String servicePath = contextRoot + urlPattern;
- sepMetaData.setEndpointAddress(getServiceEndpointAddress(null, servicePath));
+ sepMetaData.setEndpointAddress(getServiceEndpointAddress(null, servicePath,
port));
}
public static ObjectName createServiceEndpointID(Deployment dep,
ServerEndpointMetaData sepMetaData)
@@ -214,7 +220,7 @@
/** Get the web service address for a given path
*/
- public static String getServiceEndpointAddress(String uriScheme, String servicePath)
+ public static String getServiceEndpointAddress(String uriScheme, String servicePath,
int servicePort)
{
if (servicePath == null || servicePath.length() == 0)
throw new WSException("Service path cannot be null");
@@ -230,22 +236,29 @@
String host = config.getWebServiceHost();
String port = "";
- if ("https".equals(uriScheme))
+ if (servicePort != -1)
{
- int portNo = config.getWebServiceSecurePort();
- if (portNo != 443)
- {
- port = ":" + portNo;
- }
-
+ port = ":" + servicePort;
}
else
{
- int portNo = config.getWebServicePort();
- if (portNo != 80)
+ if ("https".equals(uriScheme))
{
- port = ":" + portNo;
+ int portNo = config.getWebServiceSecurePort();
+ if (portNo != 443)
+ {
+ port = ":" + portNo;
+ }
+
}
+ else
+ {
+ int portNo = config.getWebServicePort();
+ if (portNo != 80)
+ {
+ port = ":" + portNo;
+ }
+ }
}
String urlStr = uriScheme + "://" + host + port + servicePath;
@@ -319,17 +332,18 @@
if ("CONFIDENTIAL".equals(transportGuarantee))
uriScheme = "https";
- String servicePath = sepMetaData.getContextRoot() +
sepMetaData.getURLPattern();
- String serviceEndpointURL = getServiceEndpointAddress(uriScheme,
servicePath);
-
SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
ServerConfig config =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
boolean alwaysModify = config.isModifySOAPAddress();
if (alwaysModify || uriScheme == null ||
orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0)
{
+ String servicePath = sepMetaData.getContextRoot() +
sepMetaData.getURLPattern();
+ String serviceEndpointURL = getServiceEndpointAddress(uriScheme,
servicePath, -1);
+
if (log.isDebugEnabled())
log.debug("Replace service endpoint address '" +
orgAddress + "' with '" + serviceEndpointURL + "'");
+
wsdlEndpoint.setAddress(serviceEndpointURL);
sepMetaData.setEndpointAddress(serviceEndpointURL);
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -588,7 +588,7 @@
}
else
{
- if (context.getAttachment(Map.class) != null) // TODO: remove this ugly hack
+ if (context != null && context.getAttachment(Map.class) != null) //
TODO: remove this ugly hack
{
handleWSDLRequestFromInvocationContext(endpoint, outStream, context);
}
Modified:
stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
===================================================================
---
stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java 2009-10-02
10:10:22 UTC (rev 10824)
+++
stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java 2009-10-02
10:11:35 UTC (rev 10825)
@@ -39,8 +39,8 @@
*/
public final class UsecasesTestCase extends JBossWSTest
{
- private int port1 = 8878; // 8878
- private int port2 = 8878; // 8878
+ private int port1 = 8871;
+ private int port2 = 8872;
public void testTwoPorts() throws Exception
{
@@ -86,11 +86,33 @@
endpoint1.stop();
endpoint2.stop();
}
-
+
public void testTwoPortsAndIdenticalPaths() throws Exception
{
- // TODO: provide test port1/service1 vs. port2/service1
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/endpoint/number1";
+ Endpoint endpoint1 = publishEndpoint(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" + port2
+ "/jaxws-endpoint/endpoint/number1";
+ Endpoint endpoint2 = publishEndpoint(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint2(publishURL1);
+ invokeEndpoint2(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
}
+
+ /*
+ public void testEndpointException() throws Exception
+ {
+ // TODO: provide test case where endpoint throws exception
+ }
+
+ public void testAttachments() throws Exception
+ {
+ // TODO: provide test case where client sends attachment
+ }
+ */
private Endpoint publishEndpoint(Object epImpl, String publishURL)
{