use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.
the class RhinoScriptTest method setUp.
/*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
ctx = ApplicationContextHelper.getApplicationContext();
transactionService = (TransactionService) ctx.getBean("transactionComponent");
contentService = (ContentService) ctx.getBean("contentService");
nodeService = (NodeService) ctx.getBean("nodeService");
scriptService = (ScriptService) ctx.getBean("scriptService");
serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
BaseNodeServiceTest.loadModel(ctx);
}
use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.
the class PolicyComponentTest method setUp.
@Override
protected void setUp() throws Exception {
// Instantiate Dictionary Service
TenantService tenantService = new SingleTServiceImpl();
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
dictionaryDAO.setTenantService(tenantService);
initDictionaryCaches(dictionaryDAO, tenantService);
DictionaryBootstrap bootstrap = new DictionaryBootstrap();
List<String> bootstrapModels = new ArrayList<String>();
bootstrapModels.add("alfresco/model/dictionaryModel.xml");
bootstrapModels.add("alfresco/model/systemModel.xml");
bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml");
bootstrapModels.add(TEST_MODEL);
bootstrap.setModels(bootstrapModels);
bootstrap.setDictionaryDAO(dictionaryDAO);
bootstrap.setTenantService(new SingleTServiceImpl());
bootstrap.bootstrap();
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDAO);
// Instantiate Policy Component
policyComponent = new PolicyComponentImpl(dictionary);
}
use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.
the class PerformanceNodeServiceTest method setUp.
@Override
protected void setUp() throws Exception {
applicationContext = ApplicationContextHelper.getApplicationContext();
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = PerformanceNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
dictionaryService = loadModel(applicationContext);
nodeService = (NodeService) applicationContext.getBean("nodeService");
txnService = (TransactionService) applicationContext.getBean("transactionComponent");
contentService = (ContentService) applicationContext.getBean("contentService");
// create a first store directly
RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>() {
public NodeRef execute() {
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
return nodeService.getRootNode(storeRef);
}
};
rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
}
use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.
the class MTPolicyComponentTest method setUp.
@Override
protected void setUp() throws Exception {
TenantService mockTenantService = mock(TenantService.class);
when(mockTenantService.isEnabled()).thenReturn(true);
when(mockTenantService.getCurrentUserDomain()).thenReturn("test.com");
when(mockTenantService.getDomainUser(any(String.class), any(String.class))).thenReturn("System");
when(mockTenantService.getBaseName(any(NodeRef.class))).thenReturn(new NodeRef(BASE_PROTOCOL, BASE_IDENTIFIER, BASE_ID));
when(mockTenantService.getBaseName(any(StoreRef.class))).thenReturn(new StoreRef(BASE_PROTOCOL, BASE_IDENTIFIER));
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
dictionaryDAO.setTenantService(mockTenantService);
initDictionaryCaches(dictionaryDAO, mockTenantService);
DictionaryBootstrap bootstrap = new DictionaryBootstrap();
List<String> bootstrapModels = new ArrayList<String>();
bootstrapModels.add("alfresco/model/dictionaryModel.xml");
bootstrapModels.add("alfresco/model/systemModel.xml");
bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml");
bootstrapModels.add(TEST_MODEL);
bootstrap.setModels(bootstrapModels);
bootstrap.setDictionaryDAO(dictionaryDAO);
bootstrap.setTenantService(mockTenantService);
bootstrap.bootstrap();
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDAO);
// Instantiate Policy Component
PolicyComponentImpl x = new PolicyComponentImpl(dictionary);
x.setTenantService(mockTenantService);
policyComponent = x;
}
use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.
the class TemplateServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
nodeService = (NodeService) applicationContext.getBean("nodeService");
templateService = (TemplateService) applicationContext.getBean("templateService");
serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
BaseNodeServiceTest.loadModel(applicationContext);
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>() {
@SuppressWarnings("unchecked")
public Object execute() throws Exception {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "template_" + System.currentTimeMillis());
root_node = nodeService.getRootNode(store);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
properties.put(ContentModel.PROP_NAME, (Serializable) "subFolder");
NodeRef subFolderRef = nodeService.createNode(root_node, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subFolder")), ContentModel.TYPE_FOLDER, properties).getChildRef();
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubFolder");
NodeRef subSubFolderRef = nodeService.createNode(subFolderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subSubFolder")), ContentModel.TYPE_FOLDER, properties).getChildRef();
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubSubFolder");
nodeService.createNode(subSubFolderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subSubSubFolder")), ContentModel.TYPE_FOLDER, properties);
BaseNodeServiceTest.buildNodeGraph(nodeService, root_node);
return null;
}
});
}
Aggregations