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

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

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

origin: testcontainers/testcontainers-java

private String getResourcePath() {
  if (path.contains(".jar!")) {
    resourcePath = extractClassPathResourceToTempLocation(this.path);
  } else {
    resourcePath = unencodeResourceURIToFilePath(path);
  }
  return resourcePath;
}
origin: testcontainers/testcontainers-java

String urldecodedJarPath = unencodeResourceURIToFilePath(hostPath);
String internalPath = hostPath.replaceAll("[^!]*!/", "");
origin: org.testcontainers/testcontainers

/**
 * Extract a file or directory tree from a JAR file to a temporary location.
 * This allows Docker to mount classpath resources as files.
 *
 * @param hostPath the path on the host, expected to be of the format 'file:/path/to/some.jar!/classpath/path/to/resource'
 * @return the path of the temporary file/directory
 */
private String extractClassPathResourceToTempLocation(final String hostPath) {
  File tmpLocation = createTempDirectory();
  //noinspection ResultOfMethodCallIgnored
  tmpLocation.delete();
  String urldecodedJarPath = unencodeResourceURIToFilePath(hostPath);
  String internalPath = hostPath.replaceAll("[^!]*!/", "");
  try (JarFile jarFile = new JarFile(urldecodedJarPath)) {
    Enumeration<JarEntry> entries = jarFile.entries();
    while (entries.hasMoreElements()) {
      JarEntry entry = entries.nextElement();
      final String name = entry.getName();
      if (name.startsWith(internalPath)) {
        log.debug("Copying classpath resource(s) from {} to {} to permit Docker to bind", hostPath, tmpLocation);
        copyFromJarToLocation(jarFile, entry, internalPath, tmpLocation);
      }
    }
  } catch (IOException e) {
    throw new IllegalStateException("Failed to process JAR file when extracting classpath resource: " + hostPath, e);
  }
  // Mark temporary files/dirs for deletion at JVM shutdown
  deleteOnExit(tmpLocation.toPath());
  return tmpLocation.getAbsolutePath();
}
org.testcontainers.utilityMountableFileunencodeResourceURIToFilePath

Popular methods of MountableFile

  • forClasspathResource
  • forHostPath
  • getResolvedPath
  • <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
  • getModeValue,
  • getResourcePath,
  • getUnixFileMode,
  • getFileMode,
  • recursiveTar,
  • resolveFilesystemPath,
  • resolvePath,
  • transferTo

Popular in Java

  • Reactive rest calls using spring rest template
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • putExtra (Intent)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collectors (java.util.stream)
  • BoxLayout (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 plugins for Android Studio
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