abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r631352 - in /incubator/abdera/java/trunk: adapters/filesystem/ adapters/filesystem/src/ adapters/filesystem/src/main/ adapters/filesystem/src/main/java/ adapters/filesystem/src/main/java/org/ adapters/filesystem/src/main/java/org/apache/ a...
Date Tue, 26 Feb 2008 19:36:03 GMT
Author: jmsnell
Date: Tue Feb 26 11:35:58 2008
New Revision: 631352

URL: http://svn.apache.org/viewvc?rev=631352&view=rev
Log:
simple filesystem adapter implementation

Added:
    incubator/abdera/java/trunk/adapters/filesystem/
    incubator/abdera/java/trunk/adapters/filesystem/build.xml
    incubator/abdera/java/trunk/adapters/filesystem/readme
    incubator/abdera/java/trunk/adapters/filesystem/src/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/
    incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/FilesystemAdapter.java
    incubator/abdera/java/trunk/adapters/filesystem/src/test/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/FilesystemTest.java
    incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/TestSuite.java
    incubator/abdera/java/trunk/adapters/filesystem/src/test/resources/
    incubator/abdera/java/trunk/adapters/filesystem/src/test/resources/abdera/
Modified:
    incubator/abdera/java/trunk/build/build.xml

Added: incubator/abdera/java/trunk/adapters/filesystem/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/adapters/filesystem/build.xml?rev=631352&view=auto
==============================================================================
--- incubator/abdera/java/trunk/adapters/filesystem/build.xml (added)
+++ incubator/abdera/java/trunk/adapters/filesystem/build.xml Tue Feb 26 11:35:58 2008
@@ -0,0 +1,53 @@
+<project name="filesystem" default="compile">
+
+  <property name="version" value="0.4.0-incubating-SNAPSHOT" />
+  <property name="adapter.jar" value="abdera.adapter.${ant.project.name}.${version}.jar"
/>
+  <property name="retro.adapter.jar" value="abdera.adapter.${ant.project.name}.${version}.retro.jar"
/>
+  <property name="debug" value="on" />
+  
+  <property name="abdera" value="../../dist" />
+  <path id="abdera">
+    <fileset dir="${abdera}" includes="**/*.jar" excludes="**/*retro.jar"/>
+  </path>
+  <path id="retro">
+    <fileset dir="../../build/tools/retroweaver-2.0" includes="**/*.jar" />
+  </path>
+
+  <target name="dependencies">
+    <path id="dependencies">
+      <path refid="abdera" />
+    </path>
+  </target>
+  
+  <target name="compile" depends="dependencies">
+    <mkdir dir="${basedir}/build" />
+    <javac srcdir="src/main/java" classpathref="dependencies" destdir="${basedir}/build"
debug="${debug}" />
+    <javac srcdir="src/test/java" classpathref="dependencies" destdir="${basedir}/build"
debug="${debug}" />
+    <copy todir="${basedir}/build">
+      <fileset dir="src/test/resources" includes="**/*" />
+    </copy>
+    <jar destfile="${basedir}/${adapter.jar}" basedir="${basedir}/build" includes="org/apache/abdera/protocol/server/adapters/**/*"
/>
+    <java classpathref="retro" classname="net.sourceforge.retroweaver.Weaver" fork="yes">
+      <arg line="-jar &quot;${basedir}/${adapter.jar}&quot; &quot;${basedir}/${retro.adapter.jar}&quot;"
/>
+    </java>
+  </target>
+  
+  <target name="test">
+    <java classname="org.apache.abdera.protocol.server.test.filesystem.TestSuite"
+          classpath="${basedir}/build"
+          classpathref="dependencies"
+          fork="true" />
+  </target>
+  
+  <target name="clean">
+    <delete dir="${basedir}/build" />
+    <delete file="${basedir}/${adapter.jar}" />
+    <delete file="${basedir}/${retro.adapter.jar}" />
+  </target>
+  
+  <target name="dist" depends="clean,compile">
+    <copy todir="../../dist/adapters" file="${basedir}/${adapter.jar}" />
+    <copy todir="../../dist/adapters" file="${basedir}/${retro.adapter.jar}" />
+  </target>
+  
+</project>
\ No newline at end of file

