Deee92 opened a new pull request, #164:
URL: https://github.com/apache/pdfbox/pull/164

   Hello!
   
   I tried a few command-line tools on some PDF documents, and found that 
[`org.apache.pdfbox.cos.COSName.writePDF(OutputStream)`](https://github.com/apache/pdfbox/blob/b5658f36d525961a2d086acf7c2c5a188e1a1c5b/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java#L774)
 was invoked during the execution.
   
   Here are two tests that verify the invocation of 
`java.io.OutputStream.write(int)` within `writePDF`. The `OutputStream` object 
is mocked within the tests.
   
   The following test verifies the parameters with which `write` should be 
invoked within `writePDF`:
   
   ```
   @Test
   public void testBytesWrittenToOutputStreamForCOSNameType() throws IOException
   {
       // Arrange
       COSName cosNameType = COSName.TYPE;
       OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
   
       // Act
       cosNameType.writePDF(mockOutputStream);
   
       // Assert
       verify(mockOutputStream, atLeastOnce()).write(47);
       verify(mockOutputStream, atLeastOnce()).write(84);
       verify(mockOutputStream, atLeastOnce()).write(121);
       verify(mockOutputStream, atLeastOnce()).write(112);
       verify(mockOutputStream, atLeastOnce()).write(101);
   }
   ```
   
   The following test verifies that `write` should be called exactly five times 
within `writePDF`:
   
   ```
   @Test
   public void testNumberOfBytesWrittenToOutputStreamForCOSNameType() throws 
IOException
   {
       // Arrange
       COSName cosNameType = COSName.TYPE;
       OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
   
       // Act
       cosNameType.writePDF(mockOutputStream);
   
       // Assert
       verify(mockOutputStream, times(5)).write(anyInt());
   }
   ```
   
   What do you think?
   
   Thanks!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to