Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

load testing resources from classpath path #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void copyFromContainerBinaryFile() throws Exception {
assertThat(container.getId(), not(isEmptyOrNullString()));

Path temp = Files.createTempFile("", ".tar.gz");
Path binaryFile = Paths.get("src/test/resources/testCopyFromArchive/binary.dat");
Path binaryFile = Paths.get(ClassLoader.getSystemResource("testCopyFromArchive/binary.dat").toURI());
CompressArchiveUtil.tar(binaryFile, temp, true, false);

try (InputStream uploadStream = Files.newInputStream(temp)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class CopyArchiveToContainerCmdIT extends CmdIT {
public void copyFileToContainer() throws Exception {
CreateContainerResponse container = prepareContainerForCopy("1");
Path temp = Files.createTempFile("", ".tar.gz");
CompressArchiveUtil.tar(Paths.get("src/test/resources/testReadFile"), temp, true, false);
CompressArchiveUtil.tar(Paths.get(ClassLoader.getSystemResource("testReadFile").toURI()), temp, true, false);
try (InputStream uploadStream = Files.newInputStream(temp)) {
dockerRule.getClient()
.copyArchiveToContainerCmd(container.getId())
Expand All @@ -47,16 +47,16 @@ public void copyFileToContainer() throws Exception {
public void copyStreamToContainer() throws Exception {
CreateContainerResponse container = prepareContainerForCopy("2");
dockerRule.getClient().copyArchiveToContainerCmd(container.getId())
.withHostResource("src/test/resources/testReadFile")
.withHostResource(Paths.get(ClassLoader.getSystemResource("testReadFile").toURI()).toString())
.exec();
assertFileCopied(container);
}

@Test
public void copyStreamToContainerTwice() throws Exception {
CreateContainerResponse container = prepareContainerForCopy("rerun");
CopyArchiveToContainerCmd copyArchiveToContainerCmd=dockerRule.getClient().copyArchiveToContainerCmd(container.getId())
.withHostResource("src/test/resources/testReadFile");
CopyArchiveToContainerCmd copyArchiveToContainerCmd = dockerRule.getClient().copyArchiveToContainerCmd(container.getId())
.withHostResource(Paths.get(ClassLoader.getSystemResource("testReadFile").toURI()).toString());
copyArchiveToContainerCmd.exec();
assertFileCopied(container);
//run again to make sure no DockerClientException
Expand All @@ -82,9 +82,9 @@ private void assertFileCopied(CreateContainerResponse container) throws IOExcept
}

@Test(expected = NotFoundException.class)
public void copyToNonExistingContainer() {

dockerRule.getClient().copyArchiveToContainerCmd("non-existing").withHostResource("src/test/resources/testReadFile").exec();
public void copyToNonExistingContainer() throws Exception {
dockerRule.getClient().copyArchiveToContainerCmd("non-existing")
.withHostResource(Paths.get(ClassLoader.getSystemResource("testReadFile").toURI()).toString()).exec();
}

@Test
Expand Down Expand Up @@ -113,7 +113,7 @@ public void copyDirWithLastAddedTarEntryEmptyDir() throws Exception{
// cleanup dir
FileUtils.deleteDirectory(localDir.toFile());
}

@Test
public void copyFileWithExecutePermission() throws Exception {
// create script file, add permission to execute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.dockerjava.utils;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand All @@ -8,7 +9,7 @@ public class TestResources {
private TestResources() {
}

public static Path getApiImagesLoadTestTarball() {
return Paths.get("src/test/resources/api/images/load/image.tar");
public static Path getApiImagesLoadTestTarball() throws URISyntaxException {
return Paths.get(ClassLoader.getSystemResource("api/images/load/image.tar").toURI());
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.