Skip to content

Commit

Permalink
Update to Java 8 and use some of the new features, update commons-lan…
Browse files Browse the repository at this point in the history
…g3 and jacoco
  • Loading branch information
centic9 committed Dec 17, 2017
1 parent 91a270e commit 58e3a4d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 29 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'signing'

sourceCompatibility = 1.7
sourceCompatibility = 1.8
group = 'org.dstadler'
archivesBaseName = 'commons-test'

Expand All @@ -22,7 +22,7 @@ configurations {
}

dependencies {
compile 'org.apache.commons:commons-lang3:3.6'
compile 'org.apache.commons:commons-lang3:3.7'
compile 'org.dstadler:commons-dost:1.0.0.23'

// dumbster is somewhat broken, but we use it in SafeCloseSmtpServer...
Expand Down Expand Up @@ -59,7 +59,7 @@ test {
}

jacoco {
toolVersion = '0.7.8'
toolVersion = '0.7.9'
}

jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public static <T> T executePrivateConstructor(final Class<T> targetClass) throws
c.setAccessible(true);

// call it
return c.newInstance((Object[]) null);
return c.newInstance();
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/dstadler/commons/testing/TestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ public static void CloneTest(final Cloneable obj) throws Exception {

// should return the same type of object
assertTrue("clone() should return the same type of object (i.e. the same class) in CloneTest!", m // NOPMD
.invoke(obj, new Object[] {}).getClass() == obj.getClass());
.invoke(obj).getClass() == obj.getClass());

// cloned objects should be equal to the original object
assertTrue("clone() should return an object that is equal() to the original object in CloneTest!", m
.invoke(obj, new Object[] {}).equals(obj));
.invoke(obj).equals(obj));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ public void testAssertNotContainsMsg() {

@Test
public void testRunTestWithDifferentLogLevel() {
TestHelpers.runTestWithDifferentLogLevel(new Runnable() {
@Override
public void run() {
testAssertNotContains();
}
}, TestHelpers.class.getName(), Level.WARNING);
TestHelpers.runTestWithDifferentLogLevel(this::testAssertNotContains, TestHelpers.class.getName(), Level.WARNING);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import static org.junit.Assert.assertEquals;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;

@SuppressWarnings("Convert2Lambda") // should still compile with Java 7
public class ThreadTestHelperTest {

@Test
public void testExecuteTestTestRunnable() throws Throwable {
ThreadTestHelper helper =
Expand Down Expand Up @@ -47,23 +44,11 @@ public void testWaitForThreadToFinishSubstring() throws Exception {

@Test
public void testExecuteTestTestCallable() throws Throwable {
List<String> list = ThreadTestHelper.executeTest(new Callable<String>() {

@Override
public String call() throws Exception {
return "str";
}
}, 23);
List<String> list = ThreadTestHelper.executeTest(() -> "str", 23);

assertEquals(23, list.size());

list = ThreadTestHelper.executeTest(new Callable<String>() {

@Override
public String call() throws Exception {
return "str";
}
}, 1);
list = ThreadTestHelper.executeTest(() -> "str", 1);

assertEquals(1, list.size());
}
Expand Down

0 comments on commit 58e3a4d

Please sign in to comment.