use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_defaultWarPackaging.
@Test
public void testEntrypoint_defaultWarPackaging() throws IOException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(projectProperties.isWarProject()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/usr/local/jetty/start.jar").inOrder();
verifyNoInteractions(logger);
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnExpandClasspathDependencies.
@Test
public void testEntrypoint_warningOnExpandClasspathDependencies() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getEntrypoint()).thenReturn(Optional.of(Arrays.asList("custom", "entrypoint")));
when(rawConfiguration.getExpandClasspathDependencies()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("custom", "entrypoint").inOrder();
verify(projectProperties).log(LogEvent.warn("mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies are ignored " + "when entrypoint is specified"));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_extraClasspathNonWarPackaging.
@Test
public void testEntrypoint_extraClasspathNonWarPackaging() throws IOException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getExtraClasspath()).thenReturn(Collections.singletonList("/foo"));
when(projectProperties.isWarProject()).thenReturn(false);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-cp", "/foo:/app/resources:/app/classes:/app/libs/*", "java.lang.Object").inOrder();
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 testUser_null.
@Test
public void testUser_null() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getUser()).isNull();
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testPluginConfigurationProcessor_extraDirectory.
@Test
public void testPluginConfigurationProcessor_extraDirectory() throws URISyntaxException, InvalidContainerVolumeException, MainClassInferenceException, InvalidAppRootException, IOException, IncompatibleBaseImageJavaVersionException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidImageReferenceException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
Path extraDirectory = Paths.get(Resources.getResource("core/layer").toURI());
Mockito.<List<?>>when(rawConfiguration.getExtraDirectories()).thenReturn(Arrays.asList(new TestExtraDirectoriesConfiguration(extraDirectory)));
when(rawConfiguration.getExtraDirectoryPermissions()).thenReturn(ImmutableMap.of("/target/dir/foo", FilePermissions.fromOctalString("123")));
ContainerBuildPlan buildPlan = processCommonConfiguration();
List<FileEntry> extraFiles = getLayerEntries(buildPlan, "extra files");
assertThat(extraFiles).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(extraDirectory.resolve("a"), extraDirectory.resolve("a/b"), extraDirectory.resolve("a/b/bar"), extraDirectory.resolve("c"), extraDirectory.resolve("c/cat"), extraDirectory.resolve("foo"));
assertThat(extraFiles).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/target/dir/a", "/target/dir/a/b", "/target/dir/a/b/bar", "/target/dir/c", "/target/dir/c/cat", "/target/dir/foo");
Optional<FileEntry> fooEntry = extraFiles.stream().filter(layerEntry -> layerEntry.getExtractionPath().equals(AbsoluteUnixPath.get("/target/dir/foo"))).findFirst();
assertThat(fooEntry).isPresent();
assertThat(fooEntry.get().getPermissions().toOctalString()).isEqualTo("123");
}
Aggregations