Skip to content

Commit 801780b

Browse files
committed
Update junit 4.12 to 4.13.1 to remove security warning.
This also involved replacing the deprecated org.junit.Assert.assertThat with org.hamcrest.MatcherAssert.assertThat. NOTE: The security issue in junit 4.12 (which relates to information disclosure using TemporaryFolder rule) does not affect this project so this update is mostly to appease security scanners.
1 parent 4f94cc8 commit 801780b

File tree

18 files changed

+53
-49
lines changed

18 files changed

+53
-49
lines changed

openhtmltopdf-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>junit</groupId>
3535
<artifactId>junit</artifactId>
36-
<version>4.12</version>
36+
<version>${open.junit4.version}</version>
3737
<scope>test</scope>
3838
</dependency>
3939
</dependencies>

openhtmltopdf-core/src/test/java/com/openhtmltopdf/layout/BreakerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import static org.hamcrest.core.IsEqual.equalTo;
66
import static org.junit.Assert.assertTrue;
77
import static org.junit.Assert.assertFalse;
8-
import static org.junit.Assert.assertThat;
8+
import static org.hamcrest.MatcherAssert.assertThat;
99

1010
import static com.openhtmltopdf.layout.BreakerTestSupport.*;
1111

openhtmltopdf-core/src/test/java/com/openhtmltopdf/layout/BreakerTestSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.openhtmltopdf.layout;
22

33
import static org.hamcrest.core.IsEqual.equalTo;
4-
import static org.junit.Assert.assertThat;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.util.Arrays;
77
import java.util.EnumSet;

openhtmltopdf-core/src/test/java/com/openhtmltopdf/layout/TextTransformersTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22

33
import java.util.Locale;
44

5-
import org.junit.Assert;
65
import org.junit.Test;
76
import static org.hamcrest.CoreMatchers.*;
7+
import static org.hamcrest.MatcherAssert.assertThat;
88

99
import com.openhtmltopdf.extend.FSTextTransformer;
1010

1111
public class TextTransformersTest {
1212
@Test
1313
public void testSimpleToUpperTransform() {
1414
FSTextTransformer tr = new TextUtil.DefaultToUpperTransformer(Locale.US);
15-
Assert.assertThat(tr.transform("this is a Test"), equalTo("THIS IS A TEST"));
15+
assertThat(tr.transform("this is a Test"), equalTo("THIS IS A TEST"));
1616
}
1717

1818
@Test
1919
public void testSimpleToLowerTransform() {
2020
FSTextTransformer tr = new TextUtil.DefaultToLowerTransformer(Locale.US);
21-
Assert.assertThat(tr.transform("THIS IS a TEST"), equalTo("this is a test"));
21+
assertThat(tr.transform("THIS IS a TEST"), equalTo("this is a test"));
2222
}
2323

2424
@Test
2525
public void testSimpleToTitleTransform() {
2626
FSTextTransformer tr = new TextUtil.DefaultToTitleTransformer();
27-
Assert.assertThat(tr.transform("this iS a teST"), equalTo("This IS A TeST"));
27+
assertThat(tr.transform("this iS a teST"), equalTo("This IS A TeST"));
2828
}
2929

3030
@Test
@@ -35,7 +35,7 @@ public void testPunctuationUnchanged() {
3535
new TextUtil.DefaultToTitleTransformer() };
3636

3737
for (FSTextTransformer tr : trs) {
38-
Assert.assertThat(tr.transform("!@#$%^&&*()_-+=?/><,.~`"), equalTo("!@#$%^&&*()_-+=?/><,.~`"));
38+
assertThat(tr.transform("!@#$%^&&*()_-+=?/><,.~`"), equalTo("!@#$%^&&*()_-+=?/><,.~`"));
3939
}
4040
}
4141
}

openhtmltopdf-core/src/test/java/com/openhtmltopdf/layout/WordBreakerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static com.openhtmltopdf.layout.BreakerTestSupport.*;
44
import static org.hamcrest.core.IsEqual.equalTo;
5-
import static org.junit.Assert.assertThat;
5+
import static org.hamcrest.MatcherAssert.assertThat;
66

