1 package com.gitlab.pdftk_java;
2 
3 import org.junit.Test;
4 import java.io.FileInputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 
8 public class StampTest extends BlackBox {
9 
stdin_operation(String operation)10   void stdin_operation(String operation) throws IOException {
11     byte[] expected = getPdf("test/files/blank.pdf", operation, "test/files/duck.pdf", "output", "-");
12     InputStream stdinMock = new FileInputStream("test/files/blank.pdf");
13     InputStream originalIn = System.in;
14     System.setIn(stdinMock);
15     byte[] actual = getPdf("-", operation, "test/files/duck.pdf", "output", "-");
16     System.setIn(originalIn);
17     assertPdfEqualsAsSVG(expected, actual);
18   }
19 
operation_stdin(String operation)20   void operation_stdin(String operation) throws IOException {
21     byte[] expected = getPdf("test/files/blank.pdf", operation, "test/files/duck.pdf", "output", "-");
22     InputStream stdinMock = new FileInputStream("test/files/duck.pdf");
23     InputStream originalIn = System.in;
24     System.setIn(stdinMock);
25     byte[] actual = getPdf("test/files/blank.pdf", operation, "-", "output", "-");
26     System.setIn(originalIn);
27     assertPdfEqualsAsSVG(expected, actual);
28   }
29 
30   @Test
stdin_background()31   public void stdin_background() throws IOException {
32     stdin_operation("background");
33   }
34 
35   @Test
stdin_multibackground()36   public void stdin_multibackground() throws IOException {
37     stdin_operation("multibackground");
38   }
39 
40   @Test
stdin_stamp()41   public void stdin_stamp() throws IOException {
42     stdin_operation("stamp");
43   }
44 
45   @Test
stdin_multistamp()46   public void stdin_multistamp() throws IOException {
47     stdin_operation("multistamp");
48   }
49 
50   @Test
background_stdin()51   public void background_stdin() throws IOException {
52     operation_stdin("background");
53   }
54 
55   @Test
multibackground_stdin()56   public void multibackground_stdin() throws IOException {
57     operation_stdin("multibackground");
58   }
59 
60   @Test
stamp_stdin()61   public void stamp_stdin() throws IOException {
62     operation_stdin("stamp");
63   }
64 
65   @Test
multistamp_stdin()66   public void multistamp_stdin() throws IOException {
67     operation_stdin("multistamp");
68   }
69 
70 };
71