Author: heiko.braun(a)jboss.com
Date: 2008-04-07 13:20:16 -0400 (Mon, 07 Apr 2008)
New Revision: 6263
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/TJWSHttpDeamon.java
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TJWSHttpDeamonTestCase.java
Removed:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
Modified:
framework/branches/hbraun/ant-import/build-thirdparty.xml
framework/branches/hbraun/framework-3.0.iml
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
framework/branches/hbraun/version.properties
Log:
SWwitching to TJWS for embedded use
Modified: framework/branches/hbraun/ant-import/build-thirdparty.xml
===================================================================
--- framework/branches/hbraun/ant-import/build-thirdparty.xml 2008-04-07 17:19:38 UTC (rev
6262)
+++ framework/branches/hbraun/ant-import/build-thirdparty.xml 2008-04-07 17:20:16 UTC (rev
6263)
@@ -48,8 +48,7 @@
<get
src="${jboss.repository}/jboss/jboss-javaee/${jboss-javaee}/lib/jboss-javaee.jar"
dest="${thirdparty.dir}/jboss-javaee.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/jboss/jbossxb/${jboss-jbossxb}/lib/jboss-xml-binding.jar"
dest="${thirdparty.dir}/jboss-xml-binding.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/jboss/jbossxb/${jboss-jbossxb}/lib/jboss-xml-binding-sources.jar"
dest="${thirdparty.dir}/jboss-xml-binding-sources.jar"
usetimestamp="true" verbose="true"/>
- <get src="${jboss.repository}/jetty/${jetty}/lib/jetty.jar"
dest="${thirdparty.dir}/jetty.jar" usetimestamp="true"
verbose="true"/>
- <get src="${jboss.repository}/jetty/${jetty}/lib/jetty-util.jar"
dest="${thirdparty.dir}/jetty-util.jar" usetimestamp="true"
verbose="true"/>
+ <get src="${jboss.repository}/tjws/${tjws}/lib/webserver.jar"
dest="${thirdparty.dir}/webserver.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaf/${sun-jaf}/lib/activation.jar"
dest="${thirdparty.dir}/activation.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaxb/${sun-jaxb}/lib/jaxb-api.jar"
dest="${thirdparty.dir}/jaxb-api.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/sun-jaxrpc/${sun-jaxrpc}/lib/jaxrpc-api.jar"
dest="${thirdparty.dir}/jaxrpc-api.jar" usetimestamp="true"
verbose="true"/>
@@ -75,10 +74,9 @@
<pathelement location="${thirdparty.dir}/jbossws-spi.jar"/>
<pathelement location="${thirdparty.dir}/jaxws-api.jar"/>
<pathelement location="${thirdparty.dir}/jaxrpc-api.jar"/>
- <pathelement location="${thirdparty.dir}/jetty.jar"/>
- <pathelement location="${thirdparty.dir}/jetty-util.jar"/>
<pathelement location="${thirdparty.dir}/jsr181-api.jar"/>
<pathelement location="${thirdparty.dir}/saaj-api.jar"/>
+ <pathelement location="${thirdparty.dir}/webserver.jar"/>
</path>
</target>
Modified: framework/branches/hbraun/framework-3.0.iml
===================================================================
--- framework/branches/hbraun/framework-3.0.iml 2008-04-07 17:19:38 UTC (rev 6262)
+++ framework/branches/hbraun/framework-3.0.iml 2008-04-07 17:20:16 UTC (rev 6263)
@@ -165,6 +165,24 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/webserver.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-spi.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
</module>
Deleted:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-04-07
17:19:38 UTC (rev 6262)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -1,228 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.framework.transport;
-
-import org.jboss.logging.Logger;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHandler;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class HttpDeamon
-{
- private static final Logger LOG = Logger.getLogger(HttpDeamon.class);
- private static final Lock CLASS_LOCK = new ReentrantLock();
- private static HttpDeamon INSTANCE = null;
-
- private final int port;
-
- // Jetty stuff below
- private Server server = null;
- private final ContextHandlerCollection contexts;
-
- private HttpDeamon(int port)
- {
- this.port = port;
- this.server = new Server(port);
-
- this.contexts = new ContextHandlerCollection();
- this.server.setHandler(contexts);
-
- Context root = new Context(contexts,"/");
- root.addServlet(new ServletHolder(new HelloServlet("JBossWS
HttpDeamon")), "/*");
- }
-
- public int getPort()
- {
- return port;
- }
-
- public void start()
- {
- try
- {
- this.server.start();
- } catch (Exception e)
- {
- LOG.error("Failed to start Jetty", e);
- }
- }
-
- public void stop()
- {
- try
- {
- this.server.stop();
- } catch (Exception e)
- {
- LOG.error("Failed to stop Jetty", e);
- }
- }
-
- /**
- * Add a servlet for a contextand url pattern.
- *
- * @param contextPath
- * @param urlPattern
- * @param servletClass
- */
- public void addServletContext(String contextPath, String urlPattern, Servlet
servletClass)
- {
- try
- {
- Context context = new Context();
- context.setContextPath(contextPath);
- ServletHolder holder = new ServletHolder(servletClass);
- context.addServlet(holder, urlPattern);
- context.start();
- this.contexts.addHandler(context);
-
- LOG.info("Added web context " + contextPath + "/" +
urlPattern);
-
- } catch (Exception e)
- {
- throw new RuntimeException("Failed to start webcontext: "
+contextPath, e );
- }
- }
-
- public void removeServletContext(String contextPath, String urlPattern)
- {
-
- Handler match = null;
-
- for(Handler h : this.contexts.getHandlers())
- {
- if(h instanceof Context)
- {
- Context c = (Context)h;
- ServletHandler sh = c.getServletHandler();
-
- if(sh!=null)
- {
- ServletContext servletContext = sh.getServletContext();
- String ctxPath = servletContext.getContextPath();
- if(contextPath.equals(ctxPath))
- {
- // undeploy _any_ endpoint under this context
- // TODO: Verify if that's really applicable
- LOG.info("Remove web context " + ctxPath);
- try
- {
- sh.stop();
- c.stop();
- } catch (Exception e)
- {
- LOG.error("Failed to stop context", e);
- }
-
- break;
- }
- }
- }
- }
-
- if(null==match)
- {
- LOG.warn("No such context " + contextPath + "/" +
urlPattern);
- }
- else
- {
- this.contexts.removeHandler(match);
- }
- }
-
- public static HttpDeamon getInstance(int port)
- {
- CLASS_LOCK.lock();
- try
- {
- if (INSTANCE == null)
- {
- INSTANCE = new HttpDeamon(port);
-
- try
- {
- INSTANCE.start();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to start HttpDeamon", e);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- public void run()
- {
- try
- {
- INSTANCE.stop();
- } catch (Exception e)
- {
- //
- }
- }
- }, "HttpDeamonShutDownHook"));
- }
- else
- {
- LOG.warn("There is already a HttpDeamon running on port: " +
INSTANCE.getPort());
- }
- return INSTANCE;
- }
- finally
- {
- CLASS_LOCK.unlock();
- }
- }
-
- public static class HelloServlet extends HttpServlet
- {
- String greeting="Hello";
- public HelloServlet()
- {}
-
- public HelloServlet(String hi)
- {greeting=hi;}
-
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- response.setContentType("text/plain");
- response.setStatus(HttpServletResponse.SC_OK);
- response.getWriter().println(greeting);
- }
- }
-}
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.framework.transport;
+
+import javax.servlet.Servlet;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public interface HttpDeamon
+{
+
+ int DEFAULT_PORT = 20000;
+
+ int getPort();
+
+ void start();
+
+ void stop();
+
+ void addServletContext(String contextPath, String urlPattern, Servlet servletClass);
+
+ void removeServletContext(String contextPath, String urlPattern);
+}
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java 2008-04-07
17:19:38 UTC (rev 6262)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -30,9 +30,9 @@
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.transport.HttpSpec;
import org.jboss.wsf.spi.transport.ListenerRef;
import org.jboss.wsf.spi.transport.TransportManager;
-import org.jboss.wsf.spi.transport.HttpSpec;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -62,7 +62,7 @@
this.host = host;
this.port = port;
- this.httpDeamon = HttpDeamon.getInstance(DEFAULT_PORT);
+ this.httpDeamon = TJWSHttpDeamon.getInstance(DEFAULT_PORT);
this.httpDeamon.start();
}
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/TJWSHttpDeamon.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/TJWSHttpDeamon.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/TJWSHttpDeamon.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.framework.transport;
+
+import Acme.Serve.Serve;
+import org.jboss.logging.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class TJWSHttpDeamon implements HttpDeamon
+{
+ private int port;
+ private Acme.Serve.Serve server;
+
+ private static final Logger LOG = Logger.getLogger(TJWSHttpDeamon.class);
+ private static final Lock CLASS_LOCK = new ReentrantLock();
+ private static HttpDeamon INSTANCE = null;
+
+ private boolean started = false;
+
+ private Map<String, Servlet> servlets = new HashMap<String, Servlet>();
+
+ private TJWSHttpDeamon(int port)
+ {
+ this.port = port;
+ server = new Acme.Serve.Serve();
+
+ Properties properties = new java.util.Properties();
+ properties.put("port", port);
+ properties.setProperty(Acme.Serve.Serve.ARG_NOHUP, "nohup");
+
+ server.arguments = properties;
+ server.addDefaultServlets(null);
+ server.addServlet("/", new HelloServlet("JBossWS
HttpDeamon"));
+ }
+
+ public int getPort()
+ {
+ return this.port;
+ }
+
+ public void start()
+ {
+ CLASS_LOCK.lock();
+ try
+ {
+ if(!started)
+ {
+ Thread t = new Thread( new DoServe(server));
+ t.start();
+ started = true;
+ }
+
+ } finally
+ {
+ CLASS_LOCK.unlock();
+ }
+ }
+
+ public void stop()
+ {
+ try
+ {
+ server.notifyStop();
+ } catch (IOException e)
+ {
+ //
+ }
+
+ server.destroyAllServlets();
+ }
+
+ public void addServletContext(String contextPath, String urlPattern, Servlet servlet)
+ {
+ CLASS_LOCK.lock();
+
+ try
+ {
+ if(!contextPath.startsWith("/"))
+ contextPath = "/"+contextPath;
+
+ // TODO: urlpattern not used?
+
+ server.addServlet(contextPath, servlet);
+
+ // remeber servlet, required for subsequent remove
+ servlets.put(contextPath, servlet);
+ }
+ finally
+ {
+ CLASS_LOCK.unlock();
+ }
+ }
+
+ public void removeServletContext(String contextPath, String urlPattern)
+ {
+ CLASS_LOCK.lock();
+
+ try
+ {
+ Servlet servlet = servlets.remove(contextPath);
+ if(servlet!=null)
+ {
+ // TJWS is missing a removeContext method
+ server.destroyAllServlets();
+ for(String ctx : servlets.keySet())
+ {
+ server.addServlet(ctx, servlets.get(ctx));
+ }
+
+ server.addServlet("/", new HelloServlet("JBossWS
HttpDeamon"));
+ }
+
+ } finally
+ {
+ CLASS_LOCK.unlock();
+ }
+
+ }
+
+ // TODO: Move to factory base class
+ public static HttpDeamon getInstance(int port)
+ {
+ CLASS_LOCK.lock();
+ try
+ {
+ if (INSTANCE == null)
+ {
+ INSTANCE = new TJWSHttpDeamon(port);
+
+ try
+ {
+ INSTANCE.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to start HttpDeamon", e);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ public void run()
+ {
+ try
+ {
+ INSTANCE.stop();
+ } catch (Exception e)
+ {
+ //
+ }
+ }
+ }, "HttpDeamonShutDownHook"));
+ }
+ else
+ {
+ LOG.warn("There is already a HttpDeamon running on port: " +
INSTANCE.getPort());
+ }
+
+ return INSTANCE;
+ }
+ finally
+ {
+ CLASS_LOCK.unlock();
+ }
+ }
+
+ public static class HelloServlet extends HttpServlet
+ {
+ String greeting="Hello";
+ public HelloServlet()
+ {}
+
+ public HelloServlet(String hi)
+ {greeting=hi;}
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ response.setContentType("text/plain");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().println(greeting);
+ }
+ }
+
+ private class DoServe implements Runnable
+ {
+ private Acme.Serve.Serve server;
+
+
+ public void run()
+ {
+ this.server.serve();
+ }
+
+ public DoServe(Serve server)
+ {
+ this.server = server;
+ }
+ }
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/TJWSHttpDeamon.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
===================================================================
---
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java 2008-04-07
17:19:38 UTC (rev 6262)
+++
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.framework.transport;
-
-import junit.framework.TestCase;
-import org.jboss.wsf.framework.transport.HttpDeamon;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class HttpDeamonTestCase extends TestCase
-{
- private static HttpDeamon SERVER = HttpDeamon.getInstance(20000);
-
- public void testRootContext() throws Exception
- {
- String response = GETRequest("");
- assertEquals("JBossWS HttpDeamon", response.toString());
- }
-
- public void testContextCreation() throws Exception
- {
- SERVER.addServletContext("/endpoint", "/*", new
TestSampleServlet());
- assertEquals("I'm a web service endpoint",
GETRequest("endpoint"));
- }
-
- public static String GETRequest(String context)
- throws IOException
- {
- if(context.startsWith("/"))
- context = context.substring(1);
-
- URLConnection con = new
URL("http://localhost:20000/"+context).openConnection();
- con.connect();
-
- BufferedReader in = new BufferedReader(
- new InputStreamReader(
- con.getInputStream()
- )
- );
-
- String inputLine;
- StringBuffer sb = new StringBuffer();
- while ((inputLine = in.readLine()) != null)
- sb.append(inputLine);
- in.close();
- return sb.toString();
- }
-}
-
Added:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TJWSHttpDeamonTestCase.java
===================================================================
---
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TJWSHttpDeamonTestCase.java
(rev 0)
+++
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TJWSHttpDeamonTestCase.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.framework.transport;
+
+import org.jboss.wsf.framework.transport.HttpDeamon;
+import org.jboss.wsf.framework.transport.TJWSHttpDeamon;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URLConnection;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class TJWSHttpDeamonTestCase extends TestCase
+{
+ private static HttpDeamon SERVER =
TJWSHttpDeamon.getInstance(HttpDeamon.DEFAULT_PORT);
+
+ public void testRootContext() throws Exception
+ {
+ String response = GETRequest("");
+ assertEquals("JBossWS HttpDeamon", response.toString());
+ }
+
+ public void testContextCreation() throws Exception
+ {
+ SERVER.addServletContext("/endpoint", "/*", new
TestSampleServlet());
+ assertEquals("I'm a web service endpoint",
GETRequest("endpoint"));
+ }
+
+ public static String GETRequest(String context)
+ throws IOException
+ {
+ if(context.startsWith("/"))
+ context = context.substring(1);
+
+ URLConnection con = new
URL("http://localhost:20000/"+context).openConnection();
+ con.connect();
+
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(
+ con.getInputStream()
+ )
+ );
+
+ String inputLine;
+ StringBuffer sb = new StringBuffer();
+ while ((inputLine = in.readLine()) != null)
+ sb.append(inputLine);
+ in.close();
+ return sb.toString();
+ }
+}
Property changes on:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TJWSHttpDeamonTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
===================================================================
---
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java 2008-04-07
17:19:38 UTC (rev 6262)
+++
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java 2008-04-07
17:20:16 UTC (rev 6263)
@@ -23,17 +23,11 @@
import junit.framework.TestCase;
import org.jboss.wsf.framework.DefaultSPIProviderResolver;
-import org.jboss.wsf.framework.transport.HttpSpec;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.transport.ListenerRef;
-import org.jboss.wsf.spi.transport.Protocol;
-import org.jboss.wsf.spi.transport.TransportManager;
-import org.jboss.wsf.spi.transport.TransportManagerFactory;
+import org.jboss.wsf.spi.transport.*;
-import javax.management.ObjectName;
-
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -63,7 +57,7 @@
System.out.println(ref.getProtocol() +": "+ref.getAddress());
// Invoke the sample endpoint
- String response = HttpDeamonTestCase.GETRequest("/myWebContext");
+ String response = TJWSHttpDeamonTestCase.GETRequest("/myWebContext");
System.out.println(response);
// Destroy the Listener
Modified: framework/branches/hbraun/version.properties
===================================================================
--- framework/branches/hbraun/version.properties 2008-04-07 17:19:38 UTC (rev 6262)
+++ framework/branches/hbraun/version.properties 2008-04-07 17:20:16 UTC (rev 6263)
@@ -24,7 +24,7 @@
jboss-javaee=5.0.0.Beta3
jboss-microcontainer=2.0.0.Beta3
jboss-jbossxb=1.0.0.GA
-jetty=6.1.8
+tjws=1.33
sun-jaf=1.1
sun-jaxb=2.1.4
sun-jaxrpc=1.1