use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findByRepoTagPatternNonEmptyManifest.
@Test
public void findByRepoTagPatternNonEmptyManifest() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTagPattern("does/not:match", nonEmpty));
// Anchored pattern
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTagPattern("^test/image$", nonEmpty));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findByRepoTagSuccessfully.
@Test
public void findByRepoTagSuccessfully() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
ImageArchiveManifestEntry found = ImageArchiveUtil.findEntryByRepoTag("test/image:latest", nonEmpty);
Assert.assertNotNull(found);
Assert.assertTrue(found.getRepoTags().contains("test/image:latest"));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method readEmptyArchive.
@Test
public void readEmptyArchive() throws IOException {
byte[] emptyTar;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(baos)) {
tarOutput.finish();
emptyTar = baos.toByteArray();
}
ImageArchiveManifest manifest = ImageArchiveUtil.readManifest(new ByteArrayInputStream(emptyTar));
Assert.assertNull(manifest);
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method mapEntriesByIdSuccessfully.
@Test
public void mapEntriesByIdSuccessfully() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
Map<String, ImageArchiveManifestEntry> entries = ImageArchiveUtil.mapEntriesById(nonEmpty.getEntries());
Assert.assertNotNull(entries);
Assert.assertEquals(1, entries.size());
Assert.assertNotNull(entries.get("image-id-sha256"));
Assert.assertTrue(entries.get("image-id-sha256").getRepoTags().contains("test/image:latest"));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method readInvalidManifestInArchive.
@Test(expected = JsonParseException.class)
public void readInvalidManifestInArchive() throws IOException {
byte[] archiveBytes;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(baos)) {
final byte[] entryData = ("}" + UUID.randomUUID().toString() + "{").getBytes();
TarArchiveEntry tarEntry = new TarArchiveEntry(ImageArchiveUtil.MANIFEST_JSON);
tarEntry.setSize(entryData.length);
tarOutput.putArchiveEntry(tarEntry);
tarOutput.write(entryData);
tarOutput.closeArchiveEntry();
tarOutput.finish();
archiveBytes = baos.toByteArray();
}
ImageArchiveManifest manifest = ImageArchiveUtil.readManifest(new ByteArrayInputStream(archiveBytes));
Assert.assertNull(manifest);
}
Aggregations