use of com.oracle.bedrock.OptionsByType in project oracle-bedrock by coherence-community.
the class MavenTest method shouldResolveSingleArtifact.
/**
* Ensure that {@link Maven} can resolve a single artifact (without a transitive dependency).
*/
@Test
public void shouldResolveSingleArtifact() {
LocalPlatform platform = LocalPlatform.get();
MetaClass metaClass = new JavaApplication.MetaClass();
OptionsByType optionsByType = OptionsByType.empty();
optionsByType.add(Maven.artifact("org.hamcrest:hamcrest-all:jar:1.3"));
Maven maven = optionsByType.get(Maven.class);
maven.onLaunching(platform, metaClass, optionsByType);
ClassPath classPath = optionsByType.getOrDefault(ClassPath.class, null);
assertThat(classPath, is(not(nullValue())));
assertThat(classPath.size(), is(1));
assertThat(classPath.toString(), containsString("hamcrest-all-1.3.jar"));
}
use of com.oracle.bedrock.OptionsByType in project oracle-bedrock by coherence-community.
the class MavenTest method shouldOverrideArtifacts.
/**
* Ensure that {@link Maven} artifacts of the same group, artifactid, classified and extension
* are overridden when defined multiple times.
*/
@Test
public void shouldOverrideArtifacts() throws IOException {
LocalPlatform platform = LocalPlatform.get();
MetaClass metaClass = new JavaApplication.MetaClass();
OptionsByType optionsByType = OptionsByType.empty();
optionsByType.addAll(Maven.artifact("junit:junit:jar:4.10"), Maven.artifact("junit:junit:jar:4.11"), Maven.artifact("junit:junit:jar:4.12"));
Maven maven = optionsByType.get(Maven.class);
maven.onLaunching(platform, metaClass, optionsByType);
ClassPath classPath = optionsByType.getOrDefault(ClassPath.class, null);
assertThat(classPath, is(not(nullValue())));
// includes transitive dependencies
assertThat(classPath.size(), is(2));
assertThat(classPath.toString(), containsString("junit-4.12.jar"));
assertThat(classPath.toString(), containsString("hamcrest-core-1.3.jar"));
assertThat(classPath.toString(), not(containsString("junit-4.10.jar")));
assertThat(classPath.toString(), not(containsString("junit-4.11.jar")));
}
use of com.oracle.bedrock.OptionsByType in project oracle-bedrock by coherence-community.
the class MavenTest method shouldIncludeAdditionalClassPaths.
/**
* Ensure that {@link Maven} includes additional {@link ClassPath}s when requested.
*/
@Test
public void shouldIncludeAdditionalClassPaths() throws IOException {
LocalPlatform platform = LocalPlatform.get();
MetaClass metaClass = new JavaApplication.MetaClass();
OptionsByType optionsByType = OptionsByType.empty();
optionsByType.addAll(Maven.artifact("junit:junit:jar:4.12"), Maven.include(ClassPath.ofClass(MavenTest.class)), Maven.include(ClassPath.ofResource("example-resource.txt")));
Maven maven = optionsByType.get(Maven.class);
maven.onLaunching(platform, metaClass, optionsByType);
ClassPath classPath = optionsByType.getOrDefault(ClassPath.class, null);
assertThat(classPath, is(not(nullValue())));
assertThat(classPath.size(), is(3));
assertThat(classPath.toString(), containsString("junit-4.12.jar"));
assertThat(classPath.toString(), containsString("hamcrest-core-1.3.jar"));
assertThat(classPath.toString(), containsString(ClassPath.ofClass(MavenTest.class).toString()));
assertThat(classPath.toString(), containsString(ClassPath.ofResource("example-resource.txt").toString()));
}
use of com.oracle.bedrock.OptionsByType in project oracle-bedrock by coherence-community.
the class HelmCommandTest method shouldAddArgumentValues.
@Test
public void shouldAddArgumentValues() throws Exception {
Platform platform = mock(Platform.class);
OptionsByType options = OptionsByType.empty();
HelmCommand command = newInstance();
CLI copy = command.withArguments("arg-1", "arg-2");
assertThat(copy, is(notNullValue()));
assertThat(copy, is(instanceOf(command.getClass())));
assertThat(copy.getCommands(), is(command.getCommands()));
assertThat(copy.getFlags(), is(command.getFlags()));
assertThat(copy.getEnvironment(), is(command.getEnvironment()));
Arguments args = copy.getArguments();
assertThat(args, is(notNullValue()));
List<String> list = args.resolve(platform, options);
assertThat(list, is(notNullValue()));
assertThat(list, contains("arg-1", "arg-2"));
}
use of com.oracle.bedrock.OptionsByType in project oracle-bedrock by coherence-community.
the class HelmCommandTest method shouldAddArgument.
@Test
public void shouldAddArgument() throws Exception {
Platform platform = mock(Platform.class);
OptionsByType options = OptionsByType.empty();
HelmCommand command = newInstance();
CLI copy = command.withArguments(Argument.of("arg-1"), Argument.of("arg-2"));
assertThat(copy, is(notNullValue()));
assertThat(copy, is(instanceOf(command.getClass())));
assertThat(copy.getCommands(), is(command.getCommands()));
assertThat(copy.getFlags(), is(command.getFlags()));
assertThat(copy.getEnvironment(), is(command.getEnvironment()));
Arguments args = copy.getArguments();
assertThat(args, is(notNullValue()));
List<String> list = args.resolve(platform, options);
assertThat(list, is(notNullValue()));
assertThat(list, contains("arg-1", "arg-2"));
}
Aggregations