Add a test for the http-jetty support.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7f069520 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7f069520 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7f069520 Branch: refs/heads/3.0.x-fixes Commit: 7f069520125ecf0b759dcc7d76be72d22d966689 Parents: 95c3865 Author: Daniel Kulp <dk...@apache.org> Authored: Thu Sep 4 12:43:17 2014 -0400 Committer: Daniel Kulp <dk...@apache.org> Committed: Fri Sep 12 13:58:11 2014 -0400 ---------------------------------------------------------------------- osgi/itests/pom.xml | 5 +++++ .../cxf/osgi/itests/soap/HttpServiceTest.java | 19 ++++++++++++++----- .../cxf/osgi/itests/soap/HttpTestActivator.java | 13 ++++++++++++- 3 files changed, 31 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/7f069520/osgi/itests/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/itests/pom.xml b/osgi/itests/pom.xml index d2c53d4..93dce8c 100644 --- a/osgi/itests/pom.xml +++ b/osgi/itests/pom.xml @@ -45,6 +45,11 @@ </dependency> <dependency> <groupId>org.apache.cxf</groupId> + <artifactId>cxf-testutils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-jms</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/cxf/blob/7f069520/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java ---------------------------------------------------------------------- diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java index 8420a6a..731a40d 100644 --- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java +++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java @@ -22,9 +22,11 @@ import java.io.InputStream; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.osgi.itests.CXFOSGiTestSupport; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; + import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; @@ -33,6 +35,7 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import org.ops4j.pax.tinybundles.core.TinyBundles; import org.osgi.framework.Constants; + import static org.ops4j.pax.exam.CoreOptions.provision; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; @@ -43,24 +46,30 @@ public class HttpServiceTest extends CXFOSGiTestSupport { @Test public void testHttpEndpoint() throws Exception { - Greeter greeter = greeterHttp(); + Greeter greeter = greeterHttp("8181"); + String res = greeter.greetMe("Chris"); + Assert.assertEquals("Hi Chris", res); + } + @Test + public void testHttpEndpointJetty() throws Exception { + Greeter greeter = greeterHttp(HttpTestActivator.PORT); String res = greeter.greetMe("Chris"); Assert.assertEquals("Hi Chris", res); } - private Greeter greeterHttp() { + private Greeter greeterHttp(String port) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(Greeter.class); - factory.setAddress("http://localhost:8181/cxf/greeter"); + factory.setAddress("http://localhost:" + port + "/cxf/greeter"); return factory.create(Greeter.class); } @Configuration public Option[] config() { return new Option[] { - cxfBaseConfig(), + cxfBaseConfigWithTestUtils(), logLevel(LogLevel.INFO), - features(cxfUrl, "cxf-http"), + features(cxfUrl, "cxf-http", "cxf-http-jetty"), provision(serviceBundle()) }; } http://git-wip-us.apache.org/repos/asf/cxf/blob/7f069520/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java ---------------------------------------------------------------------- diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java index 5082508..6fa7226 100644 --- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java +++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java @@ -20,12 +20,14 @@ package org.apache.cxf.osgi.itests.soap; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; +import org.apache.cxf.testutil.common.TestUtil; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class HttpTestActivator implements BundleActivator { - + public static final String PORT = TestUtil.getPortNumber(HttpTestActivator.class); private Server server; + private Server serverJetty; @Override public void start(BundleContext arg0) throws Exception { @@ -34,11 +36,20 @@ public class HttpTestActivator implements BundleActivator { factory.setAddress("/greeter"); factory.setServiceBean(new GreeterImpl()); server = factory.create(); + + factory = new JaxWsServerFactoryBean(); + factory.setServiceClass(Greeter.class); + factory.setAddress("http://localhost:" + PORT + "/cxf/greeter"); + factory.setServiceBean(new GreeterImpl()); + serverJetty = factory.create(); } @Override public void stop(BundleContext arg0) throws Exception { + server.stop(); server.destroy(); + serverJetty.stop(); + serverJetty.destroy(); } }