mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-18 17:47:05 +01:00
codacy recommended updates
This commit is contained in:
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
@@ -70,6 +71,7 @@ public class ChecksumTest {
|
||||
|
||||
expectedException.expect(IOException.class);
|
||||
Checksum.getChecksum(algorithm, file);
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,11 +20,13 @@ package org.owasp.dependencycheck.utils;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -58,20 +60,31 @@ public class ExpectedOjectInputStreamTest {
|
||||
* Test of resolveClass method, of class ExpectedOjectInputStream.
|
||||
*/
|
||||
@Test
|
||||
public void testResolveClass() throws Exception {
|
||||
List<SimplePojo> data = new ArrayList<SimplePojo>();
|
||||
data.add(new SimplePojo());
|
||||
|
||||
ByteArrayOutputStream mem = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(mem));
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
byte[] buf = mem.toByteArray();
|
||||
out.close();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf);
|
||||
|
||||
ExpectedOjectInputStream instance = new ExpectedOjectInputStream(in, "java.util.ArrayList", "org.owasp.dependencycheck.utils.SimplePojo", "java.lang.Integer", "java.lang.Number");
|
||||
instance.readObject();
|
||||
public void testResolveClass() {
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
List<SimplePojo> data = new ArrayList<>();
|
||||
data.add(new SimplePojo());
|
||||
ByteArrayOutputStream mem = new ByteArrayOutputStream();
|
||||
out = new ObjectOutputStream(new BufferedOutputStream(mem));
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
byte[] buf = mem.toByteArray();
|
||||
out.close();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf);
|
||||
ExpectedOjectInputStream instance = new ExpectedOjectInputStream(in, "java.util.ArrayList", "org.owasp.dependencycheck.utils.SimplePojo", "java.lang.Integer", "java.lang.Number");
|
||||
instance.readObject();
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
fail(ex.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user