| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
import java.util.Arrays; |
| 39 |
import java.util.Collections; |
| 40 |
import java.util.List; |
| 41 |
|
| 42 |
import net.sourceforge.jnlp.ProcessResult; |
| 43 |
import net.sourceforge.jnlp.ServerAccess; |
| 44 |
import org.junit.Assert; |
| 45 |
import org.junit.Test; |
| 46 |
|
| 47 |
public class MultiJarSignedJnlpTest { |
| 48 |
|
| 49 |
private static ServerAccess server = new ServerAccess(); |
| 50 |
private final List<String> l = Collections.unmodifiableList(Arrays.asList(new String[] { "-Xtrustall" })); |
| 51 |
private final String signedJnlpException = "net.sourceforge.jnlp.LaunchException: Fatal: Application Error: " |
| 52 |
+ "The signed JNLP file did not match the launching JNLP file. Missing Resource: Signed Application " |
| 53 |
+ "did not match launching JNLP File"; |
| 54 |
|
| 55 |
@Test |
| 56 |
public void checkingForRequiredResources() throws Exception { |
| 57 |
|
| 58 |
String s = "Ending application without a Signed Jnlp"; |
| 59 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithoutSignedJnlp.jnlp"); |
| 60 |
Assert.assertTrue("Could not locate the required resources required to run this test", pr.stdout.contains(s)); |
| 61 |
} |
| 62 |
|
| 63 |
@Test |
| 64 |
public void mainJarMatchingSignedJnlpTemplate() throws Exception { |
| 65 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithMatchingSignedJnlpTemplate.jnlp"); |
| 66 |
String s = "Ending application with signed application_template jnlp"; |
| 67 |
Assert.assertTrue("Could not locate SignedJnlpTemplate class within MultiJar-SignedJnlpTemplate.jar", pr.stdout.contains(s)); |
| 68 |
Assert.assertFalse(pr.stderr.contains(signedJnlpException)); |
| 69 |
} |
| 70 |
|
| 71 |
@Test |
| 72 |
public void mainJarMatchingSignedJnlpApplication() throws Exception { |
| 73 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithMatchingSignedJnlpApplication.jnlp"); |
| 74 |
String s = "Ending application with signed application jnlp"; |
| 75 |
Assert.assertTrue("Could not locate SignedJnlpApplication class within MultiJar-SignedJnlpApplication.jar", pr.stdout.contains(s)); |
| 76 |
Assert.assertFalse(pr.stderr.contains(signedJnlpException)); |
| 77 |
} |
| 78 |
|
| 79 |
@Test |
| 80 |
public void mainJarWithUnmatchingSignedJnlpApplication() throws Exception { |
| 81 |
String s = "Ending application with signed application jnlp"; |
| 82 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithUnmatchingSignedJnlpApplication.jnlp"); |
| 83 |
Assert.assertTrue("Stdout should contains " + signedJnlpException + " but did not", pr.stderr.contains(signedJnlpException)); |
| 84 |
Assert.assertFalse( pr.stdout.contains(s)); |
| 85 |
} |
| 86 |
|
| 87 |
@Test |
| 88 |
public void mainJarWithUnmatchingSignedJnlpTemplate() throws Exception { |
| 89 |
String s = "Ending application with signed application_template jnlp"; |
| 90 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithUnmatchingSignedJnlpTemplate.jnlp"); |
| 91 |
Assert.assertTrue("Stdout should contains " + signedJnlpException + " but did not", pr.stderr.contains(signedJnlpException)); |
| 92 |
Assert.assertFalse(pr.stdout.contains(s)); |
| 93 |
} |
| 94 |
|
| 95 |
@Test |
| 96 |
public void mainJarWithoutSignedJnlp() throws Exception { |
| 97 |
ProcessResult pr = server.executeJavawsHeadless(l, "/MainJarWithoutSignedJnlp.jnlp"); |
| 98 |
String s = "Ending application without a Signed Jnlp"; |
| 99 |
Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s)); |
| 100 |
} |
| 101 |
|
| 102 |
} |