Added: incubator/abdera/java/trunk/adapters/filesystem/readme
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/adapters/filesystem/readme?rev=631352&view=auto
==============================================================================
--- incubator/abdera/java/trunk/adapters/filesystem/readme (added)
+++ incubator/abdera/java/trunk/adapters/filesystem/readme Tue Feb 26 11:35:58 2008
@@ -0,0 +1,48 @@
+Filesystem Collection Adapter
+
+Dependencies: 
+
+  * Abdera Core, Parser, Protocol, Server modules
+  
+Using the Adapter:
+
+  The Filesystem adapter is based on Abdera Managed Adapter model.  To deploy an 
+  instance of the adapter, put a file called /abdera/adapter/[id].properties
+  in the classpath where [id] is the id of the service instance.  For instance,
+  /abdera/adapter/fs.properties
+  
+  
+Sample *.properties file
+
+  subUri=fs
+  adapterClassName=org.apache.abdera.protocol.server.adapters.filesystem.FilesystemAdapter
+  title=Filesystem Feed
+  author=james
+  configFile=dummyFileLocation
+  fs.root=/home/jasnell/tmp/fs
+  
+the fs.root property is required and must be set the location where the individual
+entry documents will be stored
+  
+Then, deploy the AbderaServlet using the BasicProvider in your Web application environment:
+
+Jetty deployment example:
+
+    Server server = new Server(9002);
+    Context context = new Context(server, "/", Context.SESSIONS);
+    ServletHolder servletHolder = new ServletHolder(new AbderaServlet());
+    servletHolder.setInitParameter(ServiceManager.PROVIDER, BasicProvider.class.getName());
+    context.addServlet(servletHolder, "/*");
+    server.start();
+    
+Using this example, the following resources will be served:
+
+    http://localhost:9002/                ==>  Atompub Service Document
+    http://localhost:9002/fs              ==>  Atompub Collection Feed
+    http://localhost:9002/fs/{entry}      ==>  Entry document
+    
+Limitations:
+
+  The adapter does not support media collections.
+  
+  
\ No newline at end of file

