use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class ReferencePackageTest method testGetType.
@Test
public void testGetType() 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);
assertEquals(type, referencePackage.getType());
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class ReferencePackageTest method testGetSize.
@Test
public void testGetSize() 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);
when(distributionPackage.getSize()).thenReturn(10L);
ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
assertNotNull(referencePackage);
long size = referencePackage.getSize();
// failing assertion with assertEquals shows more details in the message
// TODO don't we already know the expetced size? this assertion is not accurate...
assertEquals(size, referencePackage.getSize());
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class ReferencePackageTest method testRelease.
@Test
public void testRelease() 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.release("queue1", "queue2");
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class LocalDistributionPackageExporterTest method testExport.
@Test
public void testExport() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
when(packageBuilder.createPackage(any(ResourceResolver.class), any(DistributionRequest.class))).thenReturn(mock(DistributionPackage.class));
LocalDistributionPackageExporter localdistributionPackageExporter = new LocalDistributionPackageExporter(packageBuilder);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
localdistributionPackageExporter.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());
}
Aggregations