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

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


                                                        MediaType.APPLICATION_ATOM_XML);
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        Unmarshaller u =
            JAXBContext.newInstance(AtomEntry.class.getPackage().getName()).createUnmarshaller();
        AtomFeed feed =
            ((JAXBElement<AtomFeed>)u.unmarshal(new ByteArrayInputStream(response
                .getContentAsByteArray()))).getValue();
        assertEquals("Report Definitions Collection", feed.getTitle().getValue());
        assertEquals("Collection of report definitions. Report definition is a XML document describing how to build the report. It describes data sources, data sets, business logic and rendering and report parameters. Report definitions may also use libraries.",
                     feed.getSubtitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/?start-index=0&max-results=30&amp;alt=text/plain",
                     feed.getLinks().get(0).getHref());
        assertEquals("first", feed.getLinks().get(0).getRel());
        assertEquals("http://b216:8080/reporting/reports?alt=application/json", feed.getLinks()
            .get(1).getHref());
        assertEquals("alternate", feed.getLinks().get(1).getRel());
        assertEquals("http://b216:8080/reporting/reports", feed.getLinks().get(2).getHref());
        assertEquals("self", feed.getLinks().get(2).getRel());
        assertEquals("admin", feed.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", feed.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definitions:collection", feed.getCategories()
            .get(0).getTerm());
        assertEquals("report definitions", feed.getCategories().get(0).getLabel());

        AtomEntry entry = feed.getEntries().get(0);
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
View Full Code Here


        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());

        Unmarshaller u =
            JAXBContext.newInstance(AtomEntry.class.getPackage().getName()).createUnmarshaller();
        AtomFeed feed =
            ((JAXBElement<AtomFeed>)u.unmarshal(new ByteArrayInputStream(response
                .getContentAsByteArray()))).getValue();
        assertEquals("Report Definitions Collection", feed.getTitle().getValue());
        assertEquals("Collection of report definitions. Report definition is a XML document describing how to build the report. It describes data sources, data sets, business logic and rendering and report parameters. Report definitions may also use libraries.",
                     feed.getSubtitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/?start-index=0&max-results=30&alt=text/plain",
                     feed.getLinks().get(0).getHref());
        assertEquals("first", feed.getLinks().get(0).getRel());
        assertEquals("http://b216:8080/reporting/reports?alt=application/json", feed.getLinks()
            .get(1).getHref());
        assertEquals("alternate", feed.getLinks().get(1).getRel());
        assertEquals("http://b216:8080/reporting/reports", feed.getLinks().get(2).getHref());
        assertEquals("self", feed.getLinks().get(2).getRel());
        assertEquals("admin", feed.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", feed.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definitions:collection", feed.getCategories()
            .get(0).getTerm());
        assertEquals("report definitions", feed.getCategories().get(0).getLabel());

        AtomEntry entry = feed.getEntries().get(0);
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
View Full Code Here

            }

            System.out.println("\nComplete XML contents (mapped into SyndFeed / Atom format):");
            Marshaller m = AtomFeed.getMarshaller();
            JAXBElement<AtomFeed> element =
                (new ObjectFactory()).createFeed(new AtomFeed(syndFeed));
            try {
                ModelUtils.marshal(m, element, System.out);
            } catch (IOException e) {
                e.printStackTrace();
            }
View Full Code Here

            AppCollection collection = workspace.getCollection(COLLECTION_TITLE);
            String href = collection.getHref();

            // Get collection of defects
            Resource feedResource = restClient.resource(href);
            AtomFeed feed = feedResource.accept(MediaType.APPLICATION_ATOM_XML).get(AtomFeed.class);

            // Browse through collection of defects.
            listDefects(feed);
            listTests(restClient, testFeed);