Added: incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/FilesystemAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/FilesystemAdapter.java?rev=631352&view=auto
==============================================================================
--- incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/FilesystemAdapter.java
(added)
+++ incubator/abdera/java/trunk/adapters/filesystem/src/main/java/org/apache/abdera/protocol/server/adapters/filesystem/FilesystemAdapter.java
Tue Feb 26 11:35:58 2008
@@ -0,0 +1,261 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server.adapters.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.i18n.templates.Template;
+import org.apache.abdera.i18n.text.Normalizer;
+import org.apache.abdera.i18n.text.Sanitizer;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.protocol.server.ProviderHelper;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.provider.managed.FeedConfiguration;
+import org.apache.abdera.protocol.server.provider.managed.ManagedCollectionAdapter;
+
+/**
+ * Simple Filesystem Adapter
+ */
+public class FilesystemAdapter 
+  extends ManagedCollectionAdapter {
+  
+  private final File root;
+  private final static FileSorter sorter = new FileSorter();
+  private final static Template paging_template = new Template("?{-join|&|count,page}");
+  
+  public FilesystemAdapter(
+    Abdera abdera, 
+    FeedConfiguration config) {
+      super(abdera, config);
+      this.root = getRoot();
+  }
+
+  private File getRoot() {
+    try {
+      String root = (String) config.getProperty("fs.root");
+      File file = new File(root);
+      if (!file.exists())
+        file.mkdirs();
+      if (!file.isDirectory())
+        throw new RuntimeException("Root must be a directory");
+      return file;
+    } catch (Exception e) {
+      if (e instanceof RuntimeException)
+        throw (RuntimeException)e;
+      throw new RuntimeException(e);
+    }
+  }
+  
+  private Entry getEntry(
+    File entryFile) {
+      if (!entryFile.exists() || !entryFile.isFile())
+        throw new RuntimeException();
+      try {
+        FileInputStream fis = new FileInputStream(entryFile);
+        Document<Entry> doc = abdera.getParser().parse(fis);
+        Entry entry = doc.getRoot();
+        return entry;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+  }
+  
+  private void addPagingLinks(
+    RequestContext request, 
+    Feed feed, 
+    int currentpage, 
+    int count) {
+      Map<String,Object> params = new HashMap<String,Object>();
+      params.put("count",count);
+      params.put("page",currentpage+1);
+      String next = paging_template.expand(params);
+      next = request.getResolvedUri().resolve(next).toString();
+      feed.addLink(next,"next");
+      if (currentpage > 0) {
+        params.put("page",currentpage-1);
+        String prev = paging_template.expand(params);
+        prev = request.getResolvedUri().resolve(prev).toString();
+        feed.addLink(prev,"previous");
+      }
+      params.put("page",0);
+      String current = paging_template.expand(params);
+      current = request.getResolvedUri().resolve(current).toString();
+      feed.addLink(current,"current");
+  }
+  
+  private void getEntries(
+    RequestContext request, 
+    Feed feed, 
+    File root) {
+    File[] files = root.listFiles();
+      Arrays.sort(files,sorter);
+      int length = ProviderHelper.getPageSize(request, "count", 25);
+      int offset = ProviderHelper.getOffset(request, "page", length);
+      String _page = request.getParameter("page");
+      int page =(_page != null) ? Integer.parseInt(_page) : 0;
+      addPagingLinks(request,feed,page,length);
+      if (offset > files.length) return;
+      for (int n = offset; n < offset+length && n < files.length; n++) {
+        File file = files[n];
+        Entry entry = getEntry(file);
+        feed.addEntry((Entry)entry.clone());
+      }
+  }
+  
+  public ResponseContext getFeed(
+    RequestContext request) {
+      Feed feed = abdera.newFeed();
+      feed.setId(
+        config.getServerConfiguration().
+          getServerUri() + "/" + 
+            config.getFeedId());
+      feed.setTitle(config.getFeedTitle());
+      feed.addAuthor(config.getFeedAuthor());
+      feed.addLink(config.getFeedUri());
+      feed.addLink(config.getFeedUri(),"self");
+      feed.setUpdated(new Date());
+      getEntries(request,feed,root);
+      return ProviderHelper.returnBase(
+        feed.getDocument(), 200, null);
+  }
+      
+  public ResponseContext deleteEntry(
+    RequestContext request) {
+      Target target = request.getTarget();
+      String key = target.getParameter("entry");
+      File file = getFile(key,false);
+      if (file.exists()) file.delete();
+      return ProviderHelper.nocontent();
+  }
+  
+  public ResponseContext getEntry(
+    RequestContext request) {
+      Target target = request.getTarget();
+      String key = target.getParameter("entry");
+      File file = getFile(key,false);
+      Entry entry = getEntry(file);
+      if (entry != null) 
+        return ProviderHelper.returnBase(entry.getDocument(), 200, null);
+      else
+        return ProviderHelper.notfound(request);
+  }
+  
+  public ResponseContext postEntry(
+    RequestContext request) {
+      if (request.isAtom()) {
+        try {
+          Entry entry = (Entry)request.getDocument().getRoot().clone();
+          String key = createKey(request);
+          setEditDetail(request,entry,key);
+          File file = getFile(key);
+          FileOutputStream out = new FileOutputStream(file);
+          entry.writeTo(out);
+          String edit = entry.getEditLinkResolvedHref().toString();
+          return ProviderHelper.returnBase(entry.getDocument(), 201, null).setLocation(edit);
+        } catch (Exception e) {
+          return ProviderHelper.badrequest(request);
+        }
+      } else {
+        return ProviderHelper.notsupported(request);
+      }
+  }
+  
+  private void setEditDetail(
+    RequestContext request, 
+    Entry entry, 
+    String key) 
+      throws IOException {
+    Target target = request.getTarget();
+    String feed = target.getParameter("feed");
+    String id = key;
+    entry.setEdited(new Date());
+    Link link = entry.getEditLink();
+    Map<String,Object> params = new HashMap<String,Object>();
+    params.put("feed", feed);
+    params.put("entry", id);
+    String href = request.absoluteUrlFor("entry", params);
+    if (link == null) {
+      entry.addLink(href, "edit");
+    } else {
+      link.setHref(href);
+    }
+  }
+  
+  private File getFile(String key) {
+    return getFile(key,true);
+  }
+  
+  private File getFile(String key, boolean post) {
+    File file = new File(root,key);
+    if (post && file.exists())
+      throw new RuntimeException("File exists");
+    return file;
+  }
+  
+  private String createKey(RequestContext request) throws IOException {
+    String slug = request.getSlug();
+    if (slug == null) {
+      slug = ((Entry)request.getDocument().getRoot()).getTitle();
+    }
+    return Sanitizer.sanitize(slug, "", true, Normalizer.Form.D);
+  }
+  
+  public ResponseContext putEntry(
+    RequestContext request) {
+      if (request.isAtom()) {
+        try {
+          Entry entry = (Entry)request.getDocument().getRoot().clone();
+          String key = request.getTarget().getParameter("entry");
+          setEditDetail(request,entry,key);
+          File file = getFile(key, false);
+          FileOutputStream out = new FileOutputStream(file);
+          entry.writeTo(out);
+          String edit = entry.getEditLinkResolvedHref().toString();
+          return ProviderHelper.returnBase(entry.getDocument(), 200, null).setLocation(edit);
+        } catch (Exception e) {
+          return ProviderHelper.badrequest(request);
+        }
+      } else {
+        return ProviderHelper.notsupported(request);
+      }
+  }
+  
+  private static class FileSorter 
+    implements Comparator<File> {
+      public int compare(
+        File o1, 
+        File o2) {
+          return o1.lastModified() > o2.lastModified() ? -1 :
+             o1.lastModified() < o2.lastModified() ? 1 : 0;
+    }
+  }
+}

Added: incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/FilesystemTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/FilesystemTest.java?rev=631352&view=auto
==============================================================================
--- incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/FilesystemTest.java
(added)
+++ incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/FilesystemTest.java
Tue Feb 26 11:35:58 2008
@@ -0,0 +1,159 @@
+package org.apache.abdera.protocol.server.test.filesystem;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+import org.apache.abdera.protocol.server.ServiceManager;
+import org.apache.abdera.protocol.server.provider.basic.BasicProvider;
+import org.apache.abdera.protocol.server.servlet.AbderaServlet;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.abdera.writer.Writer;
+import org.apache.abdera.writer.WriterFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public class FilesystemTest extends Assert {
+
+  private static Server server;
+  private static Abdera abdera = Abdera.getInstance();
+  private static AbderaClient client = new AbderaClient();
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    if (server == null) {
+      server = new Server(9002);
+      Context context = new Context(server, "/", Context.SESSIONS);
+      ServletHolder servletHolder = new ServletHolder(new AbderaServlet());
+      servletHolder.setInitParameter(ServiceManager.PROVIDER, BasicProvider.class.getName());
+      context.addServlet(servletHolder, "/*");
+      server.start();
+    }
+  }
+  
+  @AfterClass
+  public static void tearDown() throws Exception {
+    server.stop();
+  }
+
+  protected void prettyPrint(Base doc) throws IOException {
+    WriterFactory factory = abdera.getWriterFactory();
+    Writer writer = factory.getWriter("prettyxml");
+    writer.writeTo(doc, System.out);
+    System.out.println();
+  }
+
+  @Test
+  public void testGetService() {
+    ClientResponse resp = client.get("http://localhost:9002/");
+    assertNotNull(resp);
+    assertEquals(resp.getType(), ResponseType.SUCCESS);
+    assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.APP_MEDIA_TYPE));
+    Document<Service> doc = resp.getDocument();
+    Service service = doc.getRoot();
+    assertEquals(service.getWorkspaces().size(), 1);
+    Workspace workspace = service.getWorkspace("Abdera");
+    assertEquals(workspace.getCollections().size(), 2);
+    Collection collection = workspace.getCollection("Filesystem Feed");
+    assertNotNull(collection);
+    assertTrue(collection.acceptsEntry());
+    assertEquals(collection.getResolvedHref().toString(), "http://localhost:9002/fs");
+  }
+  @Test
+  public void testGetFeed() {
+    ClientResponse resp = client.get("http://localhost:9002/fs");
+    assertNotNull(resp);
+    assertEquals(resp.getType(), ResponseType.SUCCESS);
+    assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.ATOM_MEDIA_TYPE));
+    Document<Feed> doc = resp.getDocument();
+    Feed feed = doc.getRoot();
+    assertEquals(feed.getId().toString(), "http://localhost:9002/fs");
+    assertEquals(feed.getTitle(), "Filesystem Feed");
+    assertEquals(feed.getAuthor().getName(), "james");
+    assertEquals(feed.getEntries().size(), 0);
+    resp.release();
+  }
+  @Test
+  public void testPostEntry() {
+    Entry entry = abdera.newEntry();
+    entry.setId("http://localhost:9002/fs/foo");
+    entry.setTitle("test entry");
+    entry.setContent("Test Content");
+    entry.addLink("http://example.org");
+    entry.setUpdated(new Date());
+    entry.addAuthor("James");
+    ClientResponse resp = client.post("http://localhost:9002/fs", entry);
+    assertNotNull(resp);
+    assertEquals(resp.getType(), ResponseType.SUCCESS);
+    assertEquals(resp.getStatus(), 201);
+    assertEquals(resp.getLocation().toString(), "http://localhost:9002/fs/test_entry");
+    resp = client.get("http://localhost:9002/fs");
+    Document<Feed> feed_doc = resp.getDocument();
+    Feed feed = feed_doc.getRoot();
+    assertEquals(feed.getEntries().size(), 1);
+    resp.release();
+  }
+  @Test
+  public void testPostMedia() {
+    ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03, 0x04});
+    RequestOptions options = client.getDefaultRequestOptions();
+    options.setContentType("application/octet-stream");
+    ClientResponse resp = client.post("http://localhost:9002/fs", in, options);
+    assertEquals(resp.getType(), ResponseType.CLIENT_ERROR);
+    assertEquals(resp.getStatus(), 415);
+    resp.release();
+  }
+  @Test
+  public void testPutEntry() {
+    ClientResponse resp = client.get("http://localhost:9002/fs/test_entry");
+    Document<Entry> doc = resp.getDocument();
+    Entry entry = (Entry) doc.getRoot().clone();
+    entry.setTitle("This is the modified title");
+    resp.release();
+    resp = client.put("http://localhost:9002/fs/test_entry", entry);
+    assertEquals(resp.getType(), ResponseType.SUCCESS);
+    assertEquals(resp.getStatus(), 200);
+    resp.release();
+    resp = client.get("http://localhost:9002/fs/test_entry");
+    doc = resp.getDocument();
+    entry = doc.getRoot();
+    assertEquals(entry.getTitle(), "This is the modified title");
+    resp.release();
+    resp = client.get("http://localhost:9002/fs");
+    Document<Feed> feed_doc = resp.getDocument();
+    Feed feed = feed_doc.getRoot();
+    assertEquals(feed.getEntries().size(), 1);
+    resp.release();
+  }
+
+  @Test
+  public void testDeleteEntry() {
+    ClientResponse resp = client.delete("http://localhost:9002/fs/test_entry");
+    assertEquals(resp.getType(), ResponseType.SUCCESS);
+    resp.release();
+    resp = client.get("http://localhost:9002/fs");
+    Document<Feed> feed_doc = resp.getDocument();
+    Feed feed = feed_doc.getRoot();
+    assertEquals(feed.getEntries().size(), 0);
+    resp.release();
+  }
+}

