Tabnine Logo
MountableFile.getResolvedPath
Code IndexAdd Tabnine to your IDE (free)

How to use
getResolvedPath
method
in
org.testcontainers.utility.MountableFile

Best Java code snippets using org.testcontainers.utility.MountableFile.getResolvedPath (Showing top 19 results out of 315)

origin: testcontainers/testcontainers-java

@Override
public String getDescription() {
  return this.getResolvedPath();
}
origin: testcontainers/testcontainers-java

/**
 * {@inheritDoc}
 */
@Override
public void transferTo(final TarArchiveOutputStream outputStream, String destinationPathInTar) {
  recursiveTar(destinationPathInTar, this.getResolvedPath(), this.getResolvedPath(), outputStream);
}
origin: testcontainers/testcontainers-java

@Override
public long getSize() {
  final File file = new File(this.getResolvedPath());
  if (file.isFile()) {
    return file.length();
  } else {
    return 0;
  }
}
origin: testcontainers/testcontainers-java

@Override
public int getFileMode() {
  return getUnixFileMode(this.getResolvedPath());
}
origin: testcontainers/testcontainers-java

  default SELF withFileFromClasspath(String path, String resourcePath) {
    final MountableFile mountableFile = MountableFile.forClasspathResource(resourcePath);

    return ((SELF) this).withFileFromPath(path, Paths.get(mountableFile.getResolvedPath()));
  }
}
origin: testcontainers/testcontainers-java

/**
 * {@inheritDoc}
 */
@Override
public void copyFileToContainer(MountableFile mountableFile, String containerPath) {
  File sourceFile = new File(mountableFile.getResolvedPath());
  if (containerPath.endsWith("/") && sourceFile.isFile()) {
    logger().warn("folder-like containerPath in copyFileToContainer is deprecated, please explicitly specify a file path");
    copyFileToContainer((Transferable) mountableFile, containerPath + sourceFile.getName());
  } else {
    copyFileToContainer((Transferable) mountableFile, containerPath);
  }
}
origin: testcontainers/testcontainers-java

/**
 * {@inheritDoc}
 */
@Override
public void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) {
  final MountableFile mountableFile = MountableFile.forHostPath(hostPath);
  binds.add(new Bind(mountableFile.getResolvedPath(), new Volume(containerPath), mode.accessMode, selinuxContext.selContext));
}
origin: testcontainers/testcontainers-java

/**
 * {@inheritDoc}
 */
@Override
public SELF withClasspathResourceMapping(final String resourcePath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) {
  final MountableFile mountableFile = MountableFile.forClasspathResource(resourcePath);
  this.addFileSystemBind(mountableFile.getResolvedPath(), containerPath, mode, selinuxContext);
  return self();
}
origin: testcontainers/testcontainers-java

private void performChecks(final MountableFile mountableFile) {
  final String mountablePath = mountableFile.getResolvedPath();
  assertTrue("The filesystem path '" + mountablePath + "' can be found", new File(mountablePath).exists());
  assertFalse("The filesystem path '" + mountablePath + "' does not contain any URL escaping", mountablePath.contains("%20"));
}
origin: testcontainers/testcontainers-java

private boolean checkMountableFile() {
  DockerClient dockerClient = client();
  MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class");
  Volume volume = new Volume("/dummy");
  try {
    return runInsideDocker(
      createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)),
      (__, containerId) -> {
        try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) {
          stream.read();
          return true;
        } catch (Exception e) {
          return false;
        }
      }
    );
  } catch (Exception e) {
    log.debug("Failure while checking for mountable file support", e);
    return false;
  }
}
origin: testcontainers/testcontainers-java

@Test
public void forHostPathWithPlus() throws Exception {
  final Path file = createTempFile("some+path");
  final MountableFile mountableFile = MountableFile.forHostPath(file.toString());
  performChecks(mountableFile);
  assertTrue("The resolved path contains the original space", mountableFile.getResolvedPath().contains("+"));
  assertFalse("The resolved path does not contain an escaped space", mountableFile.getResolvedPath().contains(" "));
}
origin: testcontainers/testcontainers-java

@Test
public void forHostPathWithSpaces() throws Exception {
  final Path file = createTempFile("some path");
  final MountableFile mountableFile = MountableFile.forHostPath(file.toString());
  performChecks(mountableFile);
  assertTrue("The resolved path contains the original space", mountableFile.getResolvedPath().contains(" "));
  assertFalse("The resolved path does not contain an escaped space", mountableFile.getResolvedPath().contains("\\ "));
}
origin: testcontainers/testcontainers-java

