Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-11-14 17:45:54 +0000
committerJoakim Erdfelt2014-11-14 17:45:54 +0000
commit28059d96446ec9fa6ec4f8e59b3a03b3402e2257 (patch)
treefd56775348cc24782783f5b46ade79e6679d085d
parentcf90c683cdbc046468c03315f8d68336e2d989c7 (diff)
downloadorg.eclipse.jetty.project-28059d96446ec9fa6ec4f8e59b3a03b3402e2257.tar.gz
org.eclipse.jetty.project-28059d96446ec9fa6ec4f8e59b3a03b3402e2257.tar.xz
org.eclipse.jetty.project-28059d96446ec9fa6ec4f8e59b3a03b3402e2257.zip
Updating NPN test for valid module urls
-rw-r--r--jetty-npn/jetty-npn-server/src/test/java/org/eclipse/jetty/npn/server/NPNModuleTest.java78
1 files changed, 4 insertions, 74 deletions
diff --git a/jetty-npn/jetty-npn-server/src/test/java/org/eclipse/jetty/npn/server/NPNModuleTest.java b/jetty-npn/jetty-npn-server/src/test/java/org/eclipse/jetty/npn/server/NPNModuleTest.java
index e655a1b0d0..4a5c21f96e 100644
--- a/jetty-npn/jetty-npn-server/src/test/java/org/eclipse/jetty/npn/server/NPNModuleTest.java
+++ b/jetty-npn/jetty-npn-server/src/test/java/org/eclipse/jetty/npn/server/NPNModuleTest.java
@@ -18,14 +18,11 @@
package org.eclipse.jetty.npn.server;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +33,6 @@ import org.eclipse.jetty.start.FileArg;
import org.eclipse.jetty.start.Module;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
-import org.eclipse.jetty.util.IO;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,32 +40,9 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
@RunWith(Parameterized.class)
public class NPNModuleTest
{
- /** This is here to prevent pointless download attempts */
- private static final List<String> KNOWN_GOOD_NPN_URLS = new ArrayList<>();
-
- static
- {
- /** The main() method in this test case can be run to validate this list independently */
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.9.v20141016/npn-boot-1.1.9.v20141016.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.4.v20130313/npn-boot-1.1.4.v20130313.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.2.v20130305/npn-boot-1.1.2.v20130305.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.1.v20121030/npn-boot-1.1.1.v20121030.jar");
- KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.0.v20120525/npn-boot-1.1.0.v20120525.jar");
- }
-
@Parameters(name = "{index}: mod:{0}")
public static List<Object[]> data()
{
@@ -121,7 +94,7 @@ public class NPNModuleTest
FileArg farg = new FileArg(line);
if (farg.uri != null)
{
- assertTrue("Not a known good NPN URL: " + farg.uri,KNOWN_GOOD_NPN_URLS.contains(farg.uri));
+ assertThat("NPN URL", farg.uri, startsWith("maven://org.mortbay.jetty.npn/npn-boot/"));
expectedBootClasspath.add("-Xbootclasspath/p:" + farg.location);
}
}
@@ -145,47 +118,4 @@ public class NPNModuleTest
fail(err.toString());
}
}
-
- public static void main(String[] args)
- {
- File outputDir = MavenTestingUtils.getTargetTestingDir(NPNModuleTest.class.getSimpleName() + "-main");
- FS.ensureEmpty(outputDir);
- for (String ref : KNOWN_GOOD_NPN_URLS)
- {
- try
- {
- URL url = new URL(ref);
- System.err.printf("Attempting: %s%n",ref);
- HttpURLConnection connection = (HttpURLConnection)url.openConnection();
- String refname = url.toURI().getPath();
- int idx = refname.lastIndexOf('/');
- File outputFile = new File(outputDir,refname.substring(idx));
- try (InputStream stream = connection.getInputStream(); FileOutputStream out = new FileOutputStream(outputFile))
- {
- assertThat("Response Status Code",connection.getResponseCode(),is(200));
- IO.copy(stream,out);
- System.err.printf("Downloaded %,d bytes%n",outputFile.length());
- }
- catch (IOException e)
- {
- e.printStackTrace(System.err);
- }
- }
- catch (MalformedURLException e)
- {
- System.err.printf("Bad Ref: %s%n",ref);
- e.printStackTrace(System.err);
- }
- catch (URISyntaxException e)
- {
- System.err.printf("Bad Ref Syntax: %s%n",ref);
- e.printStackTrace(System.err);
- }
- catch (IOException e)
- {
- System.err.printf("Bad Connection: %s%n",ref);
- e.printStackTrace(System.err);
- }
- }
- }
}

Back to the top