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

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


      int status = client.executeMethod(get);
      Assert.assertEquals(200, status);
      System.out.println(get.getResponseBodyAsString());

      AtomServerInterface intf = createProxy(AtomServerInterface.class);
      Feed feed = intf.postFeed(RFC_COMPLEX_XML);
      assertFeed(feed);

      // Thread.sleep(1000000);

   }
View Full Code Here


      @GET
      @Path("feed")
      @Produces("application/atom+xml")
      public Feed getFeed()
      {
         Feed feed = new Feed();
         feed.getEntries().add(getEntry());
         return feed;
      }
View Full Code Here

      @GET
      @Path("text/feed")
      @Produces("application/atom+xml")
      public Feed getTextFeed()
      {
         Feed feed = new Feed();
         feed.getEntries().add(getTextEntry());
         return feed;
      }
View Full Code Here

      {
         // TODO make difference between empty list and nonsense user
         throw new ResourceNotFoundException();
      }

      Feed feed = new Feed();
      feed.setTitle("Resolved feeds for " + username);
      feed.getAuthors().add(new Person(username));
      feed.setUpdated(new Date(0));

      for (Task task : tasks)
      {
         Entry entry = new Entry();
         entry.setTitle(task.getName());
         entry.setSummary(task.getName());
         entry.setPublished(task.getCreated());
         entry.setUpdated(task.getUpdated());
         feed.getEntries().add(entry);
      }
      return feed;
   }
View Full Code Here

    }

    @Override
    public Feed toFeed(List<Event> events, String path) {
        String url =  config.getString(ConfigProperties.CANDLEPIN_URL) + path + "/";
        Feed feed = new Feed();
        feed.setUpdated(new Date());
        feed.getAuthors().add(new Person("Red Hat, Inc."));
        try {
            feed.setId(new URI(url));
        }
        catch (Exception e) {
            // ignore, shouldn't happen
        }

        if (events == null) {
            return feed;
        }

        // Add the friendly message text
        this.addMessageText(events);

        for (Event e : events) {
            Entry entry = new Entry();
            entry.setTitle(e.getTarget().toString() + " " + e.getType().toString());
            entry.setPublished(e.getTimestamp());
            entry.setUpdated(e.getTimestamp());
            entry.getAuthors().add(new Person("Red Hat, Inc."));
            URI eventURI = null;
            try {
                eventURI = new URI(url + e.getId());
            }
            catch (Exception error) {
                // ignore, shouldn't happen
            }
            entry.setId(eventURI);
            entry.getLinks().add(
                new Link(
                    "alternate",
                    eventURI,
                    MediaType.APPLICATION_JSON_TYPE));

            Content content = new Content();
            content.setType(MediaType.APPLICATION_XML_TYPE);
            content.setJAXBObject(e);
            entry.setContent(content);
            entry.setSummary(e.getMessageText());
            feed.getEntries().add(entry);
        }
        // Use the most recent event as the feed's published time. Assumes events do not
        // get modified, if they do then the feed published date could be inaccurate.
        if (events.size() > 0) {
            feed.setUpdated(events.get(0).getTimestamp());
        }

        return feed;
    }
View Full Code Here

    public void toFeed() {
        EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
        List<Event> events = new LinkedList<Event>();
        events.add(mockEvent(Event.Target.CONSUMER, Event.Type.CREATED));
        events.add(mockEvent(Event.Target.ENTITLEMENT, Event.Type.DELETED));
        Feed f = ea.toFeed(events, "/test/path");
        assertNotNull(f);
        assertNotNull(f.getEntries());
        assertFalse(f.getEntries().isEmpty());
        assertEquals(2, f.getEntries().size());
        Entry e = f.getEntries().get(0);
        assertNotNull(e);
        assertNotNull(e.getTitle());
        assertTrue(e.getTitle().contains("CONSUMER"));
        assertTrue(e.getTitle().contains("CREATED"));
        assertTrue(e.getSummary().contains("unit"));
        assertTrue(e.getSummary().contains("created"));
        assertEquals(events.get(0).getTimestamp(), f.getUpdated());
    }
View Full Code Here

    }

    @Test
    public void nullList() {
        EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
        Feed f = ea.toFeed(null, null);
        assertNotNull(f);
        assertNotNull(f.getEntries());
        assertTrue(f.getEntries().isEmpty());
    }
View Full Code Here

    }

    @Test
    public void emptyList() {
        EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
        Feed f = ea.toFeed(new LinkedList<Event>(), "/some/path");
        assertNotNull(f);
        assertNotNull(f.getEntries());
        assertTrue(f.getEntries().isEmpty());
    }
View Full Code Here

        // Make sure we're acting as the correct owner admin:
        setupPrincipal(owner, Access.ALL);

        securityInterceptor.enable();

        Feed feed = ownerResource.getOwnerAtomFeed(owner.getKey());
        assertEquals(1, feed.getEntries().size());
        Entry entry = feed.getEntries().get(0);
        assertEquals(e1.getTimestamp(), entry.getPublished());
    }
View Full Code Here

    @Test
    public void getFeed() {
        List<Event> events = getEvents(10);
        when(ec.listMostRecent(eq(1000))).thenReturn(events);
        Feed f = afr.getFeed();
        assertNotNull(f);
        assertEquals(10, f.getEntries().size());
    }
View Full Code Here

TOP

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

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.