Search in sources :

Example 1 with MetaClass

use of com.oracle.bedrock.runtime.MetaClass 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 2 with MetaClass

use of com.oracle.bedrock.runtime.MetaClass 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 3 with MetaClass

use of com.oracle.bedrock.runtime.MetaClass 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 4 with MetaClass

use of com.oracle.bedrock.runtime.MetaClass in project oracle-bedrock by coherence-community.

the class ExtendClient method build.

@Override
public ConfigurableCacheFactory build(LocalPlatform platform, CoherenceCluster cluster, OptionsByType optionsByType) {
    // ----- establish the diagnostics output table -----
    Table diagnosticsTable = new Table();
    diagnosticsTable.getOptions().add(Table.orderByColumn(0));
    // ----- establish the options for launching a local extend-based member -----
    optionsByType.add(RoleName.of("extend-client"));
    optionsByType.add(Clustering.disabled());
    optionsByType.add(LocalStorage.disabled());
    optionsByType.add(LocalHost.only());
    optionsByType.add(SystemProperty.of("tangosol.coherence.extend.enabled", true));
    optionsByType.add(CacheConfig.of(cacheConfigURI));
    // ----- notify the Profiles that we're about to launch an application -----
    MetaClass<CoherenceClusterMember> metaClass = new CoherenceClusterMember.MetaClass();
    for (Profile profile : optionsByType.getInstancesOf(Profile.class)) {
        profile.onLaunching(platform, metaClass, optionsByType);
    }
    // ----- create local system properties based on those defined by the launch options -----
    // modify the current system properties to include/override those in the schema
    com.oracle.bedrock.runtime.java.options.SystemProperties systemProperties = optionsByType.get(com.oracle.bedrock.runtime.java.options.SystemProperties.class);
    Properties properties = systemProperties.resolve(platform, optionsByType);
    Table systemPropertiesTable = new Table();
    systemPropertiesTable.getOptions().add(Table.orderByColumn(0));
    systemPropertiesTable.getOptions().add(Cell.Separator.of(""));
    systemPropertiesTable.getOptions().add(Cell.DisplayNull.asEmptyString());
    for (String propertyName : properties.stringPropertyNames()) {
        String propertyValue = properties.getProperty(propertyName);
        systemPropertiesTable.addRow(propertyName + (System.getProperties().containsKey(propertyName) ? "*" : ""), propertyValue);
        System.setProperty(propertyName, propertyValue.isEmpty() ? "" : propertyValue);
    }
    diagnosticsTable.addRow("System Properties", systemPropertiesTable.toString());
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.log(Level.INFO, "Oracle Bedrock " + Bedrock.getVersion() + ": Starting *Extend Client...\n" + "------------------------------------------------------------------------\n" + diagnosticsTable.toString() + "\n" + "------------------------------------------------------------------------\n");
    }
    // ----- establish the session -----
    // create the session
    ConfigurableCacheFactory session = new ScopedCacheFactoryBuilder().getConfigurableCacheFactory(cacheConfigURI, getClass().getClassLoader());
    return session;
}
Also used : Table(com.oracle.bedrock.table.Table) Properties(java.util.Properties) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) Profile(com.oracle.bedrock.runtime.Profile) ScopedCacheFactoryBuilder(com.tangosol.net.ScopedCacheFactoryBuilder) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) MetaClass(com.oracle.bedrock.runtime.MetaClass)

Example 5 with MetaClass

use of com.oracle.bedrock.runtime.MetaClass in project oracle-bedrock by coherence-community.

the class JprofilerProfileTest method shouldAddNoWait.

@Test
public void shouldAddNoWait() throws Exception {
    Platform platform = LocalPlatform.get();
    MetaClass metaClass = new JavaApplication.MetaClass();
    OptionsByType optionsByType = OptionsByType.empty();
    JprofilerProfile profile = JprofilerProfile.enabled("mylib").noWait();
    profile.onLaunching(platform, metaClass, optionsByType);
    assertAgentString(optionsByType, "-agentpath:mylib=", "port=8849", "nowait");
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) MetaClass(com.oracle.bedrock.runtime.MetaClass) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Aggregations

MetaClass (com.oracle.bedrock.runtime.MetaClass)25 OptionsByType (com.oracle.bedrock.OptionsByType)23 Test (org.junit.Test)22 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)19 Platform (com.oracle.bedrock.runtime.Platform)19 Application (com.oracle.bedrock.runtime.Application)5 ClassPath (com.oracle.bedrock.runtime.java.ClassPath)4 Arguments (com.oracle.bedrock.runtime.options.Arguments)4 Remove (com.oracle.bedrock.runtime.docker.commands.Remove)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Profile (com.oracle.bedrock.runtime.Profile)2 CoherenceClusterMember (com.oracle.bedrock.runtime.coherence.CoherenceClusterMember)2 Table (com.oracle.bedrock.table.Table)2 ConfigurableCacheFactory (com.tangosol.net.ConfigurableCacheFactory)2 ScopedCacheFactoryBuilder (com.tangosol.net.ScopedCacheFactoryBuilder)2 InetAddress (java.net.InetAddress)2 Properties (java.util.Properties)2 Option (com.oracle.bedrock.Option)1 AbstractPlatform (com.oracle.bedrock.runtime.AbstractPlatform)1 ApplicationLauncher (com.oracle.bedrock.runtime.ApplicationLauncher)1