use of io.fabric8.maven.generator.api.GeneratorContext in project fabric8-maven-plugin by fabric8io.
the class JavaExecGeneratorMainClassDeterminationTest method testMainClassDeterminationFromConfig.
/**
* The main class is determined via config in a non-fat-jar deployment
* @throws MojoExecutionException
*/
@Test
public void testMainClassDeterminationFromConfig() throws MojoExecutionException {
new MockBuild();
new MockProcessorConfig("the.main.ClassName");
new MockMavenProject();
final GeneratorContext generatorContext = new GeneratorContext.Builder().project(new MavenProject()).config(new ProcessorConfig()).strategy(OpenShiftBuildStrategy.docker).logger(log).build();
JavaExecGenerator generator = new JavaExecGenerator(generatorContext);
final List<ImageConfiguration> images = new ArrayList<ImageConfiguration>();
List<ImageConfiguration> customized = generator.customize(images, false);
assertEquals("1 images returned", (long) 1, (long) customized.size());
ImageConfiguration imageConfig = customized.get(0);
assertEquals("Image name", "TheImageName", imageConfig.getName());
assertEquals("Main Class set as environment variable", "the.main.ClassName", imageConfig.getBuildConfiguration().getEnv().get(JavaExecGenerator.JAVA_MAIN_CLASS_ENV_VAR));
}
use of io.fabric8.maven.generator.api.GeneratorContext in project fabric8-maven-plugin by fabric8io.
the class JavaExecGeneratorMainClassDeterminationTest method testMainClassDeterminationFromDetectionOnNonFatJar.
/**
* The main class is determined via main class detection in a non-fat-jar deployment
* @throws MojoExecutionException
*/
@Test
public void testMainClassDeterminationFromDetectionOnNonFatJar() throws MojoExecutionException {
new MockBuild();
new MockProcessorConfig(null);
new MockMavenProject();
new MockFatJarDetector(false);
new MockClassUtils();
final GeneratorContext generatorContext = new GeneratorContext.Builder().project(new MavenProject()).config(new ProcessorConfig()).strategy(OpenShiftBuildStrategy.docker).logger(log).build();
JavaExecGenerator generator = new JavaExecGenerator(generatorContext);
final List<ImageConfiguration> images = new ArrayList<ImageConfiguration>();
List<ImageConfiguration> customized = generator.customize(images, false);
assertEquals("1 images returned", (long) 1, (long) customized.size());
ImageConfiguration imageConfig = customized.get(0);
assertEquals("Image name", "TheImageName", imageConfig.getName());
assertEquals("Main Class set as environment variable", "the.detected.MainClass", imageConfig.getBuildConfiguration().getEnv().get(JavaExecGenerator.JAVA_MAIN_CLASS_ENV_VAR));
}
use of io.fabric8.maven.generator.api.GeneratorContext in project fabric8-maven-plugin by fabric8io.
the class JavaExecGeneratorMainClassDeterminationTest method testMainClassDeterminationFromFatJar.
/**
* The main class is determined as the Main-Class of a fat jar
* @throws MojoExecutionException
*/
@Test
public void testMainClassDeterminationFromFatJar() throws MojoExecutionException {
new MockBuild();
new MockProcessorConfig(null);
new MockMavenProject();
new MockFatJarDetector(true);
new MockJavaExecGenerator();
final GeneratorContext generatorContext = new GeneratorContext.Builder().project(new MavenProject()).config(new ProcessorConfig()).strategy(OpenShiftBuildStrategy.docker).logger(log).build();
JavaExecGenerator generator = new JavaExecGenerator(generatorContext);
final List<ImageConfiguration> images = new ArrayList<ImageConfiguration>();
List<ImageConfiguration> customized = generator.customize(images, false);
assertEquals("1 images returned", (long) 1, (long) customized.size());
ImageConfiguration imageConfig = customized.get(0);
assertEquals("Image name", "TheImageName", imageConfig.getName());
assertNull("Main Class is NOT set as environment variable#", imageConfig.getBuildConfiguration().getEnv().get(JavaExecGenerator.JAVA_MAIN_CLASS_ENV_VAR));
}
Aggregations