Search in sources :

Example 11 with Storable

use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.

the class JdbcStorageManagerIntegrationTest method testAdd_UnequalExistingStorable_AlreadyExistsException.

// =============== TEST METHODS ===============
@Test(expected = Exception.class)
public void testAdd_UnequalExistingStorable_AlreadyExistsException() {
    for (StorableTest test : storableTests) {
        Storable storable1 = test.getStorableList().get(0);
        Storable storable2 = test.getStorableList().get(1);
        Assert.assertEquals(storable1.getStorableKey(), storable2.getStorableKey());
        Assert.assertNotEquals(storable1, storable2);
        getStorageManager().add(storable1);
        // should throw exception
        getStorageManager().add(storable2);
    }
}
Also used : StorableTest(com.hortonworks.registries.storage.StorableTest) Storable(com.hortonworks.registries.storage.Storable) AbstractStoreManagerTest(com.hortonworks.registries.storage.AbstractStoreManagerTest) StorableTest(com.hortonworks.registries.storage.StorableTest) Test(org.junit.Test) IntegrationTest(com.hortonworks.registries.common.test.IntegrationTest)

Example 12 with Storable

use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.

the class JdbcStorageManagerIntegrationTest method testList_EmptyDb_EmptyCollection.

@Test
public void testList_EmptyDb_EmptyCollection() {
    for (StorableTest test : storableTests) {
        Collection<Storable> found = getStorageManager().list(test.getStorableList().get(0).getStorableKey().getNameSpace());
        Assert.assertNotNull(found);
        Assert.assertTrue(found.isEmpty());
    }
}
Also used : StorableTest(com.hortonworks.registries.storage.StorableTest) Storable(com.hortonworks.registries.storage.Storable) AbstractStoreManagerTest(com.hortonworks.registries.storage.AbstractStoreManagerTest) StorableTest(com.hortonworks.registries.storage.StorableTest) Test(org.junit.Test) IntegrationTest(com.hortonworks.registries.common.test.IntegrationTest)

Example 13 with Storable

use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.

the class CatalogTagService method getStorableClasses.

public static Collection<Class<? extends Storable>> getStorableClasses() {
    InputStream resourceAsStream = CatalogTagService.class.getClassLoader().getResourceAsStream("tagstorables.props");
    HashSet<Class<? extends Storable>> classes = new HashSet<>();
    try {
        List<String> classNames = IOUtils.readLines(resourceAsStream);
        for (String className : classNames) {
            classes.add((Class<? extends Storable>) Class.forName(className));
        }
    } catch (IOException | ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    return classes;
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) Storable(com.hortonworks.registries.storage.Storable) HashSet(java.util.HashSet)

Example 14 with Storable

use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.

the class GuavaCacheTest method test_put_get_existing_remove_key.

/**
 * Asserts that cache has not given key, puts (key,val) pair, retrieves key, and removes key at the end
 */
@Test
public void test_put_get_existing_remove_key() {
    try {
        Assert.assertNull(cache.get(storableKey));
        final Storable putVal = new TestStorable();
        cache.put(storableKey, putVal);
        Storable retrievedVal = cache.get(storableKey);
        Assert.assertEquals(putVal, retrievedVal);
    } finally {
        cache.remove(storableKey);
        Assert.assertNull(cache.get(storableKey));
    }
}
Also used : Storable(com.hortonworks.registries.storage.Storable) AbstractStorable(com.hortonworks.registries.storage.catalog.AbstractStorable) Test(org.junit.Test)

Aggregations

Storable (com.hortonworks.registries.storage.Storable)14 StorageManager (com.hortonworks.registries.storage.StorageManager)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IntegrationTest (com.hortonworks.registries.common.test.IntegrationTest)3 AbstractStoreManagerTest (com.hortonworks.registries.storage.AbstractStoreManagerTest)3 StorableKey (com.hortonworks.registries.storage.StorableKey)3 StorableTest (com.hortonworks.registries.storage.StorableTest)3 HashSet (java.util.HashSet)3 CacheBuilder (com.google.common.cache.CacheBuilder)2 QueryParam (com.hortonworks.registries.common.QueryParam)2 UnsupportedSchemaTypeException (com.hortonworks.registries.schemaregistry.errors.UnsupportedSchemaTypeException)2 CacheBackedStorageManager (com.hortonworks.registries.storage.CacheBackedStorageManager)2 OrderByField (com.hortonworks.registries.storage.OrderByField)2 PrimaryKey (com.hortonworks.registries.storage.PrimaryKey)2 StorageWriter (com.hortonworks.registries.storage.cache.writer.StorageWriter)2 StorageException (com.hortonworks.registries.storage.exception.StorageException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Preconditions (com.google.common.base.Preconditions)1 Lists (com.google.common.collect.Lists)1