Search in sources :

Example 1 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class InfinispanStoreTest method setUp.

@Before
public void setUp() throws Exception {
    GoraInfinispanTestDriver driver = getTestDriver();
    conf = driver.getConfiguration();
    conf.set(ISPN_CONNECTION_STRING_KEY, getTestDriver().connectionString());
    super.setUp();
    employeeDataStore = (InfinispanStore<String, Employee>) employeeStore;
    webPageDataStore = (InfinispanStore<String, WebPage>) webPageStore;
}
Also used : WebPage(org.apache.gora.examples.generated.WebPage) Employee(org.apache.gora.examples.generated.Employee) GoraInfinispanTestDriver(org.apache.gora.infinispan.GoraInfinispanTestDriver) Before(org.junit.Before)

Example 2 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class TestPersistentSerialization method testSerdeEmployee.

/**
   * Creates an Employee object in-memory setting several fields to dirty. 
   * Asserts that it can be serialized and 
   * deserialzed without loosing data. We do this by asserting
   * what we get 'before' and 'after' (de)serialization processes.
   * @throws Exception
   */
@SuppressWarnings("unchecked")
@Test
public void testSerdeEmployee() throws Exception {
    MemStore<String, Employee> store = DataStoreFactory.getDataStore(MemStore.class, String.class, Employee.class, new Configuration());
    Employee employee = DataStoreTestUtil.createEmployee();
    TestIOUtils.testSerializeDeserialize(employee);
}
Also used : Employee(org.apache.gora.examples.generated.Employee) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Example 3 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class TestPersistentSerialization method testSerdeEmployeeTwoFields.

/**
   * Creates an Employee object setting only two fields as dirty.
   * We then do (de)serialization and check 'before' and 'after'
   * states.
   * @throws Exception
   */
@Test
public void testSerdeEmployeeTwoFields() throws Exception {
    Employee employee = Employee.newBuilder().build();
    employee.setSsn(new Utf8("11111"));
    employee.setSalary(100);
    TestIOUtils.testSerializeDeserialize(employee);
}
Also used : Employee(org.apache.gora.examples.generated.Employee) Utf8(org.apache.avro.util.Utf8) Test(org.junit.Test)

Example 4 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class TestPersistentBase method testFieldsWithTwoClasses.

/**
   * Assert that field positions as found within the SCHEMA array
   * are as we would expect by accessing them directly. 
   * This tests for both WebPage and Employee data beans.
   */
@Test
public void testFieldsWithTwoClasses() {
    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);
    }
    Employee employee = Employee.newBuilder().build();
    for (int i = 0; i < Employee.SCHEMA$.getFields().toArray().length; i++) {
        int index = employee.getSchema().getFields().get(i).pos();
        assertEquals(i, index);
    }
}
Also used : WebPage(org.apache.gora.examples.generated.WebPage) Employee(org.apache.gora.examples.generated.Employee) Test(org.junit.Test)

Example 5 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class TestPersistentBase method testClone.

/**
   * Tests and asserts that an in-memory representation of the 
   * Employee object is Equal to a clone of the same object.
   * @throws IOException
   * @throws Exception
   */
@Test
public void testClone() throws Exception {
    //more tests for clone are in TestPersistentDatumReader
    @SuppressWarnings("unchecked") MemStore<String, Employee> store = DataStoreFactory.getDataStore(MemStore.class, String.class, Employee.class, new Configuration());
    Employee employee = DataStoreTestUtil.createEmployee();
    assertEquals(employee, Employee.newBuilder(employee).build());
}
Also used : Employee(org.apache.gora.examples.generated.Employee) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Aggregations

Employee (org.apache.gora.examples.generated.Employee)23 Utf8 (org.apache.avro.util.Utf8)11 Test (org.junit.Test)7 WebPage (org.apache.gora.examples.generated.WebPage)5 Metadata (org.apache.gora.examples.generated.Metadata)2 Configuration (org.apache.hadoop.conf.Configuration)2 HashMap (java.util.HashMap)1 GoraInfinispanTestDriver (org.apache.gora.infinispan.GoraInfinispanTestDriver)1 Before (org.junit.Before)1