Added: incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/TestSuite.java?rev=631352&view=auto
==============================================================================
--- incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/TestSuite.java
(added)
+++ incubator/abdera/java/trunk/adapters/filesystem/src/test/java/org/apache/abdera/protocol/server/test/filesystem/TestSuite.java
Tue Feb 26 11:35:58 2008
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server.test.filesystem;
+
+import org.junit.internal.runners.TextListener;
+import org.junit.runner.JUnitCore;
+
+public class TestSuite {
+  public static void main(String[] args) {
+    JUnitCore runner = new JUnitCore();
+    runner.addListener(new TextListener(System.out));
+    runner.run(
+      FilesystemTest.class);
+  }
+}

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=631352&r1=631351&r2=631352&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Tue Feb 26 11:35:58 2008
@@ -979,6 +979,7 @@
     <ant antfile="${basedir}/adapters/couchdb/build.xml" target="dist" dir="${basedir}/adapters/couchdb"
inheritall="false" />
     <ant antfile="${basedir}/adapters/jcr/build.xml" target="dist" dir="${basedir}/adapters/jcr"
inheritall="false" />
     <ant antfile="${basedir}/adapters/jdbc/build.xml" target="dist" dir="${basedir}/adapters/jdbc"
inheritall="false" />
+    <ant antfile="${basedir}/adapters/filesystem/build.xml" target="dist" dir="${basedir}/adapters/filesystem"
inheritall="false" />
   </target>
   
 </project>



Mime
View raw message