1717 */
1818package org .owasp .dependencycheck .utils ;
1919
20+ import org .junit .jupiter .api .Test ;
21+
2022import java .io .File ;
2123import java .io .IOException ;
2224import java .security .NoSuchAlgorithmException ;
23- import org .junit .Assert ;
24- import static org .junit .Assert .assertArrayEquals ;
2525
26- import static org .junit .Assert .assertEquals ;
27- import static org .junit .Assert .assertTrue ;
28- import static org .junit .Assert .fail ;
29- import org .junit .Test ;
26+ import static org .junit .jupiter .api .Assertions .assertEquals ;
27+ import static org .junit .jupiter .api .Assertions .assertThrows ;
28+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3029
3130/**
3231 *
3332 * @author Jeremy Long
3433 */
35- public class ChecksumTest {
34+ class ChecksumTest {
3635
3736 /**
3837 * Test of getChecksum method, of class Checksum. This checks that an
3938 * exception is thrown when an invalid path is specified.
4039 *
41- * @throws Exception is thrown when an exception occurs.
4240 */
4341 @ Test
44- public void testGetChecksum_FileNotFound () throws Exception {
42+ void testGetChecksum_FileNotFound () {
4543 String algorithm = "MD5" ;
4644 File file = new File ("not a valid file" );
47- Exception exception = Assert . assertThrows (IOException .class , () -> Checksum .getChecksum (algorithm , file ));
45+ Exception exception = assertThrows (IOException .class , () -> Checksum .getChecksum (algorithm , file ));
4846 assertTrue (exception .getMessage ().contains ("not a valid file" ));
4947 }
5048
5149 /**
5250 * Test of getChecksum method, of class Checksum. This checks that an
5351 * exception is thrown when an invalid algorithm is specified.
5452 *
55- * @throws Exception is thrown when an exception occurs.
5653 */
5754 @ Test
58- public void testGetChecksum_NoSuchAlgorithm () throws Exception {
55+ void testGetChecksum_NoSuchAlgorithm () {
5956 String algorithm = "some unknown algorithm" ;
6057 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).getPath ());
61- Exception exception = Assert . assertThrows (NoSuchAlgorithmException .class , () -> Checksum .getChecksum (algorithm , file ));
58+ Exception exception = assertThrows (NoSuchAlgorithmException .class , () -> Checksum .getChecksum (algorithm , file ));
6259 assertTrue (exception .getMessage ().contains ("some unknown algorithm" ));
6360 }
6461
@@ -68,7 +65,7 @@ public void testGetChecksum_NoSuchAlgorithm() throws Exception {
6865 * @throws Exception is thrown when an exception occurs.
6966 */
7067 @ Test
71- public void testGetMD5Checksum () throws Exception {
68+ void testGetMD5Checksum () throws Exception {
7269 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).toURI ().getPath ());
7370 //String expResult = "F0915C5F46B8CFA283E5AD67A09B3793";
7471 String expResult = "f0915c5f46b8cfa283e5ad67a09b3793" ;
@@ -82,7 +79,7 @@ public void testGetMD5Checksum() throws Exception {
8279 * @throws Exception is thrown when an exception occurs.
8380 */
8481 @ Test
85- public void testGetSHA1Checksum () throws Exception {
82+ void testGetSHA1Checksum () throws Exception {
8683 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).toURI ().getPath ());
8784 //String expResult = "B8A9FF28B21BCB1D0B50E24A5243D8B51766851A";
8885 String expResult = "b8a9ff28b21bcb1d0b50e24a5243d8b51766851a" ;
@@ -94,7 +91,7 @@ public void testGetSHA1Checksum() throws Exception {
9491 * Test of getHex method, of class Checksum.
9592 */
9693 @ Test
97- public void testGetHex () {
94+ void testGetHex () {
9895 byte [] raw = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 };
9996 //String expResult = "000102030405060708090A0B0C0D0E0F10";
10097 String expResult = "000102030405060708090a0b0c0d0e0f10" ;
@@ -106,7 +103,7 @@ public void testGetHex() {
106103 * Test of getChecksum method, of class Checksum.
107104 */
108105 @ Test
109- public void testGetChecksum_String_File () throws Exception {
106+ void testGetChecksum_String_File () throws Exception {
110107 String algorithm = "MD5" ;
111108 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).toURI ().getPath ());
112109 String expResult = "f0915c5f46b8cfa283e5ad67a09b3793" ;
@@ -121,7 +118,7 @@ public void testGetChecksum_String_File() throws Exception {
121118 * Test of getMD5Checksum method, of class Checksum.
122119 */
123120 @ Test
124- public void testGetMD5Checksum_File () throws Exception {
121+ void testGetMD5Checksum_File () throws Exception {
125122 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).toURI ().getPath ());
126123 String expResult = "f0915c5f46b8cfa283e5ad67a09b3793" ;
127124 String result = Checksum .getMD5Checksum (file );
@@ -132,7 +129,7 @@ public void testGetMD5Checksum_File() throws Exception {
132129 * Test of getSHA1Checksum method, of class Checksum.
133130 */
134131 @ Test
135- public void testGetSHA1Checksum_File () throws Exception {
132+ void testGetSHA1Checksum_File () throws Exception {
136133 File file = new File (this .getClass ().getClassLoader ().getResource ("checkSumTest.file" ).toURI ().getPath ());
137134 String expResult = "b8a9ff28b21bcb1d0b50e24a5243d8b51766851a" ;
138135 String result = Checksum .getSHA1Checksum (file );
@@ -143,7 +140,7 @@ public void testGetSHA1Checksum_File() throws Exception {
143140 * Test of getChecksum method, of class Checksum.
144141 */
145142 @ Test
146- public void testGetChecksum_String_byteArr () {
143+ void testGetChecksum_String_byteArr () {
147144 String algorithm = "SHA1" ;
148145 byte [] bytes = {-16 , -111 , 92 , 95 , 70 , -72 , -49 , -94 , -125 , -27 , -83 , 103 , -96 , -101 , 55 , -109 };
149146 String expResult = "89268a389a97f0bfba13d3ff2370d8ad436e36f6" ;
@@ -155,7 +152,7 @@ public void testGetChecksum_String_byteArr() {
155152 * Test of getMD5Checksum method, of class Checksum.
156153 */
157154 @ Test
158- public void testGetMD5Checksum_String () {
155+ void testGetMD5Checksum_String () {
159156 String text = "test string" ;
160157 String expResult = "6f8db599de986fab7a21625b7916589c" ;
161158 String result = Checksum .getMD5Checksum (text );
@@ -166,7 +163,7 @@ public void testGetMD5Checksum_String() {
166163 * Test of getSHA1Checksum method, of class Checksum.
167164 */
168165 @ Test
169- public void testGetSHA1Checksum_String () {
166+ void testGetSHA1Checksum_String () {
170167 String text = "test string" ;
171168 String expResult = "661295c9cbf9d6b2f6428414504a8deed3020641" ;
172169 String result = Checksum .getSHA1Checksum (text );
0 commit comments