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/12/08 14:54:17 UTC

svn commit: r888400 - in /cxf/trunk/systests/jaxrs/src/test: java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java resources/jaxrs_atom/WEB-INF/beans.xml

Author: sergeyb
Date: Tue Dec  8 13:54:16 2009
New Revision: 888400

URL: http://svn.apache.org/viewvc?rev=888400&view=rev
Log:
Testing custom atom provider

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java   (with props)
Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java?rev=888400&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java (added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java Tue Dec  8 13:54:16 2009
@@ -0,0 +1,47 @@
+/**
+ * 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.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.abdera.model.Feed;
+import org.apache.cxf.jaxrs.provider.AtomFeedProvider;
+
+@Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
+@Consumes({"application/atom+xml", "application/atom+xml;type=feed" })
+@Provider
+public class CustomAtomFeedProvider extends AtomFeedProvider {
+    
+    @Override
+    public void writeTo(Feed element, Class<?> clazz, Type type, Annotation[] a, 
+                        MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) 
+        throws IOException {
+        os.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>".getBytes());
+        super.writeTo(element, clazz, type, a, mt, headers, os);
+    }
+}

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

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

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java?rev=888400&r1=888399&r2=888400&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java Tue Dec  8 13:54:16 2009
@@ -149,6 +149,16 @@
                         "*/*");
     }
     
+    @Test
+    public void testGetBooksWithCustomProvider() throws Exception {
+        String endpointAddress =
+            "http://localhost:9081/bookstore/bookstore4/books/feed"; 
+        Feed feed = getFeed(endpointAddress, null);
+        assertEquals("http://localhost:9081/bookstore/bookstore4/books/feed", 
+                     feed.getBaseUri().toString());
+        assertEquals("Collection of Books", feed.getTitle());
+    }
+    
     private void getAndCompareJson(String address, 
                                    String resourcePath,
                                    String type) throws Exception {

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml?rev=888400&r1=888399&r2=888400&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml Tue Dec  8 13:54:16 2009
@@ -85,6 +85,15 @@
     </jaxrs:properties>
   </jaxrs:server>
   
+  <jaxrs:server id="atomservice4" address="/bookstore4">
+    <jaxrs:serviceBeans>
+      <ref bean="atomstore"/>
+    </jaxrs:serviceBeans>
+    <jaxrs:providers>
+        <ref bean="feed2"/>
+    </jaxrs:providers>	
+  </jaxrs:server>
+  
   <bean id="atomstore" class="org.apache.cxf.systest.jaxrs.AtomBookStore"/>
   <bean id="atomstore2" class="org.apache.cxf.systest.jaxrs.AtomBookStore2"/>
   <bean id="atomstore3" class="org.apache.cxf.systest.jaxrs.AtomBookStore3"/>
@@ -92,6 +101,11 @@
   <bean id="feed" class="org.apache.cxf.jaxrs.provider.AtomFeedProvider">
       <property name="formattedOutput" value="true"/>
   </bean>
+  <bean id="feed2" class="org.apache.cxf.systest.jaxrs.CustomAtomFeedProvider">
+  <!--
+      <property name="formattedOutput" value="true"/>
+  -->    
+  </bean>
   <bean id="entry" class="org.apache.cxf.jaxrs.provider.AtomEntryProvider"/>
   
 </beans>