77
import org.junit.Test;
88

openhtmltopdf-core/src/test/java/com/openhtmltopdf/resource/FSEntityResolverTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.InputStream;
44
import java.util.Map;
55
import static org.hamcrest.CoreMatchers.notNullValue;
6+
import static org.hamcrest.MatcherAssert.assertThat;
67
import org.junit.Assert;
78
import org.junit.Test;
89
import org.xml.sax.InputSource;
@@ -15,7 +16,7 @@ public void testResolveEntity() throws Exception {
1516
String publicId = "-//OPENHTMLTOPDF//DOC XHTML Character Entities Only 1.0//EN";
1617
InputSource resolvedEntity = instance.resolveEntity(publicId, null);
1718
try (InputStream in = resolvedEntity.getByteStream()) {
18-
Assert.assertThat(in, notNullValue());
19+
assertThat(in, notNullValue());
1920
}
2021
}
2122

openhtmltopdf-core/src/test/java/com/openhtmltopdf/swing/DefaultUriResolverTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import static org.hamcrest.core.IsEqual.equalTo;
44

5-
import org.junit.Assert;
65
import org.junit.Ignore;
76
import org.junit.Test;
7+
import static org.hamcrest.MatcherAssert.assertThat;
88

99
import com.openhtmltopdf.extend.FSUriResolver;
1010

