| 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 |
import net.sourceforge.jnlp.ContentReaderListener; |
| 42 |
import net.sourceforge.jnlp.ProcessResult; |
| 43 |
import net.sourceforge.jnlp.ServerAccess; |
| 44 |
import net.sourceforge.jnlp.annotations.Bug; |
| 45 |
import net.sourceforge.jnlp.annotations.NeedsDisplay; |
| 46 |
import net.sourceforge.jnlp.tools.AsyncJavaws; |
| 47 |
import static net.sourceforge.jnlp.tools.ClipboardHelpers.pasteFromClipboard; |
| 48 |
import static net.sourceforge.jnlp.tools.ClipboardHelpers.putToClipboard; |
| 49 |
import net.sourceforge.jnlp.tools.WaitingForStringProcess; |
| 50 |
import org.junit.Assert; |
| 51 |
import org.junit.Test; |
| 52 |
|
| 53 |
@Bug(id = "PR708") |
| 54 |
public class ClipboardContentSignedTests { |
| 55 |
|
| 56 |
private static final String contentC = "COPY#$REPRODUCER"; |
| 57 |
private static final String contentP = "PASTE#$REPRODUCER"; |
| 58 |
private static final String emptyContent = "empty content"; |
| 59 |
private static ServerAccess server = new ServerAccess(); |
| 60 |
private static final List<String> javawsTrustArg = Collections.unmodifiableList(Arrays.asList(new String[]{"-Xtrustall"})); |
| 61 |
|
| 62 |
@Test |
| 63 |
public void assertClipboardIsWorking() throws Exception { |
| 64 |
putToClipboard(emptyContent); |
| 65 |
Assert.assertEquals("Clipboard must contain new value, did not", emptyContent, pasteFromClipboard()); |
| 66 |
putToClipboard(contentC); |
| 67 |
Assert.assertEquals("Clipboard must contain new value, did not", contentC, pasteFromClipboard()); |
| 68 |
} |
| 69 |
|
| 70 |
@Test |
| 71 |
@Bug(id = "PR708") |
| 72 |
public void ClipboardContentSignedTestCopy1() throws Exception { |
| 73 |
putToClipboard(emptyContent); |
| 74 |
Assert.assertEquals("Clipboard must contain new value, did not", emptyContent, pasteFromClipboard()); |
| 75 |
WaitingForStringProcess wfsp = new WaitingForStringProcess(server, "/ClipboardContentSignedCopy1.jnlp", javawsTrustArg, true, "copied"); |
| 76 |
wfsp.run(); |
| 77 |
String ss = pasteFromClipboard(); |
| 78 |
Assert.assertEquals("Clipboard must contain new value, did not", contentC, ss); |
| 79 |
} |
| 80 |
|
| 81 |
@Test |
| 82 |
@Bug(id = "PR708") |
| 83 |
@NeedsDisplay |
| 84 |
public void ClipboardContentSignedTestCopy2() throws Exception { |
| 85 |
putToClipboard(emptyContent); |
| 86 |
Assert.assertEquals("Clipboard must contain new value, did not", emptyContent, pasteFromClipboard()); |
| 87 |
WaitingForStringProcess wfsp = new WaitingForStringProcess(server, "/ClipboardContentSignedCopy2.jnlp", javawsTrustArg, false, "copied"); |
| 88 |
wfsp.run(); |
| 89 |
String ss = pasteFromClipboard(); |
| 90 |
Assert.assertEquals("Clipboard must contain new value, did not", contentC, ss); |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
@Test |
| 95 |
@Bug(id = "PR708") |
| 96 |
public void ClipboardContentSignedTestPaste1() throws Exception { |
| 97 |
|
| 98 |
putToClipboard(emptyContent); |
| 99 |
Assert.assertEquals("Clipboard must contain new value, did not", emptyContent, pasteFromClipboard()); |
| 100 |
|
| 101 |
putToClipboard(contentP); |
| 102 |
Assert.assertEquals("Clipboard must contain new value, did not", contentP, pasteFromClipboard()); |
| 103 |
ProcessResult pr = server.executeJavawsHeadless(javawsTrustArg, "/ClipboardContentSignedPaste1.jnlp"); |
| 104 |
Assert.assertTrue("ClipboardContentSignedTestPaste stdout should contain " + contentP + " but didn't", pr.stdout.contains(contentP)); |
| 105 |
} |
| 106 |
|
| 107 |
@Test |
| 108 |
@Bug(id = "PR708") |
| 109 |
@NeedsDisplay |
| 110 |
public void ClipboardContentSignedTestPaste2() throws Exception { |
| 111 |
|
| 112 |
putToClipboard(emptyContent); |
| 113 |
Assert.assertEquals("Clipboard must contain new value, did not", emptyContent, pasteFromClipboard()); |
| 114 |
|
| 115 |
putToClipboard(contentP); |
| 116 |
Assert.assertEquals("Clipboard must contain new value, did not", contentP, pasteFromClipboard()); |
| 117 |
Assert.assertEquals("Clipboard must contain new value, did not", contentP, pasteFromClipboard()); |
| 118 |
ProcessResult pr = server.executeJavaws(javawsTrustArg, "/ClipboardContentSignedPaste2.jnlp"); |
| 119 |
Assert.assertTrue("ClipboardContentSignedTestPaste stdout should contain " + contentP + " but didn't", pr.stdout.contains(contentP)); |
| 120 |
} |
| 121 |
} |