core java cleanup

This commit is contained in:
eugenp 2016-10-28 15:32:04 +03:00
parent fe2359144e
commit bee18d779f
21 changed files with 127 additions and 116 deletions

View File

@ -1,7 +1,5 @@
package org.baeldung.equalshashcode.entities; package org.baeldung.equalshashcode.entities;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -10,7 +8,7 @@ public class ComplexClass {
private List<?> genericList; private List<?> genericList;
private Set<Integer> integerSet; private Set<Integer> integerSet;
public ComplexClass(ArrayList<?> genericArrayList, HashSet<Integer> integerHashSet) { public ComplexClass(List<?> genericArrayList, Set<Integer> integerHashSet) {
super(); super();
this.genericList = genericArrayList; this.genericList = genericArrayList;
this.integerSet = integerHashSet; this.integerSet = integerHashSet;

View File

@ -4,7 +4,7 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class CharToStringTest { public class CharToStringUnitTest {
@Test @Test
public void givenChar_whenCallingStringValueOf_shouldConvertToString() { public void givenChar_whenCallingStringValueOf_shouldConvertToString() {

View File

@ -36,7 +36,7 @@ import static java.util.stream.Collectors.toSet;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class Java8CollectorsTest { public class Java8CollectorsUnitTest {
private final List<String> givenList = Arrays.asList("a", "bb", "ccc", "dd"); private final List<String> givenList = Arrays.asList("a", "bb", "ccc", "dd");

View File

@ -1,11 +1,5 @@
package com.baeldung.file; package com.baeldung.file;
import org.apache.commons.io.FileUtils;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -20,7 +14,13 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.stream.Stream; import java.util.stream.Stream;
public class FileOperationsTest { import org.apache.commons.io.FileUtils;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
public class FileOperationsUnitTest {
@Test @Test
public void givenFileName_whenUsingClassloader_thenFileData() throws IOException { public void givenFileName_whenUsingClassloader_thenFileData() throws IOException {
@ -38,7 +38,7 @@ public class FileOperationsTest {
public void givenFileNameAsAbsolutePath_whenUsingClasspath_thenFileData() throws IOException { public void givenFileNameAsAbsolutePath_whenUsingClasspath_thenFileData() throws IOException {
String expectedData = "Hello World from fileTest.txt!!!"; String expectedData = "Hello World from fileTest.txt!!!";
Class clazz = FileOperationsTest.class; Class clazz = FileOperationsUnitTest.class;
InputStream inputStream = clazz.getResourceAsStream("/fileTest.txt"); InputStream inputStream = clazz.getResourceAsStream("/fileTest.txt");
String data = readFromInputStream(inputStream); String data = readFromInputStream(inputStream);

View File

@ -6,7 +6,7 @@ import java.io.IOException;
import org.junit.Test; import org.junit.Test;
public class EchoTest { public class NioEchoIntegrationTest {
@Test @Test
public void givenClient_whenServerEchosMessage_thenCorrect() throws IOException, InterruptedException { public void givenClient_whenServerEchosMessage_thenCorrect() throws IOException, InterruptedException {

View File

@ -6,7 +6,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class Java8DefaultStaticIntefaceMethodsTest { public class Java8DefaultStaticIntefaceMethodsUnitTest {
@Test @Test
public void callStaticInterfaceMethdosMethods_whenExpectedResults_thenCorrect() { public void callStaticInterfaceMethdosMethods_whenExpectedResults_thenCorrect() {

View File

@ -1,17 +1,26 @@
package com.baeldung.java8; package com.baeldung.java8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; public class Java8ExecutorServiceIntegrationTest {
import java.util.List;
import java.util.concurrent.*;
import static org.junit.Assert.*;
public class Java8ExecutorServiceTest {
private Runnable runnableTask; private Runnable runnableTask;
private Callable<String> callableTask; private Callable<String> callableTask;
@ -53,9 +62,7 @@ public class Java8ExecutorServiceTest {
@Test @Test
public void creationSubmittingTasksShuttingDownNow_whenShutDownAfterAwating_thenCorrect() { public void creationSubmittingTasksShuttingDownNow_whenShutDownAfterAwating_thenCorrect() {
ExecutorService threadPoolExecutor = ExecutorService threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>());
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
threadPoolExecutor.submit(callableTask); threadPoolExecutor.submit(callableTask);
@ -138,8 +145,7 @@ public class Java8ExecutorServiceTest {
@Test @Test
public void submittingTaskScheduling_whenExecuted_thenCorrect() { public void submittingTaskScheduling_whenExecuted_thenCorrect() {
ScheduledExecutorService executorService = Executors ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
.newSingleThreadScheduledExecutor();
Future<String> resultFuture = executorService.schedule(callableTask, 1, TimeUnit.SECONDS); Future<String> resultFuture = executorService.schedule(callableTask, 1, TimeUnit.SECONDS);
String result = null; String result = null;

View File

@ -1,18 +1,20 @@
package com.baeldung.java8; package com.baeldung.java8;
import static org.junit.Assert.assertEquals;
import com.baeldung.forkjoin.CustomRecursiveAction; import static org.junit.Assert.assertNotNull;
import com.baeldung.forkjoin.CustomRecursiveTask; import static org.junit.Assert.assertTrue;
import com.baeldung.forkjoin.util.PoolUtil;
import org.junit.Before;
import org.junit.Test;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool;
import static org.junit.Assert.*; import org.junit.Before;
import org.junit.Test;
public class Java8ForkJoinTest { import com.baeldung.forkjoin.CustomRecursiveAction;
import com.baeldung.forkjoin.CustomRecursiveTask;
import com.baeldung.forkjoin.util.PoolUtil;
public class Java8ForkJoinIntegrationTest {
private int[] arr; private int[] arr;
private CustomRecursiveTask customRecursiveTask; private CustomRecursiveTask customRecursiveTask;
@ -27,28 +29,23 @@ public class Java8ForkJoinTest {
customRecursiveTask = new CustomRecursiveTask(arr); customRecursiveTask = new CustomRecursiveTask(arr);
} }
@Test @Test
public void callPoolUtil_whenExistsAndExpectedType_thenCorrect() { public void callPoolUtil_whenExistsAndExpectedType_thenCorrect() {
ForkJoinPool forkJoinPool = PoolUtil.forkJoinPool; ForkJoinPool forkJoinPool = PoolUtil.forkJoinPool;
ForkJoinPool forkJoinPoolTwo = PoolUtil.forkJoinPool; ForkJoinPool forkJoinPoolTwo = PoolUtil.forkJoinPool;
assertNotNull(forkJoinPool); assertNotNull(forkJoinPool);
assertEquals(2, forkJoinPool.getParallelism()); assertEquals(2, forkJoinPool.getParallelism());
assertEquals(forkJoinPool, forkJoinPoolTwo); assertEquals(forkJoinPool, forkJoinPoolTwo);
} }
@Test @Test
public void callCommonPool_whenExistsAndExpectedType_thenCorrect() { public void callCommonPool_whenExistsAndExpectedType_thenCorrect() {
ForkJoinPool commonPool = ForkJoinPool.commonPool(); ForkJoinPool commonPool = ForkJoinPool.commonPool();
ForkJoinPool commonPoolTwo = ForkJoinPool.commonPool(); ForkJoinPool commonPoolTwo = ForkJoinPool.commonPool();
assertNotNull(commonPool); assertNotNull(commonPool);
assertEquals(commonPool, commonPoolTwo); assertEquals(commonPool, commonPoolTwo);
} }
@Test @Test
@ -63,7 +60,6 @@ public class Java8ForkJoinTest {
@Test @Test
public void executeRecursiveTask_whenExecuted_thenCorrect() { public void executeRecursiveTask_whenExecuted_thenCorrect() {
ForkJoinPool forkJoinPool = ForkJoinPool.commonPool(); ForkJoinPool forkJoinPool = ForkJoinPool.commonPool();
forkJoinPool.execute(customRecursiveTask); forkJoinPool.execute(customRecursiveTask);
@ -73,12 +69,10 @@ public class Java8ForkJoinTest {
forkJoinPool.submit(customRecursiveTask); forkJoinPool.submit(customRecursiveTask);
int resultTwo = customRecursiveTask.join(); int resultTwo = customRecursiveTask.join();
assertTrue(customRecursiveTask.isDone()); assertTrue(customRecursiveTask.isDone());
} }
@Test @Test
public void executeRecursiveTaskWithFJ_whenExecuted_thenCorrect() { public void executeRecursiveTaskWithFJ_whenExecuted_thenCorrect() {
CustomRecursiveTask customRecursiveTaskFirst = new CustomRecursiveTask(arr); CustomRecursiveTask customRecursiveTaskFirst = new CustomRecursiveTask(arr);
CustomRecursiveTask customRecursiveTaskSecond = new CustomRecursiveTask(arr); CustomRecursiveTask customRecursiveTaskSecond = new CustomRecursiveTask(arr);
CustomRecursiveTask customRecursiveTaskLast = new CustomRecursiveTask(arr); CustomRecursiveTask customRecursiveTaskLast = new CustomRecursiveTask(arr);
@ -95,6 +89,6 @@ public class Java8ForkJoinTest {
assertTrue(customRecursiveTaskSecond.isDone()); assertTrue(customRecursiveTaskSecond.isDone());
assertTrue(customRecursiveTaskLast.isDone()); assertTrue(customRecursiveTaskLast.isDone());
assertTrue(result != 0); assertTrue(result != 0);
} }
} }

View File

@ -11,7 +11,7 @@ import java.util.function.Function;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
public class Java8FunctionalInteracesLambdasTest { public class Java8FunctionalInteracesLambdasUnitTest {
private UseFoo useFoo; private UseFoo useFoo;

View File

@ -12,7 +12,7 @@ import java.util.stream.Stream;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class Java8MethodReferenceTest { public class Java8MethodReferenceUnitTest {
private List<String> list; private List<String> list;

View File

@ -1,16 +1,23 @@
package com.baeldung.java8; package com.baeldung.java8;
import com.baeldung.java_8_features.*; import static org.junit.Assert.assertEquals;
import org.junit.Before; import static org.junit.Assert.assertFalse;
import org.junit.Test; import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static org.junit.Assert.*; import org.junit.Before;
import org.junit.Test;
public class Java8OptionalTest { import com.baeldung.java_8_features.Address;
import com.baeldung.java_8_features.CustomException;
import com.baeldung.java_8_features.OptionalAddress;
import com.baeldung.java_8_features.OptionalUser;
import com.baeldung.java_8_features.User;
public class Java8OptionalUnitTest {
private List<String> list; private List<String> list;
@ -32,7 +39,6 @@ public class Java8OptionalTest {
@Test @Test
public void checkOptional_whenAsExpected_thenCorrect() { public void checkOptional_whenAsExpected_thenCorrect() {
Optional<String> optionalEmpty = Optional.empty(); Optional<String> optionalEmpty = Optional.empty();
assertFalse(optionalEmpty.isPresent()); assertFalse(optionalEmpty.isPresent());
@ -52,27 +58,19 @@ public class Java8OptionalTest {
assertTrue(listOptNull.isEmpty()); assertTrue(listOptNull.isEmpty());
Optional<User> user = Optional.ofNullable(getUser()); Optional<User> user = Optional.ofNullable(getUser());
String result = user.map(User::getAddress) String result = user.map(User::getAddress).map(Address::getStreet).orElse("not specified");
.map(Address::getStreet)
.orElse("not specified");
assertEquals(result, "1st Avenue"); assertEquals(result, "1st Avenue");
Optional<OptionalUser> optionalUser = Optional.ofNullable(getOptionalUser()); Optional<OptionalUser> optionalUser = Optional.ofNullable(getOptionalUser());
String resultOpt = optionalUser.flatMap(OptionalUser::getAddress) String resultOpt = optionalUser.flatMap(OptionalUser::getAddress).flatMap(OptionalAddress::getStreet).orElse("not specified");
.flatMap(OptionalAddress::getStreet)
.orElse("not specified");
assertEquals(resultOpt, "1st Avenue"); assertEquals(resultOpt, "1st Avenue");
Optional<User> userNull = Optional.ofNullable(getUserNull()); Optional<User> userNull = Optional.ofNullable(getUserNull());
String resultNull = userNull.map(User::getAddress) String resultNull = userNull.map(User::getAddress).map(Address::getStreet).orElse("not specified");
.map(Address::getStreet)
.orElse("not specified");
assertEquals(resultNull, "not specified"); assertEquals(resultNull, "not specified");
Optional<OptionalUser> optionalUserNull = Optional.ofNullable(getOptionalUserNull()); Optional<OptionalUser> optionalUserNull = Optional.ofNullable(getOptionalUserNull());
String resultOptNull = optionalUserNull.flatMap(OptionalUser::getAddress) String resultOptNull = optionalUserNull.flatMap(OptionalUser::getAddress).flatMap(OptionalAddress::getStreet).orElse("not specified");
.flatMap(OptionalAddress::getStreet)
.orElse("not specified");
assertEquals(resultOptNull, "not specified"); assertEquals(resultOptNull, "not specified");
} }

View File

@ -7,7 +7,7 @@ import java.io.UnsupportedEncodingException;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class ApacheCommonsEncodeDecodeTest { public class ApacheCommonsEncodeDecodeUnitTest {
// tests // tests

View File

@ -8,7 +8,7 @@ import java.util.UUID;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class Java8EncodeDecodeTest { public class Java8EncodeDecodeUnitTest {
// tests // tests

View File

@ -1,15 +1,15 @@
package com.baeldung.socket; package com.baeldung.socket;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.Executors;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import java.util.concurrent.Executors; public class EchoIntegrationTest {
import static org.junit.Assert.assertEquals;
public class EchoTest {
private static final Integer PORT = 4444; private static final Integer PORT = 4444;
@BeforeClass @BeforeClass
@ -25,9 +25,15 @@ public class EchoTest {
client.startConnection("127.0.0.1", PORT); client.startConnection("127.0.0.1", PORT);
} }
@After
public void tearDown() {
client.stopConnection();
}
//
@Test @Test
public void givenClient_whenServerEchosMessage_thenCorrect() { public void givenClient_whenServerEchosMessage_thenCorrect() {
String resp1 = client.sendMessage("hello"); String resp1 = client.sendMessage("hello");
String resp2 = client.sendMessage("world"); String resp2 = client.sendMessage("world");
String resp3 = client.sendMessage("!"); String resp3 = client.sendMessage("!");
@ -38,8 +44,4 @@ public class EchoTest {
assertEquals("good bye", resp4); assertEquals("good bye", resp4);
} }
@After
public void tearDown() {
client.stopConnection();
}
} }

View File

@ -7,7 +7,7 @@ import java.util.concurrent.Executors;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class EchoMultiTest { public class SocketEchoMultiIntegrationTest {
private static final Integer PORT = 5555; private static final Integer PORT = 5555;

View File

@ -1,13 +1,23 @@
package com.baeldung.threadpool; package com.baeldung.threadpool;
import java.util.concurrent.*; import static org.junit.Assert.assertEquals;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; public class CoreThreadPoolIntegrationTest {
public class CoreThreadPoolTest {
@Test(timeout = 1000) @Test(timeout = 1000)
public void whenCallingExecuteWithRunnable_thenRunnableIsExecuted() throws InterruptedException { public void whenCallingExecuteWithRunnable_thenRunnableIsExecuted() throws InterruptedException {
@ -132,9 +142,7 @@ public class CoreThreadPoolTest {
@Test @Test
public void whenUsingForkJoinPool_thenSumOfTreeElementsIsCalculatedCorrectly() { public void whenUsingForkJoinPool_thenSumOfTreeElementsIsCalculatedCorrectly() {
TreeNode tree = new TreeNode(5, TreeNode tree = new TreeNode(5, new TreeNode(3), new TreeNode(2, new TreeNode(2), new TreeNode(8)));
new TreeNode(3), new TreeNode(2,
new TreeNode(2), new TreeNode(8)));
ForkJoinPool forkJoinPool = ForkJoinPool.commonPool(); ForkJoinPool forkJoinPool = ForkJoinPool.commonPool();
int sum = forkJoinPool.invoke(new CountingTask(tree)); int sum = forkJoinPool.invoke(new CountingTask(tree));
@ -142,5 +150,4 @@ public class CoreThreadPoolTest {
assertEquals(20, sum); assertEquals(20, sum);
} }
} }

View File

@ -16,7 +16,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class GuavaThreadPoolTest { public class GuavaThreadPoolIntegrationTest {
@Test @Test
public void whenExecutingTaskWithDirectExecutor_thenTheTaskIsExecutedInTheCurrentThread() { public void whenExecutingTaskWithDirectExecutor_thenTheTaskIsExecutedInTheCurrentThread() {

View File

@ -1,19 +1,22 @@
package com.baeldung.util; package com.baeldung.util;
import org.junit.Test;
import java.time.*;
import java.time.temporal.ChronoField;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class CurrentDateTimeTest { import java.time.Clock;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
import org.junit.Test;
public class CurrentDateTimeUnitTest {
private static final Clock clock = Clock.fixed(Instant.parse("2016-10-09T15:10:30.00Z"), ZoneId.of("UTC")); private static final Clock clock = Clock.fixed(Instant.parse("2016-10-09T15:10:30.00Z"), ZoneId.of("UTC"));
@Test @Test
public void shouldReturnCurrentDate() { public void shouldReturnCurrentDate() {
final LocalDate now = LocalDate.now(clock); final LocalDate now = LocalDate.now(clock);
assertEquals(9, now.get(ChronoField.DAY_OF_MONTH)); assertEquals(9, now.get(ChronoField.DAY_OF_MONTH));
@ -23,7 +26,6 @@ public class CurrentDateTimeTest {
@Test @Test
public void shouldReturnCurrentTime() { public void shouldReturnCurrentTime() {
final LocalTime now = LocalTime.now(clock); final LocalTime now = LocalTime.now(clock);
assertEquals(15, now.get(ChronoField.HOUR_OF_DAY)); assertEquals(15, now.get(ChronoField.HOUR_OF_DAY));
@ -33,9 +35,9 @@ public class CurrentDateTimeTest {
@Test @Test
public void shouldReturnCurrentTimestamp() { public void shouldReturnCurrentTimestamp() {
final Instant now = Instant.now(clock); final Instant now = Instant.now(clock);
assertEquals(clock.instant().getEpochSecond(), now.getEpochSecond()); assertEquals(clock.instant().getEpochSecond(), now.getEpochSecond());
} }
} }

View File

@ -1,13 +1,17 @@
package org.baeldung.core.exceptions; package org.baeldung.core.exceptions;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.Test; import org.junit.Test;
import java.io.*; public class FileNotFoundExceptionUnitTest {
public class FileNotFoundExceptionTest { private static final Logger LOG = Logger.getLogger(FileNotFoundExceptionUnitTest.class);
private static final Logger LOG = Logger.getLogger(FileNotFoundExceptionTest.class);
private String fileName = Double.toString(Math.random()); private String fileName = Double.toString(Math.random());

View File

@ -2,22 +2,22 @@ package org.baeldung.equalshashcode.entities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class ComplexClassTest { public class ComplexClassUnitTest {
@Test @Test
public void testEqualsAndHashcodes() { public void testEqualsAndHashcodes() {
List<String> strArrayList = new ArrayList<String>();
ArrayList<String> strArrayList = new ArrayList<String>();
strArrayList.add("abc"); strArrayList.add("abc");
strArrayList.add("def"); strArrayList.add("def");
ComplexClass aObject = new ComplexClass(strArrayList, new HashSet<Integer>(45, 67)); ComplexClass aObject = new ComplexClass(strArrayList, new HashSet<Integer>(45, 67));
ComplexClass bObject = new ComplexClass(strArrayList, new HashSet<Integer>(45, 67)); ComplexClass bObject = new ComplexClass(strArrayList, new HashSet<Integer>(45, 67));
ArrayList<String> strArrayListD = new ArrayList<String>(); List<String> strArrayListD = new ArrayList<String>();
strArrayListD.add("lmn"); strArrayListD.add("lmn");
strArrayListD.add("pqr"); strArrayListD.add("pqr");
ComplexClass dObject = new ComplexClass(strArrayListD, new HashSet<Integer>(45, 67)); ComplexClass dObject = new ComplexClass(strArrayListD, new HashSet<Integer>(45, 67));

View File

@ -12,7 +12,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class ArrayListTest { public class ArrayListUnitTest {
private List<String> stringsToSearch; private List<String> stringsToSearch;