use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class JavaExecGeneratorTest method createAssemblyWithNoFatJarShouldAddDefaultFileSets.
@Test
public void createAssemblyWithNoFatJarShouldAddDefaultFileSets() {
// When
final AssemblyConfiguration result = new JavaExecGenerator(generatorContext).createAssembly();
// Then
assertThat(result).hasFieldOrPropertyWithValue("excludeFinalOutputArtifact", false).extracting(AssemblyConfiguration::getLayers).asList().hasSize(1).first().asInstanceOf(InstanceOfAssertFactories.type(Assembly.class)).extracting(Assembly::getFileSets).asList().hasSize(2);
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class JavaExecGeneratorTest method createAssemblyWithFatJarShouldAddDefaultFileSetsAndFatJar.
@Test
public void createAssemblyWithFatJarShouldAddDefaultFileSetsAndFatJar(@Mocked FatJarDetector fatJarDetector, @Mocked FatJarDetector.Result fjResult) {
// Given
// @formatter:off
new Expectations() {
{
generatorContext.getProject().getBuildPackageDirectory();
result = new File("");
generatorContext.getProject().getBaseDirectory();
result = new File("");
fjResult.getArchiveFile();
result = new File("fat.jar");
fatJarDetector.scan();
result = fjResult;
}
};
// @formatter:on
// When
final AssemblyConfiguration result = new JavaExecGenerator(generatorContext).createAssembly();
// Then
assertThat(result).hasFieldOrPropertyWithValue("excludeFinalOutputArtifact", true).extracting(AssemblyConfiguration::getLayers).asList().hasSize(1).first().asInstanceOf(InstanceOfAssertFactories.type(Assembly.class)).extracting(Assembly::getFileSets).asList().hasSize(3).extracting("directory", "includes").containsExactlyInAnyOrder(tuple(new File("src/main/jkube-includes"), Collections.emptyList()), tuple(new File("src/main/jkube-includes/bin"), Collections.emptyList()), tuple(new File(""), Collections.singletonList("fat.jar")));
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class KarafGeneratorTest method customizeWithKarafMavenPluginShouldAddImageConfiguration.
@Test
public void customizeWithKarafMavenPluginShouldAddImageConfiguration(@Mocked Plugin plugin) {
// Given
final List<ImageConfiguration> originalImageConfigurations = new ArrayList<>();
// @formatter:off
new Expectations() {
{
plugin.getGroupId();
result = "org.apache.karaf.tooling";
minTimes = 0;
plugin.getArtifactId();
result = "karaf-maven-plugin";
minTimes = 0;
generatorContext.getProject().getPlugins();
result = Collections.singletonList(plugin);
minTimes = 0;
generatorContext.getProject().getBuildDirectory();
result = temporaryFolder.getRoot();
generatorContext.getProject().getVersion();
result = "1.33.7-SNAPSHOT";
generatorContext.getConfig();
result = new ProcessorConfig();
}
};
// @formatter:on
// When
final List<ImageConfiguration> result = new KarafGenerator(generatorContext).customize(originalImageConfigurations, false);
// Then
assertThat(originalImageConfigurations, sameInstance(result));
assertThat(result, hasSize(1));
final ImageConfiguration imageConfiguration = result.iterator().next();
assertThat(imageConfiguration.getName(), equalTo("%g/%a:%l"));
assertThat(imageConfiguration.getAlias(), equalTo("karaf"));
final BuildConfiguration bc = imageConfiguration.getBuildConfiguration();
assertThat(bc.getTags(), contains("latest"));
assertThat(bc.getPorts(), contains("8181", "8778"));
assertThat(bc.getEnv(), hasEntry("DEPLOYMENTS_DIR", "/deployments"));
assertThat(bc.getEnv(), hasEntry("KARAF_HOME", "/deployments/karaf"));
final AssemblyConfiguration ac = bc.getAssembly();
assertThat(ac.getName(), equalTo("deployments"));
assertThat(ac.isExcludeFinalOutputArtifact(), equalTo(false));
assertThat(ac.getLayers(), hasSize(1));
assertThat(ac.getLayers().iterator().next().getFileSets(), contains(allOf(hasProperty("directory", equalTo(new File(temporaryFolder.getRoot(), "assembly"))), hasProperty("outputDirectory", equalTo(new File("karaf"))), hasProperty("directoryMode", equalTo("0775"))), allOf(hasProperty("directory", equalTo(temporaryFolder.getRoot().toPath().resolve("assembly").resolve("bin").toFile())), hasProperty("outputDirectory", equalTo(new File("karaf", "bin"))), hasProperty("fileMode", equalTo("0777")), hasProperty("directoryMode", equalTo("0775")))));
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method minimumRequiredFieldsWithAssemblyId.
/**
* @see #minimumRequiredFields()
*/
@Test
public void minimumRequiredFieldsWithAssemblyId() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).build();
final Assembly layer = Assembly.builder().id("layer-1").build();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("deployments").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).hasSize(16);
FileAssertions.assertThat(new File(outputDirectory, "layer-1")).exists().fileTree().containsExactlyInAnyOrder("deployments", "deployments/source-directory", "deployments/source-directory/1.txt", "deployments/source-directory/3.other", "deployments/source-directory/37", "deployments/source-directory/one", "deployments/source-directory/one/1.txt", "deployments/source-directory/one/3.other", "deployments/source-directory/one/37", "deployments/source-directory/two", "deployments/source-directory/two/1.txt", "deployments/source-directory/two/3.other", "deployments/source-directory/two/37", "deployments/source-directory/three", "deployments/source-directory/three/1.txt", "deployments/source-directory/three/3.other", "deployments/source-directory/three/37");
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardHierarchicalInclude.
@Test
public void wildcardHierarchicalInclude() throws IOException {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**/*.txt").fileMode("0766").build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).hasSize(3);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/one", "source-directory/one/1.txt", "source-directory/two", "source-directory/two/1.txt", "source-directory/three", "source-directory/three/1.txt");
}
Aggregations