Search in sources :

Example 11 with OptionsByType

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"));
}
Also used : ClassPath(com.oracle.bedrock.runtime.java.ClassPath) MetaClass(com.oracle.bedrock.runtime.MetaClass) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 12 with OptionsByType

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")));
}
Also used : ClassPath(com.oracle.bedrock.runtime.java.ClassPath) MetaClass(com.oracle.bedrock.runtime.MetaClass) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 13 with OptionsByType

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()));
}
Also used : ClassPath(com.oracle.bedrock.runtime.java.ClassPath) MetaClass(com.oracle.bedrock.runtime.MetaClass) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 14 with OptionsByType

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"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Arguments(com.oracle.bedrock.runtime.options.Arguments) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 15 with OptionsByType

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"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Arguments(com.oracle.bedrock.runtime.options.Arguments) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Aggregations

OptionsByType (com.oracle.bedrock.OptionsByType)171 Test (org.junit.Test)102 Platform (com.oracle.bedrock.runtime.Platform)56 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)30 Arguments (com.oracle.bedrock.runtime.options.Arguments)25 MetaClass (com.oracle.bedrock.runtime.MetaClass)24 Properties (java.util.Properties)19 File (java.io.File)18 Application (com.oracle.bedrock.runtime.Application)13 Option (com.oracle.bedrock.Option)12 DeployedArtifacts (com.oracle.bedrock.runtime.remote.DeployedArtifacts)10 DeploymentArtifact (com.oracle.bedrock.runtime.remote.DeploymentArtifact)10 EnvironmentVariables (com.oracle.bedrock.runtime.options.EnvironmentVariables)9 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)9 Session (com.jcraft.jsch.Session)8 Timeout (com.oracle.bedrock.options.Timeout)8 DisplayName (com.oracle.bedrock.runtime.options.DisplayName)8 SimpleJUnitTestRun (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun)8 ArrayList (java.util.ArrayList)8 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)7