Java Code Examples for com.intuit.karate.FileUtils#getPathContaining()

The following examples show how to use com.intuit.karate.FileUtils#getPathContaining() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarLoadingTest.java    From karate with MIT License 5 votes vote down vote up
@Test
public void testFileUtilsForJarFile() throws Exception {
    File file = new File("src/test/java/common.feature");
    assertTrue(!FileUtils.isJarPath(file.toPath().toUri()));
    ClassLoader cl = getJarClassLoader1();
    Class main = cl.loadClass("demo.jar1.Main");
    Path path = FileUtils.getPathContaining(main);
    assertTrue(FileUtils.isJarPath(path.toUri()));
    String relativePath = FileUtils.toRelativeClassPath(path, cl);
    assertEquals("classpath:", relativePath); // TODO doesn't matter but fix in future if possible
    path = FileUtils.fromRelativeClassPath("classpath:demo/jar1", cl);
    assertEquals(path.toString(), "/demo/jar1");
}
 
Example 2
Source File: JarLoadingTest.java    From karate with MIT License 4 votes vote down vote up
private ScenarioContext getContext() throws Exception {
    Path featureDir = FileUtils.getPathContaining(getClass());
    FeatureContext featureContext = FeatureContext.forWorkingDir("dev", featureDir.toFile());
    CallContext callContext = new CallContext(null, true);
    return new ScenarioContext(featureContext, callContext, getJarClassLoader2(), null, null);
}
 
Example 3
Source File: ChromeJavaRunner.java    From karate with MIT License 4 votes vote down vote up
public static ScenarioContext getContext() {
    Path featureDir = FileUtils.getPathContaining(ChromeJavaRunner.class);
    FeatureContext featureContext = FeatureContext.forWorkingDir("dev", featureDir.toFile());
    CallContext callContext = new CallContext(null, true);
    return new ScenarioContext(featureContext, callContext, null, null);
}
 
Example 4
Source File: DriverOptionsTest.java    From karate with MIT License 4 votes vote down vote up
private ScenarioContext getContext() {
    Path featureDir = FileUtils.getPathContaining(getClass());
    FeatureContext featureContext = FeatureContext.forWorkingDir("dev", featureDir.toFile());
    CallContext callContext = new CallContext(null, true);
    return new ScenarioContext(featureContext, callContext, null, null);
}