Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C443BDE44 for ; Fri, 27 Jul 2012 18:43:21 +0000 (UTC) Received: (qmail 71091 invoked by uid 500); 27 Jul 2012 18:43:21 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 71049 invoked by uid 500); 27 Jul 2012 18:43:21 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 71042 invoked by uid 99); 27 Jul 2012 18:43:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2012 18:43:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2012 18:43:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9327A238890B; Fri, 27 Jul 2012 18:42:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1366487 - in /cxf/sandbox/dkulp_async_clients/http-netty: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cxf/ src/main/java/org/apache/cxf/transport/ src/main/java/org/apache/cxf/tran... Date: Fri, 27 Jul 2012 18:42:31 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120727184231.9327A238890B@eris.apache.org> Author: dkulp Date: Fri Jul 27 18:42:30 2012 New Revision: 1366487 URL: http://svn.apache.org/viewvc?rev=1366487&view=rev Log: Add netty experiment - seemed to work fairly OK, but VERY VERY low level. Would need to write a lot of code to handle connection management, keep-alives, etc... Added: cxf/sandbox/dkulp_async_clients/http-netty/ cxf/sandbox/dkulp_async_clients/http-netty/pom.xml cxf/sandbox/dkulp_async_clients/http-netty/src/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPTransportFactory.java cxf/sandbox/dkulp_async_clients/http-netty/src/test/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java Added: cxf/sandbox/dkulp_async_clients/http-netty/pom.xml URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-netty/pom.xml?rev=1366487&view=auto ============================================================================== --- cxf/sandbox/dkulp_async_clients/http-netty/pom.xml (added) +++ cxf/sandbox/dkulp_async_clients/http-netty/pom.xml Fri Jul 27 18:42:30 2012 @@ -0,0 +1,111 @@ + + + 4.0.0 + org.apache.cxf + cxf-rt-transports-http-netty + jar + 2.7.0-SNAPSHOT + Apache CXF Runtime HTTP Transport + Apache CXF Runtime HTTP Netty Transport + http://cxf.apache.org + + + org.apache.cxf + cxf-parent + 2.7.0-SNAPSHOT + ../../../parent/pom.xml + + + + javax.servlet*;version="${cxf.osgi.javax.servlet.version}", + + + org.apache.cxf.*, + + + + + + junit + junit + test + + + org.easymock + easymock + test + + + org.apache.cxf + cxf-api + ${project.version} + + + org.apache.cxf + cxf-rt-core + ${project.version} + + + org.apache.cxf + cxf-rt-transports-http + ${project.version} + + + io.netty + netty + 3.5.3.Final + + + + com.ning + async-http-client + 1.7.5 + + + + + + org.slf4j + slf4j-jdk14 + test + + + org.apache.cxf + cxf-rt-transports-http-jetty + ${project.version} + test + + + org.apache.cxf + cxf-rt-frontend-jaxws + ${project.version} + test + + + org.apache.cxf + cxf-testutils + ${project.version} + test + + + + + + Added: cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java?rev=1366487&view=auto ============================================================================== --- cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java (added) +++ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java Fri Jul 27 18:42:30 2012 @@ -0,0 +1,279 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.transport.http.asyncclient; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.URL; +import java.util.List; +import java.util.Map; + + +import org.apache.cxf.Bus; +import org.apache.cxf.helpers.HttpHeaderHelper; +import org.apache.cxf.helpers.LoadingByteArrayOutputStream; +import org.apache.cxf.message.Message; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transport.http.Headers; +import org.apache.cxf.transport.https.HttpsURLConnectionInfo; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; +import org.apache.cxf.version.Version; +import org.apache.cxf.ws.addressing.EndpointReferenceType; + +import org.jboss.netty.bootstrap.ClientBootstrap; +import org.jboss.netty.buffer.ChannelBufferInputStream; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.SimpleChannelHandler; +import org.jboss.netty.channel.socket.ClientSocketChannelFactory; +import org.jboss.netty.handler.codec.http.DefaultHttpRequest; +import org.jboss.netty.handler.codec.http.DefaultHttpResponse; +import org.jboss.netty.handler.codec.http.HttpClientCodec; +import org.jboss.netty.handler.codec.http.HttpMethod; +import org.jboss.netty.handler.codec.http.HttpVersion; + +/** + * + */ +public class AsyncHTTPConduit extends HTTPConduit { + final ClientSocketChannelFactory factory; + final ClientBootstrap bootstrap; + ChannelFuture cachedChannel; + + public AsyncHTTPConduit(Bus b, EndpointInfo ei, EndpointReferenceType t, + ClientSocketChannelFactory f) throws IOException { + super(b, ei, t); + this.factory = f; + bootstrap = new ClientBootstrap(factory); + bootstrap.setPipelineFactory(new CXFClientPipelineFactory()); + } + + public void close() { + if (cachedChannel != null) { + cachedChannel.getChannel().close(); + } + } + public ChannelFuture getChannel(URL url) { + if (cachedChannel == null) { + cachedChannel = bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort())); + } + return cachedChannel; + } + + protected void setupConnection(Message message, URL url, HTTPClientPolicy csPolicy) throws IOException { + String httpRequestMethod = + (String)message.get(Message.HTTP_REQUEST_METHOD); + if (httpRequestMethod == null) { + httpRequestMethod = "POST"; + message.put(Message.HTTP_REQUEST_METHOD, httpRequestMethod); + } + + + ChannelFuture future = getChannel(url); + message.put(ChannelFuture.class, future); + message.put(ClientBootstrap.class, bootstrap); + + DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, + HttpMethod.valueOf(httpRequestMethod), + url.getPath()); + request.addHeader("Host", url.getHost() + ":" + url.getPort()); + message.put(DefaultHttpRequest.class, request); + } + + static class CXFClientPipelineFactory implements ChannelPipelineFactory { + + public ChannelPipeline getPipeline() throws Exception { + // Create a default pipeline implementation. + ChannelPipeline pipeline = org.jboss.netty.channel.Channels.pipeline(); + // Enable HTTPS if necessary. + /* + if (ssl) { + SSLEngine engine = + SecureChatSslContextFactory.getClientContext().createSSLEngine(); + engine.setUseClientMode(true); + pipeline.addLast("ssl", new SslHandler(engine)); + */ + pipeline.addLast("codec", new HttpClientCodec()); + pipeline.addLast("cxfhandler", new CXFHandler()); + return pipeline; + } + + } + static class CXFHandler extends SimpleChannelHandler { + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + AsyncWrappedOutputStream out = (AsyncWrappedOutputStream)ctx.getAttachment(); + out.handleMessage((DefaultHttpResponse)e.getMessage()); + } + } + + protected OutputStream createOutputStream(Message message, + boolean needToCacheRequest, + boolean isChunking, + int chunkThreshold) { + DefaultHttpRequest request = message.get(DefaultHttpRequest.class); + String url = request.getUri(); //FIXME get the URL + return new AsyncWrappedOutputStream(message, + needToCacheRequest, + isChunking, + chunkThreshold, + getConduitName(), + url); + } + + + class AsyncWrappedOutputStream extends WrappedOutputStream { + DefaultHttpRequest request; + ChannelFuture channelFuture; + ChannelFuture msgFuture; + LoadingByteArrayOutputStream fixedBuffer; + DefaultHttpResponse response; + public AsyncWrappedOutputStream(Message message, + boolean needToCacheRequest, + boolean isChunking, + int chunkThreshold, + String conduitName, + String url) { + super(message, needToCacheRequest, isChunking, + chunkThreshold, conduitName, + url); + request = message.get(DefaultHttpRequest.class); + channelFuture = message.get(ChannelFuture.class); + } + + public synchronized void handleMessage(DefaultHttpResponse message) { + response = message; + notifyAll(); + } + public synchronized void waitForResponse() throws IOException { + while (response == null) { + try { + wait(); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + } + + protected void setProtocolHeaders() throws IOException { + Headers h = new Headers(outMessage); + request.setHeader("Content-Type", h.determineContentType()); + for (Map.Entry> header : h.headerMap().entrySet()) { + if (HttpHeaderHelper.CONTENT_TYPE.equalsIgnoreCase(header.getKey())) { + continue; + } + + StringBuilder b = new StringBuilder(); + for (int i = 0; i < header.getValue().size(); i++) { + b.append(header.getValue().get(i)); + if (i + 1 < header.getValue().size()) { + b.append(','); + } + } + request.setHeader(header.getKey(), b.toString()); + } + if (!h.headerMap().containsKey("User-Agent")) { + request.setHeader("User-Agent", Version.getCompleteVersionString()); + } + } + + protected void setFixedLengthStreamingMode(int i) { + fixedBuffer = buffer; + } + public void thresholdReached() throws IOException { + request.setChunked(true); + } + + protected void setupWrappedStream() throws IOException { + + wrappedStream = new OutputStream() { + public void write(int b) throws IOException { + } + }; + if (fixedBuffer != null) { + request.addHeader("Content-Length", Integer.toString(fixedBuffer.size())); + request.setContent(ChannelBuffers.wrappedBuffer(fixedBuffer.getRawBytes(), 0, fixedBuffer.size())); + } + channelFuture.awaitUninterruptibly(); + channelFuture.getChannel().getPipeline().getContext("cxfhandler").setAttachment(this); + channelFuture.getChannel().write(request); + } + + protected void handleResponseAsync() throws IOException { + } + protected void closeInputStream() throws IOException { + } + + protected boolean usingProxy() { + return false; + } + protected HttpsURLConnectionInfo getHttpsURLConnectionInfo() throws IOException { + return null; + } + protected int getResponseCode() throws IOException { + waitForResponse(); + return response.getStatus().getCode(); + } + protected String getResponseMessage() throws IOException { + waitForResponse(); + return response.getStatus().getReasonPhrase(); + } + + private void readHeaders(Headers h) { + h.headerMap().clear(); + for (String n : response.getHeaderNames()) { + h.headerMap().put(n, response.getHeaders(n)); + } + } + protected void updateResponseHeaders(Message inMessage) { + Headers h = new Headers(inMessage); + readHeaders(h); + inMessage.put(Message.CONTENT_TYPE, h.determineContentType()); + cookies.readFromHeaders(h); + } + protected void updateCookiesBeforeRetransmit() { + Headers h = new Headers(); + readHeaders(h); + cookies.readFromHeaders(h); + } + protected void retransmitStream() throws IOException { + } + protected void setupNewConnection(String newURL) throws IOException { + } + protected InputStream getInputStream() throws IOException { + return new ChannelBufferInputStream(response.getContent()) { + public void close() throws IOException { + super.close(); + } + }; + } + protected InputStream getPartialResponse() throws IOException { + return null; + } + + } + +} Added: cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPTransportFactory.java URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPTransportFactory.java?rev=1366487&view=auto ============================================================================== --- cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPTransportFactory.java (added) +++ cxf/sandbox/dkulp_async_clients/http-netty/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPTransportFactory.java Fri Jul 27 18:42:30 2012 @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.transport.http.asyncclient; + +import java.io.IOException; + +import javax.annotation.Resource; + +import org.apache.cxf.Bus; +import org.apache.cxf.buslifecycle.BusLifeCycleListener; +import org.apache.cxf.buslifecycle.BusLifeCycleManager; +import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.transport.Conduit; +import org.apache.cxf.transport.http.DestinationRegistry; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transport.http.HTTPConduitConfigurer; +import org.apache.cxf.transport.http.HTTPTransportFactory; +import org.apache.cxf.ws.addressing.EndpointReferenceType; +import org.jboss.netty.channel.socket.ClientSocketChannelFactory; +import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; + +/** + * + */ +@NoJSR250Annotations(unlessNull = "bus") +public class AsyncHTTPTransportFactory extends HTTPTransportFactory implements BusLifeCycleListener { + ClientSocketChannelFactory channelFactory; + + public AsyncHTTPTransportFactory() { + super(); + } + public AsyncHTTPTransportFactory(Bus b) { + super(b); + addListener(b); + } + public AsyncHTTPTransportFactory(Bus b, DestinationRegistry registry) { + super(b, registry); + addListener(b); + } + + public AsyncHTTPTransportFactory(DestinationRegistry registry) { + super(registry); + } + + @Resource + public void setBus(Bus b) { + super.setBus(b); + addListener(b); + } + public void initComplete() { + } + public synchronized void preShutdown() { + if (channelFactory != null) { + channelFactory.releaseExternalResources(); + } + } + public void postShutdown() { + if (channelFactory != null) { + channelFactory.releaseExternalResources(); + } + } + + private void addListener(Bus b) { + b.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this); + } + + + public synchronized ClientSocketChannelFactory getChannelFactory() { + if (channelFactory == null) { + channelFactory = getBus().getExtension(ClientSocketChannelFactory.class); + if (channelFactory == null) { + channelFactory = (ClientSocketChannelFactory)getBus() + .getProperty(ClientSocketChannelFactory.class.getName()); + } + if (channelFactory == null) { + channelFactory = new NioClientSocketChannelFactory(); + } + } + return channelFactory; + } + + /** + * This call creates a new HTTP Conduit based on the EndpointInfo and + * EndpointReferenceType. + * TODO: What are the formal constraints on EndpointInfo and + * EndpointReferenceType values? + */ + public Conduit getConduit( + EndpointInfo endpointInfo, + EndpointReferenceType target + ) throws IOException { + HTTPConduit conduit = new AsyncHTTPConduit(bus, endpointInfo, target, getChannelFactory()); + // Spring configure the conduit. + String address = conduit.getAddress(); + if (address != null && address.indexOf('?') != -1) { + address = address.substring(0, address.indexOf('?')); + } + HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.class); + if (c1 != null) { + c1.configure(conduit.getBeanName(), address, conduit); + } + configure(conduit, conduit.getBeanName(), address); + conduit.finalizeConfig(); + return conduit; + } + +} Added: cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java?rev=1366487&view=auto ============================================================================== --- cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java (added) +++ cxf/sandbox/dkulp_async_clients/http-netty/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java Fri Jul 27 18:42:30 2012 @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.transport.http.asyncclient; + +import java.net.URL; + +import javax.xml.ws.Endpoint; + +import org.apache.cxf.Bus; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.hello_world.Greeter; +import org.apache.hello_world.services.SOAPService; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + + + +public class AsyncHTTPConduitTest extends AbstractBusClientServerTestBase { + public static final String PORT = allocatePort(AsyncHTTPConduitTest.class); + public static final String PORT2 = allocatePort(AsyncHTTPConduitTest.class, 2); + + static Endpoint ep; + @BeforeClass + public static void start() throws Exception { + Bus b = createStaticBus(); + new AsyncHTTPTransportFactory(b); + ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort", + new org.apache.hello_world.GreeterImpl()); + ep = Endpoint.publish("http://localhost:" + PORT2 + "/SoapContext/SoapPort", + new org.apache.hello_world.GreeterImpl()); + } + + @AfterClass + public static void stop() throws Exception { + ep.stop(); + ep = null; + } + + @Test + public void testCall() throws Exception { + URL wsdl = getClass().getResource("/wsdl/hello_world_services.wsdl"); + assertNotNull("WSDL is null", wsdl); + + SOAPService service = new SOAPService(); + assertNotNull("Service is null", service); + + StringBuilder builder = new StringBuilder("NaNaNa"); + for (int x = 0; x < 1; x++) { + builder.append(" NaNaNa "); + } + + Greeter g = service.getSoapPort(); + assertNotNull("Port is null", g); + updateAddressPort(g, PORT); + g.greetMe(builder.toString()); + } + + @Test + public void testCalls() throws Exception { + URL wsdl = getClass().getResource("/wsdl/hello_world_services.wsdl"); + assertNotNull("WSDL is null", wsdl); + + SOAPService service = new SOAPService(); + assertNotNull("Service is null", service); + + StringBuilder builder = new StringBuilder("NaNaNa"); + for (int x = 0; x < 1; x++) { + builder.append(" NaNaNa "); + } + + Greeter g = service.getSoapPort(); + assertNotNull("Port is null", g); + updateAddressPort(g, PORT); + + //warmup + for (int x = 0; x < 10000; x++) { + //builder.append("a"); + //long s1 = System.nanoTime(); + //System.out.println("aa1: " + s1); + String value = g.greetMe(builder.toString()); + //long s2 = System.nanoTime(); + //System.out.println("aa2: " + s2 + " " + (s2 - s1)); + assertEquals("Hello " + builder.toString(), value); + //System.out.println(); + } + + long start = System.currentTimeMillis(); + for (int x = 0; x < 10000; x++) { + //builder.append("a"); + //long s1 = System.nanoTime(); + //System.out.println("aa1: " + s1); + g.greetMe(builder.toString()); + //long s2 = System.nanoTime(); + //System.out.println("aa2: " + s2 + " " + (s2 - s1)); + //System.out.println(); + } + long end = System.currentTimeMillis(); + System.out.println("Total: " + (end - start)); + /* + updateAddressPort(g, PORT2); + String value = g.greetMe(builder.toString()); + assertEquals("Hello " + builder.toString(), value); + */ + } + +}