use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypointClasspath_nonDefaultAppRoot.
@Test
public void testEntrypointClasspath_nonDefaultAppRoot() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getAppRoot()).thenReturn("/my/app");
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-cp", "/my/app/resources:/my/app/classes:/my/app/libs/*", "java.lang.Object").inOrder();
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testWebAppEntrypoint_inheritedFromCustomBaseImage.
@Test
public void testWebAppEntrypoint_inheritedFromCustomBaseImage() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(projectProperties.isWarProject()).thenReturn(true);
when(rawConfiguration.getFromImage()).thenReturn(Optional.of("custom-base-image"));
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).isNull();
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testPluginConfigurationProcessor_defaults.
@Test
public void testPluginConfigurationProcessor_defaults() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-cp", "/app/resources:/app/classes:/app/libs/*", "java.lang.Object").inOrder();
verify(containerizer).setBaseImageLayersCache(Containerizer.DEFAULT_BASE_CACHE_DIRECTORY);
verify(containerizer).setApplicationLayersCache(appCacheDirectory);
ArgumentMatcher<LogEvent> isLogWarn = logEvent -> logEvent.getLevel() == LogEvent.Level.WARN;
verify(logger, never()).accept(argThat(isLogWarn));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testClasspathArgumentFile_mainClassInferenceFailureWithCustomEntrypoint.
@Test
public void testClasspathArgumentFile_mainClassInferenceFailureWithCustomEntrypoint() throws NumberFormatException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, IOException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getMainClass()).thenReturn(Optional.of("invalid main class"));
when(rawConfiguration.getEntrypoint()).thenReturn(Optional.of(Arrays.asList("bash")));
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("bash");
List<FileEntry> jvmArgFiles = getLayerEntries(buildPlan, "jvm arg files");
assertThat(jvmArgFiles).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(appCacheDirectory.resolve("jib-classpath-file"), appCacheDirectory.resolve("jib-main-class-file"));
assertThat(jvmArgFiles).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/app/jib-classpath-file", "/app/jib-main-class-file");
String classpath = new String(Files.readAllBytes(appCacheDirectory.resolve("jib-classpath-file")), StandardCharsets.UTF_8);
assertThat(classpath).isEqualTo("/app/resources:/app/classes:/app/libs/*");
String mainClass = new String(Files.readAllBytes(appCacheDirectory.resolve("jib-main-class-file")), StandardCharsets.UTF_8);
assertThat(mainClass).isEqualTo("could-not-infer-a-main-class");
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testUser.
@Test
public void testUser() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getUser()).thenReturn(Optional.of("customUser"));
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getUser()).isEqualTo("customUser");
}
Aggregations