Repository: cxf Updated Branches: refs/heads/master 3d747fa08 -> fa69cb2c5
Creating a joint RS and WS NoOsgi test with the jaxws one disabled for now Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fa69cb2c Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fa69cb2c Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fa69cb2c Branch: refs/heads/master Commit: fa69cb2c57f2ae52756f822dde543427a18dd143 Parents: 3d747fa Author: Sergey Beryozkin <[email protected]> Authored: Fri May 15 16:58:50 2015 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Fri May 15 16:58:50 2015 +0100 ---------------------------------------------------------------------- .../jaxrs/JAXRSBlueprintContextListener.java | 3 + .../jaxrs/JAXRSSoapRestBlueprintTest.java | 88 ++++++++++++++++ .../jaxrs/JAXRSUriInfoBlueprintTest.java | 103 ------------------- .../jaxrs_soap_blueprint/WEB-INF/beans.xml | 45 ++++++++ .../jaxrs_soap_blueprint/WEB-INF/web.xml | 45 ++++++++ .../jaxrs_uriinfo_blueprint/WEB-INF/beans.xml | 36 ------- .../jaxrs_uriinfo_blueprint/WEB-INF/web.xml | 45 -------- 7 files changed, 181 insertions(+), 184 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSBlueprintContextListener.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSBlueprintContextListener.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSBlueprintContextListener.java index 8aa8889..035cac6 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSBlueprintContextListener.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSBlueprintContextListener.java @@ -37,6 +37,9 @@ public class JAXRSBlueprintContextListener extends BlueprintContextListener { set.addNamespace(URI.create("http://cxf.apache.org/blueprint/jaxrs"), getClass().getResource("/schemas/blueprint/jaxrs.xsd"), new JAXRSBPNamespaceHandler()); + set.addNamespace(URI.create("http://cxf.apache.org/blueprint/jaxws"), + getClass().getResource("/schemas/blueprint/jaxws.xsd"), + new JAXRSBPNamespaceHandler()); return set; } } http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapRestBlueprintTest.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapRestBlueprintTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapRestBlueprintTest.java new file mode 100644 index 0000000..071ab17 --- /dev/null +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapRestBlueprintTest.java @@ -0,0 +1,88 @@ +/** + * 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.systest.jaxrs; + +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.soap.SOAPBinding; + +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.systest.jaxrs.jaxws.HelloWorld; +import org.apache.cxf.systest.jaxrs.jaxws.User; +import org.apache.cxf.systest.jaxrs.jaxws.UserImpl; +import org.apache.cxf.testutil.common.AbstractClientServerTestBase; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class JAXRSSoapRestBlueprintTest extends AbstractClientServerTestBase { + public static final int PORT = BlueprintServer.PORT; + @BeforeClass + public static void beforeClass() throws Exception { + // must be 'in-process' to communicate with inner class in single JVM + // and to spawn class SpringServer w/o using main() method + launchServer(BlueprintServer.class, true); + } + + @Ignore + public static class BlueprintServer extends AbstractSpringServer { + public static final int PORT = allocatePortAsInt(BlueprintServer.class); + public BlueprintServer() { + super("/jaxrs_soap_blueprint", "/bp", PORT); + } + } + @Test + public void testHelloRest() throws Exception { + String address = "http://localhost:" + PORT + "/bp/services/hello-rest"; + + HelloWorld service = JAXRSClientFactory.create(address, HelloWorld.class); + useHelloService(service); + } + + @Test + @Ignore + public void testHelloSoap() throws Exception { + final QName serviceName = new QName("http://hello.com", "HelloWorld"); + final QName portName = new QName("http://hello.com", "HelloWorldPort"); + final String address = "http://localhost:" + PORT + "/bp/services/hello-soap"; + + Service service = Service.create(serviceName); + service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address); + + HelloWorld hw = service.getPort(HelloWorld.class); + + useHelloService(hw); + } + private void useHelloService(HelloWorld service) { + assertEquals("Hello Barry", service.sayHi("Barry")); + assertEquals("Hello Fred", service.sayHiToUser(new UserImpl("Fred"))); + + Map<Integer, User> users = service.getUsers(); + assertEquals(1, users.size()); + assertEquals("Fred", users.entrySet().iterator().next().getValue().getName()); + + users = service.echoUsers(users); + assertEquals(1, users.size()); + assertEquals("Fred", users.entrySet().iterator().next().getValue().getName()); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoBlueprintTest.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoBlueprintTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoBlueprintTest.java deleted file mode 100644 index 3ff2e8f..0000000 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoBlueprintTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * 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.systest.jaxrs; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.UriInfo; - -import org.apache.cxf.jaxrs.client.WebClient; -import org.apache.cxf.testutil.common.AbstractClientServerTestBase; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -public class JAXRSUriInfoBlueprintTest extends AbstractClientServerTestBase { - public static final int PORT = SpringServer.PORT; - @BeforeClass - public static void beforeClass() throws Exception { - // must be 'in-process' to communicate with inner class in single JVM - // and to spawn class SpringServer w/o using main() method - launchServer(SpringServer.class, true); - } - - @Ignore - public static class SpringServer extends AbstractSpringServer { - public static final int PORT = allocatePortAsInt(SpringServer.class); - public SpringServer() { - super("/jaxrs_uriinfo_blueprint", "/bp", PORT); - } - } - - /** - * URI | getBaseUri | path param --------------+---------------------+----------- -/app/v1 | http://host/ | "v1" -/app/v1/ | http://host/ | "v1/" -/app/v1/test | http://host/app/v1/ | "test" -/app/v1/ | http://host/app/v1/ | "" -/app/v1 | http://host/app/v1/ | "app/v1" - * @throws Exception - */ - @Test - public void testBasePathAndPathAndPathParam() throws Exception { - checkUriInfo("http://localhost:" + PORT + "/bp/v1", "\"\"", "/"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/", "\"\"", "/"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/test", "\"test\"", "test"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/", "\"\"", "/"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1", "\"\"", "/"); - - checkUriInfo("http://localhost:" + PORT + "/bp/v1/bar", "\"bar\"", "bar"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/bar", "\"bar\"", "bar"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/bar/test", "\"bar/test\"", "bar/test"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/bar", "\"bar\"", "bar"); - checkUriInfo("http://localhost:" + PORT + "/bp/v1/bar", "\"bar\"", "bar"); - } - - private void checkUriInfo(String address, String path, String pathParam) { - WebClient wc = WebClient.create(address); - wc.accept("text/plain"); - String data = wc.get(String.class); - assertEquals("http://localhost:" + PORT + "/bp/v1/," + path + "," + pathParam, data); - } - - @Ignore - @Path("/") - public static class Resource { - - @Context - private UriInfo uriInfo; - - @GET - @Path("/{path:.*}") - @Produces("text/plain") - public String getBasePathAndPathParam(@PathParam("path") String path) { - StringBuilder sb = new StringBuilder(); - sb.append(uriInfo.getBaseUri()); - sb.append(",\"" + path + "\""); - sb.append("," + uriInfo.getPath()); - return sb.toString(); - } - - } -} http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/beans.xml new file mode 100644 index 0000000..691607c --- /dev/null +++ b/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/beans.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs" + xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" + xmlns:cxf="http://cxf.apache.org/blueprint/core" + xsi:schemaLocation=" + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd + http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd + http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxws.xsd + http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd + "> + <cxf:bus/> + + <bean id="resourceBean" class="org.apache.cxf.systest.jaxrs.jaxws.HelloWorldImpl"/> + + <jaxrs:server id="hello_rest" address="/hello-rest"> + <jaxrs:serviceBeans> + <ref component-id="resourceBean" /> + </jaxrs:serviceBeans> + </jaxrs:server> + + <jaxws:endpoint xmlns:s="http://hello.com" + serviceName="s:HelloWorld" + endpointName="s:HelloWorldPort" + id="hello_soap" + implementor="#resourceBean" + address="/hello-soap"/> +</blueprint> http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/web.xml new file mode 100644 index 0000000..22dfb3f --- /dev/null +++ b/systests/jaxrs/src/test/resources/jaxrs_soap_blueprint/WEB-INF/web.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<!-- + 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. +--> +<!-- START SNIPPET: webxml --> +<web-app> + <context-param> + <param-name>blueprintLocation</param-name> + <param-value>jaxrs_soap_blueprint/WEB-INF/beans.xml</param-value> + </context-param> + <listener> + <listener-class> + org.apache.cxf.systest.jaxrs.JAXRSBlueprintContextListener + </listener-class> + </listener> + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class> + org.apache.cxf.transport.servlet.blueprint.CXFBlueprintServlet + </servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/services/*</url-pattern> + </servlet-mapping> +</web-app> +<!-- END SNIPPET: webxml --> http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml deleted file mode 100644 index f96ca80..0000000 --- a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> - -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs" - xmlns:cxf="http://cxf.apache.org/blueprint/core" - xsi:schemaLocation=" - http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd - http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd - http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd - "> - <cxf:bus/> - - <jaxrs:server id="resourceServer" address="/"> - <jaxrs:serviceBeans> - <ref component-id="resourceBean" /> - </jaxrs:serviceBeans> - </jaxrs:server> - - <bean id="resourceBean" class="org.apache.cxf.systest.jaxrs.JAXRSUriInfoBlueprintTest.Resource"/> -</blueprint> http://git-wip-us.apache.org/repos/asf/cxf/blob/fa69cb2c/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/web.xml deleted file mode 100644 index 81c4b08..0000000 --- a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/web.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -<!-- - 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. ---> -<!-- START SNIPPET: webxml --> -<web-app> - <context-param> - <param-name>blueprintLocation</param-name> - <param-value>jaxrs_uriinfo_blueprint/WEB-INF/beans.xml</param-value> - </context-param> - <listener> - <listener-class> - org.apache.cxf.systest.jaxrs.JAXRSBlueprintContextListener - </listener-class> - </listener> - <servlet> - <servlet-name>CXFServlet</servlet-name> - <display-name>CXF Servlet</display-name> - <servlet-class> - org.apache.cxf.transport.servlet.blueprint.CXFBlueprintServlet - </servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>CXFServlet</servlet-name> - <url-pattern>/v1/*</url-pattern> - </servlet-mapping> -</web-app> -<!-- END SNIPPET: webxml -->
