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 2006/07/11 01:42:23 UTC

svn commit: r420662 [2/2] - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/ parser/src/main/java/org/apache/abdera/parser/stax/ parser/src/test/java/org/apache/abdera/test/parser/stax/

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java?rev=420662&r1=420661&r2=420662&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java (original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java Mon Jul 10 16:42:23 2006
@@ -285,19 +285,28 @@
     Factory factory = Factory.INSTANCE;
     Person author = factory.newAuthor();
     assertNotNull(author);
-    author = factory.newAuthor("a", "b", "c");
+    author = factory.newAuthor();
+    author.setName("a");
+    author.setEmail("b");
+    author.setUri("c");
     assertNotNull(author);
     assertEquals(author.getName(),"a");
     assertEquals(author.getEmail(), "b");
     assertEquals(author.getUri().toString(), "c");
-    author = factory.newAuthor("a", "b", new URI("c"));
+    author = factory.newAuthor();
+    author.setName("a");
+    author.setEmail("b");
+    author.setUri(new URI("c"));
     assertNotNull(author);
     assertEquals(author.getName(),"a");
     assertEquals(author.getEmail(), "b");
     assertEquals(author.getUri().toString(), "c");
     Category category = factory.newCategory();
     assertNotNull(category);
-    category = factory.newCategory("b", new URI("a"), "c");
+    category = factory.newCategory();
+    category.setScheme("a");
+    category.setTerm("b");
+    category.setLabel("c");
     assertNotNull(category);
     assertEquals(category.getScheme().toString(), "a");
     assertEquals(category.getTerm(), "b");
@@ -320,33 +329,45 @@
     assertEquals(content.getMimeType().toString(), "text/foo");
     Person contributor = factory.newContributor();
     assertNotNull(contributor);
-    contributor = factory.newContributor("a", "b", "c");
+    contributor = factory.newContributor();
+    contributor.setName("a");
+    contributor.setEmail("b");
+    contributor.setUri("c");
     assertNotNull(contributor);
     assertEquals(contributor.getName(),"a");
     assertEquals(contributor.getEmail(), "b");
     assertEquals(contributor.getUri().toString(), "c");
-    contributor = factory.newContributor("a", "b", new URI("c"));
+    contributor = factory.newContributor();
+    contributor.setName("a");
+    contributor.setEmail("b");
+    contributor.setUri(new URI("c"));
     assertNotNull(contributor);
     assertEquals(contributor.getName(),"a");
     assertEquals(contributor.getEmail(), "b");
     assertEquals(contributor.getUri().toString(), "c");
     Control control = factory.newControl();
     assertNotNull(control);
-    control = factory.newControl(true);
+    control = factory.newControl();
+    control.setDraft(true);
     assertTrue(control.isDraft());
     Date now = new Date();
-    DateTime dateTime = factory.newDateTime(Constants.UPDATED, AtomDate.valueOf(now), null);
+    DateTime dateTime = factory.newDateTime(Constants.UPDATED, null);
+    dateTime.setValue(AtomDate.valueOf(now));
     assertEquals(dateTime.getDate(), now);
     Calendar cal = Calendar.getInstance();
-    dateTime = factory.newDateTime(Constants.UPDATED, cal, null);
+    dateTime = factory.newDateTime(Constants.UPDATED, null);
+    dateTime.setCalendar(cal);
     assertEquals(dateTime.getCalendar(), cal);
-    dateTime = factory.newDateTime(Constants.UPDATED, now, null);
+    dateTime = factory.newDateTime(Constants.UPDATED, null);
+    dateTime.setDate(now);
     assertEquals(dateTime.getDate(), now);
     dateTime = factory.newDateTime(Constants.UPDATED, null);
     assertNotNull(dateTime);
-    dateTime = factory.newDateTime(Constants.UPDATED, now.getTime(), null);
+    dateTime = factory.newDateTime(Constants.UPDATED, null);
+    dateTime.setTime(now.getTime());
     assertEquals(dateTime.getTime(), now.getTime());
-    dateTime = factory.newDateTime(Constants.UPDATED, AtomDate.format(now), null);
+    dateTime = factory.newDateTime(Constants.UPDATED, null);
+    dateTime.setString(AtomDate.format(now));
     assertEquals(dateTime.getString(), AtomDate.format(now));
     assertEquals(dateTime.getDate(), now);
     Generator generator = factory.newDefaultGenerator();
@@ -360,7 +381,8 @@
     assertNotNull(doc);
     Element el = factory.newEmail();
     assertNotNull(el);
-    el = factory.newEmail("a");
+    el = factory.newEmail();
+    el.setText("a");
     assertEquals(el.getText(), "a");
     Entry entry = factory.newEntry();
     assertNotNull(entry);
@@ -373,60 +395,87 @@
     assertNotNull(feed);
     generator = factory.newGenerator();
     assertNotNull(generator);
-    generator = factory.newGenerator(new URI(Version.URI), Version.VERSION, Version.APP_NAME);
+    generator = factory.newGenerator();
+    generator.setUri(new URI(Version.URI));
+    generator.setVersion(Version.VERSION);
+    generator.setText(Version.APP_NAME);
     assertNotNull(generator);
     assertEquals(generator.getText(), Version.APP_NAME);
     assertEquals(generator.getVersion(), Version.VERSION);
     assertEquals(generator.getUri().toString(), Version.URI);
-    content = factory.newContent("a", Content.Type.HTML);
+    content = factory.newContent(Content.Type.HTML);
+    content.setValue("a");
     assertNotNull(content);
     assertEquals(content.getValue(), "a");
     assertEquals(content.getContentType(), Content.Type.HTML);
-    Text text = factory.newRights("a",Text.Type.HTML);
+    Text text = factory.newRights(Text.Type.HTML);
+    text.setValue("a");
     assertNotNull(text);
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.HTML);
-    text = factory.newSubtitle("a",Text.Type.HTML);
+    text = factory.newSubtitle(Text.Type.HTML);
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.HTML);
-    text = factory.newSummary("a",Text.Type.HTML);
+    text = factory.newSummary(Text.Type.HTML);
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.HTML);
-    text = factory.newText(Constants.TITLE,"a", Text.Type.HTML, null);
+    text = factory.newText(Constants.TITLE,Text.Type.HTML, null);
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.HTML);
     assertEquals(text.getQName(), Constants.TITLE);
-    text = factory.newTitle("a",Text.Type.HTML);
+    text = factory.newTitle(Text.Type.HTML);
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.HTML);
     IRI iri = factory.newIcon();
     assertNotNull(iri);
-    iri = factory.newIcon("http://example.org/foo");
+    iri = factory.newIcon();
+    iri.setValue("http://example.org/foo");
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    iri = factory.newIcon(new URI("http://example.org/foo"));
+    iri = factory.newIcon();
+    iri.setValue(new URI("http://example.org/foo"));
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
     iri = factory.newID();
     assertNotNull(iri);
-    iri = factory.newID("http://example.org/foo");
+    iri = factory.newID();
+    iri.setValue("http://example.org/foo");
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    iri = factory.newID(new URI("http://example.org/foo"));
+    iri = factory.newID();
+    iri.setValue(new URI("http://example.org/foo"));
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
     iri = factory.newIRIElement(Constants.ID, null);
     assertNotNull(iri);
-    iri = factory.newIRIElement(Constants.ID, "http://example.org/foo", null);
+    iri = factory.newIRIElement(Constants.ID, null);
+    iri.setValue("http://example.org/foo");
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    iri = factory.newIRIElement(Constants.ID, new URI("http://example.org/foo"), null);
+    iri = factory.newIRIElement(Constants.ID, null);
+    iri.setValue(new URI("http://example.org/foo"));
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
     Link link = factory.newLink();
     assertNotNull(link);
-    link = factory.newLink("http://example.org/foo", "a", new MimeType("text/foo"), "b", "en", 10);
+    link = factory.newLink();
+    link.setHref("http://example.org/foo");
+    link.setRel("a");
+    link.setMimeType(new MimeType("text/foo"));
+    link.setTitle("b");
+    link.setHrefLang("en");
+    link.setLength(10);
     assertEquals(link.getHref().toString(), "http://example.org/foo");
     assertEquals(link.getRel(), "a");
     assertEquals(link.getMimeType().toString(), "text/foo");
     assertEquals(link.getTitle(), "b");
     assertEquals(link.getHrefLang(), "en");
     assertEquals(link.getLength(), 10);
-    link = factory.newLink(new URI("http://example.org/foo"), "a", new MimeType("text/foo"), "b", "en", 10);
+    link = factory.newLink();
+    link.setHref(new URI("http://example.org/foo"));
+    link.setRel("a");
+    link.setMimeType(new MimeType("text/foo"));
+    link.setTitle("b");
+    link.setHrefLang("en");
+    link.setLength(10);
     assertEquals(link.getHref().toString(), "http://example.org/foo");
     assertEquals(link.getRel(), "a");
     assertEquals(link.getMimeType().toString(), "text/foo");
@@ -435,47 +484,63 @@
     assertEquals(link.getLength(), 10);
     iri = factory.newLogo();
     assertNotNull(iri);
-    iri = factory.newLogo("http://example.org/foo");
+    iri = factory.newLogo();
+    iri.setValue("http://example.org/foo");
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    iri = factory.newLogo(new URI("http://example.org/foo"));
+    iri = factory.newLogo();
+    iri.setValue(new URI("http://example.org/foo"));
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    content = factory.newContent(new URI("foo"), new MimeType("text/foo"));
+    content = factory.newContent(new MimeType("text/foo"));
+    content.setSrc(new URI("foo"));
     assertNotNull(content);
     assertEquals(content.getMimeType().toString(), "text/foo");
     assertEquals(content.getSrc().toString(), "foo");
-    content = factory.newContent(new DataHandler(new ByteArrayDataSource("foo".getBytes())), new MimeType("text/foo"));
+    content = factory.newContent(new MimeType("text/foo"));
+    content.setDataHandler(new DataHandler(new ByteArrayDataSource("foo".getBytes())));
     assertEquals(content.getValue(), "Zm9v");
     assertEquals(content.getContentType(), Content.Type.MEDIA);
     el = factory.newName();
     assertNotNull(el);
-    el = factory.newName("a");
+    el = factory.newName();
+    el.setText("a");
     assertEquals(el.getText(), "a");
     Parser parser = factory.newParser();
     assertNotNull(parser);
     Person person = factory.newPerson(Constants.AUTHOR, null);
     assertNotNull(person);
     assertEquals(person.getQName(), Constants.AUTHOR);
-    person = factory.newPerson(Constants.AUTHOR, "a", "b", "c", null);
+    person = factory.newPerson(Constants.AUTHOR, null);
+    person.setName("a");
+    person.setEmail("b");
+    person.setUri("c");
     assertEquals(person.getName(),"a");
     assertEquals(person.getEmail(), "b");
     assertEquals(person.getUri().toString(), "c");
-    person = factory.newPerson(Constants.AUTHOR, "a", "b", new URI("c"), null);
+    person = factory.newPerson(Constants.AUTHOR, null);
+    person.setName("a");
+    person.setEmail("b");
+    person.setUri(new URI("c"));
     assertEquals(person.getName(),"a");
     assertEquals(person.getEmail(), "b");
     assertEquals(person.getUri().toString(), "c");
     now = new Date();
-    dateTime = factory.newPublished(AtomDate.valueOf(now));
+    dateTime = factory.newPublished();
+    dateTime.setValue(AtomDate.valueOf(now));
     assertEquals(dateTime.getDate(), now);
     cal = Calendar.getInstance();
-    dateTime = factory.newPublished(cal);
+    dateTime = factory.newPublished();
+    dateTime.setCalendar(cal);
     assertEquals(dateTime.getCalendar(), cal);
-    dateTime = factory.newPublished(now);
+    dateTime = factory.newPublished();
+    dateTime.setDate(now);
     assertEquals(dateTime.getDate(), now);
     dateTime = factory.newPublished();
     assertNotNull(dateTime);
-    dateTime = factory.newPublished(now.getTime());
+    dateTime = factory.newPublished();
+    dateTime.setTime(now.getTime());
     assertEquals(dateTime.getTime(), now.getTime());
-    dateTime = factory.newPublished(AtomDate.format(now));
+    dateTime = factory.newPublished();
+    dateTime.setString(AtomDate.format(now));
     assertEquals(dateTime.getString(), AtomDate.format(now));
     assertEquals(dateTime.getDate(), now);
     Service service = factory.newService();
@@ -485,84 +550,105 @@
     el = factory.newElement(Constants.NAME);
     assertNotNull(el);
     assertEquals(el.getQName(), Constants.NAME);
-    el = factory.newElement(Constants.NAME, "a");
+    el = factory.newElement(Constants.NAME);
+    el.setText("a");
     assertNotNull(el);
     assertEquals(el.getQName(), Constants.NAME);
     assertEquals(el.getText(), "a");
     text = factory.newText(Constants.TITLE, Text.Type.TEXT);
     assertNotNull(text);
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    text = factory.newRights("a");
+    text = factory.newRights();
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    text = factory.newSubtitle("a");
+    text = factory.newSubtitle();
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    text = factory.newSummary("a");
+    text = factory.newSummary();
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    text = factory.newText(Constants.TITLE, "a", Text.Type.TEXT,null);
+    text = factory.newText(Constants.TITLE, Text.Type.TEXT,null);
+    text.setValue("a");
     assertEquals(text.getQName(), Constants.TITLE);
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    text = factory.newTitle("a");
+    text = factory.newTitle();
+    text.setValue("a");
     assertEquals(text.getValue(), "a");
     assertEquals(text.getTextType(), Text.Type.TEXT);
-    content = factory.newContent("a",Content.Type.TEXT);
+    content = factory.newContent(Content.Type.TEXT);
+    content.setValue("a");
     assertEquals(content.getValue(), "a");
     assertEquals(content.getContentType(), Content.Type.TEXT);
     now = new Date();
-    dateTime = factory.newUpdated(AtomDate.valueOf(now));
+    dateTime = factory.newUpdated();
+    dateTime.setValue(AtomDate.valueOf(now));
     assertEquals(dateTime.getDate(), now);
     cal = Calendar.getInstance();
-    dateTime = factory.newUpdated(cal);
+    dateTime = factory.newUpdated();
+    dateTime.setCalendar(cal);
     assertEquals(dateTime.getCalendar(), cal);
-    dateTime = factory.newUpdated(now);
+    dateTime = factory.newUpdated();
+    dateTime.setDate(now);
     assertEquals(dateTime.getDate(), now);
     dateTime = factory.newUpdated();
     assertNotNull(dateTime);
-    dateTime = factory.newUpdated(now.getTime());
+    dateTime = factory.newUpdated();
+    dateTime.setTime(now.getTime());
     assertEquals(dateTime.getTime(), now.getTime());
-    dateTime = factory.newUpdated(AtomDate.format(now));
+    dateTime = factory.newUpdated();
+    dateTime.setString(AtomDate.format(now));
     assertEquals(dateTime.getString(), AtomDate.format(now));
     assertEquals(dateTime.getDate(), now);
     iri = factory.newUri();
     assertNotNull(iri);
-    iri = factory.newUri("http://example.org/foo");
+    iri = factory.newUri();
+    iri.setValue("http://example.org/foo");
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
-    iri = factory.newUri(new URI("http://example.org/foo"));
+    iri = factory.newUri();
+    iri.setValue(new URI("http://example.org/foo"));
     assertEquals(iri.getValue().toString(), "http://example.org/foo");
     Workspace workspace = factory.newWorkspace();
     assertNotNull(workspace);
     div = factory.newDiv();
-    content = factory.newContent(div, Content.Type.XHTML);
+    content = factory.newContent(Content.Type.XHTML);
+    content.setValueElement(div);
     assertNotNull(content);
     assertEquals(content.getContentType(), Content.Type.XHTML);
     assertNotNull(content.getValueElement());
     assertEquals(content.getValueElement(), div);
-    content = factory.newContent(div, new MimeType("application/xml"));
+    content = factory.newContent(new MimeType("application/xml"));
+    content.setValueElement(div);
     assertNotNull(content);
     assertEquals(content.getContentType(), Content.Type.XML);
     assertNotNull(content.getValueElement());
     assertEquals(content.getValueElement(), div);
-    text = factory.newRights(div);
+    text = factory.newRights();
+    text.setValueElement(div);
     assertNotNull(text);
     assertEquals(text.getTextType(), Text.Type.XHTML);
     assertEquals(text.getValueElement(), div);
-    text = factory.newSubtitle(div);
+    text = factory.newSubtitle();
+    text.setValueElement(div);
     assertNotNull(text);
     assertEquals(text.getTextType(), Text.Type.XHTML);
     assertEquals(text.getValueElement(), div);
-    text = factory.newSummary(div);
+    text = factory.newSummary();
+    text.setValueElement(div);
     assertNotNull(text);
     assertEquals(text.getTextType(), Text.Type.XHTML);
     assertEquals(text.getValueElement(), div);
-    text = factory.newText(Constants.TITLE, div, null);
+    text = factory.newText(Constants.TITLE, null);
+    text.setValueElement(div);
     assertNotNull(text);
     assertEquals(text.getQName(), Constants.TITLE);
     assertEquals(text.getTextType(), Text.Type.XHTML);
     assertEquals(text.getValueElement(), div);
-    text = factory.newTitle(div);
+    text = factory.newTitle();
+    text.setValueElement(div);
     assertNotNull(text);
     assertEquals(text.getTextType(), Text.Type.XHTML);
     assertEquals(text.getValueElement(), div);