Author: alessio.soldano(a)jboss.com
Date: 2009-06-26 10:51:47 -0400 (Fri, 26 Jun 2009)
New Revision: 10243
Modified:
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/branches/netty/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wseventing/SubscriptionManagerTestCase.java
Log:
default port number
Modified:
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
---
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-06-26
14:18:13 UTC (rev 10242)
+++
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-06-26
14:51:47 UTC (rev 10243)
@@ -24,9 +24,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Date;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -231,19 +230,19 @@
{
// System.out.println(new Date() + " Inizio connection
attempt...");
//Start the connection attempt
- URI target;
+ URL target;
try
{
System.out.println("targetAddress: "+targetAddress);
- target = new URI(targetAddress);
+ target = new URL(targetAddress);
System.out.println("target.getHost: "+target.getHost());
System.out.println("target.getPort: "+target.getPort());
}
- catch (URISyntaxException e)
+ catch (MalformedURLException e)
{
throw new RuntimeException("Invalid address: " + targetAddress,
e);
}
- ChannelFuture future = bootstrap.connect(new
InetSocketAddress(target.getHost(), target.getPort()));
+ ChannelFuture future = bootstrap.connect(getSocketAddress(target));
//Wait until the connection attempt succeeds or fails
awaitUninterruptibly(future, timeout);
@@ -260,7 +259,7 @@
MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
//Send the HTTP request
- HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, reqMessage
!= null ? HttpMethod.POST : HttpMethod.GET, target.toASCIIString());
+ HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, reqMessage
!= null ? HttpMethod.POST : HttpMethod.GET, targetAddress);
request.addHeader(HttpHeaders.Names.HOST, target.getHost());
request.addHeader(HttpHeaders.Names.CONNECTION,
HttpHeaders.Values.KEEP_ALIVE);
Map<String, Object> additionalHeaders = new HashMap<String,
Object>();
@@ -334,6 +333,25 @@
}
}
+ private InetSocketAddress getSocketAddress(URL target)
+ {
+ int port = target.getPort();
+ if (port < 0)
+ {
+ //use default port
+ String protocol = target.getProtocol();
+ if ("http".equalsIgnoreCase(protocol))
+ {
+ port = 80;
+ }
+ else if ("https".equalsIgnoreCase(protocol))
+ {
+ port = 443;
+ }
+ }
+ return new InetSocketAddress(target.getHost(), port);
+ }
+
private void writeRequest(Channel channel, HttpRequest request, MessageAbstraction
reqMessage) throws IOException
{
if (reqMessage == null)
Modified:
stack/native/branches/netty/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wseventing/SubscriptionManagerTestCase.java
===================================================================
---
stack/native/branches/netty/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wseventing/SubscriptionManagerTestCase.java 2009-06-26
14:18:13 UTC (rev 10242)
+++
stack/native/branches/netty/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wseventing/SubscriptionManagerTestCase.java 2009-06-26
14:51:47 UTC (rev 10243)
@@ -114,7 +114,6 @@
assertNotNull(subscriptionTicket.getExpires());
assertTrue(subscriptionTicket.getExpires().getTime() >
System.currentTimeMillis());
assertNotNull(subscriptionTicket.getSubscriptionManager());
- zzzz();
}
/**
@@ -136,7 +135,6 @@
{
// ignore expected exception
}
- zzzz();
}
public void testExceedsMaxLeaseTime() throws Exception
@@ -151,7 +149,6 @@
{
// ignore expected exception
}
- zzzz();
}
/**
@@ -178,7 +175,6 @@
{
// ignore expected exception
}
- zzzz();
}
public void testDispatch() throws Exception
@@ -191,7 +187,6 @@
Element payload = DOMUtils.parse(eventString);
subscriptionManager.dispatch(eventSourceNS, payload);
- zzzz();
}
public void testXPathFilter() throws Exception
@@ -203,14 +198,5 @@
Element event = DOMUtils.parse(eventString);
subscriptionManager.dispatch(eventSourceNS, event);
- zzzz();
}
-
- private void zzzz() {
- try
- {
- Thread.currentThread().sleep(30000);
- }
- catch (Exception e) {}
- }
}
Show replies by date