You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2018/01/19 13:02:01 UTC
[cxf] 02/02: [CXF-7614] Adding test resource
This is an automated email from the ASF dual-hosted git repository.
sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 5b03b98d4de710fe6d36c520ccf4269177ef21c4
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Fri Jan 19 13:01:36 2018 +0000
[CXF-7614] Adding test resource
---
.../apache/cxf/systest/jaxrs/BookServerSub.java | 59 ++++++++++++++++++++++
.../cxf/systest/jaxrs/BookStoreSubObject.java | 34 +++++++++++++
.../jaxrs/JAXRSClientServerSubBookTest.java | 49 ++++++++++++++++++
3 files changed, 142 insertions(+)
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerSub.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerSub.java
new file mode 100644
index 0000000..0156cd2
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerSub.java
@@ -0,0 +1,59 @@
+/**
+ * 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 org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class BookServerSub extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(BookServerSub.class);
+
+ org.apache.cxf.endpoint.Server server;
+
+ protected void run() {
+ JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+ sf.setStaticSubresourceResolution(true);
+ sf.setResourceClasses(BookStoreSubObject.class);
+ sf.setResourceProvider(BookStoreSubObject.class,
+ new SingletonResourceProvider(new BookStoreSubObject(), true));
+ sf.setAddress("http://localhost:" + PORT + "/");
+ server = sf.create();
+ }
+
+ public void tearDown() throws Exception {
+ server.stop();
+ server.destroy();
+ server = null;
+ }
+
+ public static void main(String[] args) {
+ try {
+ BookServerSub s = new BookServerSub();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+
+}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSubObject.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSubObject.java
new file mode 100644
index 0000000..34b8101
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSubObject.java
@@ -0,0 +1,34 @@
+/**
+ * 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.Path;
+
+@Path("/bookstore")
+public class BookStoreSubObject {
+
+ @Path("/booksubresourceobject")
+ public Object getBookSubResourceObject() throws BookNotFoundFault {
+ return new Book();
+ }
+}
+
+
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSubBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSubBookTest.java
new file mode 100644
index 0000000..ea79fd9
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSubBookTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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 org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JAXRSClientServerSubBookTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = BookServerSub.PORT;
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ AbstractResourceInfo.clearAllMaps();
+ assertTrue("server did not launch correctly",
+ launchServer(BookServerSub.class, true));
+ createStaticBus();
+ }
+
+ @Test
+ public void testGetChapterFromBookSubObject() throws Exception {
+ WebClient wc =
+ WebClient.create("http://localhost:" + PORT + "/bookstore/booksubresourceobject/chaptersobject/sub/1");
+ WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
+ Chapter c = wc.accept("application/xml").get(Chapter.class);
+ assertNotNull(c);
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.