@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); }
@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")); }