@@ -14,44 +14,44 @@ public class DefaultUriResolverTest {
1414

1515
@Test
1616
public void testJarHttpUrlResolve() {
17-
Assert.assertThat(resolver.resolveURI("jar:http://www.foo.com/bar/baz.jar!/", "logo.png"), equalTo("jar:http://www.foo.com/bar/baz.jar!/logo.png"));
17+
assertThat(resolver.resolveURI("jar:http://www.foo.com/bar/baz.jar!/", "logo.png"), equalTo("jar:http://www.foo.com/bar/baz.jar!/logo.png"));
1818
}
1919

2020
@Test
2121
public void testJarFileUrlResolve() {
22-
Assert.assertThat(resolver.resolveURI("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/", "logo.jpg"), equalTo("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"));
22+
assertThat(resolver.resolveURI("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/", "logo.jpg"), equalTo("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"));
2323
}
2424

2525
@Test
2626
public void testAbsoluteJarFileAsRelativePart() {
27-
Assert.assertThat(resolver.resolveURI("http://example.com/", "jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"), equalTo("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"));
27+
assertThat(resolver.resolveURI("http://example.com/", "jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"), equalTo("jar:file:/E:/example/target/server-1.0.0.war!/WEB-INF/classes!/export/logo.jpg"));
2828
}
2929

3030
@Test
3131
@Ignore("Base URIs not working with out a trailing slash")
3232
public void testNonJarUrlResolveWithoutTrailingSlash() {
33-
Assert.assertThat(resolver.resolveURI("http://example.com", "logo.png"), equalTo("http://example.com/logo.png"));
33+
assertThat(resolver.resolveURI("http://example.com", "logo.png"), equalTo("http://example.com/logo.png"));
3434
}
3535

3636
@Test
3737
public void testNonJarUrlResolveWithTrailingSlash() {
38-
Assert.assertThat(resolver.resolveURI("http://example.com/", "logo.png"), equalTo("http://example.com/logo.png"));
38+
assertThat(resolver.resolveURI("http://example.com/", "logo.png"), equalTo("http://example.com/logo.png"));
3939
}
4040

4141
@Test
4242
public void testNonJarWithPath() {
43-
Assert.assertThat(resolver.resolveURI("http://example.com/path/", "logo.png"), equalTo("http://example.com/path/logo.png"));
43+
assertThat(resolver.resolveURI("http://example.com/path/", "logo.png"), equalTo("http://example.com/path/logo.png"));
4444
}
4545

4646
@Test
4747
public void testAbsoluteAsPartialUrl() {
48-
Assert.assertThat(resolver.resolveURI("http://example.com/", "http://sample.com/logo.png"), equalTo("http://sample.com/logo.png"));
48+
assertThat(resolver.resolveURI("http://example.com/", "http://sample.com/logo.png"), equalTo("http://sample.com/logo.png"));
4949
}
5050

5151
@Test
5252
@Ignore("Should empty urls should resolve to the base rather than null?")
5353
public void testEmptyUrl() {
54-
Assert.assertThat(resolver.resolveURI("http://example.com/", ""), equalTo("http://example.com/"));
54+
assertThat(resolver.resolveURI("http://example.com/", ""), equalTo("http://example.com/"));
5555
}
5656

5757

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,73 @@
11
package com.openhtmltopdf.util;
22

3-
import static org.hamcrest.CoreMatchers.is;
43
import org.junit.Test;
5-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
6+
import org.hamcrest.CoreMatchers;
67

78
public class ConfigurationTest {
89

910
@Test
1011
public void testValueFor() {
1112
String key = "xr.test-config-byte";
1213
String value = Configuration.valueFor(key);
13-
assertThat(value, is("8"));
14+
assertThat(value, CoreMatchers.is("8"));
1415
}
1516

1617
@Test
1718
public void testValueAsByte() {
1819
String key = "xr.test-config-byte";
1920
int value = Configuration.valueAsByte(key, (byte) 0);
20-
assertThat(value, is(8));
21+
assertThat(value, CoreMatchers.is(8));
2122
}
2223

2324
@Test
2425
public void testValueAsShort() {
2526
String key = "xr.test-config-short";
2627
int value = Configuration.valueAsShort(key, (short) 0);
27-
assertThat(value, is(16));
28+
assertThat(value, CoreMatchers.is(16));
2829
}
2930

3031
@Test
3132
public void testValueAsInt() {
3233
String key = "xr.test-config-int";
33-
int value = Configuration.valueAsInt(key, (int) 0);
34-
assertThat(value, is(100));
34+
int value = Configuration.valueAsInt(key, 0);
35+
assertThat(value, CoreMatchers.is(100));
3536
}
3637

3738
@Test
3839
public void testValueAsLong() {
3940
String key = "xr.test-config-long";
40-
long value = Configuration.valueAsLong(key, (long) 0);
41-
assertThat(value, is(2000L));
41+
long value = Configuration.valueAsLong(key, 0l);
42+
assertThat(value, CoreMatchers.is(2000L));
4243
}
4344

4445
@Test
4546
public void testValueAsFloat() {
4647
String key = "xr.test-config-float";
47-
float value = Configuration.valueAsFloat(key, (float) 0);
48-
assertThat(value, is(3000.25F));
48+
float value = Configuration.valueAsFloat(key, 0f);
49+
assertThat(value, CoreMatchers.is(3000.25F));
4950
}
5051

5152
@Test
5253
public void testValueAsDouble() {
5354
String key = "xr.test-config-double";
54-
double value = Configuration.valueAsDouble(key, (double) 0);
55-
assertThat(value, is(4000.50D));
55+
double value = Configuration.valueAsDouble(key, 0d);
56+
assertThat(value, CoreMatchers.is(4000.50D));
5657
}
5758

5859
@Test
5960
public void testIsTrue() {
6061
String key = "xr.test-config-boolean";
6162
boolean value = Configuration.isTrue(key, false);
62-
assertThat(value, is(true));
63+
assertThat(value, CoreMatchers.is(true));
6364
}
6465

6566
@Test
6667
public void testIsFalse() {
6768
String key = "xr.test-config-boolean";
6869
boolean value = Configuration.isFalse(key, true);
69-
assertThat(value, is(false));
70+
assertThat(value, CoreMatchers.is(false));
7071
}
7172

7273
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
package com.openhtmltopdf.util;
22

33
import java.awt.image.BufferedImage;
4-
import static org.hamcrest.CoreMatchers.is;
54
import static org.hamcrest.CoreMatchers.notNullValue;
5+
6+
import org.hamcrest.CoreMatchers;
67
import org.junit.Test;
7-
import org.junit.Assert;
8+
import static org.hamcrest.MatcherAssert.assertThat;
89

910
public class ImageUtilTest {
1011

1112
@Test
1213
public void testGetEmbeddedBase64Image() {
1314
String onePixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC";
1415
byte[] result = ImageUtil.getEmbeddedBase64Image(onePixel);
15-
Assert.assertThat(result, notNullValue());
16+
assertThat(result, notNullValue());
1617
}
1718

1819
@Test
1920
public void testLoadEmbeddedBase64Image() {
2021
String onePixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC";
2122
BufferedImage result = ImageUtil.loadEmbeddedBase64Image(onePixel);
22-
Assert.assertThat(result.getHeight(), is(1));
23-
Assert.assertThat(result.getWidth(), is(1));
23+
assertThat(result.getHeight(), CoreMatchers.is(1));
24+
assertThat(result.getWidth(), CoreMatchers.is(1));
2425
}
2526

2627
}

openhtmltopdf-examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<dependency>
119119
<groupId>junit</groupId>
120120
<artifactId>junit</artifactId>
121-
<version>4.12</version>
121+
<version>${open.junit4.version}</version>
122122
<scope>test</scope>
123123
</dependency>
124124
</dependencies>

openhtmltopdf-examples/src/test/java/com/openhtmltopdf/nonvisualregressiontests/NonVisualRegressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.openhtmltopdf.nonvisualregressiontests;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertThat;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55
import static org.hamcrest.CoreMatchers.equalTo;
66
import static org.hamcrest.CoreMatchers.instanceOf;
77

openhtmltopdf-objects/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>junit</groupId>
4848
<artifactId>junit</artifactId>
49-
<version>4.12</version>
49+
<version>${open.junit4.version}</version>
5050
<scope>test</scope>
5151
</dependency>
5252
<dependency>

openhtmltopdf-pdfa-testing/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>junit</groupId>
4747
<artifactId>junit</artifactId>
48-
<version>4.12</version>
48+
<version>${open.junit4.version}</version>
4949
<scope>test</scope>
5050
</dependency>
5151
</dependencies>

openhtmltopdf-pdfbox/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>junit</groupId>
4646
<artifactId>junit</artifactId>
47-
<version>4.12</version>
47+
<version>${open.junit4.version}</version>
4848
<scope>test</scope>
4949
</dependency>
5050
<dependency>

openhtmltopdf-slf4j/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<dependency>
6262
<groupId>junit</groupId>
6363
<artifactId>junit</artifactId>
64-
<version>4.12</version>
64+
<version>${open.junit4.version}</version>
6565
<scope>test</scope>
6666
</dependency>
6767

openhtmltopdf-slf4j/src/test/java/com/openhtmltopdf/slf4j/Slf4JLoggerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import java.io.IOException;
55
import java.io.PrintStream;
66

7-
import org.junit.Assert;
87
import org.junit.BeforeClass;
98
import org.junit.Test;
109

1110
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
1211
import com.openhtmltopdf.util.XRLog;
1312

1413
import static org.hamcrest.CoreMatchers.containsString;
14+
import static org.hamcrest.MatcherAssert.assertThat;
1515

1616
public class Slf4JLoggerTest {
1717

@@ -43,8 +43,8 @@ public void testLogger() throws IOException {
4343
old.println(log);
4444
System.setErr(old);
4545

46-
Assert.assertThat(log, containsString("] [INFO]"));
47-
Assert.assertThat(log, containsString("] [WARN]"));
46+
assertThat(log, containsString("] [INFO]"));
47+
assertThat(log, containsString("] [WARN]"));
4848
}
4949

5050
/**

openhtmltopdf-templates/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<dependency>
7575
<groupId>junit</groupId>
7676
<artifactId>junit</artifactId>
77-
<version>4.12</version>
77+
<version>${open.junit4.version}</version>
7878
<scope>test</scope>
7979
</dependency>
8080
</dependencies>

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<open.jar.plugin.version>3.2.0</open.jar.plugin.version>
152152

153153
<open.batik.version>1.12</open.batik.version>
154+
<open.junit4.version>4.13.1</open.junit4.version>
154155

155156
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
156157
</properties>

0 commit comments

Comments
 (0)