summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/protect
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-05-07 14:29:09 +0200
committerJon Bratseth <bratseth@oath.com>2018-05-07 14:29:09 +0200
commit73816655bb091fb7593af1a20e4fa744db2e6380 (patch)
tree620056ed7bcd9aac156581b1d6278d208ad6b353 /vespajlib/src/test/java/com/yahoo/protect
parent0655c2239f95566ea75e34ce72581380ba94fff0 (diff)
Use new junit API
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo/protect')
-rw-r--r--vespajlib/src/test/java/com/yahoo/protect/TestErrorMessage.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/protect/ValidatorTestCase.java15
2 files changed, 23 insertions, 2 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/protect/TestErrorMessage.java b/vespajlib/src/test/java/com/yahoo/protect/TestErrorMessage.java
index 3a923ebbb47..58a35b2bddf 100644
--- a/vespajlib/src/test/java/com/yahoo/protect/TestErrorMessage.java
+++ b/vespajlib/src/test/java/com/yahoo/protect/TestErrorMessage.java
@@ -1,11 +1,18 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.protect;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* @author bratseth
*/
-public class TestErrorMessage extends junit.framework.TestCase {
+public class TestErrorMessage {
+ @Test
public void testErrorMessages() {
ErrorMessage m1=new ErrorMessage(17,"Message");
ErrorMessage m2=new ErrorMessage(17,"Message","Detail");
@@ -17,6 +24,7 @@ public class TestErrorMessage extends junit.framework.TestCase {
assertEquals("error : Message (Detail: Throwable message)",m3.toString());
}
+ @Test
public void testErrorMessageEquality() {
assertEquals(new ErrorMessage(17,"Message"),new ErrorMessage(17,"Message"));
assertFalse(new ErrorMessage(16,"Message").equals(new ErrorMessage(17,"Message")));
diff --git a/vespajlib/src/test/java/com/yahoo/protect/ValidatorTestCase.java b/vespajlib/src/test/java/com/yahoo/protect/ValidatorTestCase.java
index 42e9cd0298b..e4549968ebd 100644
--- a/vespajlib/src/test/java/com/yahoo/protect/ValidatorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/protect/ValidatorTestCase.java
@@ -1,11 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.protect;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
/**
* @author bratseth
*/
-public class ValidatorTestCase extends junit.framework.TestCase {
+public class ValidatorTestCase {
+ @Test
public void testEnsureNotNull() {
try {
Validator.ensureNotNull("Description",null);
@@ -16,6 +22,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testEnsureNotInitialized() {
try {
Validator.ensureNotInitialized("Description","Field-owner","Initialized-field-value");
@@ -26,6 +33,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testEnsureInRange() {
try {
Validator.ensureInRange("Description",2,4,5);
@@ -36,6 +44,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testSmallerInts() {
try {
Validator.ensureSmaller("Small-description",3,"Large-description",2);
@@ -46,6 +55,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testSmallerComparables() {
try {
Validator.ensureSmaller("Small-description","b","Large-description","a");
@@ -56,6 +66,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testEnsure() {
try {
Validator.ensure("Description",false);
@@ -66,6 +77,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testEnsureInstanceOf() {
try {
Validator.ensureInstanceOf("Description","item",Integer.class);
@@ -76,6 +88,7 @@ public class ValidatorTestCase extends junit.framework.TestCase {
}
}
+ @Test
public void testVarArgsEnsure() {
Validator.ensure(true, "ignored");
try {