Examples of DecoratingRepositoryManager


Examples of org.lilyproject.server.modules.repository.DecoratingRepositoryManager

        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());
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.