use of com.oracle.bedrock.runtime.remote.DeploymentArtifact in project oracle-bedrock by coherence-community.
the class CurlHttpDeployerTest method shouldDeployEmptyArtifacts.
@Test
public void shouldDeployEmptyArtifacts() throws Exception {
Map<String, DeploymentArtifact> artifacts = new HashMap<>();
String destination = "/foo";
Platform platform = mock(Platform.class);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
OptionsByType optionsByType = OptionsByType.empty();
CurlHttpDeployer deploymentMethod = new CurlHttpDeployer();
DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
deploymentMethod.deployAllArtifacts(artifacts, destination, platform, address, optionsByType, deployedArtifacts);
verifyNoMoreInteractions(platform);
}
use of com.oracle.bedrock.runtime.remote.DeploymentArtifact in project oracle-bedrock by coherence-community.
the class AbstractHttpDeployerTest method createArtifactList.
/**
* Create a given number of random binary artifacts.
*
* @return a {@link List} containing the specified number
* of {@link DeploymentArtifact}s
*/
public List<DeploymentArtifact> createArtifactList(int count) throws Exception {
List<DeploymentArtifact> artifacts = new ArrayList<>();
Random random = new Random(System.currentTimeMillis());
File root = temporaryFolder.newFolder();
for (int i = 0; i < count; i++) {
File file = new File(root, "File-" + i + ".bin");
int size = random.nextInt(1000) * 100;
try (FileOutputStream stream = new FileOutputStream(file)) {
for (int b = 0; b < size; b++) {
stream.write(random.nextInt());
}
}
artifacts.add(new DeploymentArtifact(file));
}
return artifacts;
}
use of com.oracle.bedrock.runtime.remote.DeploymentArtifact in project oracle-bedrock by coherence-community.
the class AbstractHttpDeployerTest method createArtifactMap.
/**
* Create a given number of random binary artifacts returned in a
* {@link Map} keyed on the encoded URL path of the artifacts
* source file name.
*
* @return a {@link Map} containing the specified number
* of {@link DeploymentArtifact}s keyed on the
* encoded URL path of the artifacts source file name
*/
public Map<String, DeploymentArtifact> createArtifactMap(int count) throws Exception {
Map<String, DeploymentArtifact> artifacts = new LinkedHashMap<>();
for (DeploymentArtifact artifact : createArtifactList(count)) {
String urlPath = "/" + URLEncoder.encode(artifact.getSourceFile().getCanonicalPath(), "UTF-8");
artifacts.put(urlPath, artifact);
}
return artifacts;
}
use of com.oracle.bedrock.runtime.remote.DeploymentArtifact in project oracle-bedrock by coherence-community.
the class HttpDeployerTest method shouldHandleRequestForNonExistentArtifact.
@Test
public void shouldHandleRequestForNonExistentArtifact() throws Exception {
Map<String, DeploymentArtifact> artifacts = createArtifactMap(1);
HttpExchange exchange = mock(HttpExchange.class);
HttpDeployer.ArtifactsHandler handler = new HttpDeployer.ArtifactsHandler(artifacts);
URI uri = new File("/foo.txt").toURI();
when(exchange.getRequestURI()).thenReturn(uri);
handler.handle(exchange);
verify(exchange).sendResponseHeaders(404, 0);
}
use of com.oracle.bedrock.runtime.remote.DeploymentArtifact in project oracle-bedrock by coherence-community.
the class JSchFileShareDeployerTest method shouldDeployArtifactWithDestination.
@Test
public void shouldDeployArtifactWithDestination() throws Exception {
String content = "To fetch a pail of water";
File file = createArtifact(content);
File dest = temporaryFolder.newFolder();
DeploymentArtifact artifact = new DeploymentArtifact(file, dest);
List<DeploymentArtifact> list = Collections.singletonList(artifact);
Deployer deployer = JSchFileShareDeployer.sshFileShareDeployer(localShare, remoteShare);
deployer.deploy(list, workingDirectory, getRemotePlatform());
File expected = new File(dest, file.getName());
assertThat(expected.exists(), is(true));
try (BufferedReader reader = new BufferedReader(new FileReader(expected))) {
String line = reader.readLine();
assertThat(line, is(content));
}
}
Aggregations