pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1846538 - in /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox: cos/ pdfwriter/ pdmodel/ pdmodel/graphics/state/
Date Tue, 13 Nov 2018 20:08:25 GMT
Author: tilman
Date: Tue Nov 13 20:08:25 2018
New Revision: 1846538

URL: http://svn.apache.org/viewvc?rev=1846538&view=rev
Log:
PDFBOX-4373: add additional unit tests, by John Bergqvist with Diffblue Cover

Added:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/cos/COSObjectKeyTest.java
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntryTest.java
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageModeTest.java
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntentTest.java
Modified:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageLayoutTest.java

Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/cos/COSObjectKeyTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/cos/COSObjectKeyTest.java?rev=1846538&view=auto
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/cos/COSObjectKeyTest.java (added)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/cos/COSObjectKeyTest.java Tue
Nov 13 20:08:25 2018
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.cos;
+
+import org.apache.pdfbox.cos.COSObjectKey;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class COSObjectKeyTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void compareToInputNotNullOutputZero() {
+
+        // Arrange
+        final COSObjectKey objectUnderTest = new COSObjectKey(0L, 0);
+        final COSObjectKey other = new COSObjectKey(0L, 0);
+
+        // Act
+        final int retval = objectUnderTest.compareTo(other);
+
+        // Assert result
+        Assert.assertEquals(0, retval);
+    }
+
+    @Test
+    public void compareToInputNotNullOutputPositive() {
+
+        // Arrange
+        final COSObjectKey objectUnderTest = new COSObjectKey(0L, 0);
+        final COSObjectKey other = new COSObjectKey(-9223372036854775808L, 0);
+
+        // Act
+        final int retval = objectUnderTest.compareTo(other);
+
+        // Assert result
+        Assert.assertEquals(1, retval);
+    }
+}

Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntryTest.java?rev=1846538&view=auto
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntryTest.java
(added)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntryTest.java
Tue Nov 13 20:08:25 2018
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdfwriter;
+
+import org.apache.pdfbox.pdfwriter.COSWriterXRefEntry;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class COSWriterXRefEntryTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void compareToInputNullOutputNegative() {
+
+        // Arrange
+        final COSWriterXRefEntry objectUnderTest = new COSWriterXRefEntry(0L, null, null);
+        final COSWriterXRefEntry obj = null;
+
+        // Act
+        final int retval = objectUnderTest.compareTo(obj);
+
+        // Assert result
+        Assert.assertEquals(-1, retval);
+    }
+}

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageLayoutTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageLayoutTest.java?rev=1846538&r1=1846537&r2=1846538&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageLayoutTest.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageLayoutTest.java
Tue Nov 13 20:08:25 2018
@@ -19,14 +19,14 @@ import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
 import static org.junit.Assert.assertEquals;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-/**
- * @author Tilman Hausherr
- */
 public class PageLayoutTest
 {
     /**
+     * @author Tilman Hausherr
      * Test for completeness (PDFBOX-3362).
      */
     @Test
@@ -43,4 +43,21 @@ public class PageLayoutTest
         assertEquals(PageLayout.values().length, pageLayoutSet.size());
         assertEquals(PageLayout.values().length, stringSet.size());
     }
+
+    /**
+     * @author John Bergqvist
+     */
+    @Rule public ExpectedException thrown = ExpectedException.none();
+    @Test
+    public void fromStringInputNotNullOutputIllegalArgumentException() {
+
+        // Arrange
+        final String value = "SinglePag";
+
+        // Act
+        thrown.expect(IllegalArgumentException.class);
+        PageLayout.fromString(value);
+
+        // Method is not expected to return due to exception thrown
+    }
 }

Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageModeTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageModeTest.java?rev=1846538&view=auto
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageModeTest.java (added)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/PageModeTest.java Tue
Nov 13 20:08:25 2018
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel;
+
+import org.apache.pdfbox.pdmodel.PageMode;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.Timeout;
+
+public class PageModeTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull() {
+
+        // Arrange
+        final String value = "FullScreen";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.FULL_SCREEN, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull2() {
+
+        // Arrange
+        final String value = "UseThumbs";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.USE_THUMBS, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull3() {
+
+        // Arrange
+        final String value = "UseOC";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.USE_OPTIONAL_CONTENT, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull4() {
+
+        // Arrange
+        final String value = "UseNone";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.USE_NONE, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull5() {
+
+        // Arrange
+        final String value = "UseAttachments";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.USE_ATTACHMENTS, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull6() {
+
+        // Arrange
+        final String value = "UseOutlines";
+
+        // Act
+        final PageMode retval = PageMode.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(PageMode.USE_OUTLINES, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputIllegalArgumentException() {
+
+        // Arrange
+        final String value = "";
+
+        // Act
+        thrown.expect(IllegalArgumentException.class);
+        PageMode.fromString(value);
+
+        // Method is not expected to return due to exception thrown
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputIllegalArgumentException2() {
+
+        // Arrange
+        final String value = "Dulacb`ecj";
+
+        // Act
+        thrown.expect(IllegalArgumentException.class);
+        PageMode.fromString(value);
+
+        // Method is not expected to return due to exception thrown
+    }
+
+    @Test
+    public void stringValueOutputNotNull() {
+
+        // Arrange
+        final PageMode objectUnderTest = PageMode.USE_OPTIONAL_CONTENT;
+
+        // Act
+        final String retval = objectUnderTest.stringValue();
+
+        // Assert result
+        Assert.assertEquals("UseOC", retval);
+    }
+}

Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntentTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntentTest.java?rev=1846538&view=auto
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntentTest.java
(added)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntentTest.java
Tue Nov 13 20:08:25 2018
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.graphics.state;
+
+import org.apache.pdfbox.pdmodel.graphics.state.RenderingIntent;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class RenderingIntentTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull() {
+
+        // Arrange
+        final String value = "AbsoluteColorimetric";
+
+        // Act
+        final RenderingIntent retval = RenderingIntent.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(RenderingIntent.ABSOLUTE_COLORIMETRIC, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull2() {
+
+        // Arrange
+        final String value = "RelativeColorimetric";
+
+        // Act
+        final RenderingIntent retval = RenderingIntent.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(RenderingIntent.RELATIVE_COLORIMETRIC, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull3() {
+
+        // Arrange
+        final String value = "Perceptual";
+
+        // Act
+        final RenderingIntent retval = RenderingIntent.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(RenderingIntent.PERCEPTUAL, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull4() {
+
+        // Arrange
+        final String value = "Saturation";
+
+        // Act
+        final RenderingIntent retval = RenderingIntent.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(RenderingIntent.SATURATION, retval);
+    }
+
+    @Test
+    public void fromStringInputNotNullOutputNotNull5() {
+
+        // Arrange
+        final String value = "";
+
+        // Act
+        final RenderingIntent retval = RenderingIntent.fromString(value);
+
+        // Assert result
+        Assert.assertEquals(RenderingIntent.RELATIVE_COLORIMETRIC, retval);
+    }
+
+    @Test
+    public void stringValueOutputNotNull() {
+
+        // Arrange
+        final RenderingIntent objectUnderTest = RenderingIntent.ABSOLUTE_COLORIMETRIC;
+
+        // Act
+        final String retval = objectUnderTest.stringValue();
+
+        // Assert result
+        Assert.assertEquals("AbsoluteColorimetric", retval);
+    }
+}



Mime
View raw message