diff options
author | Jiri Vanek <[email protected]> | 2012-06-29 10:43:51 +0200 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2012-06-29 10:43:51 +0200 |
commit | d11831804f320ce432b904032d5cfbf00c1a198b (patch) | |
tree | 49e30f443b26468423778c7dda5364afd91f632b /tests/netx | |
parent | 16f2e7d40c05927c5d911380a24d11dec4f31263 (diff) |
Fixed resource tests and Browsers.none behavior
Diffstat (limited to 'tests/netx')
3 files changed, 35 insertions, 11 deletions
diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java index b8c7d5e..097ac4f 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java @@ -40,7 +40,9 @@ import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; import java.net.URI; +import java.net.URL; import java.util.Arrays; import java.util.List; import net.sourceforge.jnlp.browsertesting.Browser; @@ -48,7 +50,6 @@ import net.sourceforge.jnlp.browsertesting.BrowserFactory; import net.sourceforge.jnlp.browsertesting.BrowserTest; import net.sourceforge.jnlp.browsertesting.Browsers; import net.sourceforge.jnlp.annotations.NeedsDisplay; -import net.sourceforge.jnlp.annotations.TestInBrowsers; import net.sourceforge.jnlp.browsertesting.browsers.LinuxBrowser; import net.sourceforge.jnlp.annotations.TestInBrowsers; import org.junit.Assert; @@ -62,7 +63,7 @@ public class ResourcesTest extends BrowserTest{ @NeedsDisplay public void testNonExisitngBrowserWillNotDeadlock() throws Exception { server.setCurrentBrowser(Browsers.none); - ServerAccess.ProcessResult pr = server.executeBrowser("simpletest1.jnlp"); + ServerAccess.ProcessResult pr = server.executeBrowser("/simpletest1.jnlp"); Assert.assertNull(pr.process); Assert.assertEquals(pr.stderr, ""); Assert.assertEquals(pr.stdout, ""); @@ -85,9 +86,16 @@ public class ResourcesTest extends BrowserTest{ } @Test + public void testGetUrlUponThisInstance() throws MalformedURLException{ + URL u1=server.getUrlUponThisInstance("simple.jsp"); + URL u2=server.getUrlUponThisInstance("/simple.jsp"); + Assert.assertEquals(u1, u2); + } + + @Test @TestInBrowsers(testIn=Browsers.none) public void testNonExisitngBrowserWillNotCauseMess() throws Exception { - ServerAccess.ProcessResult pr = server.executeBrowser("simpletest1.jnlp"); + ServerAccess.ProcessResult pr = server.executeBrowser("/simpletest1.jnlp"); Assert.assertNull(pr.process); Assert.assertEquals(pr.stderr, ""); Assert.assertEquals(pr.stdout, ""); @@ -175,15 +183,15 @@ public class ResourcesTest extends BrowserTest{ expected = 2; Assert.assertTrue("Created from " + s + "there must be " + expected + " browsers in factory. Is" + bf.getAllBrowsers().size(), bf.getAllBrowsers().size() == expected); - s = Browsers.firefox.toExec() + ":" + Browsers.chromiumBrowser + ":" + Browsers.googleChrome.toExec() + ":" + Browsers.opera; + s = Browsers.firefox.toExec() + ":" + Browsers.chromiumBrowser + ":" + Browsers.googleChrome.toExec() + ":" + Browsers.opera + ":" + Browsers.epiphany + ":" + Browsers.midori; bf = new BrowserFactory(s); - expected = 4; + expected = 6; Assert.assertTrue("Created from " + s + "there must be " + expected + " browsers in factory. Is" + bf.getAllBrowsers().size(), bf.getAllBrowsers().size() == expected); testFullFactory(bf); - s = "fgfd/" + Browsers.firefox.toExec() + ":" + "/fgfd/" + Browsers.chromiumBrowser + ":" + "fgfd/dfsdf/" + Browsers.googleChrome.toExec() + ":" + "/g/fgfd/" + Browsers.opera; + s = "fgfd/" + Browsers.firefox.toExec() + ":" + "/fgfd/" + Browsers.chromiumBrowser + ":" + "fgfd/dfsdf/" + Browsers.googleChrome.toExec() + ":" + "/g/fgfd/" + Browsers.opera + ":" + Browsers.epiphany + ":" + Browsers.midori; bf = new BrowserFactory(s); - expected = 4; + expected = 6; Assert.assertTrue("Created from " + s + "there must be " + expected + " browsers in factory. Is" + bf.getAllBrowsers().size(), bf.getAllBrowsers().size() == expected); testFullFactory(bf); @@ -289,7 +297,7 @@ public class ResourcesTest extends BrowserTest{ e2.append(s).append("\n"); } }; - ServerAccess.ProcessResult pr=server.executeBrowser("simpletest1.jnlp",le,lo); + ServerAccess.ProcessResult pr = server.executeBrowser("/simpletest1.jnlp", le, lo); server.setCurrentBrowser(BrowserFactory.getFactory().getFirst().getID()); Assert.assertNotNull(server.getCurrentBrowsers()); Assert.assertNotNull(server.getCurrentBrowser()); @@ -310,6 +318,8 @@ public class ResourcesTest extends BrowserTest{ Assert.assertEquals(bf.getBrowser(Browsers.googleChrome).getID(), Browsers.googleChrome); Assert.assertEquals(bf.getBrowser(Browsers.firefox).getID(), Browsers.firefox); Assert.assertEquals(bf.getBrowser(Browsers.opera).getID(), Browsers.opera); + Assert.assertEquals(bf.getBrowser(Browsers.epiphany).getID(), Browsers.epiphany); + Assert.assertEquals(bf.getBrowser(Browsers.midori).getID(), Browsers.midori); } private void testBrowser(Browser browser) throws IOException { diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java index e5490fd..af16a63 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java @@ -906,7 +906,10 @@ public class ServerAccess { * @return * @throws MalformedURLException */ - private URL getUrlUponThisInstance(String resource) throws MalformedURLException { + public URL getUrlUponThisInstance(String resource) throws MalformedURLException { + if (!resource.startsWith("/")) { + resource = "/" + resource; + } return new URL("http", server.getServerName(), getPort(), resource); } diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java index ae2934f..36350e8 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java @@ -36,12 +36,16 @@ public class BrowserTestRunner extends BlockJUnit4ClassRunner { String mbr = System.getProperty("modified.browsers.run"); if (mbr != null) { if (mbr.equalsIgnoreCase("all")) { - testableBrowsers = BrowserFactory.getFactory().getBrowsers(new Browsers[]{Browsers.all}); + if (!isBrowsersNoneSet(tib)) { + testableBrowsers = BrowserFactory.getFactory().getBrowsers(new Browsers[]{Browsers.all}); + } } else if (mbr.equalsIgnoreCase("one")) { //this complication here is for case like // namely enumerated concrete browsers, so we want to pick up // random one from those already enumerated - testableBrowsers = Arrays.asList(new Browsers[]{testableBrowsers.get(new Random().nextInt(testableBrowsers.size()))}); + if (isBrowsersNoneSet(tib)) { + testableBrowsers = Arrays.asList(new Browsers[]{testableBrowsers.get(new Random().nextInt(testableBrowsers.size()))}); + } } else if (mbr.equalsIgnoreCase("ignore")) { testableBrowsers = BrowserFactory.getFactory().getBrowsers(new Browsers[]{Browsers.none}); browserIgnoration = true; @@ -66,6 +70,13 @@ public class BrowserTestRunner extends BlockJUnit4ClassRunner { } } + private boolean isBrowsersNoneSet(TestInBrowsers tib) { + if (tib.testIn().length == 1 && tib.testIn()[0] == Browsers.none) { + return true; + } + return false; + } + private void injectBrowserCatched(FrameworkMethod method, Browsers browser) { try { injcetBrowser(method, browser); |