@Test public void testResolve_ReturnsNull_NonJarURL() throws MalformedURLException { URL url = new URL("file:/C:/Users/4thex/Workspace/TestApplication/bin/com/_4thex/Main.class"); PathResolver resolver = new JarPathResolver(); String path = resolver.getPath(url, "/com/_4thex/Main.class"); assertNull(path); }
@Test public void testResolve_ReturnsCorrectPath_ForValidJarURL() throws MalformedURLException { URL url = new URL( "jar:file:/C:/Program%20Files/Java/jdk1.7.0_51/jre/lib/rt.jar!/java/io/PrintStream.class"); PathResolver resolver = new JarPathResolver(); String path = resolver.getPath(url, "/java/io/PrintStream.class"); String expected = new File("C:/Program Files/Java/jdk1.7.0_51/jre/lib/rt.jar").getPath(); assertEquals(expected, path); }
protected void initContextPaths() { ctx.init( this, PathResolver.create( ctx.getRequest(), getClass().getAnnotation(Path.class).value(), "/skin", X_ECR_ROOT_URL, X_ECR_BASE_URL)); initPath(); }
private Set<FileInfo> resolveFiles(List<String> files, boolean serveOnly) { if (files != null) { Set<FileInfo> resolvedFiles = new LinkedHashSet<FileInfo>(); for (String f : files) { f = pathRewriter.rewrite(f); boolean isPatch = f.startsWith("patch"); if (isPatch) { String[] tokens = f.split(" ", 2); f = tokens[1].trim(); } if (f.startsWith("http://") || f.startsWith("https://")) { resolvedFiles.add(new FileInfo(f, -1, -1, false, false, null)); } else { File file = basePath != null ? new File(basePath.getAbsoluteFile(), f) : new File(f); File testFile = file.getAbsoluteFile(); File dir = testFile.getParentFile().getAbsoluteFile(); final String pattern = file.getName(); String[] filteredFiles = dir.list( new GlobFilenameFilter( pattern, GlobCompiler.DEFAULT_MASK | GlobCompiler.CASE_INSENSITIVE_MASK)); if (filteredFiles == null || filteredFiles.length == 0) { String error = "The patterns/paths " + f + " used in the configuration" + " file didn't match any file, the files patterns/paths need to be relative to" + " the configuration file."; System.err.println(error); throw new RuntimeException(error); } Arrays.sort(filteredFiles, String.CASE_INSENSITIVE_ORDER); for (String filteredFile : filteredFiles) { String resolvedFilePath = pathResolver.resolvePath( dir.getAbsolutePath() + FileInfo.SEPARATOR_CHAR + filteredFile); File resolvedFile = new File(resolvedFilePath); resolvedFiles.add( new FileInfo( resolvedFilePath, resolvedFile.lastModified(), -1, isPatch, serveOnly, null)); } } } return resolvedFiles; } return Collections.emptySet(); }
public IBuildEnvironmentVariable getVariable( String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { if (!Tools.isWindows()) { return null; } if (variableName == null) { return null; } if (!"PATH".equalsIgnoreCase(variableName)) { return null; } String p = PathResolver.getBinPath(); if (p != null) { String sDelimiter = System.getProperty("path.separator", ":"); String sPath = p.replace('/', '\\'); return new BuildEnvVar("PATH", sPath, 3, sDelimiter); } return null; }
@Test public void testFound() { makeTargetFindable(); fakeResource(spec); given(resourceFinder.loadResource(ScriptResource.class, AppBase, specName)).willReturn(spec); given(pathResolver.specLocationFor(AppBase)).willReturn(AppBase); JasmineScriptEnvironment jse = new JasmineScriptEnvironment( dependencies, global, resourceFinder, pathResolver, makeResourceLoaded(target)); assertThat(jse.name(), is(specName)); assertThat(jse.script(), is(jasmineBootScript)); verifyDependentSetup(jasmine, jse); verifyDependentSetup(jasmineBoot, jse); verifyDependentSetup(jasmineRun, jse); verifyDependentSetup(target, jse); verifyDependentSetup(spec, jse); // make sure we ran our setup (at least the part that matters internally) verify(dependencies.mockRhinoContextProvider().context).executeScript(jasmineScript, global); // TODO VERIFY THE SCOPE! // need some test tools for this // and need to tweak down the scope anyway. it's not right, yet. // inject needs to be renamed // require needs to be renamed // verify the sha is build from all our script buddies. kind of goofy but correct // this is sort of future-prep but this might become a target for socket connections at // some point, to deliver test run results to the browser. maybe assertThat(jse.sha1(), is("4a117d7e27db77e337750a4e380ef4587be12f40")); }