View Full Code Here

        }
    }

    private static void listTests(RestClient restClient, String url) {
        Resource feedResource = restClient.resource(url);
        AtomFeed feed = feedResource.accept(MediaType.APPLICATION_ATOM_XML).get(AtomFeed.class);
        List<AtomEntry> entries = feed.getEntries();
        for (AtomEntry atomEntry : entries) {
            System.out.println("ID> " + atomEntry.getId()
                + " Title> "
                + atomEntry.getTitle().getValue());
            System.out.println("Content> " + atomEntry.getContent().getValue());
View Full Code Here

            throw new WebApplicationException(e);
        }
    }

    public AtomFeed toAtomFeed(UriInfo uriInfo) {
        AtomFeed feed = new AtomFeed();
        feed.setId(id+"");
        feed.setTitle(new AtomText(title));
        feed.setUpdated(updated);
        Set<Integer> ids = entries.keySet();
        List<Integer> idList = new ArrayList<Integer>(ids);
        Collections.sort(idList);
        AtomLink link = null;
        for (Integer entryId : idList) {
            link = new AtomLink();
            link.setHref(uriInfo.getBaseUri() + "blogservice/blogs/"
                + this.id
                + "/entries/"
                + entries.get(entryId).getId());
            link.setTitle(entries.get(entryId).getTitle());
            feed.getLinks().add(link);
        }
        return feed;
    }
View Full Code Here

    }

    @GET
    @Produces("application/atom+xml")
    public AtomFeed getBlogs() {
        AtomFeed ret = new AtomFeed();
        ret.setId(BlogService.ID);
        ret.setTitle(new AtomText(BlogService.ID));
        AtomLink link = null;
        for(int i = 0; i < BlogService.blogs.size(); ++i) {
            link = new AtomLink();
            link.setHref(baseUri.getAbsolutePath() + "/blogs/" + i);
            link.setTitle(BlogService.blogs.get(i).getTitle());
            ret.getLinks().add(link);
        }
        return ret;
    }
View Full Code Here

    public void testJAXBElementProviderReaderWriter() throws SecurityException,
        NoSuchFieldException {

        JAXBElementXmlProvider provider = new JAXBElementXmlProvider();
        AtomFeed af = new AtomFeed();
        org.apache.wink.common.model.atom.ObjectFactory objectFactory =
            new org.apache.wink.common.model.atom.ObjectFactory();
        JAXBElement<AtomFeed> feed = objectFactory.createFeed(af);
        Type genericType =
            JAXBElementProviderTest.class.getDeclaredField("atomfeed").getGenericType();
View Full Code Here

    }

    public void testJAXBXmlElementProviderReaderWriter() throws SecurityException,
        NoSuchFieldException {
        JAXBXmlProvider provider = new JAXBXmlProvider();
        AtomFeed af = new AtomFeed();

        assertTrue(provider.isWriteable(af.getClass(), null, null, new MediaType("text", "xml")));
        assertTrue(provider.isWriteable(af.getClass(), null, null, new MediaType("application",
                                                                                 "xml")));
        assertTrue(provider.isWriteable(af.getClass(), null, null, new MediaType("application",
                                                                                 "atom+xml")));
        assertTrue(provider.isWriteable(af.getClass(), null, null, new MediaType("application",
                                                                                 "atomsvc+xml")));
        assertFalse(provider.isWriteable(af.getClass(), null, null, new MediaType("text", "plain")));

        assertTrue(provider.isReadable(af.getClass(), null, null, new MediaType("text", "xml")));
        assertTrue(provider.isReadable(af.getClass(), null, null, new MediaType("application",
                                                                                "xml")));
        assertTrue(provider.isReadable(af.getClass(), null, null, new MediaType("application",
                                                                                "atom+xml")));
        assertTrue(provider.isReadable(af.getClass(), null, null, new MediaType("application",
                                                                                "atomsvc+xml")));
        assertFalse(provider.isReadable(af.getClass(), null, null, new MediaType("text", "plain")));
    }
View Full Code Here

       
        String[] elements =
            getElementsFromList("<feeds>", "</feeds>", feedString, invoke.getContentAsString());
        assertEquals(4, elements.length);

        AtomFeed feed = null;
        for (int i = 1; i < elements.length; ++i) {
            feed =
                (AtomFeed)((JAXBElement<?>)unmarshallElement(AtomFeed.class, feedString + elements[i]))
                    .getValue();
            assertEquals("" + (i - 1) + "10", feed.getId());
        }
    }
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.