Search in sources :

Example 6 with OptionsByType

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

the class SftpDeployerTest method shouldFindAsDeploymentMethodInOptions.

@Test
public void shouldFindAsDeploymentMethodInOptions() throws Exception {
    Deployer sftp = new SftpDeployer();
    OptionsByType optionsByType = OptionsByType.of(sftp);
    Deployer result = optionsByType.get(Deployer.class);
    assertThat(result, is(sameInstance(sftp)));
}
Also used : OptionsByType(com.oracle.bedrock.OptionsByType) Deployer(com.oracle.bedrock.runtime.remote.options.Deployer) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 7 with OptionsByType

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

the class FileShareDeployerTest method shouldDeployArtifactWithDestination.

@Test
public void shouldDeployArtifactWithDestination() throws Exception {
    Platform platform = mock(Platform.class);
    Option option = mock(Option.class);
    OptionsByType platformOptions = OptionsByType.empty();
    File localShareFolder = temporaryFolder.newFolder();
    File remoteShareFolder = temporaryFolder.newFolder();
    File workingFolder = temporaryFolder.newFolder();
    String content = "File 1";
    File sourceFile = createSourceFile(content);
    File destinationFolder = temporaryFolder.newFolder();
    File destinationFile = new File(destinationFolder, "foo.txt");
    when(platform.getOptions()).thenReturn(platformOptions);
    DeploymentArtifact artifact = new DeploymentArtifact(sourceFile, destinationFile);
    FileShareDeployerStub deployer = new FileShareDeployerStub(localShareFolder.getAbsolutePath(), remoteShareFolder.getAbsolutePath());
    deployer.deploy(Collections.singletonList(artifact), workingFolder.getCanonicalPath(), platform, option);
    assertThat(destinationFile.exists(), is(true));
    try (BufferedReader reader = new BufferedReader(new FileReader(destinationFile))) {
        String line = reader.readLine();
        assertThat(line, is(content));
    }
    assertThat(deployer.platform, is(sameInstance(platform)));
    assertThat(deployer.optionsByType.asArray(), hasItemInArray(sameInstance(option)));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) BufferedReader(java.io.BufferedReader) Option(com.oracle.bedrock.Option) FileReader(java.io.FileReader) Matchers.anyString(org.mockito.Matchers.anyString) OptionsByType(com.oracle.bedrock.OptionsByType) File(java.io.File) DeploymentArtifact(com.oracle.bedrock.runtime.remote.DeploymentArtifact) Test(org.junit.Test)

Example 8 with OptionsByType

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

the class FileShareDeployerTest method shouldDeployArtifactWhenFinalDestinationIsRemoteShare.

@Test
public void shouldDeployArtifactWhenFinalDestinationIsRemoteShare() throws Exception {
    Platform platform = mock(Platform.class);
    Option option = mock(Option.class);
    OptionsByType platformOptions = OptionsByType.empty();
    File localShareFolder = temporaryFolder.newFolder();
    File remoteShareFolder = temporaryFolder.newFolder();
    File workingFolder = temporaryFolder.newFolder();
    String content = "File 3";
    File sourceFile = createSourceFile(content);
    File destinationFile = new File(remoteShareFolder, sourceFile.getName());
    when(platform.getOptions()).thenReturn(platformOptions);
    DeploymentArtifact artifact = new DeploymentArtifact(sourceFile, destinationFile);
    FileShareDeployer deployer = new FileShareDeployerStub(localShareFolder.getAbsolutePath(), remoteShareFolder.getAbsolutePath());
    FileShareDeployer spy = spy(deployer);
    spy.deploy(Collections.singletonList(artifact), workingFolder.getCanonicalPath(), platform, option);
    verify(spy, never()).performRemoteCopy(anyString(), anyString(), any(Platform.class), any(OptionsByType.class));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Option(com.oracle.bedrock.Option) Matchers.anyString(org.mockito.Matchers.anyString) OptionsByType(com.oracle.bedrock.OptionsByType) File(java.io.File) DeploymentArtifact(com.oracle.bedrock.runtime.remote.DeploymentArtifact) Test(org.junit.Test)

Example 9 with OptionsByType

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

the class JSchSessionFactoryTest method shouldDisableStrictHostChecking.

@Test
public void shouldDisableStrictHostChecking() throws Exception {
    JSchSocketFactory socketFactory = new JSchSocketFactory();
    String hostName = "test.oracle.com";
    int port = 1234;
    String userName = "Larry";
    JSch jSch = mock(JSch.class);
    OptionsByType optionsByType = OptionsByType.of(StrictHostChecking.disabled());
    JSchBasedAuthentication auth = mock(JSchBasedAuthentication.class);
    Session session = mock(Session.class);
    when(jSch.getSession(userName, hostName, port)).thenReturn(session);
    JSchSessionFactory factory = new JSchSessionFactory(jSch);
    Session result = factory.createSession(hostName, port, userName, auth, socketFactory, optionsByType);
    assertThat(result, is(sameInstance(session)));
    ArgumentCaptor<Properties> configCaptor = ArgumentCaptor.forClass(Properties.class);
    verify(session).setConfig(configCaptor.capture());
    Properties configuration = configCaptor.getValue();
    assertThat(configuration.getProperty("StrictHostKeyChecking"), is("no"));
}
Also used : JSch(com.jcraft.jsch.JSch) Properties(java.util.Properties) OptionsByType(com.oracle.bedrock.OptionsByType) Session(com.jcraft.jsch.Session) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 10 with OptionsByType

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

the class JSchSessionFactoryTest method shouldObtainSession.

@Test
public void shouldObtainSession() throws Exception {
    Assume.assumeThat("Test ignored as private key file does not exist", privateKeyFileExists(), is(true));
    JSchSocketFactory socketFactory = new JSchSocketFactory();
    OptionsByType optionsByType = OptionsByType.of(StrictHostChecking.disabled());
    JSchSessionFactory factory = new JSchSessionFactory();
    Session session = null;
    try {
        session = factory.createSession(getRemoteHostName(), 22, getRemoteUserName(), getRemoteAuthentication(), socketFactory, optionsByType);
        assertThat(session.isConnected(), is(true));
    } finally {
        if (session != null) {
            session.disconnect();
        }
    }
}
Also used : OptionsByType(com.oracle.bedrock.OptionsByType) Session(com.jcraft.jsch.Session) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) 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