cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r821008 [2/2] - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/common/util/ 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/ap...
Date Fri, 02 Oct 2009 13:17:22 GMT
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
Fri Oct  2 13:17:21 2009
@@ -38,8 +38,15 @@
 
 package org.apache.cxf.systest.jaxrs;
 
-public class BookStoreWithInterface extends BookStoreStorage implements BookInterface {
 
+
+
+
+public class BookStoreWithInterface extends BookStoreStorage 
+    implements BookInterface, LifecycleInterface {
+
+    private boolean postConstructCalled;
+    
     public BookStoreWithInterface() {
         Book book = new Book();
         book.setId(bookId);
@@ -47,7 +54,18 @@
         books.put(book.getId(), book);
     }
     
+    public void postConstruct() {
+        postConstructCalled = true;
+    }
+    
+    public void preDestroy() {
+        System.out.println("PreDestroy called");
+    }
+    
     public Book getThatBook(Long id, String s) throws BookNotFoundFault {
+        if (!postConstructCalled) {
+            throw new RuntimeException();
+        }
         if (!id.toString().equals(s)) {
             throw new RuntimeException();
         }
@@ -55,6 +73,9 @@
     }
     
     public Book getThatBook(Long id) throws BookNotFoundFault {
+        if (!postConstructCalled) {
+            throw new RuntimeException();
+        }
         return doGetBook(id);
     }
     

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java?rev=821008&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
Fri Oct  2 13:17:21 2009
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+
+/**
+ * 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.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+
+
+public class BookStoreWithInterface2 extends BookStoreStorage implements BookInterface {
+
+    private ServletContext servletContext; 
+    
+    public BookStoreWithInterface2() {
+        Book book = new Book();
+        book.setId(bookId);
+        book.setName("CXF in Action");
+        books.put(book.getId(), book);
+    }
+    
+    public BookStoreWithInterface2(@Context ServletContext scontext) {
+        this();
+        this.servletContext = scontext;
+    }
+    
+    public Book getThatBook(Long id, String s) throws BookNotFoundFault {
+        if (servletContext == null) {
+            throw new RuntimeException();
+        }
+        if (!id.toString().equals(s)) {
+            throw new RuntimeException();
+        }
+        return doGetBook(id);
+    }
+    
+    public Book getThatBook(Long id) throws BookNotFoundFault {
+        if (servletContext == null) {
+            throw new RuntimeException();
+        }
+        return doGetBook(id);
+    }
+    
+    private Book doGetBook(Long id) throws BookNotFoundFault {
+        System.out.println("----invoking getBook with id: " + id);
+        Book book = books.get(id);
+        if (book != null) {
+            return book;
+        } else {
+            BookNotFoundDetails details = new BookNotFoundDetails();
+            details.setId(id);
+            throw new BookNotFoundFault(details);
+        }
+    }
+
+    public Book getThatBook() throws BookNotFoundFault {
+        if (servletContext == null) {
+            throw new RuntimeException();
+        }
+        return books.get(123L);
+    }
+
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
Fri Oct  2 13:17:21 2009
@@ -64,6 +64,32 @@
     }
     
     @Test
+    public void testGetThatBookSingleton() throws Exception {
+        getBook("http://localhost:9080/test/4/bookstore/books/123");
+        getBook("http://localhost:9080/test/4/bookstore/books/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterfaceSingleton() throws Exception {
+        getBook("http://localhost:9080/test/4/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
+    public void testGetThatBookPrototype() throws Exception {
+        getBook("http://localhost:9080/test/5/bookstore/books/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterfacePrototype() throws Exception {
+        getBook("http://localhost:9080/test/5/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterface2Prototype() throws Exception {
+        getBook("http://localhost:9080/test/6/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
     public void testGetThatBook123UserResource() throws Exception {
         getBook("http://localhost:9080/test/2/bookstore/books/123");
     }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Fri Oct  2 13:17:21 2009
@@ -67,7 +67,7 @@
     
     @Test
     public void testGetBookXSLTHtml() throws Exception {
-        
+
         String endpointAddress =
             "http://localhost:9080/the/thebooks5/bookstore/books/xslt";
         WebClient wc = WebClient.create(endpointAddress);
@@ -326,7 +326,7 @@
     @Test
     public void testReaderWriterFromJaxrsFilters() throws Exception {
         String endpointAddress =
-            "http://localhost:9080/the/thebooks5/bookstore/books/convert2";
+            "http://localhost:9080/the/thebooks5/bookstore/books/convert2/123";
         WebClient wc = WebClient.create(endpointAddress);
         wc.type("application/xml").accept("application/xml");
         Book2 b = new Book2();

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Fri Oct  2 13:17:21 2009
@@ -221,7 +221,7 @@
         objects.put(MediaType.APPLICATION_XML, jaxb);
         objects.put(MediaType.APPLICATION_JSON, json);
         objects.put(MediaType.APPLICATION_OCTET_STREAM, is1);
-        Collection<Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
+        Collection<? extends Attachment> coll = client.postAndGetCollection(objects,
Attachment.class);
         List<Attachment> result = new ArrayList<Attachment>(coll);
         Book jaxb2 = readBookFromInputStream(result.get(0).getDataHandler().getInputStream());
         assertEquals("jaxb", jaxb2.getName());
@@ -250,7 +250,7 @@
         objects.add(new Attachment("theroot", MediaType.APPLICATION_XML, jaxb));
         objects.add(new Attachment("thejson", MediaType.APPLICATION_JSON, json));
         objects.add(new Attachment("theimage", MediaType.APPLICATION_OCTET_STREAM, is1));
-        Collection<Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
+        Collection<? extends Attachment> coll = client.postAndGetCollection(objects,
Attachment.class);
         List<Attachment> result = new ArrayList<Attachment>(coll);
         Book jaxb2 = readBookFromInputStream(result.get(0).getDataHandler().getInputStream());
         assertEquals("jaxb", jaxb2.getName());
@@ -279,7 +279,7 @@
         List<Book> books = new ArrayList<Book>();
         books.add(b);
         books.add(b2);
-        Collection<Book> coll = client.postAndGetCollection(books, Book.class);
+        Collection<? extends Book> coll = client.postAndGetCollection(books, Book.class);
         List<Book> result = new ArrayList<Book>(coll);
         Book jaxb = result.get(0);
         assertEquals("jaxb", jaxb.getName());

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java?rev=821008&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
Fri Oct  2 13:17:21 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+public interface LifecycleInterface {
+    @PostConstruct
+    void postConstruct();
+    @PreDestroy
+    void preDestroy();
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
Fri Oct  2 13:17:21 2009
@@ -20,9 +20,12 @@
 
 import java.io.InputStream;
 
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.message.Message;
@@ -30,9 +33,17 @@
 
 public class XmlStreamReaderProvider implements RequestHandler {
 
+    @Context
+    private MessageContext context;
+    
     public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
-        String method = m.get(Message.HTTP_REQUEST_METHOD).toString();
+        String method = context.get(Message.HTTP_REQUEST_METHOD).toString();
+        
         if ("PUT".equals(method)) {
+            MultivaluedMap<String, String> map = context.getUriInfo().getPathParameters();
+            if (!"123".equals(map.getFirst("id"))) {
+                throw new RuntimeException();
+            }
             XMLStreamReader reader = 
                 StaxUtils.createXMLStreamReader(m.getContent(InputStream.class));
             m.setContent(XMLStreamReader.class, new CustomXmlStreamReader(reader));

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
Fri Oct  2 13:17:21 2009
@@ -31,7 +31,7 @@
 @Path("/bookstorestorage/")
 public class SecureBookStoreNoAnnotations implements BookInterface {
     private Map<Long, Book> books = new HashMap<Long, Book>();
-  
+    
     public SecureBookStoreNoAnnotations() {
         Book book = new Book();
         book.setId(123L);

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml?rev=821008&r1=821007&r2=821008&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml Fri Oct  2 13:17:21
2009
@@ -39,7 +39,14 @@
   <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 id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
   
+  <bean id="bookstoreInterface" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface"/>
+  <bean id="exceptionMapper" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper">
+      <property name="toHandle" value="true"/>
+  </bean>   
+
   <jaxrs:server id="bookservice"
 		        address="/">
     <jaxrs:serviceBeans>
@@ -50,11 +57,7 @@
       <ref bean="exceptionMapper"/>
     </jaxrs:providers>		   
   </jaxrs:server>
-  <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
-  <bean id="bookstoreInterface" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface"/>
-  <bean id="exceptionMapper" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper">
-      <property name="toHandle" value="true"/>
-  </bean>   
+
   <jaxrs:server id="bookservice2" address="/2"
     modelRef="classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml">
     <jaxrs:serviceBeans>
@@ -70,8 +73,44 @@
       <ref bean="bookstore3"/>
     </jaxrs:serviceBeans>		   
   </jaxrs:server>
-  <bean id="bookstore3" class="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotationsImpl"/>
+
+  <jaxrs:server id="bookservice4" address="/4">
+    <jaxrs:serviceFactories>
+      <ref bean="sfactory1"/>
+      <ref bean="sfactory2"/>
+    </jaxrs:serviceFactories>		   
+  </jaxrs:server>
+    
+  <jaxrs:server id="bookservice5" address="/5"
+     beanNames="bookstorePrototype bookstoreInterfacePrototype"/>
   
+  <jaxrs:server id="bookservice6" address="/6">
+    <jaxrs:serviceFactories>
+      <ref bean="sfactory5"/>
+    </jaxrs:serviceFactories>		
+    <jaxrs:properties>
+         <entry key="org.apache.cxf.service.scope" value="request"/>
+     </jaxrs:properties>
+       
+  </jaxrs:server>
+
+
+  <bean id="sfactory1" class="org.apache.cxf.jaxrs.spring.SpringResourceFactory"> 

+      <property name="beanId" value="bookstore"/>
+  </bean>
+  
+  <bean id="sfactory2" class="org.apache.cxf.jaxrs.spring.SpringResourceFactory"> 

+      <property name="beanId" value="bookstoreInterface"/>
+  </bean>
+  
+  <bean id="sfactory5" class="org.apache.cxf.jaxrs.spring.SpringResourceFactory"> 

+      <property name="beanId" value="bookstoreInterface2Prototype"/>
+  </bean>
+  <bean id="bookstorePrototype" class="org.apache.cxf.systest.jaxrs.BookStore" scope="prototype"/>
+  <bean id="bookstoreInterface2Prototype" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface2"
scope="prototype"/>
+  <bean id="bookstore3" class="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotationsImpl"/>
+
+  <bean id="bookstoreInterfacePrototype" class="org.apache.cxf.systest.jaxrs.BookStoreWithInterface"
scope="prototype"/>
   <aop:config>
 		<aop:aspect id="loggingAspect" ref="simpleLogger">
 			<aop:before



Mime
View raw message