use of org.apache.gora.examples.generated.WebPage in project gora by apache.
the class DataStoreTestUtil method testPutMixedMapTypes.
public static void testPutMixedMapTypes(DataStore<String, WebPage> store) {
WebPage webpage = createWebPage();
webpage.getByteData().put(new Utf8("byteData"), ByteBuffer.wrap(ByteUtils.toBytes("hello map")));
webpage.getStringData().put(new Utf8("stringData"), "hello map");
store.createSchema();
store.put(webpage.getUrl().toString(), webpage);
store.flush();
assertNotNull(store.get(webpage.getUrl().toString()));
}
use of org.apache.gora.examples.generated.WebPage in project gora by apache.
the class MemStoreTest method testGetMissingValue.
@Test
public void testGetMissingValue() {
DataStore<String, WebPage> store = new MemStore<>();
WebPage nullWebPage = store.get("missing", new String[0]);
assertNull(nullWebPage);
store.close();
}
use of org.apache.gora.examples.generated.WebPage in project gora by apache.
the class MemStoreTest method testGetWithFields.
@Test
public void testGetWithFields() throws Exception {
DataStore<String, WebPage> store = new MemStore<>();
BeanFactory<String, WebPage> beanFactory = new BeanFactoryImpl<>(String.class, WebPage.class);
store.setBeanFactory(beanFactory);
WebPageDataCreator.createWebPageData(store);
String[] interestFields = new String[2];
interestFields[0] = "url";
interestFields[1] = "content";
WebPage page = store.get(URLS[1], interestFields);
assertNotNull(page);
assertNotNull(page.getUrl());
assertEquals(page.getUrl().toString(), URLS[1]);
assertNotNull(page.getContent());
assertEquals("Map of Outlinks should have a size of '0' as it is omitted at retrieval", 0, page.getOutlinks().size());
assertEquals("Map of Parsed Content should have a size of '0' as it is omitted at retrieval", 0, page.getParsedContent().size());
}
use of org.apache.gora.examples.generated.WebPage in project gora by apache.
the class TestPersistentBase method testGetFieldIndex.
/**
* Assert that field positions as found within the SCHEMA array
* are as we would expect by accessing them directly.
*/
@Test
public void testGetFieldIndex() {
WebPage page = WebPage.newBuilder().build();
for (int i = 0; i < WebPage.SCHEMA$.getFields().toArray().length; i++) {
int index = page.getSchema().getFields().get(i).pos();
assertEquals(i, index);
}
}
use of org.apache.gora.examples.generated.WebPage in project gora by apache.
the class TestAvroUtils method testDeepClonePersistent.
@Test
public void testDeepClonePersistent() throws Exception {
CharSequence url = new Utf8("http://gora.apache.org/");
WebPage.Builder builder = WebPage.newBuilder().setUrl(url).setContent(ByteBuffer.wrap("Gora".getBytes("UTF-8")));
WebPage webPage = builder.build();
WebPage clonedWebPage = AvroUtils.deepClonePersistent(webPage);
assertThat(clonedWebPage, is(notNullValue()));
assertThat(clonedWebPage.getUrl(), is(equalTo(url)));
assertThat(clonedWebPage.getContent(), is(notNullValue()));
String clonedWebPageContent = new String(clonedWebPage.getContent().array(), "UTF-8");
assertThat(clonedWebPageContent, is(equalTo("Gora")));
}
Aggregations