forked from hugegraph/hugegraph-sync
refact: upgrade a string of dependencies to address CVEs report & clean code (#110)
Note: after use junit-2.13, some assert-api's error messages has changed, check it in other repos (and avoid use long & fixed error message)
This commit is contained in:
parent
b783da5bde
commit
ae54f28308
|
|
@ -19,3 +19,4 @@ target
|
|||
gen-java
|
||||
build
|
||||
node*
|
||||
*.versionsBackup
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>hugegraph-common</artifactId>
|
||||
<name>${artifactId}</name>
|
||||
<name>${project.artifactId}</name>
|
||||
<url>https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common</url>
|
||||
<description>
|
||||
hugegraph-common is a common module for HugeGraph and its peripheral components.
|
||||
|
|
@ -211,7 +211,6 @@
|
|||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${compiler.source}</source>
|
||||
<target>${compiler.target}</target>
|
||||
|
|
@ -226,7 +225,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<index>true</index>
|
||||
|
|
@ -281,7 +279,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
|
|
@ -294,7 +291,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
|
@ -307,7 +303,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.function.Function;
|
|||
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.InsertionOrderUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class BatchMapperIterator<T, R> extends WrappedIterator<R> {
|
||||
|
|
|
|||
|
|
@ -361,7 +361,8 @@ public final class PerfUtil {
|
|||
sb.append("',");
|
||||
|
||||
sb.append("value:");
|
||||
sb.append(w.totalCost()); // w.totalCost() - w.totalWasted() ?
|
||||
// w.totalCost() - w.totalWasted() ?
|
||||
sb.append(w.totalCost());
|
||||
sb.append(',');
|
||||
|
||||
sb.append("cost:");
|
||||
|
|
@ -419,7 +420,7 @@ public final class PerfUtil {
|
|||
return c.parent().equals(parent.id());
|
||||
});
|
||||
// Fill other cost
|
||||
long sumCost = children.mapToLong(c -> c.totalCost()).sum();
|
||||
long sumCost = children.mapToLong(Stopwatch::totalCost).sum();
|
||||
long otherCost = parent.totalCost() - sumCost;
|
||||
if (otherCost > 0L) {
|
||||
Stopwatch other = newStopwatch("~", parent.id());
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ public abstract class AbstractRestClient implements RestClient {
|
|||
public static class BearerRequestFilter implements ClientRequestFilter {
|
||||
|
||||
@Override
|
||||
public void filter(ClientRequestContext context) throws IOException {
|
||||
public void filter(ClientRequestContext context) {
|
||||
String token = context.getClient().getConfiguration()
|
||||
.getProperty(TOKEN_KEY).toString();
|
||||
context.getHeaders().add(HttpHeaders.AUTHORIZATION,
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public final class LongEncoding {
|
|||
|
||||
public static Number decodeNumber(String str, Class<?> clazz) {
|
||||
long value = decodeSortable(str);
|
||||
Number number = NumericUtil.sortableLongToNumber(value, clazz);
|
||||
return number;
|
||||
return NumericUtil.sortableLongToNumber(value, clazz);
|
||||
}
|
||||
|
||||
public static String encodeSortable(long num) {
|
||||
|
|
@ -130,10 +129,11 @@ public final class LongEncoding {
|
|||
for (char ch : encoded.toCharArray()) {
|
||||
num *= B;
|
||||
int pos = symbols.indexOf(ch);
|
||||
if (pos < 0)
|
||||
if (pos < 0) {
|
||||
throw new NumberFormatException(String.format(
|
||||
"Can't decode symbol '%s' in string '%s'",
|
||||
ch, encoded));
|
||||
}
|
||||
num += pos;
|
||||
}
|
||||
return num;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ import com.google.common.base.Functions;
|
|||
import com.google.common.collect.Ordering;
|
||||
|
||||
/**
|
||||
* Reference: https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values
|
||||
* Reference:
|
||||
* <a href="https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values">...</a>
|
||||
*/
|
||||
public class OrderLimitMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||
extends TreeMap<K, V> {
|
||||
|
|
|
|||
|
|
@ -39,14 +39,11 @@ import javassist.NotFoundException;
|
|||
public final class ReflectionUtil {
|
||||
|
||||
public static boolean isSimpleType(Class<?> type) {
|
||||
if (type.isPrimitive() ||
|
||||
type.equals(String.class) ||
|
||||
type.equals(Boolean.class) ||
|
||||
type.equals(Character.class) ||
|
||||
NumericUtil.isNumber(type)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return type.isPrimitive() ||
|
||||
type.equals(String.class) ||
|
||||
type.equals(Boolean.class) ||
|
||||
type.equals(Character.class) ||
|
||||
NumericUtil.isNumber(type);
|
||||
}
|
||||
|
||||
public static List<Method> getMethodsAnnotatedWith(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package org.apache.hugegraph.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
|
||||
public final class UnitUtil {
|
||||
|
|
@ -34,7 +35,7 @@ public final class UnitUtil {
|
|||
|
||||
public static double doubleWith2Scale(double value) {
|
||||
BigDecimal decimal = new BigDecimal(value);
|
||||
return decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return decimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
public static String bytesToReadableString(long bytes) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
|
|
@ -79,7 +80,7 @@ public final class VersionUtil {
|
|||
* https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest
|
||||
*/
|
||||
String className = clazz.getSimpleName() + ".class";
|
||||
String classPath = clazz.getResource(className).toString();
|
||||
String classPath = Objects.requireNonNull(clazz.getResource(className)).toString();
|
||||
if (!classPath.startsWith("jar:file:")) {
|
||||
// Class not from JAR
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
|
||||
Assert.assertThrows(AssertionError.class, () -> {
|
||||
Assert.assertEquals(1, (Long) 1l);
|
||||
Assert.assertEquals(1, (Long) 1L);
|
||||
}, e -> {
|
||||
Assert.assertContains("expected: java.lang.Integer",
|
||||
e.getMessage());
|
||||
|
|
@ -192,9 +192,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
Assert.fail("Expect error");
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals("No exception was thrown" +
|
||||
"(expected java.lang.NullPointerException)",
|
||||
e.getMessage());
|
||||
Assert.assertContains("java.lang.NullPointerException", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -203,10 +201,8 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
Assert.fail("Expect error");
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals("Bad exception type " +
|
||||
"java.lang.RuntimeException" +
|
||||
"(expected java.lang.NullPointerException)",
|
||||
e.getMessage());
|
||||
Assert.assertContains("java.lang.NullPointerException", e.getMessage());
|
||||
Assert.assertContains("java.lang.RuntimeException", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +250,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
|
||||
Assert.assertThrows(AssertionError.class, () -> {
|
||||
Assert.assertGt(1, Character.valueOf('2'));
|
||||
Assert.assertGt(1, '2');
|
||||
}, e -> {
|
||||
Assert.assertContains("Expected: an instance of java.lang.Integer",
|
||||
e.getMessage());
|
||||
|
|
@ -312,7 +308,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
|
||||
Assert.assertThrows(AssertionError.class, () -> {
|
||||
Assert.assertGte(1, Character.valueOf('2'));
|
||||
Assert.assertGte(1, '2');
|
||||
}, e -> {
|
||||
Assert.assertContains("Expected: an instance of java.lang.Integer",
|
||||
e.getMessage());
|
||||
|
|
@ -342,7 +338,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
|
||||
Assert.assertThrows(AssertionError.class, () -> {
|
||||
Assert.assertGt(1, Character.valueOf('0'));
|
||||
Assert.assertGt(1, '0');
|
||||
}, e -> {
|
||||
Assert.assertContains("Expected: an instance of java.lang.Integer",
|
||||
e.getMessage());
|
||||
|
|
@ -379,7 +375,7 @@ public class AssertTest extends BaseUnitTest {
|
|||
});
|
||||
|
||||
Assert.assertThrows(AssertionError.class, () -> {
|
||||
Assert.assertLte(1, Character.valueOf('0'));
|
||||
Assert.assertLte(1, '0');
|
||||
}, e -> {
|
||||
Assert.assertContains("Expected: an instance of java.lang.Integer",
|
||||
e.getMessage());
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.apache.hugegraph.testutil.Assert;
|
|||
|
||||
public class BarrierEventTest {
|
||||
|
||||
private static int WAIT_THREADS_COUNT = 10;
|
||||
private static final int WAIT_THREADS_COUNT = 10;
|
||||
|
||||
@Test(timeout = 5000)
|
||||
public void testAWait() throws InterruptedException {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class LockGroupTest extends BaseUnitTest {
|
|||
|
||||
private static final String GROUP = "LockGroupTest-test-group";
|
||||
|
||||
private LockGroup group = new LockGroup(GROUP);
|
||||
private final LockGroup group = new LockGroup(GROUP);
|
||||
|
||||
@Test
|
||||
public void testLock() {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.apache.hugegraph.concurrent.PausableScheduledThreadPool;
|
|||
public class PausableScheduledThreadPoolTest {
|
||||
|
||||
@Test
|
||||
public void testscheduleWithFixedDelay() throws InterruptedException {
|
||||
public void testScheduleWithFixedDelay() throws InterruptedException {
|
||||
PausableScheduledThreadPool executor =
|
||||
ExecutorUtil.newPausableScheduledThreadPool("test");
|
||||
long period = 500L;
|
||||
|
|
@ -64,7 +64,7 @@ public class PausableScheduledThreadPoolTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testscheduleWithFixedRate() throws InterruptedException {
|
||||
public void testScheduleWithFixedRate() throws InterruptedException {
|
||||
PausableScheduledThreadPool executor =
|
||||
ExecutorUtil.newPausableScheduledThreadPool(2, "test");
|
||||
long period = 500L;
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ public class HugeConfigTest extends BaseUnitTest {
|
|||
|
||||
@Test
|
||||
public void testOptionRequired() {
|
||||
Assert.assertEquals(false, TestOptions.text1.required());
|
||||
Assert.assertEquals(true, TestSubOptions.text2.required());
|
||||
Assert.assertFalse(TestOptions.text1.required());
|
||||
Assert.assertTrue(TestSubOptions.text2.required());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -670,6 +670,6 @@ public class HugeConfigTest extends BaseUnitTest {
|
|||
|
||||
public enum WeekDay {
|
||||
|
||||
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
|
||||
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,12 +80,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventAddListener() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener);
|
||||
|
||||
|
|
@ -98,12 +93,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventAddListenerTwice() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener);
|
||||
this.eventHub.listen(event, listener);
|
||||
|
|
@ -118,12 +108,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventRemoveListener() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener);
|
||||
|
||||
|
|
@ -141,12 +126,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventRemoveListenerButNonResult() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener);
|
||||
|
||||
|
|
@ -167,12 +147,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
final String event1 = "event-test1";
|
||||
final String event2 = "event-test2";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event1, listener);
|
||||
this.eventHub.listen(event2, listener);
|
||||
|
|
@ -200,19 +175,8 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventRemoveListenerByEvent() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener1 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
EventListener listener2 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener1 = (Event e) -> null;
|
||||
EventListener listener2 = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener1);
|
||||
this.eventHub.listen(event, listener2);
|
||||
|
|
@ -232,19 +196,8 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventRemoveListenerByEventButNonResult() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener1 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
EventListener listener2 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener1 = (Event e) -> null;
|
||||
EventListener listener2 = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener1);
|
||||
this.eventHub.listen(event, listener2);
|
||||
|
|
@ -263,12 +216,7 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventRemoveListenerByEventOf2SameListener() {
|
||||
final String event = "event-test";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event arg0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
EventListener listener = (Event e) -> null;
|
||||
|
||||
this.eventHub.listen(event, listener);
|
||||
this.eventHub.listen(event, listener);
|
||||
|
|
@ -446,27 +394,21 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventNotifyWithMultiThreads() throws InterruptedException {
|
||||
final String notify = "event-notify";
|
||||
|
||||
EventListener listener1 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event event) {
|
||||
Assert.assertEquals(notify, event.name());
|
||||
event.checkArgs(Integer.class);
|
||||
return null;
|
||||
}
|
||||
EventListener listener1 = event -> {
|
||||
Assert.assertEquals(notify, event.name());
|
||||
event.checkArgs(Integer.class);
|
||||
return null;
|
||||
};
|
||||
|
||||
EventListener listener2 = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event event) {
|
||||
Assert.assertEquals(notify, event.name());
|
||||
EventListener listener2 = event -> {
|
||||
Assert.assertEquals(notify, event.name());
|
||||
|
||||
event.checkArgs(Integer.class);
|
||||
int i = (int) event.args()[0];
|
||||
if (i % 10000 == 0) {
|
||||
System.out.println("On event '" + notify + "': " + i);
|
||||
}
|
||||
return null;
|
||||
event.checkArgs(Integer.class);
|
||||
int i = (int) event.args()[0];
|
||||
if (i % 10000 == 0) {
|
||||
System.out.println("On event '" + notify + "': " + i);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Thread listenerUpdateThread = new Thread(() -> {
|
||||
|
|
@ -503,15 +445,12 @@ public class EventHubTest extends BaseUnitTest {
|
|||
public void testEventCallWithMultiThreads() {
|
||||
final String call = "event-call";
|
||||
|
||||
EventListener listener = new EventListener() {
|
||||
@Override
|
||||
public Object event(Event event) {
|
||||
Assert.assertEquals(call, event.name());
|
||||
EventListener listener = event -> {
|
||||
Assert.assertEquals(call, event.name());
|
||||
|
||||
event.checkArgs(Integer.class);
|
||||
int i = (int) event.args()[0];
|
||||
return i;
|
||||
}
|
||||
event.checkArgs(Integer.class);
|
||||
int i = (int) event.args()[0];
|
||||
return i;
|
||||
};
|
||||
|
||||
this.eventHub.listen(call, listener);
|
||||
|
|
|
|||
|
|
@ -123,12 +123,8 @@ public class BatchMapperIteratorTest extends BaseUnitTest {
|
|||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -159,9 +155,7 @@ public class BatchMapperIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 2; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -281,12 +275,8 @@ public class BatchMapperIteratorTest extends BaseUnitTest {
|
|||
results = new BatchMapperIterator<>(1, DATA3.iterator(), batch -> {
|
||||
return null;
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ public class ExtendableIteratorTest extends BaseUnitTest {
|
|||
public void testNext() {
|
||||
Iterator<Integer> results = new ExtendableIterator<>(DATA1.iterator());
|
||||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -101,9 +99,7 @@ public class ExtendableIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertEquals(2, (int) results.next());
|
||||
Assert.assertEquals(3, (int) results.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -114,9 +110,7 @@ public class ExtendableIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -143,15 +137,11 @@ public class ExtendableIteratorTest extends BaseUnitTest {
|
|||
@Test
|
||||
public void testRemoveWithoutResult() {
|
||||
Iterator<Integer> results = new ExtendableIterator<>();
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.remove();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::remove);
|
||||
|
||||
List<Integer> list = new ArrayList<>();
|
||||
Iterator<Integer> results2 = new ExtendableIterator<>(list.iterator());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results2.remove();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results2::remove);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -95,12 +95,8 @@ public class FilterIteratorTest extends BaseUnitTest {
|
|||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -120,9 +116,7 @@ public class FilterIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 4; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -130,12 +124,8 @@ public class FilterIteratorTest extends BaseUnitTest {
|
|||
Iterator<Integer> vals = DATA.iterator();
|
||||
|
||||
Iterator<Integer> results = new FilterIterator<>(vals, val -> false);
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -94,9 +94,7 @@ public class FlatMapperFilterIteratorTest extends BaseUnitTest {
|
|||
key -> DATA.get(key).iterator(),
|
||||
val -> false);
|
||||
Assert.assertFalse(results2.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results2.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results2::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -113,12 +111,8 @@ public class FlatMapperFilterIteratorTest extends BaseUnitTest {
|
|||
results.next();
|
||||
}
|
||||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
|
||||
Iterator<Integer> results2 = new FlatMapperFilterIterator<>(keys,
|
||||
key -> DATA.get(key).iterator(),
|
||||
|
|
@ -140,9 +134,7 @@ public class FlatMapperFilterIteratorTest extends BaseUnitTest {
|
|||
Iterator<Integer> results2 = new FlatMapperFilterIterator<>(keys,
|
||||
key -> DATA.get(key).iterator(),
|
||||
val -> false);
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results2.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results2::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -155,19 +147,13 @@ public class FlatMapperFilterIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 10; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
|
||||
Iterator<Integer> results2 = new FlatMapperFilterIterator<>(keys,
|
||||
key -> DATA.get(key).iterator(),
|
||||
val -> false);
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results2.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results2.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results2::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results2::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -107,12 +107,8 @@ public class FlatMapperIteratorTest extends BaseUnitTest {
|
|||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -132,9 +128,7 @@ public class FlatMapperIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 10; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -157,12 +151,8 @@ public class FlatMapperIteratorTest extends BaseUnitTest {
|
|||
Assert.assertNull(DATA.get(key));
|
||||
return null;
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -95,12 +95,8 @@ public class LimitIteratorTest extends BaseUnitTest {
|
|||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
|
||||
Iterator<Integer> results2 = new LimitIterator<>(vals, val -> false);
|
||||
Assert.assertFalse(results2.hasNext());
|
||||
|
|
@ -123,9 +119,7 @@ public class LimitIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 4; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -133,12 +127,8 @@ public class LimitIteratorTest extends BaseUnitTest {
|
|||
Iterator<Integer> vals = DATA.iterator();
|
||||
|
||||
Iterator<Integer> results = new LimitIterator<>(vals, val -> true);
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -100,9 +100,7 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
public void testNext() {
|
||||
Iterator<Integer> results = new ListIterator<>(-1, DATA1.iterator());
|
||||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -111,9 +109,7 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(ImmutableList.of(1),
|
||||
((ListIterator<?>) results).list());
|
||||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -121,9 +117,7 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Iterator<Integer> results = new ListIterator<>(-1, DATA2.iterator());
|
||||
Assert.assertEquals(2, (int) results.next());
|
||||
Assert.assertEquals(3, (int) results.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -134,9 +128,7 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(1, (int) results.next());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -147,13 +139,9 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(ImmutableList.of(4, 5, 6), list);
|
||||
Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list());
|
||||
|
||||
Assert.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
results.remove();
|
||||
});
|
||||
Assert.assertThrows(UnsupportedOperationException.class, results::remove);
|
||||
results.next();
|
||||
Assert.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
results.remove();
|
||||
});
|
||||
Assert.assertThrows(UnsupportedOperationException.class, results::remove);
|
||||
|
||||
Assert.assertEquals(ImmutableList.of(4, 5, 6), list);
|
||||
Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list());
|
||||
|
|
@ -162,15 +150,11 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
@Test
|
||||
public void testRemoveWithoutResult() {
|
||||
Iterator<Integer> results = new ListIterator<>(-1, EMPTY);
|
||||
Assert.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
results.remove();
|
||||
});
|
||||
Assert.assertThrows(UnsupportedOperationException.class, results::remove);
|
||||
|
||||
List<Integer> list0 = new ArrayList<>();
|
||||
Iterator<Integer> results2 = new ListIterator<>(-1, list0.iterator());
|
||||
Assert.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
results2.remove();
|
||||
});
|
||||
Assert.assertThrows(UnsupportedOperationException.class, results2::remove);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -207,17 +191,13 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
public void testHasNextAndNextWithConstructFromList() {
|
||||
ListIterator<Integer> results0 = new ListIterator<>(ImmutableList.of());
|
||||
Assert.assertFalse(results0.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results0.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results0::next);
|
||||
|
||||
ListIterator<Integer> results1 = new ListIterator<>(DATA1);
|
||||
Assert.assertTrue(results1.hasNext());
|
||||
Assert.assertEquals(1, results1.next());
|
||||
Assert.assertFalse(results1.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results1.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results1::next);
|
||||
|
||||
ListIterator<Integer> results3 = new ListIterator<>(DATA3);
|
||||
Assert.assertTrue(results3.hasNext());
|
||||
|
|
@ -227,25 +207,19 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Assert.assertTrue(results3.hasNext());
|
||||
Assert.assertEquals(6, results3.next());
|
||||
Assert.assertFalse(results3.hasNext());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results3.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results3::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextWithConstructFromList() {
|
||||
ListIterator<Integer> results0 = new ListIterator<>(ImmutableList.of());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results0.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results0::next);
|
||||
|
||||
ListIterator<Integer> results3 = new ListIterator<>(DATA3);
|
||||
Assert.assertEquals(4, results3.next());
|
||||
Assert.assertEquals(5, results3.next());
|
||||
Assert.assertEquals(6, results3.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results3.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results3::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -255,8 +229,6 @@ public class ListIteratorTest extends BaseUnitTest {
|
|||
Assert.assertEquals(4, results3.next());
|
||||
Assert.assertEquals(5, results3.next());
|
||||
Assert.assertEquals(6, results3.next());
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results3.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results3::next);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ public class MapperIteratorTest extends BaseUnitTest {
|
|||
"forth", 4
|
||||
);
|
||||
|
||||
private static final Function<String, Integer> MAPPER = key -> {
|
||||
return DATA.get(key);
|
||||
};
|
||||
private static final Function<String, Integer> MAPPER = DATA::get;
|
||||
|
||||
@Test
|
||||
public void testMapper() {
|
||||
|
|
@ -100,12 +98,8 @@ public class MapperIteratorTest extends BaseUnitTest {
|
|||
Assert.assertFalse(results.hasNext());
|
||||
Assert.assertFalse(results.hasNext());
|
||||
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -125,9 +119,7 @@ public class MapperIteratorTest extends BaseUnitTest {
|
|||
for (int i = 0; i < 4; i++) {
|
||||
results.next();
|
||||
}
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -147,9 +139,7 @@ public class MapperIteratorTest extends BaseUnitTest {
|
|||
Iterator<Integer> results = new MapperIterator<>(keys, key -> {
|
||||
return null;
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, () -> {
|
||||
results.next();
|
||||
});
|
||||
Assert.assertThrows(NoSuchElementException.class, results::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -157,8 +147,7 @@ public class MapperIteratorTest extends BaseUnitTest {
|
|||
CloseableItor<String> keys = new CloseableItor<>(
|
||||
ImmutableList.of("fifth").iterator());
|
||||
|
||||
MapperIterator<String, Integer> results =
|
||||
new MapperIterator<>(keys, k -> null);
|
||||
MapperIterator<String, Integer> results = new MapperIterator<>(keys, k -> null);
|
||||
|
||||
Assert.assertFalse(keys.closed());
|
||||
results.close();
|
||||
|
|
|
|||
|
|
@ -49,21 +49,21 @@ public class StopwatchTest extends BaseUnitTest {
|
|||
Assert.assertEquals(watch4, watch1.child("w4", null));
|
||||
Assert.assertEquals(watch5, watch1.child("w5", null));
|
||||
|
||||
Assert.assertEquals(null, watch1.child("w2"));
|
||||
Assert.assertEquals(null, watch1.child("w3"));
|
||||
Assert.assertEquals(null, watch1.child("w4"));
|
||||
Assert.assertEquals(null, watch1.child("w5"));
|
||||
Assert.assertNull(watch1.child("w2"));
|
||||
Assert.assertNull(watch1.child("w3"));
|
||||
Assert.assertNull(watch1.child("w4"));
|
||||
Assert.assertNull(watch1.child("w5"));
|
||||
|
||||
Assert.assertEquals(null, watch1.child("w2", watch2));
|
||||
Assert.assertEquals(null, watch1.child("w3", watch3));
|
||||
Assert.assertEquals(null, watch1.child("w4", watch4));
|
||||
Assert.assertEquals(null, watch1.child("w5", watch5));
|
||||
Assert.assertNull(watch1.child("w2", watch2));
|
||||
Assert.assertNull(watch1.child("w3", watch3));
|
||||
Assert.assertNull(watch1.child("w4", watch4));
|
||||
Assert.assertNull(watch1.child("w5", watch5));
|
||||
|
||||
watch1.clear();
|
||||
Assert.assertEquals(null, watch1.child("w2"));
|
||||
Assert.assertEquals(null, watch1.child("w3"));
|
||||
Assert.assertEquals(null, watch1.child("w4"));
|
||||
Assert.assertEquals(null, watch1.child("w5"));
|
||||
Assert.assertNull(watch1.child("w2"));
|
||||
Assert.assertNull(watch1.child("w3"));
|
||||
Assert.assertNull(watch1.child("w4"));
|
||||
Assert.assertNull(watch1.child("w5"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -85,20 +85,20 @@ public class StopwatchTest extends BaseUnitTest {
|
|||
Assert.assertEquals(watch4, watch1.child("w4", null));
|
||||
Assert.assertEquals(watch5, watch1.child("w5", null));
|
||||
|
||||
Assert.assertEquals(null, watch1.child("w2"));
|
||||
Assert.assertEquals(null, watch1.child("w3"));
|
||||
Assert.assertEquals(null, watch1.child("w4"));
|
||||
Assert.assertEquals(null, watch1.child("w5"));
|
||||
Assert.assertNull(watch1.child("w2"));
|
||||
Assert.assertNull(watch1.child("w3"));
|
||||
Assert.assertNull(watch1.child("w4"));
|
||||
Assert.assertNull(watch1.child("w5"));
|
||||
|
||||
Assert.assertEquals(null, watch1.child("w2", watch2));
|
||||
Assert.assertEquals(null, watch1.child("w3", watch3));
|
||||
Assert.assertEquals(null, watch1.child("w4", watch4));
|
||||
Assert.assertEquals(null, watch1.child("w5", watch5));
|
||||
Assert.assertNull(watch1.child("w2", watch2));
|
||||
Assert.assertNull(watch1.child("w3", watch3));
|
||||
Assert.assertNull(watch1.child("w4", watch4));
|
||||
Assert.assertNull(watch1.child("w5", watch5));
|
||||
|
||||
watch1.clear();
|
||||
Assert.assertEquals(null, watch1.child("w2"));
|
||||
Assert.assertEquals(null, watch1.child("w3"));
|
||||
Assert.assertEquals(null, watch1.child("w4"));
|
||||
Assert.assertEquals(null, watch1.child("w5"));
|
||||
Assert.assertNull(watch1.child("w2"));
|
||||
Assert.assertNull(watch1.child("w3"));
|
||||
Assert.assertNull(watch1.child("w4"));
|
||||
Assert.assertNull(watch1.child("w5"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ public class BytesTest extends BaseUnitTest {
|
|||
|
||||
@Test
|
||||
public void testBytesCompare() {
|
||||
Assert.assertTrue(Bytes.compare(b("12345678"), b("12345678")) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(b("12345678"), b("12345678")));
|
||||
Assert.assertTrue(Bytes.compare(b("12345678"), b("1234567")) > 0);
|
||||
Assert.assertTrue(Bytes.compare(b("12345678"), b("12345679")) < 0);
|
||||
|
||||
Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7},
|
||||
new byte[]{1, 3, 5, 7}) == 0);
|
||||
Assert.assertEquals(0,
|
||||
Bytes.compare(new byte[]{1, 3, 5, 7}, new byte[]{1, 3, 5, 7}));
|
||||
|
||||
Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7},
|
||||
new byte[]{1, 3, 5, 6}) > 0);
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ public class LongEncodingTest extends BaseUnitTest {
|
|||
int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes());
|
||||
|
||||
if (num1 == num2) {
|
||||
Assert.assertTrue(cmp == 0);
|
||||
Assert.assertEquals(0, cmp);
|
||||
} else if (num1 > num2) {
|
||||
Assert.assertTrue(cmp > 0);
|
||||
} else {
|
||||
|
|
@ -675,7 +675,7 @@ public class LongEncodingTest extends BaseUnitTest {
|
|||
int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes());
|
||||
|
||||
if (cmpExpected == 0) {
|
||||
Assert.assertTrue(cmp == 0);
|
||||
Assert.assertEquals(0, cmp);
|
||||
} else if (cmpExpected > 0) {
|
||||
Assert.assertTrue(cmp > 0);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
public void testIntToSortableBytesAndCompare() {
|
||||
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456);
|
||||
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(1);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(2);
|
||||
|
|
@ -156,7 +156,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-123456);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-123456);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-1);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-2);
|
||||
|
|
@ -191,7 +191,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
public void testLongToSortableBytesAndCompare() {
|
||||
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456L);
|
||||
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456L);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(1L);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(2L);
|
||||
|
|
@ -207,7 +207,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-123456L);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-123456L);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-1L);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-2L);
|
||||
|
|
@ -242,7 +242,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
public void testFloatToSortableBytesAndCompare() {
|
||||
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456F);
|
||||
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456F);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(1F);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(2F);
|
||||
|
|
@ -258,7 +258,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-123456F);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-123456F);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-1F);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-2F);
|
||||
|
|
@ -293,7 +293,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
public void testDoubleToSortableBytesAndCompare() {
|
||||
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456D);
|
||||
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456D);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(1D);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(2D);
|
||||
|
|
@ -309,7 +309,7 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-123456D);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-123456D);
|
||||
Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
|
||||
Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
|
||||
|
||||
bytes1 = NumericUtil.numberToSortableBytes(-1D);
|
||||
bytes2 = NumericUtil.numberToSortableBytes(-2D);
|
||||
|
|
@ -392,28 +392,28 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
|
||||
@Test
|
||||
public void testIsNumber() {
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(byte.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Byte.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(short.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Short.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(int.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Integer.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(long.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Long.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(float.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Float.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(double.class));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(Double.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(byte.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Byte.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(short.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Short.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(int.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Integer.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(long.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Long.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(float.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Float.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(double.class));
|
||||
Assert.assertTrue(NumericUtil.isNumber(Double.class));
|
||||
|
||||
Assert.assertEquals(false, NumericUtil.isNumber(char.class));
|
||||
Assert.assertEquals(false, NumericUtil.isNumber(Character.class));
|
||||
Assert.assertFalse(NumericUtil.isNumber(char.class));
|
||||
Assert.assertFalse(NumericUtil.isNumber(Character.class));
|
||||
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(1));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(1L));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(1.0f));
|
||||
Assert.assertEquals(true, NumericUtil.isNumber(1.0d));
|
||||
Assert.assertEquals(false, NumericUtil.isNumber('1'));
|
||||
Assert.assertEquals(false, NumericUtil.isNumber((Object) null));
|
||||
Assert.assertTrue(NumericUtil.isNumber(1));
|
||||
Assert.assertTrue(NumericUtil.isNumber(1L));
|
||||
Assert.assertTrue(NumericUtil.isNumber(1.0f));
|
||||
Assert.assertTrue(NumericUtil.isNumber(1.0d));
|
||||
Assert.assertFalse(NumericUtil.isNumber('1'));
|
||||
Assert.assertFalse(NumericUtil.isNumber((Object) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -421,13 +421,13 @@ public class NumericUtilTest extends BaseUnitTest {
|
|||
Assert.assertEquals(1, NumericUtil.convertToNumber(1));
|
||||
Assert.assertEquals(1.2, NumericUtil.convertToNumber(1.2));
|
||||
|
||||
Assert.assertEquals(new BigDecimal(1.25),
|
||||
Assert.assertEquals(new BigDecimal("1.25"),
|
||||
NumericUtil.convertToNumber("1.25"));
|
||||
|
||||
Date date = new Date();
|
||||
Assert.assertEquals(date.getTime(), NumericUtil.convertToNumber(date));
|
||||
|
||||
Assert.assertEquals(null, NumericUtil.convertToNumber(null));
|
||||
Assert.assertNull(NumericUtil.convertToNumber(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class ReflectionUtilTest extends BaseUnitTest {
|
|||
List<String> classes = ReflectionUtil.nestedClasses(
|
||||
TestClass.class.getName());
|
||||
Assert.assertEquals(5, classes.size());
|
||||
classes.sort((c1, c2) -> c1.compareTo(c2));
|
||||
classes.sort(String::compareTo);
|
||||
Assert.assertEquals(Bar.class.getName(), classes.get(0));
|
||||
Assert.assertEquals(Base.class.getName(), classes.get(1));
|
||||
Assert.assertEquals(Foo.class.getName(), classes.get(2));
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@
|
|||
package org.apache.hugegraph.unit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.hugegraph.testutil.Assert;
|
||||
import org.apache.hugegraph.util.StringUtil;
|
||||
import org.apache.hugegraph.util.StringUtil.Chars;
|
||||
import org.apache.hugegraph.testutil.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
public class StringUtilTest {
|
||||
|
|
@ -155,9 +156,7 @@ public class StringUtilTest {
|
|||
|
||||
private static List<String> toStringList(String[] stringArray) {
|
||||
List<String> results = new ArrayList<>(stringArray.length);
|
||||
for (String str : stringArray) {
|
||||
results.add(str);
|
||||
}
|
||||
Collections.addAll(results, stringArray);
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class UnitUtilTest {
|
|||
Assert.assertEquals(0d, value, 0d);
|
||||
|
||||
// KB
|
||||
value = UnitUtil.bytesToMB(Bytes.KB * 1);
|
||||
value = UnitUtil.bytesToMB(1 * Bytes.KB);
|
||||
Assert.assertEquals(0d, value, 0d);
|
||||
|
||||
value = UnitUtil.bytesToMB(Bytes.KB * 10);
|
||||
|
|
@ -86,7 +86,7 @@ public class UnitUtilTest {
|
|||
Assert.assertEquals(0d, value, 0d);
|
||||
|
||||
// MB
|
||||
value = UnitUtil.bytesToGB(Bytes.MB * 1);
|
||||
value = UnitUtil.bytesToGB(1 * Bytes.MB);
|
||||
Assert.assertEquals(0d, value, 0d);
|
||||
|
||||
value = UnitUtil.bytesToGB(Bytes.MB * 10);
|
||||
|
|
|
|||
|
|
@ -133,8 +133,7 @@ public class VersionUtilTest extends BaseUnitTest {
|
|||
VersionUtil.getImplementationVersion(manifestPath));
|
||||
|
||||
manifestPath = "file:./src/test/resources2";
|
||||
Assert.assertEquals(null,
|
||||
VersionUtil.getImplementationVersion(manifestPath));
|
||||
Assert.assertNull(VersionUtil.getImplementationVersion(manifestPath));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>hugegraph-rpc</artifactId>
|
||||
<name>${artifactId}</name>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>HugeGraph RPC component</description>
|
||||
|
||||
<properties>
|
||||
|
|
@ -104,7 +104,6 @@
|
|||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${compiler.source}</source>
|
||||
<target>${compiler.target}</target>
|
||||
|
|
@ -119,7 +118,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<index>true</index>
|
||||
|
|
@ -174,7 +172,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
|
|
@ -187,7 +184,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
|
@ -200,7 +196,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ public interface RpcServiceConfig4Server {
|
|||
|
||||
<T, S extends T> String addService(Class<T> clazz, S serviceImpl);
|
||||
|
||||
<T, S extends T> String addService(String graph,
|
||||
Class<T> clazz, S serviceImpl);
|
||||
<T, S extends T> String addService(String graph, Class<T> clazz, S serviceImpl);
|
||||
|
||||
void removeService(String serviceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ServerClientTest extends BaseUnitTest {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() throws Exception {
|
||||
public static void clear() {
|
||||
if (rpcClient != null) {
|
||||
rpcClient.destroy();
|
||||
}
|
||||
|
|
@ -711,13 +711,13 @@ public class ServerClientTest extends BaseUnitTest {
|
|||
RpcCommonConfig.initRpcConfigs(RpcOptions.CONSUMER_RETRIES, 2);
|
||||
}
|
||||
|
||||
public static interface HelloService {
|
||||
public interface HelloService {
|
||||
|
||||
public String hello(String string);
|
||||
String hello(String string);
|
||||
|
||||
public String echo(String string);
|
||||
String echo(String string);
|
||||
|
||||
public double sum(long a, double b);
|
||||
double sum(long a, double b);
|
||||
}
|
||||
|
||||
public static class HelloServiceImpl implements HelloService {
|
||||
|
|
|
|||
12
pom.xml
12
pom.xml
|
|
@ -60,21 +60,21 @@
|
|||
<top.level.dir>${project.basedir}/..</top.level.dir>
|
||||
<compiler.source>1.8</compiler.source>
|
||||
<compiler.target>1.8</compiler.target>
|
||||
<log4j2.version>2.17.0</log4j2.version>
|
||||
<log4j2.version>2.18.0</log4j2.version>
|
||||
<commons.configuration.version>1.10</commons.configuration.version>
|
||||
<commons.configuration2.version>2.3</commons.configuration2.version>
|
||||
<commons.configuration2.version>2.8.0</commons.configuration2.version>
|
||||
<commons.beanutils.version>1.9.4</commons.beanutils.version>
|
||||
<commons.collections.version>3.2.2</commons.collections.version>
|
||||
<commons.io.version>2.7</commons.io.version>
|
||||
<commons.codec.version>1.11</commons.codec.version>
|
||||
<guava.version>25.1-jre</guava.version>
|
||||
<commons.codec.version>1.13</commons.codec.version>
|
||||
<guava.version>30.0-jre</guava.version>
|
||||
<javax.json.version>1.0</javax.json.version>
|
||||
<jsr305.version>3.0.1</jsr305.version>
|
||||
<javassist.version>3.28.0-GA</javassist.version>
|
||||
<jersey.version>3.0.3</jersey.version>
|
||||
<jersey.hk2.version>3.0.3</jersey.hk2.version>
|
||||
<jackson.version>2.12.1</jackson.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<jackson.version>2.14.0-rc1</jackson.version>
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<mockito.version>4.1.0</mockito.version>
|
||||
<jakarta.xml.version>4.0.0-RC2</jakarta.xml.version>
|
||||
<sun.xml.version>3.0.2</sun.xml.version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue