use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findByRepoTagPatternInvalidPattern.
@Test(expected = PatternSyntaxException.class)
public void findByRepoTagPatternInvalidPattern() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTagPattern("*(?", nonEmpty));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findByRepoTagEmptyManifest.
@Test
public void findByRepoTagEmptyManifest() {
ImageArchiveManifest empty = new ImageArchiveManifestAdapter(new JsonArray());
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag("anything", empty));
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag("anything", null));
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag(null, null));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findEntriesByRepoTagPatternInvalidPattern.
@Test(expected = PatternSyntaxException.class)
public void findEntriesByRepoTagPatternInvalidPattern() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
Assert.assertNull(ImageArchiveUtil.findEntryByRepoTagPattern("*(?", nonEmpty));
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method readInvalidJsonInArchive.
@Test
public void readInvalidJsonInArchive() 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("not-the-" + 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);
}
use of io.fabric8.maven.docker.model.ImageArchiveManifest in project docker-maven-plugin by fabric8io.
the class ImageArchiveUtilTest method findEntriesByRepoTagPatternSuccessfully.
@Test
public void findEntriesByRepoTagPatternSuccessfully() {
ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
Map<String, ImageArchiveManifestEntry> entries;
// Complete match
entries = ImageArchiveUtil.findEntriesByRepoTagPattern("test/image:latest", nonEmpty);
Assert.assertNotNull(entries);
Assert.assertNotNull(entries.get("test/image:latest"));
Assert.assertTrue(entries.get("test/image:latest").getRepoTags().contains("test/image:latest"));
// Unanchored match
entries = ImageArchiveUtil.findEntriesByRepoTagPattern("test/image", nonEmpty);
Assert.assertNotNull(entries);
Assert.assertNotNull(entries.get("test/image:latest"));
Assert.assertTrue(entries.get("test/image:latest").getRepoTags().contains("test/image:latest"));
// Initial anchor
entries = ImageArchiveUtil.findEntriesByRepoTagPattern("^test/image", nonEmpty);
Assert.assertNotNull(entries);
Assert.assertNotNull(entries.get("test/image:latest"));
Assert.assertTrue(entries.get("test/image:latest").getRepoTags().contains("test/image:latest"));
}
Aggregations