Builder addArchive(Archive<?> archive) { this.archive.add(archive, ROOT_ARCHIVE_PATH, ZipExporter.class); return this; }
public Builder addResource(Asset resource, String target) { archive.add(resource, target); return this; }
private Builder(String name, ClassPath.Builder classPathBuilder) { this.classPathBuilder = classPathBuilder; this.archive = ShrinkWrap.create(GenericArchive.class, name).add(EmptyAsset.INSTANCE, MARKER_FILE_ARCHIVE_PATH); }
private Builder() { this.archive = ShrinkWrap.create(GenericArchive.class).add(EmptyAsset.INSTANCE, MARKER_FILE_ARCHIVE_PATH); this.systemProperties = new Properties(); this.files = new HashSet<>(); }
public Builder addClass(Class<?> clazz) { archive.add(new ClassAsset(clazz), ClassPath.ROOT_ARCHIVE_PATH + clazz.getName()); return this; }
public static Payload tarredDockerfile() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ShrinkWrap.create(GenericArchive.class, "archive.tar") .add(new ClassLoaderAsset("Dockerfile"), "Dockerfile") .as(TarExporter.class).exportTo(bytes); return Payloads.newByteArrayPayload(bytes.toByteArray()); } }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class).from("tomee").exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class) .from(BASE_IMAGE) .exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class).from("mysql").exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); } }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class).from("tomee").exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); } }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class).from("tomee").exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class) .from(BASE_IMAGE) .exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); } }
@CubeDockerFile public static Archive<?> createDockerfile() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class) .from(BASE_IMAGE) .exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); }
@CubeDockerFile public static Archive<?> createContainer() { String dockerDescriptor = Descriptors.create(DockerDescriptor.class) .from("jonmorehouse/ping-pong") .expose(8080) .exportAsString(); return ShrinkWrap.create(GenericArchive.class) .add(new StringAsset(dockerDescriptor), "Dockerfile"); }
@Test public void testImportArchiveAsTypeFromFilter() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); Collection<JavaArchive> jars = archive .getAsType(JavaArchive.class, Filters.include(".*jar"), ArchiveFormat.ZIP); Assert.assertEquals("Unexpected result found", 1, jars.size()); JavaArchive jar = jars.iterator().next().add(new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromString() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath, ArchiveFormat.ZIP).add( new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromArchivePath() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath), ArchiveFormat.ZIP) .add(new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromStringUsingDefaultFormat() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath).add(new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromArchivePathUsingDefaultFormat() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath)).add( new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }