congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
MountableFile.copyFromJarToLocation
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: testcontainers/testcontainers-java

    hostPath,
    tmpLocation);
copyFromJarToLocation(jarFile, entry, internalPath, tmpLocation);
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.utilityMountableFilecopyFromJarToLocation

Popular methods of MountableFile

  • forClasspathResource
  • forHostPath
  • getResolvedPath
  • <init>
  • 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

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • 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