Package org.lilyproject.lilyservertestfw

Examples of org.lilyproject.lilyservertestfw.LilyProxy


    private static LilyProxy lilyProxy;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        TestHelper.setupLogging();
        lilyProxy = new LilyProxy(null, null, null, true);
        byte[] schemaData = IOUtils.toByteArray(LilyProxyTest.class.getResourceAsStream("lilytestutility_solr_schema.xml"));
        lilyProxy.start(schemaData);
        LilyClient lilyClient = lilyProxy.getLilyServerProxy().getClient();
        repository = lilyClient.getRepository();
    }
View Full Code Here


    private Repository repository;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        TestHelper.setupLogging();
        lilyProxy = new LilyProxy(null, null, null, true);
        byte[] schemaData = IOUtils.toByteArray(LilyProxyTest.class.getResourceAsStream("lilytestutility_solr_schema.xml"));
        lilyProxy.start(schemaData);
        lilyClient = lilyProxy.getLilyServerProxy().getClient();
    }
View Full Code Here

    private static HttpClient httpClient;
    private static LilyProxy lilyProxy;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        lilyProxy = new LilyProxy();
        lilyProxy.start();

        httpClient = new DefaultHttpClient();

        BASE_URI = "http://localhost:12060/repository";
View Full Code Here

        File customConfDir = setupConfDirectory(tmpDir);
        System.setProperty("lily.conf.dir", basedir + "/../server/conf");
        System.setProperty("lily.conf.customdir", customConfDir.getAbsolutePath());

        try {
            lilyProxy = new LilyProxy();
            lilyProxy.start();
        } finally {
            // Make sure it's properties won't be used by later-running tests
            System.getProperties().remove("lily.plugin.dir");
            System.getProperties().remove("lily.conf.dir");
View Full Code Here

    // working in a different way.
    private static List<String> TABLE_NAMES = Lists.newArrayList("record");//, "links-forward", "links-backward");

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        lilyProxy = new LilyProxy();

        //
        // Make multiple record table splits
        //
View Full Code Here

*/
public class DecoratorTest {

    @Test
    public void test() throws Exception {
        LilyProxy lilyProxy = createLilyProxy();

        LilyClient client = lilyProxy.getLilyServerProxy().getClient();

        RepositoryModelImpl repositoryModel = new RepositoryModelImpl(lilyProxy.getLilyServerProxy().getZooKeeper());
        repositoryModel.create("repo1");
        assertTrue(repositoryModel.waitUntilRepositoryInState("repo1", RepositoryLifecycleState.ACTIVE, 60000L));
        repositoryModel.create("repo2");
        assertTrue(repositoryModel.waitUntilRepositoryInState("repo2", RepositoryLifecycleState.ACTIVE, 60000L));
        repositoryModel.close();

        // Make a schema
        TypeManager typeMgr = client.getDefaultRepository().getTypeManager();

        QName field1 = new QName("ns", "f1");
        FieldType fieldType1 = typeMgr.newFieldType(typeMgr.getValueType("STRING"), field1, Scope.NON_VERSIONED);
        fieldType1 = typeMgr.createFieldType(fieldType1);

        QName field2 = new QName("ns", "f2");
        FieldType fieldType2 = typeMgr.newFieldType(typeMgr.getValueType("STRING"), field2, Scope.NON_VERSIONED);
        fieldType2 = typeMgr.createFieldType(fieldType2);

        QName typeName = new QName("ns", "rt1");
        RecordType recordType = typeMgr.newRecordType(typeName);
        recordType.addFieldTypeEntry(fieldType1.getId(), false);
        recordType.addFieldTypeEntry(fieldType2.getId(), false);
        recordType = typeMgr.createRecordType(recordType);

        DecoratingRepositoryManager repositoryMgr = (DecoratingRepositoryManager)lilyProxy.getLilyServerProxy()
                .getLilyServerTestingUtility().getRuntime().getModuleById("repository")
                .getApplicationContext().getBean("repositoryManager");
        IdentityHashMap<Object, Object> chains = new IdentityHashMap<Object, Object>();

        // Test the decorator is applied for each repository and each table
        for (String repositoryName : new String[] {"default", "repo1", "repo2"}) {
            LRepository repository = client.getRepository(repositoryName);

            repository.getTableManager().createTable("table1");
            repository.getTableManager().createTable("table2");

            for (String tableName : new String[] {"record", "table1", "table2"}) {
                LTable table = repository.getTable(tableName);
                Record record = table.newRecord();
                record.setRecordType(typeName);
                record.setField(field1, "foobar");
                record = table.create(record);
                assertEquals("foo", record.getField(field2));
                assertEquals("foo", table.read(record.getId()).getField(field2));

                // Test we can get access to our test decorator: this is something that is occasionally useful
                // in test cases to check certain conditions, e.g. if the decorator would have async side effects.
                RepositoryDecoratorChain chain = repositoryMgr.getRepositoryDecoratorChain(repositoryName, tableName);
                assertNotNull(chain);
                assertNotNull(chain.getDecorator(TestRepositoryDecoratorFactory.NAME));
                chains.put(chain.getDecorator(TestRepositoryDecoratorFactory.NAME), null);
                assertEquals(2, chain.getEntries().size());
            }
        }

        // There should be one instance of the decorator created for each repository-table combination (that
        // was accessed)
        assertEquals(3 * 3, chains.size());

        // Check that if we ask the same table twice, we get the same instance (verifies cache works)
        assertTrue(client.getRepository("repo1").getTable("table1") == client.getRepository("repo1").getTable("table1"));

        lilyProxy.stop();

        // Check each of the decorators was properly closed
        assertEquals(9, TestRepositoryDecoratorFactory.CLOSE_COUNT.get());
    }
View Full Code Here

        File customConfDir = setupConfDirectory(tmpDir);
        System.setProperty("lily.conf.dir", basedir + "/../server/conf");
        System.setProperty("lily.conf.customdir", customConfDir.getAbsolutePath());

        try {
            LilyProxy lilyProxy = new LilyProxy();
            lilyProxy.start();
            return lilyProxy;
        } finally {
            // Make sure it's properties won't be used by later-running tests
            System.getProperties().remove("lily.plugin.dir");
            System.getProperties().remove("lily.conf.dir");
View Full Code Here

    /**
     * Verifies the authorization context is properly passed on to HBase.
     */
    @Test
    public void testAuthContextPassOn() throws Exception {
        LilyProxy lilyProxy = new LilyProxy();
        System.setProperty("lily.test.hbase.coprocessor.region.classes", AuthzRegionObserver.class.getName());
        lilyProxy.start();

        // Set the authorization context
        setUser("jules", Sets.newHashSet("engineering"));

        // In-VM access to the repository manager (not going over the RPC interface)
        RepositoryManager repositoryManager = (RepositoryManager)lilyProxy.getLilyServerProxy()
                .getLilyServerTestingUtility().getRuntime().getJavaServiceManager()
                .getService(org.lilyproject.repository.api.RepositoryManager.class);

        // Create a record type
        LRepository repository = repositoryManager.getDefaultRepository();
View Full Code Here

            }
            if (arg.startsWith("n=")) {
                nrOfTimes = Integer.valueOf(arg.substring(2));
            }
        }
        lilyProxy = new LilyProxy();
        lilyProxy.start();
        LilyClient lilyClient = lilyProxy.getLilyServerProxy().getClient();
        repository = lilyClient.getRepository();
        typeManager = repository.getTypeManager();
        resetDurations();
View Full Code Here

public class LilyClientTest {
    private static LilyProxy lilyProxy;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        lilyProxy = new LilyProxy();
        lilyProxy.start();
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.lilyservertestfw.LilyProxy

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.