cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r619898 - in /incubator/cxf/trunk: rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/...
Date Fri, 08 Feb 2008 14:37:14 GMT
Author: jliu
Date: Fri Feb  8 06:37:10 2008
New Revision: 619898

URL: http://svn.apache.org/viewvc?rev=619898&view=rev
Log:
Apply patch CXF-1421 (Provide JAX-RS Providers for handling Atom Feed and Entries) on behalf of Sergey Beryozkin.   

Added:
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java   (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml Fri Feb  8 06:37:10 2008
@@ -67,6 +67,16 @@
              <artifactId>jsr311-api</artifactId>
              <version>0.4</version>
          </dependency>
+         <dependency>
+         <groupId>org.apache.abdera</groupId>
+            <artifactId>abdera-core</artifactId>
+            <version>0.3.0-incubating</version>
+         </dependency>
+         <dependency>
+           <groupId>org.apache.abdera</groupId>
+           <artifactId>abdera-parser</artifactId>
+           <version>0.3.0-incubating</version>
+         </dependency>  
         <dependency>
 	            <groupId>org.apache.geronimo.specs</groupId>
 	            <artifactId>geronimo-servlet_2.5_spec</artifactId>
@@ -88,6 +98,14 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+
+    <repositories>
+        <repository>
+            <id>apache.incubating</id>
+            <name>Apache Incubating Repository</name>
+            <url>http://people.apache.org/repo/m2-incubating-repository</url>
+        </repository>
+    </repositories>
 
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/rs</connection>

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java Fri Feb  8 06:37:10 2008
@@ -209,6 +209,14 @@
                 //Iterate through sub-resources
                 ClassResourceInfo subCri = createClassResourceInfo(subResourceClass);
                 cri.addSubClassResourceInfo(subCri);
+            } else if (m.getAnnotation(HttpMethod.class) != null) {
+                String httpMethod = m.getAnnotation(HttpMethod.class).value();
+                OperationResourceInfo ori = new OperationResourceInfo(m, cri);
+                String uriTemplate = "/";
+                ori.setURITemplate(new URITemplate(uriTemplate, URITemplate.UNLIMITED_REGEX_SUFFIX));
+                ori.setHttpMethod(httpMethod);
+                md.bind(ori, m);
+                
             }
         }
 

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,113 @@
+/**
+ * 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.jaxrs;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+public class MetadataMap implements MultivaluedMap<String, Object> {
+
+    private Map<String, List<Object>> m = new HashMap<String, List<Object>>();
+    
+    public void add(String key, Object value) {
+        List<Object> data = m.get(key);
+        if (data == null) {
+            data = new ArrayList<Object>();    
+            m.put(key, data);
+        }
+        data.add(value);
+    }
+
+    public Object getFirst(String key) {
+        List<Object> data = m.get(key);
+        return data == null ? null : data.get(0);
+    }
+
+    public void putSingle(String key, Object value) {
+        List<Object> data = new ArrayList<Object>();
+        data.add(value);
+        m.put(key, data);
+    }
+
+    public void clear() {
+        m.clear();
+
+    }
+
+    public boolean containsKey(Object key) {
+        return m.containsKey(key);
+    }
+
+    public boolean containsValue(Object value) {
+        return m.containsValue(value);
+    }
+
+    public Set<Entry<String, List<Object>>> entrySet() {
+        return m.entrySet();
+    }
+
+    public List<Object> get(Object key) {
+        return m.get(key);
+    }
+
+    public boolean isEmpty() {
+        return m.isEmpty();
+    }
+
+    public Set<String> keySet() {
+        return m.keySet();
+    }
+
+    public List<Object> put(String key, List<Object> value) {
+        return m.put(key, value);
+    }
+
+    public void putAll(Map<? extends String, ? extends List<Object>> map) {
+        m.putAll(map);
+    }
+
+    public List<Object> remove(Object key) {
+        return m.remove(key);
+    }
+
+    public int size() {
+        return m.size();
+    }
+
+    public Collection<List<Object>> values() {
+        return m.values();
+    }
+
+    @Override
+    public int hashCode() {
+        return m.hashCode();
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+        return m.equals(o);
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Fri Feb  8 06:37:10 2008
@@ -37,6 +37,7 @@
 import org.apache.cxf.jaxrs.JAXRSUtils;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactoryImpl;
+import org.apache.cxf.jaxrs.provider.ResponseImpl;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -70,10 +71,13 @@
             Object responseObj = objs.get(0);
             if (objs.get(0) instanceof Response) {
                 Response response = (Response)responseObj;
-                responseObj = response.getEntity();   
-
+                
                 message.put(Message.RESPONSE_CODE, response.getStatus());
+                if (response instanceof ResponseImpl) {
+                    ((ResponseImpl)response).serializeMetadata(message);
+                }
                 
+                responseObj = response.getEntity();
                 if (responseObj == null) {
                     return;
                 }

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java Fri Feb  8 06:37:10 2008
@@ -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.jaxrs.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.EntityProvider;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+
+@ProduceMime("application/atom+xml")
+@ConsumeMime("application/atom+xml")
+public class AtomEntryProvider implements EntityProvider<Entry> {
+
+    private static final Abdera ATOM_ENGINE = new Abdera();
+    
+    public Entry readFrom(Class<Entry> clazz, MediaType mt, 
+                          MultivaluedMap <String, String> headers, InputStream is)
+        throws IOException {
+        Document<Entry> doc = ATOM_ENGINE.getParser().parse(is);
+        return doc.getRoot();
+    }
+
+    public boolean supports(Class<?> type) {
+        return Entry.class.isAssignableFrom(type);
+    }
+
+    public void writeTo(Entry entry, MediaType mt, 
+                        MultivaluedMap<String, Object> headers, OutputStream os)
+        throws IOException {
+        entry.writeTo(os);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,60 @@
+/**
+ * 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.jaxrs.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.EntityProvider;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Feed;
+
+@ProduceMime("application/atom+xml")
+@ConsumeMime("application/atom+xml")
+public class AtomFeedProvider implements EntityProvider<Feed> {
+
+    private static final Abdera ATOM_ENGINE = new Abdera();
+    
+    public Feed readFrom(Class<Feed> clazz, MediaType mt, 
+                         MultivaluedMap<String, String> headers, InputStream is)
+        throws IOException {
+        Document<Feed> doc = ATOM_ENGINE.getParser().parse(is);
+        return doc.getRoot();
+    }
+
+    public boolean supports(Class<?> type) {
+        
+        return Feed.class.isAssignableFrom(type);
+    }
+
+    public void writeTo(Feed feed, MediaType mt, 
+                        MultivaluedMap<String, Object> headers, OutputStream os)
+        throws IOException {
+        feed.writeTo(os);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java Fri Feb  8 06:37:10 2008
@@ -21,31 +21,33 @@
 
 import java.net.URI;
 import java.util.Date;
+
 import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.jaxrs.MetadataMap;
+
 
 public final class BuilderImpl extends Response.Builder {
     private int status = 200;
     private Object entity;
+    private MultivaluedMap<String, Object> metadata = new MetadataMap();
 
     public BuilderImpl() {
     }
 
-    public BuilderImpl(Response r) {
-        this.status = r.getStatus();
-        this.entity = r.getEntity();
-    }
-    
-    static Response.Builder create(Response response) {
-        return new BuilderImpl(response);
-    }
-
+       
     public Response build() {
-        return new ResponseImpl(status, entity);
+        Response r = new ResponseImpl(status, entity);
+        MetadataMap m = new MetadataMap();
+        m.putAll(metadata);
+        r.addMetadata(m);
+        reset();
+        return r;
     }
 
     public Response.Builder status(int s) {
@@ -71,7 +73,8 @@
     }
 
     public Response.Builder location(URI location) {
-        return null;
+        metadata.putSingle("Location", location.toString());
+        return this;
     }
 
     public Response.Builder contentLocation(URI location) {
@@ -99,7 +102,13 @@
     }
 
     public Response.Builder header(String name, Object value) {
+        // TODO: we need to use HeaderProviders to have headers serialized
         return null;
     }
 
+    private void reset() {
+        metadata.clear();
+        entity = null;
+        status = 200;
+    }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java Fri Feb  8 06:37:10 2008
@@ -42,10 +42,13 @@
 
     public ProviderFactoryImpl() {
         //TODO: search for EntityProviders from classpath or config file.
+        //or dynamically instantiate them based on mime types being active 
         entityProviders.add(new JAXBElementProvider());
         entityProviders.add(new JSONProvider());
         entityProviders.add(new StringProvider());
         entityProviders.add(new DOMSourceProvider());
+        entityProviders.add(new AtomFeedProvider());
+        entityProviders.add(new AtomEntryProvider());
 
         sort();
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java Fri Feb  8 06:37:10 2008
@@ -22,9 +22,13 @@
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.message.Message;
+
 public final class ResponseImpl implements Response {
     private final int status;
     private final Object entity;
+    private MultivaluedMap<String, Object> metadata;
+    
     
     ResponseImpl(int s, Object e) {
         this.status = s;
@@ -39,6 +43,18 @@
         return status;
     }
 
-    public void addMetadata(MultivaluedMap<String, Object> metadata) {        
+    public void addMetadata(MultivaluedMap<String, Object> meta) { 
+        this.metadata = meta;
+    }
+    
+    public MultivaluedMap<String, Object> getMetadata() {
+        // don't worry about cloning for now
+        return metadata;
+    }
+    
+    public void serializeMetadata(Message m) {
+        
+        m.put(Message.PROTOCOL_HEADERS, metadata);
+        
     }
-}
\ No newline at end of file
+}

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java Fri Feb  8 06:37:10 2008
@@ -127,11 +127,16 @@
         assertTrue(subCri.getURITemplate() == null);
         assertEquals(org.apache.cxf.jaxrs.resources.Book.class, subCri.getResourceClass());
         MethodDispatcher subMd = subCri.getMethodDispatcher();
-        assertEquals(1, subMd.getOperationResourceInfos().size());
+        assertEquals(2, subMd.getOperationResourceInfos().size());
         //getChapter method
         OperationResourceInfo subOri = subMd.getOperationResourceInfos().iterator().next();
         assertEquals("GET", subOri.getHttpMethod());
         assertNotNull(subOri.getURITemplate());
+        
+        //getState method
+        OperationResourceInfo subOri2 = subMd.getOperationResourceInfos().iterator().next();
+        assertEquals("GET", subOri2.getHttpMethod());
+        assertNotNull(subOri2.getURITemplate());
     }
 
 }

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,67 @@
+/**
+ * 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.jaxrs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class MetadataMapTest extends Assert {
+    
+    @Test
+    public void testPutSingle() {
+        MetadataMap m = new MetadataMap();
+        List<Object> value1 = new ArrayList<Object>();
+        value1.add("bar");
+        value1.add("foo");
+        m.put("baz", value1);
+        
+        m.putSingle("baz", "clazz");
+        List<Object> value2 = m.get("baz");
+        assertEquals("Only a single value should be in the list", 1, value2.size());
+        assertEquals("Value is wrong", "clazz", value2.get(0));
+    }
+    
+    @Test
+    public void testAddAndGetFirst() {
+        MetadataMap m = new MetadataMap();
+        m.add("baz", "bar");
+        
+        List<Object> value = m.get("baz");
+        assertEquals("Only a single value should be in the list", 1, value.size());
+        assertEquals("Value is wrong", "bar", value.get(0));
+        
+        m.add("baz", "foo");
+        
+        value = m.get("baz");
+        assertEquals("Two values should be in the list", 2, value.size());
+        assertEquals("Value1 is wrong", "bar", value.get(0));
+        assertEquals("Value2 is wrong", "foo", value.get(1));
+        
+        assertEquals("GetFirst value is wrong", "bar", m.getFirst("baz"));
+    }
+    
+    
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,83 @@
+/**
+ * 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.jaxrs.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.stax.FOMEntry;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AtomEntryProviderTest extends Assert {
+
+    private AtomEntryProvider afd;
+    
+    @Before
+    public void setUp() {
+        afd = new AtomEntryProvider();
+    }
+    
+    @Test
+    public void testReadFrom() throws Exception {
+        InputStream is = getClass().getResourceAsStream("atomEntry.xml");
+        Entry simple = afd.readFrom(Entry.class, null, null, is);
+        assertEquals("Wrong entry title", 
+                     "Atom-Powered Robots Run Amok", simple.getTitle());
+        
+    }
+    
+    @Test
+    public void testWriteTo() throws Exception {
+        InputStream is = getClass().getResourceAsStream("atomEntry.xml");
+        Entry simple = afd.readFrom(Entry.class, null, null, is);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        afd.writeTo(simple, null, null, bos);
+        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+        Entry simpleCopy = afd.readFrom(Entry.class, null, null, bis);
+        assertEquals("Wrong entry title", 
+                     "Atom-Powered Robots Run Amok", simpleCopy.getTitle());
+        assertEquals("Wrong entry title", 
+                     simple.getTitle(), simpleCopy.getTitle());
+    }
+    
+    @Test
+    public void testSupports() {
+        assertTrue(afd.supports(Entry.class));
+        assertTrue(afd.supports(FOMEntry.class));
+        assertFalse(afd.supports(Feed.class));
+    }
+    
+    @Test
+    public void testAnnotations() {
+        assertEquals("application/atom+xml",
+                     afd.getClass().getAnnotation(ProduceMime.class).value()[0]);
+        assertEquals("application/atom+xml",
+                     afd.getClass().getAnnotation(ConsumeMime.class).value()[0]);
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,81 @@
+/**
+ * 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.jaxrs.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.stax.FOMFeed;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AtomFeedProviderTest extends Assert {
+
+    private AtomFeedProvider afd;
+    
+    @Before
+    public void setUp() {
+        afd = new AtomFeedProvider();
+    }
+    
+    @Test
+    public void testReadFrom() throws Exception {
+        InputStream is = getClass().getResourceAsStream("atomFeed.xml");
+        Feed simple = afd.readFrom(Feed.class, null, null, is);
+        assertEquals("Wrong feed title", "Example Feed", simple.getTitle());
+        
+    }
+    
+    public void testWriteTo() throws Exception {
+        InputStream is = getClass().getResourceAsStream("atomFeed.xml");
+        Feed simple = afd.readFrom(Feed.class, null, null, is);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        afd.writeTo(simple, null, null, bos);
+        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+        Feed simpleCopy = afd.readFrom(Feed.class, null, null, bis);
+        assertEquals("Wrong entry title", 
+                     "Example Feed", simpleCopy.getTitle());
+        assertEquals("Wrong entry title", 
+                     simple.getTitle(), simpleCopy.getTitle());
+    }
+    
+    @Test
+    public void testSupports() {
+        assertTrue(afd.supports(Feed.class));
+        assertTrue(afd.supports(FOMFeed.class));
+        assertFalse(afd.supports(Entry.class));
+    }
+    
+    @Test
+    public void testAnnotations() {
+        assertEquals("application/atom+xml",
+                     afd.getClass().getAnnotation(ProduceMime.class).value()[0]);
+        assertEquals("application/atom+xml",
+                     afd.getClass().getAnnotation(ConsumeMime.class).value()[0]);
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,62 @@
+/**
+ * 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.jaxrs.provider;
+
+import java.net.URI;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.MetadataMap;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class BuilderImplTest extends Assert {
+
+        
+    @Test
+    public void testOkBuild() {
+      
+        checkBuild(Response.Builder.ok().build(),
+                          200, null, new MetadataMap());
+        
+    }
+    
+    @Test
+    public void testCreatedNoEntity() throws Exception {
+        
+        MetadataMap m = new MetadataMap();
+        m.putSingle("Location", "http://foo");
+        
+        checkBuild(Response.Builder.created(new URI("http://foo")).build(),
+                   201, null, m);
+        
+        
+    }
+    
+    private void checkBuild(Response r, int status, Object entity, 
+                            MetadataMap meta) {
+        ResponseImpl ri = (ResponseImpl)r;
+        assertEquals("Wrong status", ri.getStatus(), status);
+        assertSame("Wrong entity", ri.getEntity(), entity);
+        assertEquals("Wrong meta", ri.getMetadata(), meta);
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java Fri Feb  8 06:37:10 2008
@@ -30,6 +30,8 @@
 import javax.ws.rs.ext.EntityProvider;
 import javax.ws.rs.ext.ProviderFactory;
 
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
 import org.apache.cxf.helpers.IOUtils;
 import org.junit.Assert;
 import org.junit.Before;
@@ -68,6 +70,26 @@
         EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
         .createEntityProvider(String.class, methodMimeTypes, false);
         assertTrue(provider instanceof StringProvider);
+    }
+    
+    @Test
+    public void testGetAtomProvider() throws Exception {
+        String[] methodMimeTypes = {"application/atom+xml"};
+        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
+        .createEntityProvider(Feed.class, methodMimeTypes, false);
+        assertTrue(provider instanceof AtomFeedProvider);
+        
+        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
+        .createEntityProvider(Feed.class, methodMimeTypes, true);
+        assertTrue(provider instanceof AtomFeedProvider);
+        
+        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
+        .createEntityProvider(Entry.class, methodMimeTypes, false);
+        assertTrue(provider instanceof AtomEntryProvider);
+        
+        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
+        .createEntityProvider(Entry.class, methodMimeTypes, true);
+        assertTrue(provider instanceof AtomEntryProvider);
     }
     
     @Test

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,45 @@
+/**
+ * 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.jaxrs.provider;
+
+import org.apache.cxf.jaxrs.MetadataMap;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ResponseImplTest extends Assert {
+    
+    @Test
+    public void testResourceImpl() {
+        String entity = "bar";
+        ResponseImpl ri = new ResponseImpl(200, entity);
+        assertEquals("Wrong status", ri.getStatus(), 200);
+        assertSame("Wrong entity", entity, ri.getEntity());
+        
+        MetadataMap meta = new MetadataMap();
+        Message m = new MessageImpl();
+        ri.addMetadata(meta);
+        ri.serializeMetadata(m);
+        assertSame("Wrong metadata", meta, m.get(Message.PROTOCOL_HEADERS));
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml Fri Feb  8 06:37:10 2008
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://example.org/">
+  
+   <title>Atom-Powered Robots Run Amok</title>
+    <link href="/2003/12/13/atom03"/>
+    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+    <updated>2003-12-13T18:30:02Z</updated>
+    <summary>Some text.</summary>
+
+</entry>

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomEntry.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml Fri Feb  8 06:37:10 2008
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://example.org/">
+  
+  <title>Example Feed</title>
+  <link href=""/>
+  <updated>2003-12-13T18:30:02Z</updated>
+  <author>
+    <name>John Doe</name>
+  </author>
+  <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
+
+  <entry>
+    <title>Atom-Powered Robots Run Amok</title>
+    <link href="/2003/12/13/atom03"/>
+    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+    <updated>2003-12-13T18:30:02Z</updated>
+    <summary>Some text.</summary>
+  </entry>
+
+</feed>

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/atomFeed.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java?rev=619898&r1=619897&r2=619898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java Fri Feb  8 06:37:10 2008
@@ -58,4 +58,8 @@
         return chapters.get(new Long(chapterid));
     }   
 
+    @HttpMethod("GET")
+    public String getState() {
+        return "";
+    }
 }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java Fri Feb  8 06:37:10 2008
@@ -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 javax.ws.rs.HttpMethod;
+import javax.ws.rs.ProduceMime;
+
+import org.apache.abdera.model.Entry;
+
+
+public class AtomBook {
+    private Book book;
+    
+    public AtomBook(Book book) {
+        this.book = book;
+    }
+    
+    
+    
+    @HttpMethod("GET")
+    @ProduceMime("application/atom+xml")
+    public Entry getAsEntry() {
+        try {
+            return AtomUtils.createBookEntry(book);
+        } catch (Exception ex) {
+            // common, it's just a test
+        }
+        return null;
+    }
+    
+    
+    
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java Fri Feb  8 06:37:10 2008
@@ -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.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+    
+public class AtomBookServer extends AbstractBusTestServerBase {
+
+    protected void run() {
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(AtomBookStore.class);
+        //default lifecycle is per-request, change it to singleton
+        sf.setResourceProvider(AtomBookStore.class, new SingletonResourceProvider());
+        sf.setAddress("http://localhost:9080/");
+
+        sf.create();        
+    }
+
+    public static void main(String[] args) {
+        try {
+            AtomBookServer s = new AtomBookServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,156 @@
+/**
+ * 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.StringReader;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.ProduceMime;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.UriTemplate;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.cxf.customer.book.BookNotFoundDetails;
+import org.apache.cxf.customer.book.BookNotFoundFault;
+
+@UriTemplate("/bookstore/")
+public class AtomBookStore {
+
+    private Map<Long, Book> books = new HashMap<Long, Book>();
+    private Map<Long, CD> cds = new HashMap<Long, CD>();
+    private long bookId = 123;
+    private long cdId = 123;
+    
+    public AtomBookStore() {
+        init();
+        System.out.println("----books: " + books.size());
+    }
+    
+    @HttpMethod("GET")
+    @UriTemplate("/books/feed")
+    @ProduceMime("application/atom+xml")
+    public Feed getBooksAsFeed() {
+        Factory factory = Abdera.getNewFactory();
+        Feed f = factory.newFeed();
+        f.setTitle("Collection of Books");
+        f.setId("http://www.books.com");
+        f.addAuthor("BookStore Management Company");
+        try {
+            for (Book b : books.values()) {
+                
+                Entry e = AtomUtils.createBookEntry(b);
+                
+                f.addEntry(e);
+            }
+        } catch (Exception ex) {
+            // ignore
+        }
+        return f;
+    }
+    
+    @HttpMethod("POST")
+    @UriTemplate("/books/feed")
+    @ConsumeMime("application/atom+xml")
+    public Response addBookAsEntry(Entry e) {
+        try {
+            String text = e.getContentElement().getValue();
+            StringReader reader = new StringReader(text);
+            JAXBContext jc = JAXBContext.newInstance(Book.class);
+            Book b = (Book)jc.createUnmarshaller().unmarshal(reader);
+            books.put(b.getId(), b);
+            
+            // this code is broken as Response does not
+            URI uri = new URI("http://localhost:9080/bookstore/books/entries/" + b.getId());
+            return Response.Builder.created(uri).build();
+        } catch (Exception ex) {
+            return Response.Builder.serverError().build();
+        }
+    }
+    
+    @HttpMethod("GET")
+    @UriTemplate("/books/entries/{bookId}/")
+    @ProduceMime("application/atom+xml")
+    public Entry getBookAsEntry(@UriParam("bookId") String id) throws BookNotFoundFault {
+        System.out.println("----invoking getBook with id: " + id);
+        Book book = books.get(Long.parseLong(id));
+        if (book != null) {
+            try {
+                return AtomUtils.createBookEntry(book);
+            } catch (Exception ex) {
+                // ignore
+            }
+        } else {
+            BookNotFoundDetails details = new BookNotFoundDetails();
+            details.setId(Long.parseLong(id));
+            throw new BookNotFoundFault(details);
+        }
+        return null;
+    }
+    
+    @UriTemplate("/books/subresources/{bookId}/")
+    public AtomBook getBook(@UriParam("bookId") String id) throws BookNotFoundFault {
+        System.out.println("----invoking getBook with id: " + id);
+        Book book = books.get(Long.parseLong(id));
+        if (book != null) {
+            try {
+                return new AtomBook(book);
+            } catch (Exception ex) {
+                // ignore
+            }
+        } else {
+            BookNotFoundDetails details = new BookNotFoundDetails();
+            details.setId(Long.parseLong(id));
+            throw new BookNotFoundFault(details);
+        }
+        return null;
+    }
+    
+    
+    
+    
+    final void init() {
+        Book book = new Book();
+        book.setId(bookId);
+        book.setName("CXF in Action");
+        books.put(book.getId(), book);
+
+        CD cd = new CD();
+        cd.setId(cdId);
+        cd.setName("BOHEMIAN RHAPSODY");
+        cds.put(cd.getId(), cd);
+        CD cd1 = new CD();
+        cd1.setId(++cdId);
+        cd1.setName("BICYCLE RACE");
+        cds.put(cd1.getId(), cd1);
+    }
+}
+
+

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,132 @@
+/**
+ * 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.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.bind.JAXBContext;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AtomClientBookTest extends AbstractBusClientServerTestBase {
+
+    private Abdera abdera = new Abdera();
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(AtomBookServer.class));
+    }
+    
+    @Test
+    public void testGetBooks() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstore/books/feed"; 
+        URL url = new URL(endpointAddress);
+        InputStream in = url.openStream();
+        assertNotNull(in);           
+
+        Document<Feed> doc = abdera.getParser().parse(in);
+        Feed feed = doc.getRoot();
+        assertEquals("Collection of Books", feed.getTitle());
+        
+        
+        // add new book
+        Book b = new Book();
+        b.setId(256);
+        b.setName("AtomBook");
+        Entry e = createBookEntry(b);
+        StringWriter w = new StringWriter();
+        e.writeTo(w);
+        
+        PostMethod post = new PostMethod(endpointAddress);
+        post.setRequestEntity(
+             new StringRequestEntity(w.toString(), "application/atom+xml", null));
+        HttpClient httpclient = new HttpClient();
+        
+        String location = null;
+        try {
+            int result = httpclient.executeMethod(post);
+            assertEquals(201, result);
+            location = post.getResponseHeader("Location").getValue();
+        } finally {
+            // Release current connection to the connection pool once you are done
+            post.releaseConnection();
+        }         
+        
+        url = new URL(location);
+        in = url.openStream();
+        assertNotNull(in);
+        
+        Document<Entry> entryDoc = abdera.getParser().parse(in);
+        Entry entry = entryDoc.getRoot();
+        assertEquals("AtomBook", entry.getTitle());
+        
+        in.close();
+        
+        // get existing book
+        
+        endpointAddress =
+            "http://localhost:9080/bookstore/books/subresources/123"; 
+        url = new URL(endpointAddress);
+        in = url.openStream();
+        assertNotNull(in);           
+
+        entryDoc = abdera.getParser().parse(in);
+        entry = entryDoc.getRoot();
+        assertEquals("CXF in Action", entry.getTitle());
+        
+        in.close();
+        
+    }
+    
+    private Entry createBookEntry(Book b) throws Exception {
+        Factory factory = Abdera.getNewFactory();
+        JAXBContext jc = JAXBContext.newInstance(Book.class);
+        
+        Entry e = factory.getAbdera().newEntry();
+        e.setTitle(b.getName());
+        e.setId(Long.toString(b.getId()));
+        
+        
+        StringWriter writer = new StringWriter();
+        jc.createMarshaller().marshal(b, writer);
+        
+        e.setContentElement(factory.newContent());
+        e.getContentElement().setContentType(Content.Type.XML);
+        e.getContentElement().setValue(writer.toString());
+        
+        return e;
+    }   
+    
+   
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java?rev=619898&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java Fri Feb  8 06:37:10 2008
@@ -0,0 +1,57 @@
+/**
+ * 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.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+
+public final class AtomUtils {
+    
+    private AtomUtils() {
+        
+    }
+    
+    public static Entry createBookEntry(Book b) throws Exception {
+        Factory factory = Abdera.getNewFactory();
+        JAXBContext jc = JAXBContext.newInstance(Book.class);
+        
+        Entry e = factory.getAbdera().newEntry();
+        e.setTitle(b.getName());
+        e.setId(Long.toString(b.getId()));
+        
+        
+        StringWriter writer = new StringWriter();
+        jc.createMarshaller().marshal(b, writer);
+        
+        e.setContentElement(factory.newContent());
+        e.getContentElement().setContentType(Content.Type.XML);
+        e.getContentElement().setValue(writer.toString());
+        
+        return e;
+    }
+
+}

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

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



Mime
View raw message