use of org.apache.sling.distribution.packaging.DistributionPackageInfo in project sling by apache.
the class SimpleDistributionAgentTest method testDistributionWithAllowedRoot.
@Test
public void testDistributionWithAllowedRoot() throws Exception {
String name = "sample-agent";
DistributionPackageImporter packageImporter = mock(DistributionPackageImporter.class);
DistributionPackageExporter packageExporter = mock(DistributionPackageExporter.class);
DistributionRequestAuthorizationStrategy packageExporterStrategy = mock(DistributionRequestAuthorizationStrategy.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DistributionQueueDispatchingStrategy queueDistributionStrategy = mock(DistributionQueueDispatchingStrategy.class);
DistributionEventFactory distributionEventFactory = mock(DistributionEventFactory.class);
ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
when(queueDistributionStrategy.add(any(DistributionPackage.class), any(DistributionQueueProvider.class))).thenReturn(Collections.singletonList(new DistributionQueueItemStatus(DistributionQueueItemState.QUEUED, "default")));
SimpleDistributionAgent agent = new SimpleDistributionAgent(name, false, null, "serviceName", packageImporter, packageExporter, packageExporterStrategy, queueProvider, queueDistributionStrategy, null, distributionEventFactory, resolverFactory, mock(SlingRepository.class), mock(DefaultDistributionLog.class), null, new String[] { "/content" }, 0);
DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/content");
final DistributionPackage distributionPackage = mock(DistributionPackage.class);
DistributionPackageInfo packageInfo = new DistributionPackageInfo("type");
when(distributionPackage.getInfo()).thenReturn(packageInfo);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
queueDistributionStrategy.add(distributionPackage, queueProvider);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
((DistributionPackageProcessor) args[2]).process(distributionPackage);
return null;
}
}).when(packageExporter).exportPackages(any(ResourceResolver.class), any(DistributionRequest.class), any(DistributionPackageProcessor.class));
when(queueProvider.getQueue(DistributionQueueDispatchingStrategy.DEFAULT_QUEUE_NAME)).thenReturn(new SimpleDistributionQueue(name, "name"));
DistributionResponse response = agent.execute(resourceResolver, request);
assertTrue(response.isSuccessful());
}
use of org.apache.sling.distribution.packaging.DistributionPackageInfo in project sling by apache.
the class ReferencePackageTest method testAcquire.
@Test
public void testAcquire() throws Exception {
DistributionPackage distributionPackage = mock(DistributionPackage.class);
String type = "dummy";
when(distributionPackage.getType()).thenReturn(type);
DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
when(distributionPackage.getInfo()).thenReturn(info);
ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
assertNotNull(referencePackage);
referencePackage.acquire("queue1", "queue2");
}
use of org.apache.sling.distribution.packaging.DistributionPackageInfo in project sling by apache.
the class ReferencePackageTest method testGetId.
@Test
public void testGetId() throws Exception {
DistributionPackage distributionPackage = mock(DistributionPackage.class);
String type = "dummy";
when(distributionPackage.getType()).thenReturn(type);
DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
when(distributionPackage.getInfo()).thenReturn(info);
ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
assertNotNull(referencePackage);
String id = referencePackage.getId();
assertNotNull(id);
}
use of org.apache.sling.distribution.packaging.DistributionPackageInfo in project sling by apache.
the class ReferencePackageTest method testCreateInputStream.
@Test
public void testCreateInputStream() throws Exception {
DistributionPackage distributionPackage = mock(DistributionPackage.class);
String type = "dummy";
when(distributionPackage.getType()).thenReturn(type);
DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
when(distributionPackage.getInfo()).thenReturn(info);
ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
assertNotNull(referencePackage);
InputStream inputStream = referencePackage.createInputStream();
assertNotNull(inputStream);
}
use of org.apache.sling.distribution.packaging.DistributionPackageInfo in project sling by apache.
the class ReferencePackageTest method testClose.
@Test
public void testClose() throws Exception {
DistributionPackage distributionPackage = mock(DistributionPackage.class);
String type = "dummy";
when(distributionPackage.getType()).thenReturn(type);
DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
when(distributionPackage.getInfo()).thenReturn(info);
ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
assertNotNull(referencePackage);
referencePackage.close();
}
Aggregations