Package org.apache.wink.common.model.atom

Examples of org.apache.wink.common.model.atom.AtomFeed


        }

        @POST
        @Path("xmlrootwithfactory")
        public AtomFeed createBare(AtomFeed feed) {
            AtomFeed atomFeed = new AtomFeed();
            atomFeed.setId(feed.getId());
            return atomFeed;
        }
View Full Code Here


        @GET
        @Path("atomfeed")
        @Produces("application/atom+xml")
        public AtomFeed getAtomFeed() throws IOException {
            AtomFeed feed = AtomFeed.unmarshal(new StringReader(FEED));
            return feed;
        }
View Full Code Here

        @GET
        @Path("atomfeedelement")
        @Produces("application/atom+xml")
        public JAXBElement<AtomFeed> getAtomFeedElement() throws IOException {
            AtomFeed feed = AtomFeed.unmarshal(new StringReader(FEED));
            org.apache.wink.common.model.atom.ObjectFactory of =
                new org.apache.wink.common.model.atom.ObjectFactory();
            return of.createFeed(feed);
        }
View Full Code Here

        @GET
        @Path("atomsyndfeed")
        @Produces("application/atom+xml")
        public SyndFeed getSyndFeed() throws IOException {
            AtomFeed feed = AtomFeed.unmarshal(new StringReader(FEED));
            return feed.toSynd(new SyndFeed());
        }
View Full Code Here

    public static class Resource {

        @POST
        @Path("jaxbfeed")
        public JAXBElement<AtomFeed> createWrappedFeed(JAXBElement<AtomFeed> feed) {
            AtomFeed atomFeed = new AtomFeed();
            atomFeed.setId(feed.getValue().getId());
            JAXBElement<AtomFeed> wrappedFeed = new ObjectFactory().createFeed(atomFeed);
            return wrappedFeed;
        }
View Full Code Here

    final private static String BASE_URI = ServerEnvironmentInfo.getBaseURI() + "/optionalproviders/blogservice";

    public void testAtomGETBlogs() throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(BASE_URI);
        AtomFeed feed = resource.accept("application/atom+xml").get(AtomFeed.class);
        assertEquals(BlogService.ID, feed.getId());
        assertEquals(BlogService.ID, feed.getTitle().getValue());
       
        List<AtomLink> expectedLinks = new ArrayList<AtomLink>();
        AtomLink link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0");
        expectedLinks.add(link);
        link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/1");
        expectedLinks.add(link);
        List<AtomLink> actual = feed.getLinks();
        assertEquals(expectedLinks.size(), actual.size());
        for(int i = 0; i < actual.size(); ++i)
            assertEquals(expectedLinks.get(i).getHref(), actual.get(i).getHref());
    }
View Full Code Here

    }
   
    public void testAtomGETBlog() throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(BASE_URI+"/blogs/0");
        AtomFeed feed = resource.accept("application/atom+xml").get(AtomFeed.class);
        assertEquals("0", feed.getId());
        assertEquals("wink-developer-blog", feed.getTitle().getValue());
       
        List<AtomLink> expectedLinks = new ArrayList<AtomLink>();
        AtomLink link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/0");
        expectedLinks.add(link);
        link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/1");
        expectedLinks.add(link);
        List<AtomLink> actual = feed.getLinks();
        assertEquals(expectedLinks.size(), actual.size());
        for(int i = 0; i < actual.size(); ++i)
            assertEquals(expectedLinks.get(i).getHref(), actual.get(i).getHref());
       
        client = new RestClient();
        resource = client.resource(BASE_URI+"/blogs/1");
        feed = resource.accept("application/atom+xml").get(AtomFeed.class);
        assertEquals("1", feed.getId());
        assertEquals("wink-user-blog", feed.getTitle().getValue());
       
        expectedLinks = new ArrayList<AtomLink>();
        link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/1/entries/2");
        expectedLinks.add(link);
        actual = feed.getLinks();
        assertEquals(expectedLinks.size(), actual.size());
        for(int i = 0; i < actual.size(); ++i)
            assertEquals(expectedLinks.get(i).getHref(), actual.get(i).getHref());
    }
View Full Code Here

        assertEquals("This is a new entry in the blog", entry.getContent().getValue());
        assertEquals("New blog entry", entry.getTitle().getValue());
        assertEquals(0, entry.getLinks().size());
       
        resource = client.resource(BASE_URI+"/blogs/0");
        AtomFeed feed = resource.accept("application/atom+xml").get(AtomFeed.class);
        List<AtomLink> expectedLinks = new ArrayList<AtomLink>();
        AtomLink link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/0");
        expectedLinks.add(link);
        link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/1");
        expectedLinks.add(link);
        link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/3");
        expectedLinks.add(link);
        List<AtomLink> actual = feed.getLinks();
        assertEquals(expectedLinks.size(), actual.size());
        for(int i = 0; i < actual.size(); ++i)
            assertEquals(expectedLinks.get(i).getHref(), actual.get(i).getHref());
    }
View Full Code Here

    private String diffFeed(String expectedFileName, String actual) throws Exception {
        InputStream expected = TestUtils.getResourceOfSamePackage(expectedFileName, getClass());

        // sort feeds
        AtomFeed expectedFeed = AtomFeed.unmarshal(new InputStreamReader(expected));
        AtomFeed actualFeed = AtomFeed.unmarshal(new StringReader(actual));
        Collections.sort(actualFeed.getEntries(), new AtomEntryComparator());
        Collections.sort(expectedFeed.getEntries(), new AtomEntryComparator());

        ByteArrayOutputStream actualOS = new ByteArrayOutputStream();
        ByteArrayOutputStream expectedOS = new ByteArrayOutputStream();
        AtomFeed.marshal(expectedFeed, expectedOS);
View Full Code Here

            Resource resource =
                client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
                    .getServerPort())));

            AtomFeedProvider afp = new AtomFeedProvider();
            AtomFeed entryToPost =
                afp.readFrom(AtomFeed.class,
                             null,
                             null,
                             MediaType.APPLICATION_ATOM_XML_TYPE,
                             null,
                             new ByteArrayInputStream(FEED.getBytes()));
            AtomFeed responseEntity =
                resource.accept(MediaType.APPLICATION_ATOM_XML_TYPE)
                    .contentType(MediaType.APPLICATION_ATOM_XML_TYPE).post(AtomFeed.class,
                                                                           entryToPost);

            ByteArrayOutputStream os = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.wink.common.model.atom.AtomFeed

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.