use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.
the class EnricherManagerTest method createDefaultResources.
@Test
public void createDefaultResources() {
new Expectations() {
{
context.getConfig();
result = new ProcessorConfig(Arrays.asList("fmp-controller"), null, null);
context.getImages();
result = new ImageConfiguration.Builder().alias("img1").name("img1").build();
}
};
EnricherManager manager = new EnricherManager(null, context);
KubernetesListBuilder builder = new KubernetesListBuilder();
manager.createDefaultResources(builder);
assertTrue(builder.build().getItems().size() > 0);
}
use of io.fabric8.maven.core.config.ProcessorConfig 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.core.config.ProcessorConfig 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.core.config.ProcessorConfig 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));
}
use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.
the class AutoTLSEnricherTest method testSecretName.
@Test
public void testSecretName() throws Exception {
final SecretNameTestConfig[] data = new SecretNameTestConfig[] { new SecretNameTestConfig(PlatformMode.kubernetes, null, null), new SecretNameTestConfig(PlatformMode.openshift, null, "projectA-tls"), new SecretNameTestConfig(PlatformMode.openshift, "custom-secret", "custom-secret") };
for (final SecretNameTestConfig tc : data) {
final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap(AutoTLSEnricher.ENRICHER_NAME, new TreeMap(Collections.singletonMap(AutoTLSEnricher.Config.tlsSecretName.name(), tc.tlsSecretNameConfig))));
final Properties projectProps = new Properties();
projectProps.put(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE, tc.mode.name());
// Setup mock behaviour
new Expectations() {
{
project.getProperties();
result = projectProps;
project.getArtifactId();
result = "projectA";
minTimes = 0;
context.getProject();
result = project;
context.getConfig();
result = config;
}
};
AutoTLSEnricher enricher = new AutoTLSEnricher(context);
Map<String, String> annotations = enricher.getAnnotations(Kind.SERVICE);
if (tc.mode == PlatformMode.kubernetes) {
assertNull(annotations);
continue;
}
assertEquals(1, annotations.size());
assertEquals(tc.tlsSecretName, annotations.get(AutoTLSEnricher.AUTOTLS_ANNOTATION_KEY));
}
}
Aggregations