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 2009/05/21 16:17:32 UTC
svn commit: r777126 [2/2] - in /cxf/trunk:
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/
rt/frontend/jaxrs/src/main/java/org...
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Thu May 21 14:17:30 2009
@@ -44,6 +44,8 @@
<xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="properties" type="beans:mapType" minOccurs="0"/>
<xsd:element name="serviceBeans" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="modelBeans" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="model" type="model" minOccurs="0"/>
<xsd:element name="serviceFactory" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="extensionMappings" type="xsd:anyType" minOccurs="0"/>
@@ -59,6 +61,7 @@
<xsd:attribute name="transportId" type="xsd:string"/>
<xsd:attribute name="endpointName" type="xsd:QName" />
<xsd:attribute name="serviceName" type="xsd:QName" />
+ <xsd:attribute name="modelRef" type="xsd:string" />
<xsd:attribute name="staticSubresourceResolution" type="xsd:boolean" />
</xsd:extension>
</xsd:complexContent>
@@ -79,6 +82,8 @@
<xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="properties" type="beans:mapType" minOccurs="0"/>
<xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="modelBeans" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="model" type="model" minOccurs="0"/>
<xsd:element name="headers" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="schemaLocations" type="schemasType" minOccurs="0"/>
</xsd:all>
@@ -87,6 +92,7 @@
<xsd:attribute name="serviceClass" type="xsd:string"/>
<xsd:attribute name="inheritHeaders" type="xsd:boolean"/>
<xsd:attribute name="bus" type="xsd:string" />
+ <xsd:attribute name="modelRef" type="xsd:string" />
<xsd:attribute name="username" type="xsd:string"/>
<xsd:attribute name="password" type="xsd:string"/>
</xsd:extension>
@@ -100,4 +106,35 @@
</xsd:sequence>
</xsd:complexType>
+ <xsd:complexType name="model">
+ <xsd:sequence>
+ <xsd:element name="resource" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="operation" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="param" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="type" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="path" type="xsd:string"/>
+ <xsd:attribute name="verb" type="xsd:string"/>
+ <xsd:attribute name="consumes" type="xsd:string"/>
+ <xsd:attribute name="produces" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="path" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string"/>
+ </xsd:complexType>
+
</xsd:schema>
Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java Thu May 21 14:17:30 2009
@@ -22,6 +22,7 @@
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
+import org.apache.cxf.jaxrs.model.ParameterType;
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageImpl;
Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Thu May 21 14:17:30 2009
@@ -1025,10 +1025,9 @@
Customer.class.getMethod("setUriInfoContext",
new Class[]{UriInfo.class});
OperationResourceInfo ori =
- new OperationResourceInfo(methodToInvoke, cri);
+ new OperationResourceInfo(methodToInvoke,
+ AnnotationUtils.getAnnotatedMethod(methodToInvoke), cri);
ori.setHttpMethod("GET");
- ori.setAnnotatedMethod(AnnotationUtils.getAnnotatedMethod(methodToInvoke));
-
Message m = new MessageImpl();
Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java Thu May 21 14:17:30 2009
@@ -19,10 +19,21 @@
package org.apache.cxf.jaxrs.utils;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.UriInfo;
import org.apache.cxf.jaxrs.Customer;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserOperation;
+import org.apache.cxf.jaxrs.model.UserResource;
import org.junit.Assert;
import org.junit.Test;
@@ -38,5 +49,32 @@
assertEquals(String.class, c.getParameterTypes()[1]);
}
+ @Test
+ public void testClassResourceInfoUserResource() throws Exception {
+ UserResource ur = new UserResource();
+ ur.setName(HashMap.class.getName());
+ ur.setPath("/hashmap");
+ UserOperation op = new UserOperation();
+ op.setPath("/key/{id}");
+ op.setName("get");
+ op.setVerb("POST");
+ op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));
+ ur.setOperations(Collections.singletonList(op));
+
+ Map<String, UserResource> resources = new HashMap<String, UserResource>();
+ resources.put(ur.getName(), ur);
+ ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(resources, ur, true);
+ assertNotNull(cri);
+ assertEquals("/hashmap", cri.getURITemplate().getValue());
+ Method method =
+ HashMap.class.getMethod("get", new Class[]{Object.class});
+ OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(method);
+ assertNotNull(ori);
+ assertEquals("/key/{id}", ori.getURITemplate().getValue());
+ List<Parameter> params = ori.getParameters();
+ assertNotNull(params);
+ Parameter p = params.get(0);
+ assertEquals("id", p.getName());
+ }
}
Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java?rev=777126&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java Thu May 21 14:17:30 2009
@@ -0,0 +1,50 @@
+/**
+ * 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.HashMap;
+import java.util.Map;
+
+public class BookStoreNoAnnotations {
+
+ private Map<Long, Book> books = new HashMap<Long, Book>();
+
+ public BookStoreNoAnnotations() {
+ Book b = new Book();
+ b.setId(123L);
+ b.setName("CXF in Action");
+ books.put(b.getId(), b);
+ }
+
+ public Book getBook(Long id) throws BookNotFoundFault {
+ return books.get(id);
+ }
+
+ public ChapterNoAnnotations getBookChapter(Long id) throws BookNotFoundFault {
+ Book b = books.get(id);
+ Chapter ch = b.getChapter(1);
+
+ ChapterNoAnnotations ch2 = new ChapterNoAnnotations();
+ ch2.setId(ch.getId());
+ ch2.setTitle(ch.getTitle());
+ return ch2;
+ }
+
+}
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java?rev=777126&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java Thu May 21 14:17:30 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement(name = "Chapter")
+public class ChapterNoAnnotations {
+ private String title;
+ private long id;
+
+ public ChapterNoAnnotations() {
+ }
+
+ public void setTitle(String n) {
+ title = n;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setId(long i) {
+ id = i;
+ }
+ public long getId() {
+ return id;
+ }
+
+ public ChapterNoAnnotations getItself() {
+ return this;
+ }
+}
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java Thu May 21 14:17:30 2009
@@ -39,8 +39,15 @@
@Test
public void testGetThatBook123() throws Exception {
- String endpointAddress =
- "http://localhost:9080/test/bookstorestorage/thosebooks/123";
+ getBook("http://localhost:9080/test/bookstorestorage/thosebooks/123");
+ }
+
+ @Test
+ public void testGetThatBook123UserResource() throws Exception {
+ getBook("http://localhost:9080/test/bookstore/books/123");
+ }
+
+ private void getBook(String endpointAddress) throws Exception {
URL url = new URL(endpointAddress);
URLConnection connect = url.openConnection();
connect.addRequestProperty("Accept", "application/xml");
@@ -48,41 +55,17 @@
InputStream expected = getClass()
.getResourceAsStream("resources/expected_get_book123.txt");
-
- //System.out.println("---" + getStringFromInputStream(in));
- assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+ assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
}
@Test
public void testGetThatBookOverloaded() throws Exception {
- String endpointAddress =
- "http://localhost:9080/test/bookstorestorage/thosebooks/123/123";
- URL url = new URL(endpointAddress);
- URLConnection connect = url.openConnection();
- connect.addRequestProperty("Accept", "application/xml");
- InputStream in = connect.getInputStream();
-
- InputStream expected = getClass()
- .getResourceAsStream("resources/expected_get_book123.txt");
-
- //System.out.println("---" + getStringFromInputStream(in));
- assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+ getBook("http://localhost:9080/test/bookstorestorage/thosebooks/123/123");
}
@Test
public void testGetThatBookOverloaded2() throws Exception {
- String endpointAddress =
- "http://localhost:9080/test/bookstorestorage/thosebooks";
- URL url = new URL(endpointAddress);
- URLConnection connect = url.openConnection();
- connect.addRequestProperty("Accept", "application/xml");
- InputStream in = connect.getInputStream();
-
- InputStream expected = getClass()
- .getResourceAsStream("resources/expected_get_book123.txt");
-
- //System.out.println("---" + getStringFromInputStream(in));
- assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+ getBook("http://localhost:9080/test/bookstorestorage/thosebooks");
}
@Test
Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Thu May 21 14:17:30 2009
@@ -35,6 +35,7 @@
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.ext.xml.XMLSource;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
@@ -48,7 +49,7 @@
@BeforeClass
public static void startServers() throws Exception {
assertTrue("server did not launch correctly",
- launchServer(BookServerSpring.class));
+ launchServer(BookServerSpring.class, true));
}
@Test
@@ -189,6 +190,42 @@
getBook(endpointAddress, "resources/expected_add_book_aegis.txt", "application/xml");
}
+ @Test
+ public void testGetBookUserResource() throws Exception {
+
+ String endpointAddress =
+ "http://localhost:9080/the/thebooks6/bookstore/books/123";
+ getBook(endpointAddress, "resources/expected_get_book123.txt", "application/xml");
+ }
+
+ @Test
+ public void testGetBookUserResource2() throws Exception {
+
+ String endpointAddress =
+ "http://localhost:9080/the/thebooks7/bookstore/books/123";
+ getBook(endpointAddress, "resources/expected_get_book123.txt", "application/xml");
+ }
+
+ @Test
+ public void testGetBookUserResourceFromProxy() throws Exception {
+
+ String endpointAddress =
+ "http://localhost:9080/the/thebooks6";
+ BookStoreNoAnnotations bStore = JAXRSClientFactory.createFromModel(
+ endpointAddress,
+ BookStoreNoAnnotations.class,
+ "classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml",
+ null);
+ Book b = bStore.getBook(123L);
+ assertNotNull(b);
+ assertEquals(123L, b.getId());
+ assertEquals("CXF in Action", b.getName());
+ ChapterNoAnnotations proxy = bStore.getBookChapter(123L);
+ ChapterNoAnnotations c = proxy.getItself();
+ assertNotNull(c);
+ assertEquals(1, c.getId());
+ assertEquals("chapter 1", c.getTitle());
+ }
@Test
public void testGetBookXSLTXml() throws Exception {
Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java?rev=777126&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java Thu May 21 14:17:30 2009
@@ -0,0 +1,166 @@
+/**
+ * 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.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserOperation;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JAXRSClientServerUserResourceTest extends AbstractBusClientServerTestBase {
+
+ @Ignore
+ public static class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+ sf.setAddress("http://localhost:9080/");
+
+ UserResource ur = new UserResource();
+ ur.setName(BookStoreNoAnnotations.class.getName());
+ ur.setPath("/bookstoreNoAnnotations");
+ UserOperation op = new UserOperation();
+ op.setPath("/books/{id}");
+ op.setName("getBook");
+ op.setVerb("GET");
+ op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));
+
+ UserOperation op2 = new UserOperation();
+ op2.setPath("/books/{id}/chapter");
+ op2.setName("getBookChapter");
+ op2.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));
+
+ List<UserOperation> ops = new ArrayList<UserOperation>();
+ ops.add(op);
+ ops.add(op2);
+
+ ur.setOperations(ops);
+
+ UserResource ur2 = new UserResource();
+ ur2.setName(ChapterNoAnnotations.class.getName());
+ UserOperation op3 = new UserOperation();
+ op3.setPath("/");
+ op3.setName("getItself");
+ op3.setVerb("GET");
+ ur2.setOperations(Collections.singletonList(op3));
+
+ sf.setModelBeans(ur, ur2);
+
+ sf.create();
+
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
+ launchServer(Server.class));
+ }
+
+ @Test
+ public void testGetBook123() throws Exception {
+ getAndCompare("http://localhost:9080/bookstoreNoAnnotations/books/123",
+ "application/xml", 200);
+ }
+
+ @Test
+ public void testGetChapter() throws Exception {
+
+ getAndCompareChapter("http://localhost:9080/bookstoreNoAnnotations/books/123/chapter",
+ "application/xml", 200);
+ }
+
+ private void getAndCompare(String address,
+ String acceptType,
+ int expectedStatus) throws Exception {
+ GetMethod get = new GetMethod(address);
+ get.setRequestHeader("Accept", acceptType);
+ HttpClient httpClient = new HttpClient();
+ try {
+ int result = httpClient.executeMethod(get);
+ assertEquals(expectedStatus, result);
+ Book book = readBook(get.getResponseBodyAsStream());
+ assertEquals(123, book.getId());
+ assertEquals("CXF in Action", book.getName());
+ } finally {
+ get.releaseConnection();
+ }
+ }
+
+ private void getAndCompareChapter(String address,
+ String acceptType,
+ int expectedStatus) throws Exception {
+ GetMethod get = new GetMethod(address);
+ get.setRequestHeader("Accept", acceptType);
+ HttpClient httpClient = new HttpClient();
+ try {
+ int result = httpClient.executeMethod(get);
+ assertEquals(expectedStatus, result);
+ Chapter c = readChapter(get.getResponseBodyAsStream());
+ assertEquals(1, c.getId());
+ assertEquals("chapter 1", c.getTitle());
+ } finally {
+ get.releaseConnection();
+ }
+ }
+
+
+
+ private Book readBook(InputStream is) throws Exception {
+ JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
+ Unmarshaller u = c.createUnmarshaller();
+ return (Book)u.unmarshal(is);
+ }
+
+ private Chapter readChapter(InputStream is) throws Exception {
+ JAXBContext c = JAXBContext.newInstance(new Class[]{Chapter.class});
+ Unmarshaller u = c.createUnmarshaller();
+ return (Chapter)u.unmarshal(is);
+ }
+}
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml?rev=777126&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml Thu May 21 14:17:30 2009
@@ -0,0 +1,13 @@
+<model xmlns="http://cxf.apache.org/jaxrs">
+ <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" path="bookstore">
+ <operation name="getBook" verb="GET" path="/books/{id}">
+ <param name="id" type="PATH"/>
+ </operation>
+ <operation name="getBookChapter" path="/books/{id}/chapter">
+ <param name="id" type="PATH"/>
+ </operation>
+ </resource>
+ <resource name="org.apache.cxf.systest.jaxrs.ChapterNoAnnotations">
+ <operation name="getItself" verb="GET"/>
+ </resource>
+</model>
\ No newline at end of file
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml Thu May 21 14:17:30 2009
@@ -39,7 +39,7 @@
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
-
+
<bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" id="serviceBean"/>
<jaxrs:server id="bookservice"
@@ -123,14 +123,30 @@
<bean id="xsltProvider" class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider">
<property name="resolver" ref="uriResolver"/>
- <!--
- <property name="outTemplate" value="classpath:/org/apache/cxf/systest/jaxrs/resources/template.xsl"/>
- -->
<property name="outMediaTemplates" ref="outTemplates"/>
<property name="outClassNames" ref="outClassNames"/>
</bean>
<bean id="uriResolver" class="org.apache.cxf.systest.jaxrs.URIResolverImpl"/>
+
+ <jaxrs:server id="bookservice6" address="/thebooks6"
+ modelRef="classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml"/>
+
+ <jaxrs:server id="bookservice7" address="/thebooks7">
+ <jaxrs:model>
+ <jaxrs:resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" path="bookstore">
+ <jaxrs:operation name="getBook" verb="GET" path="/books/{id}">
+ <jaxrs:param name="id" type="PATH"/>
+ </jaxrs:operation>
+ <jaxrs:operation name="getBookChapter" path="/books/{id}/chapter">
+ <jaxrs:param name="id" type="PATH"/>
+ </jaxrs:operation>
+ </jaxrs:resource>
+ <jaxrs:resource name="org.apache.cxf.systest.jaxrs.ChapterNoAnnotations">
+ <jaxrs:operation name="getItself" verb="GET"/>
+ </jaxrs:resource>
+ </jaxrs:model>
+ </jaxrs:server>
<bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
<property name="schemaHandler" ref="schemaHolder"/>
Modified: cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml?rev=777126&r1=777125&r2=777126&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml Thu May 21 14:17:30 2009
@@ -47,8 +47,16 @@
<ref bean="bookstoreInterface"/>
</jaxrs:serviceBeans>
</jaxrs:server>
- <bean id="bookstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStore"/>
- <bean id="bookstoreInterface" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface"/>
+ <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
+ <bean id="bookstoreInterface" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface"/>
+
+ <jaxrs:server id="bookservice2" address="/2"
+ modelRef="classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml">
+ <jaxrs:serviceBeans>
+ <ref bean="bookstore2"/>
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
+ <bean id="bookstore2" class="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations"/>
<aop:config>
<aop:aspect id="loggingAspect" ref="simpleLogger">