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)));
}
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)));
}
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));
}
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"));
}
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();
}
}
}
Aggregations