You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2011/09/20 17:57:20 UTC
svn commit: r1173209 [48/49] - in /abdera/abdera2: ./ .settings/ activities/
activities/src/ activities/src/main/ activities/src/main/java/
activities/src/main/java/org/ activities/src/main/java/org/apache/
activities/src/main/java/org/apache/abdera2/ ...
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,217 @@
+/*
+ * 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.abdera2.test.server.custom;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.RequestContext.Scope;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.ProviderHelper;
+import org.apache.abdera2.common.protocol.ResponseContextException;
+import org.apache.abdera2.common.protocol.TargetType;
+import org.apache.abdera2.common.text.UrlEncoding;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
+import org.apache.abdera2.protocol.server.context.FOMResponseContext;
+import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.writer.StreamWriter;
+
+@SuppressWarnings("unchecked")
+public class SimpleAdapter extends AbstractAtompubCollectionAdapter {
+
+ @Override
+ public String getAuthor(RequestContext request) throws ResponseContextException {
+ return "Simple McGee";
+ }
+
+ @Override
+ public String getId(RequestContext request) {
+ return "tag:example.org,2008:feed";
+ }
+
+ public String getHref(RequestContext request) {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("collection", "feed");
+ return request.urlFor(TargetType.TYPE_COLLECTION, params);
+ }
+
+ public String getTitle(RequestContext request) {
+ return "A simple feed";
+ }
+
+ public ResponseContext extensionRequest(RequestContext request) {
+ return ProviderHelper.notallowed(request, "Method Not Allowed", ProviderHelper.getDefaultMethods(request));
+ }
+
+ private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {
+ Feed feed = (Feed)context.getAttribute(Scope.SESSION, "feed");
+ if (feed == null) {
+ feed = createFeedBase(context);
+ feed.setBaseUri(getHref(context));
+ context.setAttribute(Scope.SESSION, "feed", feed);
+ }
+ return feed.getDocument();
+ }
+
+ public ResponseContext getItemList(RequestContext request) {
+ Document<Feed> feed;
+ try {
+ feed = getFeedDocument(request);
+ } catch (ResponseContextException e) {
+ return e.getResponseContext();
+ }
+
+ return AbstractAtompubProvider.returnBase(feed, 200, feed.getRoot().getUpdated()).setEntityTag(AbstractAtompubProvider
+ .calculateEntityTag(feed.getRoot()));
+ }
+
+ public ResponseContext deleteItem(RequestContext request) {
+ Entry entry = getAbderaEntry(request);
+ if (entry != null)
+ entry.discard();
+ return ProviderHelper.nocontent();
+ }
+
+ public ResponseContext getItem(RequestContext request) {
+ Entry entry = (Entry)getAbderaEntry(request);
+ if (entry != null) {
+ Feed feed = entry.getParentElement();
+ entry = (Entry)entry.clone();
+ entry.setSource(feed.getAsSource());
+ Document<Entry> entry_doc = entry.getDocument();
+ return AbstractAtompubProvider.returnBase(entry_doc, 200, entry.getEdited()).setEntityTag(AbstractAtompubProvider
+ .calculateEntityTag(entry));
+ } else {
+ return ProviderHelper.notfound(request);
+ }
+ }
+
+ public ResponseContext postItem(RequestContext context) {
+ AtompubRequestContext request = (AtompubRequestContext) context;
+ Abdera abdera = request.getAbdera();
+ try {
+ Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+ if (entry_doc != null) {
+ Entry entry = entry_doc.getRoot();
+ if (!AbstractAtompubProvider.isValidEntry(entry))
+ return ProviderHelper.badrequest(request);
+ setEntryDetails(request, entry, abdera.getFactory().newUuidUri());
+ Feed feed = getFeedDocument(request).getRoot();
+ feed.insertEntry(entry);
+ feed.setUpdated(new Date());
+ FOMResponseContext<?> rc =
+ (FOMResponseContext<?>)AbstractAtompubProvider.returnBase(entry_doc, 201, entry.getEdited());
+ return rc.setLocation(ProviderHelper.resolveBase(request).resolve(entry.getEditLinkResolvedHref())
+ .toString()).setContentLocation(rc.getLocation().toString()).setEntityTag(AbstractAtompubProvider
+ .calculateEntityTag(entry));
+ } else {
+ return ProviderHelper.badrequest(request);
+ }
+ } catch (ParseException pe) {
+ return ProviderHelper.notsupported(request);
+ } catch (ClassCastException cce) {
+ return ProviderHelper.notsupported(request);
+ } catch (Exception e) {
+ return ProviderHelper.badrequest(request);
+ }
+ }
+
+ private void setEntryDetails(RequestContext request, Entry entry, String id) {
+ entry.setUpdated(new Date());
+ entry.setEdited(entry.getUpdated());
+ entry.getIdElement().setValue(id);
+ entry.addLink(getEntryLink(request, entry.getId().toASCIIString()), "edit");
+ }
+
+ private String getEntryLink(RequestContext request, String entryid) {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put("collection", request.getTarget().getParameter("collection"));
+ params.put("entry", entryid);
+ return request.urlFor(TargetType.TYPE_ENTRY, params);
+ }
+
+ public ResponseContext putItem(RequestContext context) {
+ AtompubRequestContext request = (AtompubRequestContext) context;
+ Abdera abdera = request.getAbdera();
+ Entry orig_entry = getAbderaEntry(request);
+ if (orig_entry != null) {
+ try {
+ Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+ if (entry_doc != null) {
+ Entry entry = entry_doc.getRoot();
+ if (!entry.getId().equals(orig_entry.getId()))
+ return ProviderHelper.conflict(request);
+ if (!AbstractAtompubProvider.isValidEntry(entry))
+ return ProviderHelper.badrequest(request);
+ setEntryDetails(request, entry, orig_entry.getId().toString());
+ orig_entry.discard();
+ Feed feed = getFeedDocument(request).getRoot();
+ feed.insertEntry(entry);
+ feed.setUpdated(new Date());
+ return ProviderHelper.nocontent();
+ } else {
+ return ProviderHelper.badrequest(request);
+ }
+ } catch (ParseException pe) {
+ return ProviderHelper.notsupported(request);
+ } catch (ClassCastException cce) {
+ return ProviderHelper.notsupported(request);
+ } catch (Exception e) {
+ return ProviderHelper.badrequest(request);
+ }
+ } else {
+ return ProviderHelper.notfound(request);
+ }
+ }
+
+ private Entry getAbderaEntry(RequestContext request) {
+ try {
+ return getFeedDocument(request).getRoot().getEntry(getResourceName(request));
+ } catch (Exception e) {
+ }
+ return null;
+ }
+
+ public String getResourceName(RequestContext request) {
+ if (request.getTarget().getType() != TargetType.TYPE_ENTRY)
+ return null;
+ String[] segments = request.getUri().toString().split("/");
+ return UrlEncoding.decode(segments[segments.length - 1]);
+ }
+
+ public ResponseContext getCategories(RequestContext context) {
+ AtompubRequestContext request = (AtompubRequestContext) context;
+ return new StreamWriterResponseContext(request.getAbdera()) {
+ protected void writeTo(StreamWriter sw) throws IOException {
+ sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
+ .writeCategory("baz").endCategories().endDocument();
+ }
+ }.setStatus(200).setContentType(Constants.CAT_MEDIA_TYPE);
+ }
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.abdera2.test.server.customer;
+
+public class Customer {
+ private int id;
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/Customer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,166 @@
+/*
+ * 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.abdera2.test.server.customer;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.ResponseContextException;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Person;
+import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
+import org.apache.abdera2.protocol.server.impl.AbstractEntityCollectionAdapter;
+
+public class CustomerAdapter extends AbstractEntityCollectionAdapter<Customer> {
+ private static final String ID_PREFIX = "urn:acme:customer:";
+
+ private AtomicInteger nextId = new AtomicInteger(1000);
+ private Map<Integer, Customer> customers = new HashMap<Integer, Customer>();
+ private Factory factory = Abdera.getInstance().getFactory();
+
+ public CustomerAdapter() {
+ }
+
+ public String getId(RequestContext request) {
+ return "tag:example.org,2007:feed";
+ }
+
+ public <S extends ResponseContext>S getCategories(RequestContext request) {
+ return null;
+ }
+
+ @Override
+ public Customer postEntry(String title,
+ IRI id,
+ String summary,
+ Date updated,
+ List<Person> authors,
+ Content content,
+ RequestContext request) throws ResponseContextException {
+ Customer customer = contentToCustomer(content);
+ customers.put(customer.getId(), customer);
+
+ return customer;
+ }
+
+ private Customer contentToCustomer(Content content) {
+ Customer customer = new Customer();
+
+ return contentToCustomer(content, customer);
+ }
+
+ private Customer contentToCustomer(Content content, Customer customer) {
+ Element firstChild = content.getFirstChild();
+ customer.setName(firstChild.getAttributeValue("name"));
+ customer.setId(nextId.incrementAndGet());
+ return customer;
+ }
+
+ public void deleteEntry(String resourceName, RequestContext request) throws ResponseContextException {
+ Integer id = getIdFromResourceName(resourceName);
+ customers.remove(id);
+ }
+
+ public String getAuthor(RequestContext request) {
+ return "Acme Industries";
+ }
+
+ @Override
+ public List<Person> getAuthors(Customer entry, RequestContext context) throws ResponseContextException {
+ AtompubRequestContext request = (AtompubRequestContext) context;
+ Person author = request.getAbdera().getFactory().newAuthor();
+ author.setName("Acme Industries");
+ return Arrays.asList(author);
+ }
+
+ public Object getContent(Customer entry, RequestContext request) {
+ Content content = factory.newContent();
+ Element customerEl = factory.newElement(new QName("customer"));
+ customerEl.setAttributeValue(new QName("name"), entry.getName());
+
+ content.setValueElement(customerEl);
+ return content;
+ }
+
+ public Iterable<Customer> getEntries(RequestContext request) {
+ return customers.values();
+ }
+
+ public Customer getEntry(String resourceName, RequestContext request) throws ResponseContextException {
+ Integer id = getIdFromResourceName(resourceName);
+ return customers.get(id);
+ }
+
+ private Integer getIdFromResourceName(String resourceName) throws ResponseContextException {
+ int idx = resourceName.indexOf("-");
+ if (idx == -1) {
+ throw new ResponseContextException(404);
+ }
+ Integer id = new Integer(resourceName.substring(0, idx));
+ return id;
+ }
+
+ public Customer getEntryFromId(String id, RequestContext request) {
+ return customers.get(new Integer(id));
+ }
+
+ public String getId(Customer entry) {
+ // TODO: is this valid?
+ return ID_PREFIX + entry.getId();
+ }
+
+ public String getName(Customer entry) {
+ return entry.getId() + "-" + entry.getName().replaceAll(" ", "_");
+ }
+
+ public String getTitle(RequestContext request) {
+ return "Acme Customer Database";
+ }
+
+ public String getTitle(Customer entry) {
+ return entry.getName();
+ }
+
+ public Date getUpdated(Customer entry) {
+ return new Date();
+ }
+
+ @Override
+ public void putEntry(Customer entry,
+ String title,
+ Date updated,
+ List<Person> authors,
+ String summary,
+ Content content,
+ RequestContext request) throws ResponseContextException {
+ contentToCustomer(content, entry);
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,213 @@
+/*
+ * 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.abdera2.test.server.customer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.http.ResponseType;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.model.Workspace;
+import org.apache.abdera2.protocol.client.AbderaClient;
+import org.apache.abdera2.protocol.client.AbderaClientResponse;
+import org.apache.abdera2.protocol.client.AbderaSession;
+import org.apache.abdera2.protocol.client.RequestOptions;
+import org.apache.abdera2.protocol.server.AtompubProvider;
+import org.apache.abdera2.protocol.server.impl.DefaultAtompubProvider;
+import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
+import org.apache.abdera2.test.JettyUtil;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.protocol.servlet.AbderaServlet;
+import org.apache.abdera2.writer.Writer;
+import org.apache.abdera2.writer.WriterFactory;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.junit.After;
+import org.junit.Test;
+
+public class CustomerAdapterTest {
+
+ private DefaultAtompubProvider customerProvider;
+
+ private void setupAbdera(String base) throws Exception {
+ customerProvider = new DefaultAtompubProvider(base);
+
+ CustomerAdapter ca = new CustomerAdapter();
+ ca.setHref("customers");
+
+ SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
+ wi.setTitle("Customer Workspace");
+ wi.addCollection(ca);
+
+ customerProvider.addWorkspace(wi);
+ }
+
+ @Test
+ public void testCustomerProvider() throws Exception {
+ setupAbdera("/");
+ initializeJetty("/");
+
+ runTests("/");
+ }
+
+ @Test
+ public void testCustomerProviderWithNonRootContextPath() throws Exception {
+ setupAbdera("/");
+ initializeJetty("/foo");
+ runTests("/foo/");
+ }
+
+ private void runTests(String base) throws IOException {
+ Abdera abdera = Abdera.getInstance();
+ Factory factory = abdera.getFactory();
+
+ AbderaClient client = new AbderaClient(abdera);
+ AbderaSession session = (AbderaSession) client.newSession();
+
+ String uri = "http://localhost:9002" + base;
+
+ // Service document test.
+
+ AbderaClientResponse res = (AbderaClientResponse) session.get(uri);
+ assertNotNull(res);
+ try {
+ assertEquals(200, res.getStatus());
+ assertEquals(ResponseType.SUCCESSFUL, res.getType());
+ assertTrue(MimeTypeHelper.isMatch(res.getContentType().toString(), Constants.APP_MEDIA_TYPE));
+
+ Document<Service> doc = res.getDocument();
+ Service service = doc.getRoot();
+ assertEquals(1, service.getWorkspaces().size());
+
+ Workspace workspace = service.getWorkspaces().get(0);
+ assertEquals(1, workspace.getCollections().size());
+
+ // Keep the loop in case we add other collections to the test.
+
+ for (Collection collection : workspace.getCollections()) {
+ if (collection.getTitle().equals("Acme Customer Database")) {
+ String expected = uri + "customers";
+ String actual = collection.getResolvedHref().toString();
+ assertEquals(expected, actual);
+ }
+ }
+ } finally {
+ res.release();
+ }
+
+ // Testing of entry creation
+ IRI colUri = new IRI(uri).resolve("customers");
+
+ Entry entry = factory.newEntry();
+ entry.setTitle("This is ignored right now");
+ entry.setUpdated(new Date());
+ entry.addAuthor("Acme Industries");
+ entry.setId(factory.newUuidUri());
+ entry.setSummary("Customer document");
+
+ Element customerEl = factory.newElement(new QName("customer"));
+ customerEl.setAttributeValue(new QName("name"), "Dan Diephouse");
+ entry.setContent(customerEl);
+
+ RequestOptions opts = new RequestOptions();
+ opts.setContentType("application/atom+xml;type=entry");
+ res = (AbderaClientResponse) session.post(colUri.toString() + "?test=foo", entry, opts);
+ assertEquals(201, res.getStatus());
+
+ // prettyPrint(abdera, res.getDocument());
+
+ IRI location = res.getLocation();
+ assertEquals(uri + "customers/1001-Dan_Diephouse", location.toString());
+
+ // GET the entry
+ res = (AbderaClientResponse) session.get(location.toString());
+ assertEquals(200, res.getStatus());
+ org.apache.abdera2.model.Document<Entry> entry_doc = res.getDocument();
+ // prettyPrint(abdera, entry_doc);
+ entry = entry_doc.getRoot();
+ assertEquals(uri + "customers/1001-Dan_Diephouse", entry_doc.getRoot().getEditLinkResolvedHref().toString());
+ res.release();
+
+ // HEAD
+ res = (AbderaClientResponse) session.head(location.toString());
+ assertEquals(200, res.getStatus());
+ assertEquals(0, res.getContentLength());
+ res.release();
+
+ // Try invalid resources
+ res = (AbderaClientResponse) session.get(colUri + "/foobar");
+ assertEquals(404, res.getStatus());
+ res.release();
+
+ res = (AbderaClientResponse) session.head(colUri + "/foobar");
+ assertEquals(404, res.getStatus());
+ assertEquals(0, res.getContentLength());
+ res.release();
+
+ IRI badColUri = new IRI(uri).resolve("customersbad");
+ // GET the service doc
+ res = (AbderaClientResponse) session.get(colUri.toString());
+ assertEquals(200, res.getStatus());
+ res.release();
+ res = (AbderaClientResponse) session.get(badColUri.toString());
+ assertEquals(404, res.getStatus());
+ res.release();
+ client.shutdown();
+ }
+
+ protected void prettyPrint(Abdera abdera, Base doc) throws IOException {
+ WriterFactory factory = abdera.getWriterFactory();
+ Writer writer = factory.getWriter("prettyxml");
+ writer.writeTo(doc, System.out);
+ System.out.println();
+ }
+
+ @SuppressWarnings("serial")
+ private void initializeJetty(String contextPath) throws Exception {
+
+ JettyUtil.addServlet(new ServletHolder(new AbderaServlet() {
+ @Override
+ protected AtompubProvider createProvider() {
+ customerProvider.init(Abdera.getInstance(), null);
+ return customerProvider;
+ }
+ }), "/*");
+ JettyUtil.setContextPath(contextPath);
+ JettyUtil.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ JettyUtil.stop();
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,87 @@
+package org.apache.abdera2.test.server.multipart;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.mail.MessagingException;
+
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.protocol.server.multipart.AbstractMultipartCollectionAdapter;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.EmptyResponseContext;
+import org.apache.abdera2.common.protocol.ProviderHelper;
+
+@SuppressWarnings("unchecked")
+public class MultipartRelatedAdapter extends AbstractMultipartCollectionAdapter {
+
+ @Override
+ public String getAuthor(RequestContext request) {
+ return "Acme Industries";
+ }
+
+ @Override
+ public String getId(RequestContext request) {
+ return "tag:example.org,2008:feed";
+ }
+
+ public <S extends ResponseContext>S deleteItem(RequestContext request) {
+ return (S)ProviderHelper.notallowed(request);
+ }
+
+ public <S extends ResponseContext>S getItem(RequestContext request) {
+ return (S)ProviderHelper.notallowed(request);
+ }
+
+ public <S extends ResponseContext>S getItemList(RequestContext request) {
+ return (S)ProviderHelper.notallowed(request);
+ }
+
+ public <S extends ResponseContext>S postItem(RequestContext request) {
+ return (S)ProviderHelper.notallowed(request);
+ }
+
+ public <S extends ResponseContext>S putItem(RequestContext request) {
+ return (S)ProviderHelper.notallowed(request);
+ }
+
+ public <S extends ResponseContext>S postMedia(RequestContext request) {
+ try {
+ if (MimeTypeHelper.isMultipart(request.getContentType().toString())) {
+ getMultipartRelatedData(request);
+ // Post object is a wrapper for the media resource and the media link entry.
+ // Once we get it we can save them following the rfc specification.
+ }
+
+ return (S)new EmptyResponseContext(201);
+ } catch (ParseException pe) {
+ return (S)new EmptyResponseContext(415, pe.getLocalizedMessage());
+ } catch (IOException ioe) {
+ return (S)new EmptyResponseContext(500, ioe.getLocalizedMessage());
+ } catch (MessagingException e) {
+ return (S)new EmptyResponseContext(500, e.getLocalizedMessage());
+ }
+ }
+
+ public String getTitle(RequestContext request) {
+ return "Acme Multipart/related adapter";
+ }
+
+ @SuppressWarnings("serial")
+ public Map<String, String> getAlternateAccepts(RequestContext request) {
+ if (accepts == null) {
+ accepts = new HashMap<String, String>() {
+ {
+ put("video/*", null); /* doesn't accept multipart related */
+ put("image/jpg", ""); /* doesn't accept multipart related */
+ put("image/png", Constants.LN_ALTERNATE_MULTIPART_RELATED /* multipart-related */);
+ }
+ };
+ }
+ return accepts;
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,122 @@
+package org.apache.abdera2.test.server.multipart;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.protocol.RequestProcessor;
+import org.apache.abdera2.common.protocol.TargetType;
+import org.apache.abdera2.common.protocol.servlet.AbderaServlet;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.protocol.client.AbderaClient;
+import org.apache.abdera2.protocol.client.AbderaClientResponse;
+import org.apache.abdera2.protocol.client.AbderaSession;
+import org.apache.abdera2.protocol.client.Client;
+import org.apache.abdera2.protocol.server.AtompubProvider;
+import org.apache.abdera2.protocol.server.impl.DefaultAtompubProvider;
+import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
+import org.apache.abdera2.protocol.server.processors.MultipartRelatedServiceRequestProcessor;
+import org.apache.abdera2.test.JettyUtil;
+import org.apache.http.entity.mime.content.InputStreamBody;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.junit.After;
+import org.junit.Test;
+
+@SuppressWarnings("serial")
+public class MultipartRelatedTest {
+
+ private void initializeJetty(String contextPath) throws Exception {
+
+ JettyUtil.addServlet(new ServletHolder(new AbderaServlet() {
+ @Override
+ protected AtompubProvider createProvider() {
+ DefaultAtompubProvider provider = new DefaultAtompubProvider("/");
+ Map<TargetType,RequestProcessor> map =
+ new HashMap<TargetType,RequestProcessor>();
+ map.put(TargetType.TYPE_SERVICE,
+ new MultipartRelatedServiceRequestProcessor());
+ provider.addRequestProcessors(map);
+
+ MultipartRelatedAdapter ca = new MultipartRelatedAdapter();
+ ca.setHref("media");
+
+ SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
+ wi.setTitle("multimedia/related Workspace");
+ wi.addCollection(ca);
+
+ provider.addWorkspace(wi);
+
+ provider.init(Abdera.getInstance(), null);
+ return provider;
+ }
+ }), "/*");
+ JettyUtil.setContextPath(contextPath);
+ JettyUtil.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ JettyUtil.stop();
+ }
+
+ @Test
+ public void testServiceDocument() throws Exception {
+ initializeJetty("/");
+ Client client = new AbderaClient(Abdera.getInstance());
+ AbderaSession session = (AbderaSession) client.newSession();
+ AbderaClientResponse res = (AbderaClientResponse) session.get("http://localhost:9002/");
+ assertEquals(200, res.getStatus());
+ StringWriter sw = new StringWriter();
+ res.getDocument().writeTo(sw);
+ res.release();
+ assertTrue(sw.toString().contains("accept alternate=\"multipart-related\">image/png"));
+ assertTrue(sw.toString().contains("accept>video/*"));
+ assertTrue(sw.toString().contains("accept>image/jpg"));
+ client.shutdown();
+ }
+
+ @Test
+ public void testPostMedia() throws Exception {
+ execTest(201, "image/png");
+ }
+
+ @Test
+ public void testPostMediaInvalidContentType() throws Exception {
+ // collection doesn't accept multipart files with this content type
+ execTest(415, "image/jpg");
+ }
+
+ private void execTest(int status, String contentType) throws Exception {
+ initializeJetty("/");
+
+ Abdera abdera = Abdera.getInstance();
+ Factory factory = abdera.getFactory();
+
+ Client client = new AbderaClient(abdera);
+ AbderaSession session = (AbderaSession) client.newSession();
+
+ Entry entry = factory.newEntry();
+
+ entry.setTitle("my image");
+ entry.addAuthor("david");
+ entry.setId("tag:apache.org,2008:234534344");
+ entry.setSummary("multipart test");
+ entry.setContent(new IRI("cid:234234@example.com"), contentType);
+
+ AbderaClientResponse res =
+ (AbderaClientResponse) session.post(
+ "http://localhost:9002/media",
+ entry,
+ new InputStreamBody(this.getClass().getResourceAsStream("/info.png"),contentType,null));
+ assertEquals(status, res.getStatus());
+
+ res.release();
+ client.shutdown();
+ }
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,306 @@
+/*
+ * 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.abdera2.test.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.parser.AbstractParserOptions;
+import org.junit.Test;
+
+public class AbstractParserOptionsTest {
+
+ private static final class TestParserOptions extends AbstractParserOptions {
+
+ @Override
+ protected void checkFactory(Factory factory) {
+ }
+
+ @Override
+ protected void initFactory() {
+ }
+ }
+
+ @Test
+ public void checkAllEntities() throws Exception {
+ TestParserOptions fomParserOptions = new TestParserOptions();
+
+ assertEquals("00A1", getHexValue("iexcl", fomParserOptions));
+ assertEquals("00A2", getHexValue("cent", fomParserOptions));
+ assertEquals("00A3", getHexValue("pound", fomParserOptions));
+ assertEquals("00A4", getHexValue("curren", fomParserOptions));
+ assertEquals("00A5", getHexValue("yen", fomParserOptions));
+ assertEquals("00A6", getHexValue("brvbar", fomParserOptions));
+ assertEquals("00A7", getHexValue("sect", fomParserOptions));
+ assertEquals("00A8", getHexValue("uml", fomParserOptions));
+ assertEquals("00A9", getHexValue("copy", fomParserOptions));
+ assertEquals("00AA", getHexValue("ordf", fomParserOptions));
+ assertEquals("00AB", getHexValue("laquo", fomParserOptions));
+ assertEquals("00AC", getHexValue("not", fomParserOptions));
+ assertEquals("00AD", getHexValue("shy", fomParserOptions));
+ assertEquals("00AE", getHexValue("reg", fomParserOptions));
+ assertEquals("00AF", getHexValue("macr", fomParserOptions));
+ assertEquals("00B0", getHexValue("deg", fomParserOptions));
+ assertEquals("00B1", getHexValue("plusmn", fomParserOptions));
+ assertEquals("00B2", getHexValue("sup2", fomParserOptions));
+ assertEquals("00B3", getHexValue("sup3", fomParserOptions));
+ assertEquals("00B4", getHexValue("acute", fomParserOptions));
+ assertEquals("00B5", getHexValue("micro", fomParserOptions));
+ assertEquals("00B6", getHexValue("para", fomParserOptions));
+ assertEquals("00B7", getHexValue("middot", fomParserOptions));
+ assertEquals("00B8", getHexValue("cedil", fomParserOptions));
+ assertEquals("00B9", getHexValue("sup1", fomParserOptions));
+ assertEquals("00BA", getHexValue("ordm", fomParserOptions));
+ assertEquals("00BB", getHexValue("raquo", fomParserOptions));
+ assertEquals("00BC", getHexValue("frac14", fomParserOptions));
+ assertEquals("00BD", getHexValue("frac12", fomParserOptions));
+ assertEquals("00BE", getHexValue("frac34", fomParserOptions));
+ assertEquals("00BF", getHexValue("iquest", fomParserOptions));
+ assertEquals("00C0", getHexValue("Agrave", fomParserOptions));
+ assertEquals("00C1", getHexValue("Aacute", fomParserOptions));
+ assertEquals("00C2", getHexValue("Acirc", fomParserOptions));
+ assertEquals("00C3", getHexValue("Atilde", fomParserOptions));
+ assertEquals("00C4", getHexValue("Auml", fomParserOptions));
+ assertEquals("00C5", getHexValue("Aring", fomParserOptions));
+ assertEquals("00C6", getHexValue("AElig", fomParserOptions));
+ assertEquals("00C7", getHexValue("Ccedil", fomParserOptions));
+ assertEquals("00C8", getHexValue("Egrave", fomParserOptions));
+ assertEquals("00C9", getHexValue("Eacute", fomParserOptions));
+ assertEquals("00CA", getHexValue("Ecirc", fomParserOptions));
+ assertEquals("00CB", getHexValue("Euml", fomParserOptions));
+ assertEquals("00CC", getHexValue("Igrave", fomParserOptions));
+ assertEquals("00CD", getHexValue("Iacute", fomParserOptions));
+ assertEquals("00CE", getHexValue("Icirc", fomParserOptions));
+ assertEquals("00CF", getHexValue("Iuml", fomParserOptions));
+ assertEquals("00D0", getHexValue("ETH", fomParserOptions));
+ assertEquals("00D1", getHexValue("Ntilde", fomParserOptions));
+ assertEquals("00D2", getHexValue("Ograve", fomParserOptions));
+ assertEquals("00D3", getHexValue("Oacute", fomParserOptions));
+ assertEquals("00D4", getHexValue("Ocirc", fomParserOptions));
+ assertEquals("00D5", getHexValue("Otilde", fomParserOptions));
+ assertEquals("00D6", getHexValue("Ouml", fomParserOptions));
+ assertEquals("00D7", getHexValue("times", fomParserOptions));
+ assertEquals("00D8", getHexValue("Oslash", fomParserOptions));
+ assertEquals("00D9", getHexValue("Ugrave", fomParserOptions));
+ assertEquals("00DA", getHexValue("Uacute", fomParserOptions));
+ assertEquals("00DB", getHexValue("Ucirc", fomParserOptions));
+ assertEquals("00DC", getHexValue("Uuml", fomParserOptions));
+ assertEquals("00DD", getHexValue("Yacute", fomParserOptions));
+ assertEquals("00DE", getHexValue("THORN", fomParserOptions));
+ assertEquals("00DF", getHexValue("szlig", fomParserOptions));
+ assertEquals("00E0", getHexValue("agrave", fomParserOptions));
+ assertEquals("00E1", getHexValue("aacute", fomParserOptions));
+ assertEquals("00E2", getHexValue("acirc", fomParserOptions));
+ assertEquals("00E3", getHexValue("atilde", fomParserOptions));
+ assertEquals("00E4", getHexValue("auml", fomParserOptions));
+ assertEquals("00E5", getHexValue("aring", fomParserOptions));
+ assertEquals("00E6", getHexValue("aelig", fomParserOptions));
+ assertEquals("00E7", getHexValue("ccedil", fomParserOptions));
+ assertEquals("00E8", getHexValue("egrave", fomParserOptions));
+ assertEquals("00E9", getHexValue("eacute", fomParserOptions));
+ assertEquals("00EA", getHexValue("ecirc", fomParserOptions));
+ assertEquals("00EB", getHexValue("euml", fomParserOptions));
+ assertEquals("00EC", getHexValue("igrave", fomParserOptions));
+ assertEquals("00ED", getHexValue("iacute", fomParserOptions));
+ assertEquals("00EE", getHexValue("icirc", fomParserOptions));
+ assertEquals("00EF", getHexValue("iuml", fomParserOptions));
+ assertEquals("00F0", getHexValue("eth", fomParserOptions));
+ assertEquals("00F1", getHexValue("ntilde", fomParserOptions));
+ assertEquals("00F2", getHexValue("ograve", fomParserOptions));
+ assertEquals("00F3", getHexValue("oacute", fomParserOptions));
+ assertEquals("00F4", getHexValue("ocirc", fomParserOptions));
+ assertEquals("00F5", getHexValue("otilde", fomParserOptions));
+ assertEquals("00F6", getHexValue("ouml", fomParserOptions));
+ assertEquals("00F7", getHexValue("divide", fomParserOptions));
+ assertEquals("00F8", getHexValue("oslash", fomParserOptions));
+ assertEquals("00F9", getHexValue("ugrave", fomParserOptions));
+ assertEquals("00FA", getHexValue("uacute", fomParserOptions));
+ assertEquals("00FB", getHexValue("ucirc", fomParserOptions));
+ assertEquals("00FC", getHexValue("uuml", fomParserOptions));
+ assertEquals("00FD", getHexValue("yacute", fomParserOptions));
+ assertEquals("00FE", getHexValue("thorn", fomParserOptions));
+ assertEquals("00FF", getHexValue("yuml", fomParserOptions));
+ assertEquals("0192", getHexValue("fnof", fomParserOptions));
+ assertEquals("0391", getHexValue("Alpha", fomParserOptions));
+ assertEquals("0392", getHexValue("Beta", fomParserOptions));
+ assertEquals("0393", getHexValue("Gamma", fomParserOptions));
+ assertEquals("0394", getHexValue("Delta", fomParserOptions));
+ assertEquals("0395", getHexValue("Epsilon", fomParserOptions));
+ assertEquals("0396", getHexValue("Zeta", fomParserOptions));
+ assertEquals("0397", getHexValue("Eta", fomParserOptions));
+ assertEquals("0398", getHexValue("Theta", fomParserOptions));
+ assertEquals("0399", getHexValue("Iota", fomParserOptions));
+ assertEquals("039A", getHexValue("Kappa", fomParserOptions));
+ assertEquals("039B", getHexValue("Lambda", fomParserOptions));
+ assertEquals("039C", getHexValue("Mu", fomParserOptions));
+ assertEquals("039D", getHexValue("Nu", fomParserOptions));
+ assertEquals("039E", getHexValue("Xi", fomParserOptions));
+ assertEquals("039F", getHexValue("Omicron", fomParserOptions));
+ assertEquals("03A0", getHexValue("Pi", fomParserOptions));
+ assertEquals("03A1", getHexValue("Rho", fomParserOptions));
+ assertEquals("03A3", getHexValue("Sigma", fomParserOptions));
+ assertEquals("03A4", getHexValue("Tau", fomParserOptions));
+ assertEquals("03A5", getHexValue("Upsilon", fomParserOptions));
+ assertEquals("03A6", getHexValue("Phi", fomParserOptions));
+ assertEquals("03A7", getHexValue("Chi", fomParserOptions));
+ assertEquals("03A8", getHexValue("Psi", fomParserOptions));
+ assertEquals("03A9", getHexValue("Omega", fomParserOptions));
+ assertEquals("03B1", getHexValue("alpha", fomParserOptions));
+ assertEquals("03B2", getHexValue("beta", fomParserOptions));
+ assertEquals("03B3", getHexValue("gamma", fomParserOptions));
+ assertEquals("03B4", getHexValue("delta", fomParserOptions));
+ assertEquals("03B5", getHexValue("epsilon", fomParserOptions));
+ assertEquals("03B6", getHexValue("zeta", fomParserOptions));
+ assertEquals("03B7", getHexValue("eta", fomParserOptions));
+ assertEquals("03B8", getHexValue("theta", fomParserOptions));
+ assertEquals("03B9", getHexValue("iota", fomParserOptions));
+ assertEquals("03BA", getHexValue("kappa", fomParserOptions));
+ assertEquals("03BB", getHexValue("lambda", fomParserOptions));
+ assertEquals("03BC", getHexValue("mu", fomParserOptions));
+ assertEquals("03BD", getHexValue("nu", fomParserOptions));
+ assertEquals("03BE", getHexValue("xi", fomParserOptions));
+ assertEquals("03BF", getHexValue("omicron", fomParserOptions));
+ assertEquals("03C0", getHexValue("pi", fomParserOptions));
+ assertEquals("03C1", getHexValue("rho", fomParserOptions));
+ assertEquals("03C2", getHexValue("sigmaf", fomParserOptions));
+ assertEquals("03C3", getHexValue("sigma", fomParserOptions));
+ assertEquals("03C4", getHexValue("tau", fomParserOptions));
+ assertEquals("03C5", getHexValue("upsilon", fomParserOptions));
+ assertEquals("03C6", getHexValue("phi", fomParserOptions));
+ assertEquals("03C7", getHexValue("chi", fomParserOptions));
+ assertEquals("03C8", getHexValue("psi", fomParserOptions));
+ assertEquals("03C9", getHexValue("omega", fomParserOptions));
+ assertEquals("03D1", getHexValue("thetasym", fomParserOptions));
+ assertEquals("03D2", getHexValue("upsih", fomParserOptions));
+ assertEquals("03D6", getHexValue("piv", fomParserOptions));
+ assertEquals("2022", getHexValue("bull", fomParserOptions));
+ assertEquals("2026", getHexValue("hellip", fomParserOptions));
+ assertEquals("2032", getHexValue("prime", fomParserOptions));
+ assertEquals("2033", getHexValue("Prime", fomParserOptions));
+ assertEquals("203E", getHexValue("oline", fomParserOptions));
+ assertEquals("2044", getHexValue("frasl", fomParserOptions));
+ assertEquals("2118", getHexValue("weierp", fomParserOptions));
+ assertEquals("2111", getHexValue("image", fomParserOptions));
+ assertEquals("211C", getHexValue("real", fomParserOptions));
+ assertEquals("2122", getHexValue("trade", fomParserOptions));
+ assertEquals("2135", getHexValue("alefsym", fomParserOptions));
+ assertEquals("2190", getHexValue("larr", fomParserOptions));
+ assertEquals("2191", getHexValue("uarr", fomParserOptions));
+ assertEquals("2192", getHexValue("rarr", fomParserOptions));
+ assertEquals("2193", getHexValue("darr", fomParserOptions));
+ assertEquals("2194", getHexValue("harr", fomParserOptions));
+ assertEquals("21B5", getHexValue("crarr", fomParserOptions));
+ assertEquals("21D0", getHexValue("lArr", fomParserOptions));
+ assertEquals("21D1", getHexValue("uArr", fomParserOptions));
+ assertEquals("21D2", getHexValue("rArr", fomParserOptions));
+ assertEquals("21D3", getHexValue("dArr", fomParserOptions));
+ assertEquals("21D4", getHexValue("hArr", fomParserOptions));
+ assertEquals("2200", getHexValue("forall", fomParserOptions));
+ assertEquals("2202", getHexValue("part", fomParserOptions));
+ assertEquals("2203", getHexValue("exist", fomParserOptions));
+ assertEquals("2205", getHexValue("empty", fomParserOptions));
+ assertEquals("2207", getHexValue("nabla", fomParserOptions));
+ assertEquals("2208", getHexValue("isin", fomParserOptions));
+ assertEquals("2209", getHexValue("notin", fomParserOptions));
+ assertEquals("220B", getHexValue("ni", fomParserOptions));
+ assertEquals("220F", getHexValue("prod", fomParserOptions));
+ assertEquals("2211", getHexValue("sum", fomParserOptions));
+ assertEquals("2212", getHexValue("minus", fomParserOptions));
+ assertEquals("2217", getHexValue("lowast", fomParserOptions));
+ assertEquals("221A", getHexValue("radic", fomParserOptions));
+ assertEquals("221D", getHexValue("prop", fomParserOptions));
+ assertEquals("221E", getHexValue("infin", fomParserOptions));
+ assertEquals("2220", getHexValue("ang", fomParserOptions));
+ assertEquals("2227", getHexValue("and", fomParserOptions));
+ assertEquals("2228", getHexValue("or", fomParserOptions));
+ assertEquals("2229", getHexValue("cap", fomParserOptions));
+ assertEquals("222A", getHexValue("cup", fomParserOptions));
+ assertEquals("222B", getHexValue("int", fomParserOptions));
+ assertEquals("2234", getHexValue("there4", fomParserOptions));
+ assertEquals("223C", getHexValue("sim", fomParserOptions));
+ assertEquals("2245", getHexValue("cong", fomParserOptions));
+ assertEquals("2248", getHexValue("asymp", fomParserOptions));
+ assertEquals("2260", getHexValue("ne", fomParserOptions));
+ assertEquals("2261", getHexValue("equiv", fomParserOptions));
+ assertEquals("2264", getHexValue("le", fomParserOptions));
+ assertEquals("2265", getHexValue("ge", fomParserOptions));
+ assertEquals("2282", getHexValue("sub", fomParserOptions));
+ assertEquals("2283", getHexValue("sup", fomParserOptions));
+ assertEquals("2284", getHexValue("nsub", fomParserOptions));
+ assertEquals("2286", getHexValue("sube", fomParserOptions));
+ assertEquals("2287", getHexValue("supe", fomParserOptions));
+ assertEquals("2295", getHexValue("oplus", fomParserOptions));
+ assertEquals("2297", getHexValue("otimes", fomParserOptions));
+ assertEquals("22A5", getHexValue("perp", fomParserOptions));
+ assertEquals("22C5", getHexValue("sdot", fomParserOptions));
+ assertEquals("2308", getHexValue("lceil", fomParserOptions));
+ assertEquals("2309", getHexValue("rceil", fomParserOptions));
+ assertEquals("230A", getHexValue("lfloor", fomParserOptions));
+ assertEquals("230B", getHexValue("rfloor", fomParserOptions));
+ assertEquals("2329", getHexValue("lang", fomParserOptions));
+ assertEquals("232A", getHexValue("rang", fomParserOptions));
+ assertEquals("25CA", getHexValue("loz", fomParserOptions));
+ assertEquals("2660", getHexValue("spades", fomParserOptions));
+ assertEquals("2663", getHexValue("clubs", fomParserOptions));
+ assertEquals("2665", getHexValue("hearts", fomParserOptions));
+ assertEquals("2666", getHexValue("diams", fomParserOptions));
+ assertEquals("0022", getHexValue("quot", fomParserOptions));
+ assertEquals("0026", getHexValue("amp", fomParserOptions));
+ assertEquals("003C", getHexValue("lt", fomParserOptions));
+ assertEquals("003E", getHexValue("gt", fomParserOptions));
+ assertEquals("0152", getHexValue("OElig", fomParserOptions));
+ assertEquals("0153", getHexValue("oelig", fomParserOptions));
+ assertEquals("0160", getHexValue("Scaron", fomParserOptions));
+ assertEquals("0161", getHexValue("scaron", fomParserOptions));
+ assertEquals("0178", getHexValue("Yuml", fomParserOptions));
+ assertEquals("02C6", getHexValue("circ", fomParserOptions));
+ assertEquals("02DC", getHexValue("tilde", fomParserOptions));
+ assertEquals("2002", getHexValue("ensp", fomParserOptions));
+ assertEquals("2003", getHexValue("emsp", fomParserOptions));
+ assertEquals("2009", getHexValue("thinsp", fomParserOptions));
+ assertEquals("200C", getHexValue("zwnj", fomParserOptions));
+ assertEquals("200D", getHexValue("zwj", fomParserOptions));
+ assertEquals("200E", getHexValue("lrm", fomParserOptions));
+ assertEquals("200F", getHexValue("rlm", fomParserOptions));
+ assertEquals("2013", getHexValue("ndash", fomParserOptions));
+ assertEquals("2014", getHexValue("mdash", fomParserOptions));
+ assertEquals("2018", getHexValue("lsquo", fomParserOptions));
+ assertEquals("2019", getHexValue("rsquo", fomParserOptions));
+ assertEquals("201A", getHexValue("sbquo", fomParserOptions));
+ assertEquals("201C", getHexValue("ldquo", fomParserOptions));
+ assertEquals("201D", getHexValue("rdquo", fomParserOptions));
+ assertEquals("201E", getHexValue("bdquo", fomParserOptions));
+ assertEquals("2020", getHexValue("dagger", fomParserOptions));
+ assertEquals("2021", getHexValue("Dagger", fomParserOptions));
+ assertEquals("2030", getHexValue("permil", fomParserOptions));
+ assertEquals("20AC", getHexValue("euro", fomParserOptions));
+ }
+
+ private String getHexValue(String entity, AbstractParserOptions fomParserOptions) {
+ String hexValue = fomParserOptions.resolveEntity(entity);
+ char hexChar = hexValue.charAt(0);
+ StringBuilder result = new StringBuilder(Integer.toHexString(hexChar));
+ if (result.length() == 2) {
+ result.insert(0, "00");
+ } else if (result.length() == 3) {
+ result.insert(0, "0");
+ }
+ return result.toString().toUpperCase();
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/ConfigurationTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/ConfigurationTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/ConfigurationTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/ConfigurationTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.abdera2.test.util;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.util.Configuration;
+import org.junit.Test;
+
+public class ConfigurationTest {
+
+ @Test
+ public void testDefaultConfigurationProperties() {
+ Abdera abdera = Abdera.getInstance();
+ Configuration config = abdera.getConfiguration();
+ assertNotNull(config);
+ assertNotNull(config.getExtensionFactories());
+ assertNotNull(config.getParsers());
+ assertNotNull(config.getWriters());
+ assertNotNull(config.getStreamWriters());
+ assertNotNull(config.newInstance(abdera, Parser.class));
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/ConfigurationTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/XmlRestrictedCharReaderTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/XmlRestrictedCharReaderTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/XmlRestrictedCharReaderTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/XmlRestrictedCharReaderTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.abdera2.test.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.StringReader;
+
+import org.apache.abdera2.common.xml.XmlRestrictedCharReader;
+import org.junit.Test;
+
+public class XmlRestrictedCharReaderTest {
+
+ @Test
+ public void testXmlRestrictedCharReader() throws Exception {
+ String s = "\u0001abcdefghijklmnop\u0002";
+ StringReader r = new StringReader(s);
+ XmlRestrictedCharReader x = new XmlRestrictedCharReader(r);
+ char[] chars = new char[s.length() + 1];
+ int n = x.read(chars); // the first and last characters should never show up
+ assertEquals(s.length() - 2, n);
+ assertEquals("abcdefghijklmnop", new String(chars, 0, n));
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/XmlRestrictedCharReaderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/WriterTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/WriterTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/WriterTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/WriterTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,52 @@
+package org.apache.abdera2.test.writer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Person;
+import org.apache.abdera2.writer.StreamWriter;
+import org.apache.abdera2.writer.Writer;
+import org.junit.Test;
+
+public class WriterTest {
+
+ @Test
+ public void writerTest() throws IOException {
+ Abdera abdera = Abdera.getInstance();
+ Entry entry = abdera.newEntry();
+ Writer writer = abdera.getWriter();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writer.writeTo(entry, out);
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ Document<Entry> doc = abdera.getParser().parse(in);
+ entry = doc.getRoot();
+ assertNotNull(entry);
+ }
+
+ @Test
+ public void streamWriterTest() throws IOException {
+ Abdera abdera = Abdera.getInstance();
+ StreamWriter sw = abdera.create(StreamWriter.class);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ sw.setOutputStream(out);
+ sw.startDocument()
+ .startEntry()
+ .writeAuthor("James")
+ .endEntry()
+ .endDocument()
+ .close();
+ ByteArrayInputStream in =
+ new ByteArrayInputStream(out.toByteArray());
+ Document<Entry> doc = abdera.getParser().parse(in);
+ Entry entry = doc.getRoot();
+ Person person = entry.getAuthor();
+ assertEquals("James",person.getName());
+ }
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/WriterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/XPathTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/XPathTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/XPathTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/XPathTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,27 @@
+package org.apache.abdera2.test.writer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Person;
+import org.apache.abdera2.xpath.XPath;
+import org.junit.Test;
+
+public class XPathTest {
+
+ @Test
+ public void xpathTest() {
+ Abdera abdera = Abdera.getInstance();
+ Entry entry = abdera.newEntry();
+ entry.addAuthor("James");
+ entry.addAuthor("Joe");
+ XPath xpath = abdera.getXPath();
+ List<?> list = xpath.selectNodes("/a:entry/a:author[a:name=\"James\"]", entry);
+ Person person = (Person) list.get(0);
+ assertEquals("James",person.getName());
+ }
+
+}
Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/writer/XPathTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/abdera/adapter/sample.properties
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/abdera/adapter/sample.properties?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/abdera/adapter/sample.properties (added)
+++ abdera/abdera2/test/src/main/resources/abdera/adapter/sample.properties Tue Sep 20 15:56:46 2011
@@ -0,0 +1,5 @@
+subUri=sample
+adapterClassName=org.apache.abdera2.test.server.basic.SampleBasicAdapter
+title=title for any sample feed
+author=rayc
+configFile=dummyFileLocation
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/abdera/adapter/sample.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/activities/adapter/sample.properties
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/activities/adapter/sample.properties?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/activities/adapter/sample.properties (added)
+++ abdera/abdera2/test/src/main/resources/activities/adapter/sample.properties Tue Sep 20 15:56:46 2011
@@ -0,0 +1,5 @@
+subUri=sample
+adapterClassName=org.apache.abdera2.test.activities.server.SampleBasicAdapter
+title=title for any sample feed
+author=rayc
+configFile=dummyFileLocation
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/activities/adapter/sample.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/complete.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/complete.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/complete.xml (added)
+++ abdera/abdera2/test/src/main/resources/complete.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:fh="http://purl.org/syndication/history/1.0">
+ <fh:complete />
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/complete.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/content.xslt
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/content.xslt?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/content.xslt (added)
+++ abdera/abdera2/test/src/main/resources/content.xslt Tue Sep 20 15:56:46 2011
@@ -0,0 +1,7 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:a="http://example.org"
+ version="1.0" >
+ <xsl:output method="text" />
+ <xsl:template match = "/" >This is a test <xsl:value-of select="a:a/a:b/a:c" /></xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/content.xslt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/entry.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/entry.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/entry.xml (added)
+++ abdera/abdera2/test/src/main/resources/entry.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<entry xmlns="http://www.w3.org/2005/Atom">
+<title>Atom-Powered Robots Run Amok</title>
+<link href="http://example.org/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>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/entry.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/feed.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/feed.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/feed.xml (added)
+++ abdera/abdera2/test/src/main/resources/feed.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+<title>Example Feed</title>
+<link href="http://example.org/"/>
+<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="http://example.org/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>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/feed.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/info.png
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/info.png?rev=1173209&view=auto
==============================================================================
Binary file - no diff available.
Propchange: abdera/abdera2/test/src/main/resources/info.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: abdera/abdera2/test/src/main/resources/key.jks
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/key.jks?rev=1173209&view=auto
==============================================================================
Binary file - no diff available.
Propchange: abdera/abdera2/test/src/main/resources/key.jks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: abdera/abdera2/test/src/main/resources/rss1.rdf
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/rss1.rdf?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/rss1.rdf (added)
+++ abdera/abdera2/test/src/main/resources/rss1.rdf Tue Sep 20 15:56:46 2011
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns="http://purl.org/rss/1.0/"
+>
+
+ <channel rdf:about="http://www.xml.com/xml/news.rss">
+ <title>XML.com</title>
+ <link>http://xml.com/pub</link>
+ <dc:creator>James Snell (mailto:jasnell@example.com)</dc:creator>
+ <dc:subject>Anything</dc:subject>
+ <dc:identifier>foo</dc:identifier>
+ <dc:rights>Copyright 2007 Foo</dc:rights>
+ <dc:date>2000-01-01T12:00+00:00</dc:date>
+ <dc:language>en-US</dc:language>
+ <dc:contributor>John Doe (mailto:jdoe@example.org)</dc:contributor>
+ <description>
+ XML.com features a rich mix of information and services
+ for the XML community.
+ </description>
+
+ <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" />
+
+ <items>
+ <rdf:Seq>
+ <rdf:li resource="http://xml.com/pub/2000/08/09/xslt/xslt.html" />
+ <rdf:li resource="http://xml.com/pub/2000/08/09/rdfdb/index.html" />
+ </rdf:Seq>
+ </items>
+
+ <textinput rdf:resource="http://search.xml.com" />
+
+ </channel>
+
+ <image rdf:about="http://xml.com/universal/images/xml_tiny.gif">
+ <title>XML.com</title>
+ <link>http://www.xml.com</link>
+ <url>http://xml.com/universal/images/xml_tiny.gif</url>
+ </image>
+
+ <item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html">
+ <title>Processing Inclusions with XSLT</title>
+ <link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link>
+ <description>
+ Processing document inclusions with general XML tools can be
+ problematic. This article proposes a way of preserving inclusion
+ information through SAX-based processing.
+ </description>
+ <content:encoded>testing</content:encoded>
+ <dc:creator>Bob (mailto:bob@example.org)</dc:creator>
+ </item>
+
+ <item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html">
+ <title>Putting RDF to Work</title>
+ <link>http://xml.com/pub/2000/08/09/rdfdb/index.html</link>
+ <description>
+ Tool and API support for the Resource Description Framework
+ is slowly coming of age. Edd Dumbill takes a look at RDFDB,
+ one of the most exciting new RDF toolkits.
+ </description>
+ <content:encoded>testing</content:encoded>
+ <dc:creator>Joe (mailto:joe@example.org)</dc:creator>
+ </item>
+
+ <textinput rdf:about="http://search.xml.com">
+ <title>Search XML.com</title>
+ <description>Search XML.com's XML collection</description>
+ <name>s</name>
+ <link>http://search.xml.com</link>
+ </textinput>
+
+</rdf:RDF>
\ No newline at end of file
Added: abdera/abdera2/test/src/main/resources/simple.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/simple.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/simple.xml (added)
+++ abdera/abdera2/test/src/main/resources/simple.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title>Example Feed</title>
+ <link href="http://example.org/"/>
+ <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="http://example.org/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>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/simple.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/simpleEntry.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/simpleEntry.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/simpleEntry.xml (added)
+++ abdera/abdera2/test/src/main/resources/simpleEntry.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<entry xmlns="http://www.w3.org/2005/Atom">
+ <!-- no content -->
+</entry>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/simpleEntry.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/simpleFeed.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/simpleFeed.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/simpleFeed.xml (added)
+++ abdera/abdera2/test/src/main/resources/simpleFeed.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <!-- no content -->
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/simpleFeed.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/simpleService.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/simpleService.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/simpleService.xml (added)
+++ abdera/abdera2/test/src/main/resources/simpleService.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<service xmlns="http://purl.org/atom/app#">
+ <!-- no content -->
+</service>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/simpleService.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/test.xslt
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/test.xslt?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/test.xslt (added)
+++ abdera/abdera2/test/src/main/resources/test.xslt Tue Sep 20 15:56:46 2011
@@ -0,0 +1,7 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:a="http://www.w3.org/2005/Atom"
+ version="1.0" >
+ <xsl:output method="text" />
+ <xsl:template match = "/" >This is a test <xsl:value-of select="a:feed/a:id" /></xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/test.xslt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/utf8characters.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/utf8characters.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/utf8characters.xml (added)
+++ abdera/abdera2/test/src/main/resources/utf8characters.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>
+<entry xmlns="http://www.w3.org/2005/Atom">
+ <title>Item</title>
+ <content type="xhtml" xmlns:xhtml = "http://www.w3.org/1999/xhtml" >
+ <xhtml:div>
+ <p>This is simple XHTML Ȁȁ contained within a xhtml:div tag.</p>
+ </xhtml:div>
+ </content>
+</entry>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/utf8characters.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/atom10_namespace.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/atom10_namespace.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/atom10_namespace.xml (added)
+++ abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/atom10_namespace.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,7 @@
+<!--
+Description: Atom namespace (official)
+Expect: not bozo and feed['title'] == u'Example Atom'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Example Atom</title>
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/atom10_namespace.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_email.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_email.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_email.xml (added)
+++ abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_email.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,13 @@
+<!--
+Description: entry author email
+Expect: not bozo and entries[0]['author_detail']['email'] == u'me@example.com'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <author>
+ <name>Example author</name>
+ <email>me@example.com</email>
+ <uri>http://example.com/</uri>
+ </author>
+</entry>
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_email.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_name.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_name.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_name.xml (added)
+++ abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_name.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,13 @@
+<!--
+Description: entry author name
+Expect: not bozo and entries[0]['author_detail']['name'] == u'Example author'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <author>
+ <name>Example author</name>
+ <email>me@example.com</email>
+ <uri>http://example.com/</uri>
+ </author>
+</entry>
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_author_name.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64.xml (added)
+++ abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,11 @@
+<!--
+Description: entry content base64-encoded
+Expect: not bozo and entries[0]['content'][0]['value'] == u'Example <b>Atom</b>'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <content type="application/octet-stream">
+ RXhhbXBsZSA8Yj5BdG9tPC9iPg==
+ </content>
+</entry>
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64_2.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64_2.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64_2.xml (added)
+++ abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64_2.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,11 @@
+<!--
+Description: entry content base64-encoded
+Expect: not bozo and entries[0]['content'][0]['value'] == u'<p>History of the <blink> tag</p>'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+<content type="application/octet-stream">
+PHA+SGlzdG9yeSBvZiB0aGUgJmx0O2JsaW5rJmd0OyB0YWc8L3A+
+</content>
+</entry>
+</feed>
\ No newline at end of file
Propchange: abdera/abdera2/test/src/main/resources/www.feedparser.org/tests/wellformed/atom10/entry_content_base64_2.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain