Package org.jboss.resteasy.plugins.providers.atom

Examples of org.jboss.resteasy.plugins.providers.atom.Entry


      Assert.assertEquals(self.getType(), MediaType.APPLICATION_ATOM_XML_TYPE);
      Assert.assertEquals(self.getHreflang(), null);
      Assert.assertEquals(self.getHref(), new URI("http://example.org/feed.atom"));

      Assert.assertEquals(1, feed.getEntries().size());
      Entry entry = feed.getEntries().get(0);
      Assert.assertEquals("Atom draft-07 snapshot", entry.getTitle());
      alternate = entry.getLinkByRel("alternate");
      Assert.assertNotNull(alternate);
      Assert.assertEquals(alternate.getType(), MediaType.valueOf("text/html"));
      Assert.assertEquals(alternate.getHref(), new URI("http://example.org/2005/04/02/atom"));
      Link enclosure = entry.getLinkByRel("enclosure");
      Assert.assertNotNull(enclosure);
      Assert.assertEquals(enclosure.getType(), MediaType.valueOf("audio/mpeg"));
      Assert.assertEquals(enclosure.getLength(), "1337");
      Assert.assertEquals(enclosure.getHref(), new URI(
              "http://example.org/audio/ph34r_my_podcast.mp3"));
      Assert.assertEquals(entry.getId(), new URI("tag:example.org,2003:3.2397"));
      Assert.assertNotNull(entry.getUpdated());
      Assert.assertNotNull(entry.getPublished());
      Person author = entry.getAuthors().get(0);
      Assert.assertEquals(author.getName(), "Mark Pilgrim");
      Assert.assertEquals(author.getUri(), new URI("http://example.org/"));
      Assert.assertEquals(author.getEmail(), "f8dy@example.com");
      Assert.assertEquals(entry.getContributors().get(0).getName(), "Sam Ruby");
      Assert.assertEquals(entry.getContributors().get(1).getName(), "Joe Gregorio");
      Assert.assertEquals(entry.getContent().getType(), MediaType.APPLICATION_XML_TYPE);
      Assert.assertEquals(entry.getContent().getLanguage(), "en");
      Assert.assertEquals(entry.getContent().getBase(), new URI("http://diveintomark.org/"));
      System.out.println(entry.getContent().getElement().getNodeName());
      System.out.println(entry.getContent().getElement().getNamespaceURI());
      CustomerAtom cust = entry.getContent().getJAXBObject(CustomerAtom.class);
      Assert.assertEquals(cust.getName(), "bill");

   }
View Full Code Here


   @Test
   public void testXmlType() throws Exception
   {
      AtomServerInterface intf = createProxy(AtomServerInterface.class);
      Entry entry = intf.getXmlType();
      DataCollectionRecord record = entry.getContent().getJAXBObject(DataCollectionRecord.class);
      Assert.assertEquals("hello world", record.getCollectedData());

   }
View Full Code Here

      @GET
      @Path("entry")
      @Produces("application/atom+xml")
      public Entry getEntry()
      {
         Entry entry = new Entry();
         entry.setTitle("Hello World");
         Content content = new Content();
         content.setJAXBObject(new CustomerAtom("bill"));
         entry.setContent(content);
         return entry;
      }
View Full Code Here

      @GET
      @Path("text/entry")
      @Produces("application/atom+xml")
      public Entry getTextEntry()
      {
         Entry entry = new Entry();
         entry.setTitle("Hello World");
         Content content = new Content();
         content.setText("<pre>How are you today?\nNotBad!</pre>");
         content.setType(MediaType.TEXT_HTML_TYPE);
         entry.setContent(content);
         return entry;
      }
View Full Code Here

      @GET
      @Path("xmltype")
      @Produces("application/atom+xml")
      public Entry getXmlType()
      {
         Entry entry = new Entry();
         entry.setTitle("Hello World");
         Content content = new Content();
         DataCollectionRecord record = new DataCollectionRecord();
         record.setCollectedData("hello world");
         content.setJAXBObject(record);
         entry.setContent(content);
         return entry;

      }
View Full Code Here

    @Test
    public void testComplexType() throws Exception {

        URI baseUri = new URI("resteasy-test");

        Entry entry = new Entry();
        entry.setTitle("testtitle");
        entry.setSummary("testdesc");
        entry.setPublished(new Date());
        entry.getAuthors().add(new Person("testperson"));
        entry.setId(baseUri);

        AtomAssetMetadata atomAssetMetadata = entry.getAnyOtherJAXBObject(AtomAssetMetadata.class);
        if (atomAssetMetadata == null) {
            atomAssetMetadata = new AtomAssetMetadata();
        }
        atomAssetMetadata.setArchived(false);
        atomAssetMetadata.setUuid("testuuid");
        atomAssetMetadata.setCategories(new String[]{"a", "b", "c"});

        entry.setAnyOtherJAXBObject(atomAssetMetadata);

        Content content = new Content();
        content.setSrc(UriBuilder.fromUri(baseUri).path("binary").build());
        content.setType(MediaType.APPLICATION_OCTET_STREAM_TYPE);
        entry.setContent(content);


        Class[] classes = new Class[]{AtomAssetMetadata.class, Entry.class};
        JAXBContext jaxbContext = JAXBContext.newInstance(classes);


        Marshaller marshaller = jaxbContext.createMarshaller();

        Writer xmlWriter = new StringWriter();
        marshaller.marshal(entry, xmlWriter);
        String xmlOut = xmlWriter.toString();

        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        StringReader xmlReader = new StringReader(xmlOut);

        Entry newEntry = (Entry) unmarshaller.unmarshal(xmlReader);
        atomAssetMetadata = newEntry.getAnyOtherJAXBObject(AtomAssetMetadata.class);
        assertNotNull(atomAssetMetadata);
        assertNotNull(atomAssetMetadata.getCategories());

    }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.plugins.providers.atom.Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.