use of org.apache.sling.distribution.packaging.DistributionPackage 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();
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class AgentDistributionPackageExporterTest method testTestExport.
@Test
public void testTestExport() throws Exception {
AgentDistributionPackageExporter distributionPackageExporter = new AgentDistributionPackageExporter(null, mock(DistributionAgent.class), mock(DistributionPackageBuilderProvider.class), null);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
// vargarg doesn't match and causes compiler warning
String[] args = new String[0];
DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.TEST, args);
final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
distributionPackageExporter.exportPackages(resourceResolver, distributionRequest, new DistributionPackageProcessor() {
@Override
public void process(DistributionPackage distributionPackage) {
distributionPackages.add(distributionPackage);
}
@Override
public List<DistributionResponse> getAllResponses() {
return null;
}
@Override
public int getPackagesCount() {
return 0;
}
@Override
public long getPackagesSize() {
return 0;
}
});
assertNotNull(distributionPackages);
assertEquals(1, distributionPackages.size());
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class ImportingDistributionPackageProcessorTest method testProcess.
@Test
public void testProcess() throws Exception {
DistributionPackageImporter importer = mock(DistributionPackageImporter.class);
SlingRepository repository = mock(SlingRepository.class);
String agentService = "agentService";
ResourceResolverFactory resourceResolverFactory = mock(ResourceResolverFactory.class);
String subServiceName = "ssn";
SimpleDistributionAgentAuthenticationInfo authInfo = new SimpleDistributionAgentAuthenticationInfo(repository, agentService, resourceResolverFactory, subServiceName);
String callingUser = "foo";
String requestId = "123";
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
ImportingDistributionPackageProcessor processor = new ImportingDistributionPackageProcessor(importer, authInfo, callingUser, requestId, log);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
Map<String, Object> map = new HashMap<String, Object>();
map.put(DistributionPackageInfo.PROPERTY_REQUEST_PATHS, "/");
map.put(DistributionPackageInfo.PROPERTY_REQUEST_TYPE, DistributionRequestType.TEST);
DistributionPackageInfo info = new DistributionPackageInfo("foo", map);
when(distributionPackage.getInfo()).thenReturn(info);
processor.process(distributionPackage);
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class RemoteDistributionPackageExporterTest method testNothingExported.
@Test
public void testNothingExported() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
String[] endpoints = new String[0];
RemoteDistributionPackageExporter remotedistributionPackageExporter = new RemoteDistributionPackageExporter(mock(DefaultDistributionLog.class), packageBuilder, distributionTransportSecretProvider, endpoints, 1, new HttpConfiguration(10000));
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
remotedistributionPackageExporter.exportPackages(resourceResolver, distributionRequest, new DistributionPackageProcessor() {
@Override
public void process(DistributionPackage distributionPackage) {
distributionPackages.add(distributionPackage);
}
@Override
public List<DistributionResponse> getAllResponses() {
return null;
}
@Override
public int getPackagesCount() {
return 0;
}
@Override
public long getPackagesSize() {
return 0;
}
});
assertNotNull(distributionPackages);
assertTrue(distributionPackages.isEmpty());
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class LocalDistributionPackageExporterTest method testGetPackage.
@Test
public void testGetPackage() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
when(packageBuilder.getPackage(any(ResourceResolver.class), any(String.class))).thenReturn(mock(DistributionPackage.class));
LocalDistributionPackageExporter localdistributionPackageExporter = new LocalDistributionPackageExporter(packageBuilder);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = localdistributionPackageExporter.getPackage(resourceResolver, "123");
assertNotNull(distributionPackage);
}
Aggregations