use of org.alfresco.repo.jscript.ClasspathScriptLocation in project alfresco-repository by Alfresco.
the class ReplicationServiceIntegrationTest method testJavascriptAPI.
public void testJavascriptAPI() throws Exception {
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
// Setup some replication tasks
ReplicationDefinition empty = replicationService.createReplicationDefinition(ACTION_NAME, "Empty");
ReplicationDefinition persisted = replicationService.createReplicationDefinition(ACTION_NAME2, "Persisted");
persisted.setTargetName(TRANSFER_TARGET);
persisted.getPayload().add(new NodeRef("workspace://SpacesStore/Testing"));
persisted.getPayload().add(new NodeRef("workspace://SpacesStore/Testing2"));
replicationService.saveReplicationDefinition(persisted);
ReplicationDefinition persisted2 = replicationService.createReplicationDefinition(ACTION_NAME3, "Persisted2");
persisted2.setTargetName("AnotherTarget");
replicationService.saveReplicationDefinition(persisted2);
// Call the test
Map<String, Object> model = new HashMap<String, Object>();
model.put("Empty", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, empty));
model.put("EmptyName", ACTION_NAME);
model.put("Persisted", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, persisted));
model.put("PersistedName", ACTION_NAME2);
model.put("PersistedNodeRef", persisted.getNodeRef().toString());
model.put("PersistedTarget", persisted.getTargetName());
model.put("Persisted2", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, persisted2));
model.put("Persisted2Name", ACTION_NAME3);
model.put("Persisted2NodeRef", persisted2.getNodeRef().toString());
model.put("Persisted2Target", persisted2.getTargetName());
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/replication/script/test_replicationService.js");
this.scriptService.executeScript(location, model);
}
use of org.alfresco.repo.jscript.ClasspathScriptLocation in project alfresco-repository by Alfresco.
the class RenditionServiceIntegrationTest method testJavascriptAPI.
@Test
public void testJavascriptAPI() throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
model.put("testSourceNode", this.nodeWithImageContent);
model.put("testDocNode", this.nodeWithDocContent);
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/rendition/script/test_renditionService.js");
this.scriptService.executeScript(location, model);
}
use of org.alfresco.repo.jscript.ClasspathScriptLocation in project alfresco-repository by Alfresco.
the class ScriptTransferServiceTest method testJSAPI.
// == Test the JavaScript API ==
@Test
public void testJSAPI() throws Exception {
/**
* Prepare some dummy data for tests
*/
TransferTargetImpl dummyTarget = new TransferTargetImpl();
dummyTarget.setName("dummyTarget");
dummyTarget.setNodeRef(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "4"));
Set<TransferTarget> dummyTargets = new HashSet<TransferTarget>();
dummyTargets.add(dummyTarget);
TransferService mockedTransferService = Mockito.mock(TransferService.class);
scriptTransferService.setTransferService(mockedTransferService);
// When the transfer method is called return a node ref - mocks a good call.
// When the transfer method is called with a transfer name of exception - throw a transferException
Mockito.when(mockedTransferService.transfer(Matchers.anyString(), Matchers.isA(TransferDefinition.class))).thenReturn(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "123"));
Mockito.when(mockedTransferService.transfer(Matchers.eq("exception"), Matchers.isA(TransferDefinition.class))).thenThrow(new TransferException("mocked transfer exception"));
// When getTransferTarget called return a TransferTarget
Mockito.when(mockedTransferService.getTransferTarget(Matchers.anyString())).thenReturn(dummyTarget);
Mockito.when(mockedTransferService.getTransferTargets(Matchers.anyString())).thenReturn(dummyTargets);
Mockito.when(mockedTransferService.getTransferTargets()).thenReturn(dummyTargets);
// Execute the unit test script
Map<String, Object> model = new HashMap<String, Object>(1);
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/transfer/script/test_transferService.js");
this.scriptService.executeScript(location, model);
}
use of org.alfresco.repo.jscript.ClasspathScriptLocation in project alfresco-repository by Alfresco.
the class TaggingServiceImplTest method test93JSTagScope.
@Test
@Category({ RedundantTests.class, LuceneTests.class })
public void test93JSTagScope() throws Exception {
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
// Add a load of tags to test the global tag methods with
taggingService.createTag(storeRef, "alpha");
taggingService.createTag(storeRef, "alpha double");
taggingService.createTag(storeRef, "beta");
taggingService.createTag(storeRef, "gamma");
taggingService.createTag(storeRef, "delta");
// Add a load of tags and tag scopes to the object and commit before executing the script
taggingService.addTagScope(folder);
taggingService.addTagScope(subFolder);
taggingService.addTag(subDocument, TAG_1);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(subDocument, TAG_2);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(subDocument, TAG_3);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(subFolder, TAG_1);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(subFolder, TAG_2);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(document, TAG_1);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(document, TAG_2);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
taggingService.addTag(folder, TAG_1);
return null;
}
});
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
Map<String, Object> model = new HashMap<String, Object>(0);
model.put("folder", folder);
model.put("subFolder", subFolder);
model.put("document", document);
model.put("subDocument", subDocument);
model.put("tagScopeTest", true);
model.put("store", storeRef.toString());
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/tagging/script/test_taggingService.js");
scriptService.executeScript(location, model);
// Let the script run
return null;
}
});
}
use of org.alfresco.repo.jscript.ClasspathScriptLocation in project alfresco-repository by Alfresco.
the class ThumbnailServiceImplTest method testJSAPI.
// == Test the JavaScript API ==
@Test
public void testJSAPI() throws Exception {
NodeRef jpgOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
NodeRef gifOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_GIF);
NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF);
NodeRef docOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_WORD);
Map<String, Object> model = new HashMap<String, Object>(2);
model.put("jpgOrig", jpgOrig);
model.put("gifOrig", gifOrig);
model.put("pdfOrig", pdfOrig);
model.put("docOrig", docOrig);
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js");
this.scriptService.executeScript(location, model);
}
Aggregations