Fixed many warnings

This commit is contained in:
Ziver Koc 2018-05-27 01:23:21 +02:00
parent c570847f3a
commit ccecc067b2
160 changed files with 951 additions and 1151 deletions

View file

@ -15,13 +15,13 @@ import static org.junit.Assert.fail;
public class CronTimerTest {
@Test
public void getRange() throws Exception {
public void getRange() {
// invalid numbers
assertEquals(Collections.EMPTY_LIST, CronTimer.getRange("", 0,60));
assertEquals(Collections.EMPTY_LIST, CronTimer.getRange(null, 0,60));
// individual numbers
assertEquals(Arrays.asList(55), CronTimer.getRange("55", 0,60));
assertEquals(Collections.singletonList(55), CronTimer.getRange("55", 0,60));
assertEquals(Arrays.asList(5,10,15), CronTimer.getRange("5,10,15", 0, 60));
// ranges
@ -29,7 +29,7 @@ public class CronTimerTest {
assertEquals(Arrays.asList(5,6,7,8,9,10), CronTimer.getRange("5-10", 0,60));
// intervals
assertEquals(Arrays.asList(), CronTimer.getRange("15/10", 0,60));
assertEquals(Collections.emptyList(), CronTimer.getRange("15/10", 0,60));
assertEquals(Arrays.asList(0,10,20,30,40,50,60), CronTimer.getRange("0-60/10", 0,60));
// wildcards

View file

@ -27,6 +27,7 @@ package zutil;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
@ -43,9 +44,9 @@ public class StringUtilTest {
public void formatTimeToStringTest() {
assertEquals( "1 sec ", StringUtil.formatTimeToString( 1000 ) );
assertEquals( "1 month 1 day 1 hour 1 min 1 sec 1 milisec ",
StringUtil.formatTimeToString( 2629743830l+86400000+3600000+60000+1000+1 ) );
StringUtil.formatTimeToString(2629743830L +86400000+3600000+60000+1000+1 ) );
assertEquals( "2 months 2 days 2 hours 2 min 2 sec 2 milisec ",
StringUtil.formatTimeToString( (2629743830l+86400000+3600000+60000+1000+1)*2 ) );
StringUtil.formatTimeToString( (2629743830L +86400000+3600000+60000+1000+1)*2 ) );
}
@Test
@ -72,7 +73,7 @@ public class StringUtilTest {
@Test
public void joinTest(){
assertEquals("", StringUtil.join(",", Arrays.asList()));
assertEquals("", StringUtil.join(",", Collections.emptyList()));
assertEquals("1,2,3,4,5", StringUtil.join(",", 1,2,3,4,5));
assertEquals("1,2,3,4,5", StringUtil.join(",", Arrays.asList(1,2,3,4,5)));
assertEquals("animal,monkey,dog", StringUtil.join(",", "animal", "monkey", "dog"));

View file

@ -40,7 +40,7 @@ public class StringSplitBenchmark {
public void substring(){
for(int i=0; i<TEST_EXECUTIONS; i++) {
List<String> splitList = StringUtil.split(str, delimiter.charAt(0));
assertSplit(splitList.toArray(new String[splitList.size()]));
assertSplit(splitList.toArray(new String[0]));
}
}

View file

@ -44,13 +44,13 @@ public class DBConnectionTest {
db.exec("UPDATE ...");
// Query 3
String s = db.exec("SELECT hello", new SimpleSQLResult<String>());
String s = db.exec("SELECT hello", new SimpleSQLResult<>());
System.out.println( s );
// Query 4
PreparedStatement sql2 = db.getPreparedStatement("SELECT ?");
sql2.setString(1, "hello");
String s2 = DBConnection.exec(sql2, new SimpleSQLResult<String>());
String s2 = DBConnection.exec(sql2, new SimpleSQLResult<>());
System.out.println( s2 );
db.close();

View file

@ -41,11 +41,11 @@ import java.io.InputStream;
@SuppressWarnings({ "unused", "rawtypes" })
public class ImageProcessorTest implements ProgressListener{
private static String imgPath = "test.gif";
//private static String imgPath = "test2.jpg";
private static final String IMAGE_PATH = "test.gif";
//private static final String IMAGE_PATH = "test2.jpg";
private JLabel processedLabel;
private JLabel orginalLabel;
private JLabel originalLabel;
private JProgressBar progress;
public static void main(String[] args){
@ -59,15 +59,15 @@ public class ImageProcessorTest implements ProgressListener{
try {
// Read from an input stream
InputStream is = new BufferedInputStream(new FileInputStream(imgPath));
InputStream is = new BufferedInputStream(new FileInputStream(IMAGE_PATH));
img = ImageIO.read(is);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
ImageIcon orginalIcon = new ImageIcon(img);
orginalLabel.setIcon(orginalIcon);
ImageIcon originalIcon = new ImageIcon(img);
originalLabel.setIcon(originalIcon);
frame.setVisible(true);
frame.pack();
@ -98,7 +98,7 @@ public class ImageProcessorTest implements ProgressListener{
private JFrame getJFrame() {
processedLabel = new JLabel("Processed");
orginalLabel = new JLabel("Orginal");
originalLabel = new JLabel("Original");
progress = new JProgressBar();
progress.setMaximum(100);
@ -108,7 +108,7 @@ public class ImageProcessorTest implements ProgressListener{
JPanel jPanel = new JPanel();
jPanel.setLayout(new BorderLayout());
jPanel.add(orginalLabel, BorderLayout.NORTH);
jPanel.add(originalLabel, BorderLayout.NORTH);
jPanel.add(processedLabel, BorderLayout.CENTER);
jPanel.add(progress, BorderLayout.SOUTH);

View file

@ -262,7 +262,7 @@ public class BufferedBoundaryInputStreamTest {
"aaaaaaaaaaaa#aa#aaaaaaaaaaaaaaa#", "#", 10);
byte[] buff = new byte[100];
int n = 0;
int n;
assertTrue(in.hasNext());
n = in.read(buff) + in.read(buff);
assertEquals(12, n);

View file

@ -5,6 +5,7 @@ import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* Created by Ziver on 2016-07-12.
@ -18,7 +19,7 @@ public class IOUtilTest {
assertEquals("test", IOUtil.readLine(in));
assertEquals("test2", IOUtil.readLine(in));
assertEquals("test3", IOUtil.readLine(in));
assertEquals(null, IOUtil.readLine(in));
assertNull(IOUtil.readLine(in));
}
@Test
public void readLineCarriageReturn() throws IOException {
@ -26,6 +27,6 @@ public class IOUtilTest {
assertEquals("test", IOUtil.readLine(in));
assertEquals("test2", IOUtil.readLine(in));
assertEquals(null, IOUtil.readLine(in));
assertNull(IOUtil.readLine(in));
}
}

View file

@ -30,7 +30,7 @@ import java.net.URISyntaxException;
public class FileChangedTest implements FileChangeListener{
public static void main(String[] args) throws URISyntaxException, FileNotFoundException{
public static void main(String[] args) throws FileNotFoundException{
FileWatcher watcher = new FileWatcher(FileUtil.find("test.txt"));
watcher.setListener(new FileChangedTest());

View file

@ -7,8 +7,7 @@ import java.io.IOException;
import java.util.Iterator;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
/**
* JUnit test for MultipartParser class
@ -41,8 +40,8 @@ public class MultipartParserTest {
assertEquals("bar", stringField.getValue());
assertFalse(it.hasNext());
assertEquals(null, it.next());
assertEquals(null, it.next());
assertNull(it.next());
assertNull(it.next());
}
@Test

View file

@ -37,7 +37,7 @@ public class HttpDigestAuthPageTest {
HttpHeader rspHeader = HttpTestUtil.makeRequest(page);
assertEquals(401, rspHeader.getHTTPCode());
assertTrue(rspHeader.getHeader("WWW-Authenticate") != null);
assertNotNull(rspHeader.getHeader("WWW-Authenticate"));
assertEquals("Digest", parseAuthType(rspHeader));
Map<String,String> authHeader = parseAuthHeader(rspHeader);
assertTrue(authHeader.containsKey("realm"));

View file

@ -46,7 +46,7 @@ public class HttpGuessTheNumber implements HttpPage {
private static final String COOKIE_KEY_HIGH = "high";
public static void main(String[] args) throws IOException{
public static void main(String[] args) {
LogUtil.setGlobalLevel(Level.ALL);
LogUtil.setGlobalFormatter(new CompactLogFormatter());

View file

@ -37,7 +37,7 @@ import java.security.NoSuchAlgorithmException;
@SuppressWarnings("unused")
public class NetworkClientTest {
public static void main(String[] args) throws NoSuchAlgorithmException, InterruptedException {
public static void main(String[] args) throws InterruptedException {
try {
//LogUtil.setGlobalLevel(Level.ALL);
LogUtil.setGlobalFormatter(new CompactLogFormatter());

View file

@ -34,7 +34,7 @@ import java.security.NoSuchAlgorithmException;
@SuppressWarnings("unused")
public class NetworkServerTest {
public static void main(String[] args) throws NoSuchAlgorithmException, InterruptedException {
public static void main(String[] args) throws InterruptedException {
try {
//LogUtil.setGlobalLevel(Level.ALL);
LogUtil.setGlobalFormatter(new CompactLogFormatter());

View file

@ -9,7 +9,7 @@ import java.util.logging.Level;
/**
* Sends a test email with SmtpClient class.
*
* @See <a href="https://nilhcem.github.io/FakeSMTP/">Fake SMTP Server</a>
* @see <a href="https://nilhcem.github.io/FakeSMTP/">Fake SMTP Server</a>
*/
public class SmtpClientTest {

View file

@ -36,7 +36,7 @@ import java.util.logging.Level;
// TODO: COnvert to JUnit
public class SOAPClientTest {
public static void main(String[] args) throws InstantiationException, IllegalAccessException, MalformedURLException {
public static void main(String[] args) throws MalformedURLException {
LogUtil.setGlobalLevel(Level.ALL);
LogUtil.setFormatter("", new CompactLogFormatter());
@ -47,9 +47,9 @@ public class SOAPClientTest {
public interface TestClient extends WSInterface{
public void m();
void m();
public void c();
void c();
}
}

View file

@ -116,7 +116,7 @@ public class SOAPTest {
@WSReturnName("stringArray")
@WSParamDocumentation("Documentation of stringArrayMethod()")
public String[][] stringArrayMethod (
@WSParamName("StringName") String str) throws Exception{
@WSParamName("StringName") String str) {
System.out.println("Executing method: stringArrayMethod(String str='"+str+"')");
return new String[][]{{"test","test2"},{"test3","test4"}};
}
@ -124,7 +124,7 @@ public class SOAPTest {
@WSReturnName("specialReturnClass")
@WSParamDocumentation("Documentation of specialReturnMethod()")
public SpecialReturnClass[] specialReturnMethod (
@WSParamName("StringName2") String str) throws Exception{
@WSParamName("StringName2") String str) {
System.out.println("Executing method: specialReturnMethod(String str='"+str+"')");
return new SpecialReturnClass[]{new SpecialReturnClass(), new SpecialReturnClass()};
}
@ -132,7 +132,7 @@ public class SOAPTest {
@WSReturnName("SimpleReturnClass")
@WSParamDocumentation("null is the kala")
public SimpleReturnClass simpleReturnClassMethod (
@WSParamName("byte") String lol) throws Exception{
@WSParamName("byte") String lol) {
System.out.println("Executing method: simpleReturnClassMethod()");
SimpleReturnClass tmp = new SimpleReturnClass();
tmp.param1 = "newParam1";

View file

@ -30,6 +30,7 @@ import java.io.IOException;
import java.io.StringReader;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
@ -41,7 +42,7 @@ public class CSVParserTest {
@Test
public void emptyTest(){
DataNode node = CSVParser.read("");
assertEquals(null, node);
assertNull(node);
}
@Test

View file

@ -29,6 +29,7 @@ import org.junit.Test;
import java.io.UnsupportedEncodingException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
@ -38,7 +39,7 @@ public class URLDecoderTest {
@Test
public void simpleTest(){
assertEquals(null, URLDecoder.decode(null));
assertNull(URLDecoder.decode(null));
assertEquals("", URLDecoder.decode(""));
assertEquals("space space", URLDecoder.decode("space space"));
assertEquals("space space", URLDecoder.decode("space+space"));

View file

@ -30,8 +30,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.*;
/**
@ -166,10 +165,10 @@ public class BinaryStructInputStreamTest {
public void assertObj(){
assertEquals("i1", 6, i1);
assertEquals("b2", true, b2);
assertEquals("b3", true, b3);
assertEquals("b4", false, b4);
assertEquals("b5", true, b5);
assertTrue("b2", b2);
assertTrue("b3", b3);
assertFalse("b4", b4);
assertTrue("b5", b5);
}
};
@ -194,12 +193,12 @@ public class BinaryStructInputStreamTest {
}
public static class ByteStringSerializer implements BinaryFieldSerializer<String>{
public String read(InputStream in, BinaryFieldData field) throws IOException {
String ret = "";
StringBuilder ret = new StringBuilder();
for (int c; (c=in.read()) > 0; )
ret += c;
return ret;
ret.append(c);
return ret.toString();
}
public void write(OutputStream out, String obj, BinaryFieldData field) throws IOException {}
public void write(OutputStream out, String obj, BinaryFieldData field) {}
}

View file

@ -138,7 +138,7 @@ public class BinaryStructOutputStreamTest {
assertArrayEquals(new byte[]{0b0000_0001,0b0000_0010,0b0000_0011,0b0000_0100}, data);
}
public static class ByteStringSerializer implements BinaryFieldSerializer<String>{
public String read(InputStream in, BinaryFieldData field) throws IOException {
public String read(InputStream in, BinaryFieldData field) {
return null;
}
public void write(OutputStream out, String obj, BinaryFieldData field) throws IOException {

View file

@ -28,8 +28,7 @@ import org.junit.Test;
import zutil.parser.DataNode;
import zutil.parser.DataNode.DataType;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
public class JSONParserTest {
@ -75,23 +74,23 @@ public class JSONParserTest {
assertEquals( DataType.Number, data.getType());
assertEquals( 12.34, data.getDouble(), 0);
}
@Test
public void valueBoolean(){
DataNode data = JSONParser.read("false");
assert(data.isValue());
assertEquals( DataType.Boolean, data.getType());
assertEquals( false, data.getBoolean());
assertFalse(data.getBoolean());
}
@Test
public void valueBooleanUpperCase(){
DataNode data = JSONParser.read("TRUE");
assert(data.isValue());
assertEquals( DataType.Boolean, data.getType());
assertEquals( true, data.getBoolean());
assertTrue(data.getBoolean());
}
@Test
public void valueStringNoQuotes(){
DataNode data = JSONParser.read("teststring");
@ -99,7 +98,7 @@ public class JSONParserTest {
assertEquals( DataType.String, data.getType());
assertEquals( "teststring", data.getString());
}
@Test
public void toManyCommasInList(){
DataNode data = JSONParser.read("[1,2,3,]");

View file

@ -39,7 +39,7 @@ public class JSONSerializerBenchmark {
public BenchmarkRule benchmarkRun = new BenchmarkRule();
@Test
public void testJavaLegacySerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testJavaLegacySerialize() throws IOException, ClassNotFoundException{
for(int i=0; i<TEST_EXECUTIONS; i++){
TestClass sourceObj = new TestClass().init();
@ -60,7 +60,7 @@ public class JSONSerializerBenchmark {
}
@Test
public void testJavaJSONSerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testJavaJSONSerialize() throws IOException {
for(int i=0; i<TEST_EXECUTIONS; i++){
TestClass sourceObj = new TestClass().init();
@ -71,7 +71,7 @@ public class JSONSerializerBenchmark {
}
@Test
public void testOutputJavaLegacySerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testOutputJavaLegacySerialize() throws IOException {
for(int i=0; i<TEST_EXECUTIONS; i++){
TestClass sourceObj = new TestClass().init();
@ -85,7 +85,7 @@ public class JSONSerializerBenchmark {
}
@Test
public void testOutputJavaJSONSerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testOutputJavaJSONSerialize() throws IOException {
for(int i=0; i<TEST_EXECUTIONS; i++){
TestClass sourceObj = new TestClass().init();
@ -94,7 +94,7 @@ public class JSONSerializerBenchmark {
}
@Test
public void testInputJavaLegacySerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputJavaLegacySerialize() throws IOException, ClassNotFoundException{
TestClass sourceObj = new TestClass().init();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
@ -113,12 +113,12 @@ public class JSONSerializerBenchmark {
}
@Test
public void testInputJavaJSONSerialize() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputJavaJSONSerialize() throws IOException {
TestClass sourceObj = new TestClass().init();
String sourceStr = JSONSerializerTest.writeObjectToJson(sourceObj);
for(int i=0; i<TEST_EXECUTIONS; i++){
TestClass targetObj = JSONSerializerTest.readObjectFromJson(sourceStr);
JSONSerializerTest.readObjectFromJson(sourceStr);
}
}
}

View file

@ -41,7 +41,7 @@ import static org.junit.Assert.assertThat;
public class JSONSerializerTest{
@Test
public void testOutputSerializerWithPrimitives() throws InterruptedException, IOException, ClassNotFoundException{
public void testOutputSerializerWithPrimitives() throws IOException {
TestClass sourceObj = new TestClass().init();
String data = writeObjectToJson(sourceObj);
@ -53,7 +53,7 @@ public class JSONSerializerTest{
}
@Test
public void testInputSerializerWithPrimitives() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputSerializerWithPrimitives() throws IOException {
TestClass sourceObj = new TestClass().init();
TestClass targetObj = sendReceiveObject(sourceObj);
@ -62,7 +62,7 @@ public class JSONSerializerTest{
}
@Test
public void testOutputSerializerWithClones() throws InterruptedException, IOException, ClassNotFoundException{
public void testOutputSerializerWithClones() throws IOException {
TestClassObjClone sourceObj = new TestClassObjClone().init();
String data = writeObjectToJson(sourceObj);
@ -74,7 +74,7 @@ public class JSONSerializerTest{
}
@Test
public void testInputSerializerWithClones() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputSerializerWithClones() throws IOException {
TestClassObjClone sourceObj = new TestClassObjClone().init();
TestClassObjClone targetObj = sendReceiveObject(sourceObj);
@ -95,7 +95,7 @@ public class JSONSerializerTest{
}
@Test
public void testInputSerializerWithArrays() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputSerializerWithArrays() throws IOException {
TestClassArray sourceObj = new TestClassArray().init();
TestClassArray targetObj = sendReceiveObject(sourceObj);
@ -103,7 +103,7 @@ public class JSONSerializerTest{
}
@Test
public void testInputSerializerWithStringArrays() throws InterruptedException, IOException, ClassNotFoundException{
public void testInputSerializerWithStringArrays() throws IOException {
TestClassStringArray sourceObj = new TestClassStringArray().init();
TestClassStringArray targetObj = sendReceiveObject(sourceObj);
@ -111,7 +111,7 @@ public class JSONSerializerTest{
}
@Test
public void testSerializerWithNullFieldsHidden() throws InterruptedException, IOException, ClassNotFoundException{
public void testSerializerWithNullFieldsHidden() throws IOException {
TestClass sourceObj = new TestClass();
String data = writeObjectToJson(sourceObj, false);
@ -125,7 +125,7 @@ public class JSONSerializerTest{
}
@Test
public void testSerializerWithMapField() throws InterruptedException, IOException, ClassNotFoundException{
public void testSerializerWithMapField() throws IOException {
TestClassMap sourceObj = new TestClassMap().init();
TestClassMap targetObj = sendReceiveObject(sourceObj);
@ -133,7 +133,7 @@ public class JSONSerializerTest{
}
@Test
public void testSerializerWithMapFieldWithNullEntry() throws InterruptedException, IOException, ClassNotFoundException{
public void testSerializerWithMapFieldWithNullEntry() throws IOException {
TestClassMap sourceObj = new TestClassMap().init();
sourceObj.map.put("key1", null);
@ -143,7 +143,7 @@ public class JSONSerializerTest{
}
@Test
public void testSerializerWithListField() throws InterruptedException, IOException, ClassNotFoundException{
public void testSerializerWithListField() throws IOException {
TestClassList sourceObj = new TestClassList().init();
String data = writeObjectToJson(sourceObj);
@ -155,7 +155,7 @@ public class JSONSerializerTest{
}
@Test
public void testSerializerWithMultipleObj() throws InterruptedException, IOException, ClassNotFoundException{
public void testSerializerWithMultipleObj() throws IOException {
TestClass sourceObj1 = new TestClass().init();
TestClass sourceObj2 = new TestClass().init();
@ -175,13 +175,13 @@ public class JSONSerializerTest{
/******************* Utility Functions ************************************/
public static <T> T sendReceiveObject(T sourceObj) throws IOException{
static <T> T sendReceiveObject(T sourceObj) throws IOException{
return readObjectFromJson(
writeObjectToJson(sourceObj));
}
@SuppressWarnings("unchecked")
public static <T> T readObjectFromJson(String json) throws IOException{
static <T> T readObjectFromJson(String json) throws IOException{
StringReader bin = new StringReader(json);
JSONObjectInputStream in = new JSONObjectInputStream(bin);
T targetObj = (T) in.readObject();
@ -190,10 +190,10 @@ public class JSONSerializerTest{
return targetObj;
}
public static <T> String writeObjectToJson(T sourceObj) throws IOException{
static <T> String writeObjectToJson(T sourceObj) throws IOException{
return writeObjectToJson(sourceObj, true);
}
public static <T> String writeObjectToJson(T sourceObj, boolean metadata) throws IOException{
private static <T> String writeObjectToJson(T sourceObj, boolean metadata) throws IOException{
StringOutputStream bout = new StringOutputStream();
JSONObjectOutputStream out = new JSONObjectOutputStream(bout);
out.enableMetaData(metadata);
@ -202,8 +202,7 @@ public class JSONSerializerTest{
out.flush();
out.close();
String data = bout.toString();
return data;
return bout.toString();
}
/******************** Test Classes ************************************/

View file

@ -32,7 +32,7 @@ import java.util.Random;
/**
* This code may be used, modified, and redistributed provided that the
* This code may be used, modified, and redistributed provided that the
* author tag below remains intact.
*
* @author Ian Clarke <ian@uprizer.com>
@ -41,13 +41,13 @@ import java.util.Random;
public class BloomFilterTest extends TestCase {
public void testBloomFilter() {
DecimalFormat df = new DecimalFormat("0.00000");
Random r = new Random(124445l);
Random r = new Random(124445L);
int bfSize = 400000;
System.out.println("Testing " + bfSize + " bit SimpleBloomFilter");
for (int i = 5; i < 10; i++) {
int addCount = 10000 * (i + 1);
BloomFilter<Integer> bf = new BloomFilter<Integer>(bfSize, addCount);
HashSet<Integer> added = new HashSet<Integer>();
BloomFilter<Integer> bf = new BloomFilter<>(bfSize, addCount);
HashSet<Integer> added = new HashSet<>();
for (int x = 0; x < addCount; x++) {
int num = r.nextInt();
added.add(num);

View file

@ -40,7 +40,7 @@ public class CircularBufferTest {
@Test
public void addToEmpty() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(0);
CircularBuffer<Integer> buff = new CircularBuffer<>(0);
try {
buff.add(10);
fail("IndexOutOfBoundsException was not thrown");
@ -49,7 +49,7 @@ public class CircularBufferTest {
@Test
public void addOneElement() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(1);
CircularBuffer<Integer> buff = new CircularBuffer<>(1);
assertEquals(0, buff.size());
buff.add(10);
assertEquals(1, buff.size());
@ -58,7 +58,7 @@ public class CircularBufferTest {
@Test
public void addThreeElements() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(10);
CircularBuffer<Integer> buff = new CircularBuffer<>(10);
buff.add(10);
buff.add(11);
buff.add(12);
@ -70,7 +70,7 @@ public class CircularBufferTest {
@Test
public void addOutOfRange() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(2);
CircularBuffer<Integer> buff = new CircularBuffer<>(2);
buff.add(10);
buff.add(11);
buff.add(12);
@ -85,7 +85,7 @@ public class CircularBufferTest {
@Test(expected = NoSuchElementException.class)
public void iteratorEmpty() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(10);
CircularBuffer<Integer> buff = new CircularBuffer<>(10);
Iterator<Integer> it = buff.iterator();
assert (!it.hasNext());
@ -94,7 +94,7 @@ public class CircularBufferTest {
@Test(expected = NoSuchElementException.class)
public void iteratorThreeElements() {
CircularBuffer<Integer> buff = new CircularBuffer<Integer>(10);
CircularBuffer<Integer> buff = new CircularBuffer<>(10);
buff.add(10);
buff.add(11);
buff.add(12);

View file

@ -42,7 +42,7 @@ public class ObjectCacheTest {
@Test
public void emptyCache() throws InterruptedException {
public void emptyCache() {
ObjectCache cache = new ObjectCache(10);
assertFalse(cache.containsKey(KEY));
assertEquals(0, cache.size());
@ -78,6 +78,7 @@ public class ObjectCacheTest {
//@Test
// This TC does not work
@SuppressWarnings("RedundantStringConstructorCall")
public void javaGRC() throws InterruptedException {
ObjectCache cache = new ObjectCache(10000);
{