use of org.alfresco.repo.tenant.SingleTServiceImpl in project alfresco-repository by Alfresco.
the class RepoDictionaryDAOTest method testADB159.
public void testADB159() throws Exception {
// source dictionary
TenantService tenantService = new SingleTServiceImpl();
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
dictionaryDAO.setTenantService(tenantService);
initDictionaryCaches(dictionaryDAO, tenantService);
// destination dictionary
DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl();
dictionaryDAO2.setTenantService(tenantService);
initDictionaryCaches(dictionaryDAO2, tenantService);
List<String> models = new ArrayList<String>();
models.add("alfresco/model/dictionaryModel.xml");
models.add("alfresco/model/systemModel.xml");
models.add("alfresco/model/contentModel.xml");
models.add("alfresco/model/applicationModel.xml");
models.add("org/alfresco/repo/security/authentication/userModel.xml");
models.add("org/alfresco/repo/action/actionModel.xml");
models.add("org/alfresco/repo/rule/ruleModel.xml");
models.add("org/alfresco/repo/version/version_model.xml");
// round-trip default models
for (String bootstrapModel : models) {
InputStream modelStream = getClass().getClassLoader().getResourceAsStream(bootstrapModel);
if (modelStream == null) {
throw new DictionaryException("Could not find bootstrap model " + bootstrapModel);
}
try {
// parse model from xml
M2Model model = M2Model.createModel(modelStream);
dictionaryDAO.putModel(model);
// regenerate xml from model
ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
model.toXML(xml1);
// register regenerated xml with other dictionary
M2Model model2 = M2Model.createModel(new ByteArrayInputStream(xml1.toByteArray()));
dictionaryDAO2.putModel(model2);
} catch (DictionaryException e) {
throw new DictionaryException("Could not import bootstrap model " + bootstrapModel, e);
}
}
// specific test case
M2Model model = M2Model.createModel("test:adb25");
model.createNamespace(TEST_URL, "test");
model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.DICTIONARY_MODEL_PREFIX);
model.createImport(NamespaceService.SYSTEM_MODEL_1_0_URI, NamespaceService.SYSTEM_MODEL_PREFIX);
model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
M2Type testType = model.createType("test:adb25");
testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName());
M2Property prop1 = testType.createProperty("test:prop1");
prop1.setMandatory(false);
prop1.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
prop1.setMultiValued(false);
ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
model.toXML(xml1);
}
Aggregations