use of org.apache.abdera.model.Entry in project cxf by apache.
the class AtomBookStore method doGetBookAsFeed.
private Feed doGetBookAsFeed(@Context UriInfo uParam) {
Factory factory = Abdera.getNewFactory();
Feed f = factory.newFeed();
f.setBaseUri(uParam.getAbsolutePath().toString());
f.setTitle("Collection of Books");
f.setId("http://www.books.com");
f.addAuthor("BookStore Management Company");
try {
for (Book b : books.values()) {
Entry e = AtomUtils.createBookEntry(factory, b);
f.addEntry(e);
}
} catch (Exception ex) {
// ignore
}
return f;
}
use of org.apache.abdera.model.Entry in project cxf by apache.
the class AtomPojoProvider method setFeedFromCollection.
// CHECKSTYLE:OFF
protected void setFeedFromCollection(Factory factory, Feed feed, Object wrapper, Class<?> wrapperCls, Object collection, Class<?> collectionCls, Type collectionType, boolean writerUsed) throws Exception {
// CHECKSTYLE:ON
Object[] arr = collectionCls.isArray() ? (Object[]) collection : ((Collection<?>) collection).toArray();
Class<?> memberClass = InjectionUtils.getActualType(collectionType);
for (Object o : arr) {
Entry entry = createEntryFromObject(factory, o, memberClass);
feed.addEntry(entry);
}
if (!writerUsed) {
setFeedProperties(factory, feed, wrapper, wrapperCls, collection, collectionCls, collectionType);
}
}
use of org.apache.abdera.model.Entry in project cxf by apache.
the class AtomEntryProviderTest method testWriteTo.
@Test
public void testWriteTo() throws Exception {
InputStream is = getClass().getResourceAsStream("atomEntry.xml");
Entry simple = afd.readFrom(Entry.class, null, null, MediaType.valueOf("application/atom+xml;type=entry"), null, is);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
afd.writeTo(simple, null, null, null, MediaType.valueOf("application/atom+xml;type=entry"), null, bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
Entry simpleCopy = afd.readFrom(Entry.class, null, null, MediaType.valueOf("application/atom+xml"), null, bis);
assertEquals("Wrong entry title", "Atom-Powered Robots Run Amok", simpleCopy.getTitle());
assertEquals("Wrong entry title", simple.getTitle(), simpleCopy.getTitle());
}
use of org.apache.abdera.model.Entry in project cxf by apache.
the class AtomEntryProviderTest method testReadFrom.
@Test
public void testReadFrom() throws Exception {
InputStream is = getClass().getResourceAsStream("atomEntry.xml");
Entry simple = afd.readFrom(Entry.class, null, null, null, null, is);
assertEquals("Wrong entry title", "Atom-Powered Robots Run Amok", simple.getTitle());
}
use of org.apache.abdera.model.Entry in project wildfly-camel by wildfly-extras.
the class AtomIntegrationTest method testConsumeAtomFeed.
@Test
public void testConsumeAtomFeed() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("atom://http://localhost:8080/atom-test/atom/feed?splitEntries=true").to("seda:end");
}
});
PollingConsumer pollingConsumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
pollingConsumer.start();
camelctx.start();
try {
Entry result = pollingConsumer.receive(5000).getIn().getBody(Entry.class);
Assert.assertEquals(FeedConstants.ENTRY_TITLE, result.getTitle());
Assert.assertEquals(FeedConstants.ENTRY_CONTENT, result.getContent());
} finally {
camelctx.stop();
}
}
Aggregations