abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r616577 - in /incubator/abdera/java/trunk/server/src: main/java/org/apache/abdera/protocol/server/impl/ test/java/org/apache/abdera/protocol/server/test/customer/
Date Wed, 30 Jan 2008 01:21:55 GMT
Author: dandiep
Date: Tue Jan 29 17:21:54 2008
New Revision: 616577

URL: http://svn.apache.org/viewvc?rev=616577&view=rev
Log:
Fix test.

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
    incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=616577&r1=616576&r2=616577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
Tue Jan 29 17:21:54 2008
@@ -99,8 +99,7 @@
                                  entry.getContentElement(), request);
           entry.getIdElement().setValue(getId(entryObj));
         
-          IRI entryBaseUri = getEntryBaseFromFeedIRI(ProviderHelper.resolveBase(request));
-          
+          IRI entryBaseUri = new IRI(getHref(request) + "/");          
           IRI entryIri = entryBaseUri.resolve(getName(entryObj));
           entry.addLink(entryIri.toString(), "edit");
     
@@ -352,16 +351,15 @@
       T doc = postMedia(request.getContentType(), request.getSlug(), 
                                request.getInputStream(), request);
 
-      IRI baseIri = ProviderHelper.resolveBase(request);
-      IRI entryIri = getEntryBaseFromFeedIRI(baseIri);
+      IRI feedUri = new IRI(getHref(request) + "/");
 
       Entry entry = request.getAbdera().getFactory().newEntry();
 
-      addEntryDetails(request, entry, entryIri, doc);
+      addEntryDetails(request, entry, feedUri, doc);
 
-      addMediaContent(entryIri, entry, doc);
+      addMediaContent(feedUri, entry, doc);
 
-      return buildCreateMediaEntryResponse(entryIri, entry);
+      return buildCreateMediaEntryResponse(feedUri, entry);
     } catch (IOException e) {
       return new EmptyResponseContext(500);
     } catch (ResponseContextException e) {
@@ -388,9 +386,9 @@
         
         entry.getIdElement().setValue(getId(entryObj));
 
-        IRI entryBaseUri = getEntryBaseFromFeedIRI(ProviderHelper.resolveBase(request));
+        IRI feedUri = new IRI(getHref(request) + "/");
 
-        IRI entryIri = entryBaseUri.resolve(getName(entryObj));
+        IRI entryIri = feedUri.resolve(getName(entryObj));
         entry.addLink(entryIri.toString(), "edit");
 
         return buildCreateEntryResponse(entryIri, entry);
@@ -400,10 +398,6 @@
     } catch (ResponseContextException e) {
       return createErrorResponse(e);
     }
-  }
-
-  protected IRI getEntryBaseFromFeedIRI(IRI baseIri) {
-    return new IRI(baseIri.toString() + "/");
   }
 
   protected Entry getEntryFromCollectionProvider(IRI feedIri, RequestContext request) throws
ResponseContextException {

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java?rev=616577&r1=616576&r2=616577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
Tue Jan 29 17:21:54 2008
@@ -97,6 +97,10 @@
   public Target resolve(Request request) {
     RequestContext context = (RequestContext) request;
     String uri = context.getTargetPath();
+    int idx = uri.indexOf('?');
+    if (idx != -1) {
+      uri = uri.substring(0, idx);
+    }
     for(Map.Entry<Route, TargetType> entry : targets.entrySet()) {
       if (entry.getKey().match(uri)) {
         CollectionAdapter ca = route2CA.get(entry.getKey());

Modified: incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java?rev=616577&r1=616576&r2=616577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
(original)
+++ incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
Tue Jan 29 17:21:54 2008
@@ -53,18 +53,14 @@
   public void testCustomerProvider() throws Exception {
     setupAbdera("/");
     
-    String base = "http://localhost:9002/";
-
-    runTests(base);
+    runTests("/");
   }
   
   @Test
   public void testCustomerProviderWithDifferentBase() throws Exception {
     setupAbdera("/base/");
     
-    String base = "http://localhost:9002/base/";
-
-    runTests(base);
+    runTests("/base/");
   }
 
   private void runTests(String base) throws IOException {
@@ -73,8 +69,10 @@
 
     AbderaClient client = new AbderaClient(abdera);
 
+    String uri = "http://localhost:9002" + base;
+    
     // Testing of entry creation
-    IRI colUri = new IRI(base).resolve("customers"); 
+    IRI colUri = new IRI(uri).resolve("customers"); 
                                                           
     Entry entry = factory.newEntry();
     entry.setTitle("This is ignored right now");
@@ -92,14 +90,14 @@
     ClientResponse res = client.post(colUri.toString() + "?test=foo", entry, opts);
     assertEquals(201, res.getStatus());
 
-    // prettyPrint(abdera, res.getDocument());
+    prettyPrint(abdera, res.getDocument());
 
     IRI location = res.getLocation();
-    assertEquals(colUri + "/1001-Dan_Diephouse", 
+    assertEquals(base + "customers/1001-Dan_Diephouse", 
                  location.toString());
 
     // GET the entry
-    res = client.get(location.toString());
+    res = client.get(colUri.resolve(location.toString()).toString());
     assertEquals(200, res.getStatus());
 
     // prettyPrint(abdera, res.getDocument());



Mime
View raw message