@Test
public void copyFolderToContainerFolderTest() throws Exception {
  try (
    GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
      .withCommand("top")
  ) {
    alpineCopyToContainer.start();
    final MountableFile mountableFile = MountableFile.forClasspathResource("mappable-resource/");
    alpineCopyToContainer.copyFileToContainer(mountableFile, "/home/test/");
    File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
    alpineCopyToContainer.copyFileFromContainer("/home/test/test-resource.txt", actualFile.getPath());
    File expectedFile = new File(mountableFile.getResolvedPath() + "/test-resource.txt");
    assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
  }
}
origin: testcontainers/testcontainers-java

@Test
public void copyFileToContainerFileTest() throws Exception {
  try (
    GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
      .withCommand("top")
  ) {
    alpineCopyToContainer.start();
    final MountableFile mountableFile = MountableFile.forClasspathResource("test_copy_to_container.txt");
    alpineCopyToContainer.copyFileToContainer(mountableFile, "/test.txt");
    File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
    alpineCopyToContainer.copyFileFromContainer("/test.txt", actualFile.getPath());
    File expectedFile = new File(mountableFile.getResolvedPath());
    assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
  }
}
origin: testcontainers/testcontainers-java

@Test
public void copyFileToContainerFolderTest() throws Exception {
  try (
    GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
      .withCommand("top")
  ) {
    alpineCopyToContainer.start();
    final MountableFile mountableFile = MountableFile.forClasspathResource("test_copy_to_container.txt");
    alpineCopyToContainer.copyFileToContainer(mountableFile, "/home/");
    File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
    alpineCopyToContainer.copyFileFromContainer("/home/test_copy_to_container.txt", actualFile.getPath());
    File expectedFile = new File(mountableFile.getResolvedPath());
    assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
  }
}
origin: testcontainers/testcontainers-java

  @Test
  public void shouldCopyFileFromContainerTest() throws IOException {
    try (
      GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
        .withCommand("top")
    ) {

      alpineCopyToContainer.start();
      final MountableFile mountableFile = MountableFile.forClasspathResource("test_copy_to_container.txt");
      alpineCopyToContainer.copyFileToContainer(mountableFile, "/home/");

      File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_from_container.txt");
      alpineCopyToContainer.copyFileFromContainer("/home/test_copy_to_container.txt", actualFile.getPath());

      File expectedFile = new File(mountableFile.getResolvedPath());
      assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
    }
  }
}
origin: org.testcontainers/testcontainers

@Override
public long getSize() {
  final File file = new File(this.getResolvedPath());
  if (file.isFile()) {
    return file.length();
  } else {
    return 0;
  }
}
origin: org.testcontainers/testcontainers

  default SELF withFileFromClasspath(String path, String resourcePath) {
    final MountableFile mountableFile = MountableFile.forClasspathResource(resourcePath);

    return ((SELF) this).withFileFromPath(path, Paths.get(mountableFile.getResolvedPath()));
  }
}
origin: org.testcontainers/testcontainers

private boolean checkMountableFile() {
  DockerClient dockerClient = client();
  MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class");
  Volume volume = new Volume("/dummy");
  try {
    return runInsideDocker(createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)), (__, containerId) -> {
      try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) {
        stream.read();
        return true;
      } catch (Exception e) {
        return false;
      }
    });
  } catch (Exception e) {
    log.debug("Failure while checking for mountable file support", e);
    return false;
  }
}
org.testcontainers.utilityMountableFilegetResolvedPath

Popular methods of MountableFile

  • forClasspathResource
  • forHostPath
  • <init>
  • copyFromJarToLocation
  • createTempDirectory
  • deleteOnExit
  • extractClassPathResourceToTempLocation
    Extract a file or directory tree from a JAR file to a temporary location. This allows Docker to moun
  • getClasspathResource
  • getFilesystemPath
  • getModeValue
  • getResourcePath
  • getUnixFileMode
  • getResourcePath,
  • getUnixFileMode,
  • unencodeResourceURIToFilePath,
  • getFileMode,
  • recursiveTar,
  • resolveFilesystemPath,
  • resolvePath,
  • transferTo

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • String (java.lang)
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JPanel (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now