rework TCK to Junit5 (#297)
* rework TCK to Junit5, replace System.out/err.println by java.util.logging.Logger
Signed-off-by: aserkes <andrii.serkes@oracle.com>
diff --git a/tck/pom.xml b/tck/pom.xml
index eab4f86..87753b8 100644
--- a/tck/pom.xml
+++ b/tck/pom.xml
@@ -56,6 +56,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
+ <junit.jupiter.version>5.7.2</junit.jupiter.version>
+ <arquillian.junit5.version>1.7.0.Alpha5</arquillian.junit5.version>
</properties>
<dependencies>
@@ -72,14 +74,20 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>1.6.0.Final</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit.jupiter.version}</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit.jupiter.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit5</groupId>
+ <artifactId>arquillian-junit5-container</artifactId>
+ <version>${arquillian.junit5.version}</version>
</dependency>
</dependencies>
+
</project>
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/JSONP_Util.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/JSONP_Util.java
index 94145de..d6ccde3 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/JSONP_Util.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/JSONP_Util.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -29,14 +29,15 @@
import java.math.BigInteger;
import java.math.BigDecimal;
+import java.util.logging.Logger;
import jakarta.json.*;
import jakarta.json.stream.*;
-import jakarta.json.stream.JsonParser.Event.*;
-import jakarta.json.JsonValue.ValueType.*;
public final class JSONP_Util {
+ private static final Logger LOGGER = Logger.getLogger(JSONP_Util.class.getName());
+
// Charset CONSTANTS for all the supported UTF encodings
public static final Charset UTF_8 = Charset.forName("UTF-8");
@@ -68,13 +69,13 @@
* void dumpContentsOfResource(String resource)
*********************************************************************************/
public static void dumpContentsOfResource(String resource) {
- System.out.println("Dumping contents of Resource file: " + resource);
+ LOGGER.info("Dumping contents of Resource file: " + resource);
BufferedReader reader = null;
try {
InputStream iStream = JSONP_Util.class
.getResourceAsStream("/" + resource);
if (iStream == null) {
- System.err.println(
+ LOGGER.warning(
"dumpContentsOfResource: no resource found in classpath or archive named "
+ resource);
return;
@@ -82,7 +83,7 @@
reader = new BufferedReader(new InputStreamReader(iStream));
String thisLine;
while ((thisLine = reader.readLine()) != null) {
- System.out.println(thisLine);
+ LOGGER.info(thisLine);
}
} catch (Exception e) {
@@ -92,7 +93,7 @@
try {
reader.close();
} catch (Exception e) {
- System.err.println("exception closing stream: " + e);
+ LOGGER.warning("exception closing stream: " + e);
}
}
}
@@ -101,18 +102,18 @@
* void dumpFile(String file)
*********************************************************************************/
public static void dumpFile(String file) {
- System.out.println("Dumping contents of file: " + file);
+ LOGGER.info("Dumping contents of file: " + file);
BufferedReader reader = null;
try {
FileInputStream fis = new FileInputStream(file);
if (fis == null) {
- System.err.println("dumpFile: no file found named " + file);
+ LOGGER.warning("dumpFile: no file found named " + file);
return;
}
reader = new BufferedReader(new InputStreamReader(fis));
String thisLine;
while ((thisLine = reader.readLine()) != null) {
- System.out.println(thisLine);
+ LOGGER.info(thisLine);
}
} catch (Exception e) {
@@ -122,7 +123,7 @@
try {
reader.close();
} catch (Exception e) {
- System.err.println("exception closing stream: " + e);
+ LOGGER.warning("exception closing stream: " + e);
}
}
}
@@ -137,7 +138,7 @@
InputStream iStream = JSONP_Util.class
.getResourceAsStream("/" + resource);
if (iStream == null) {
- System.err.println(
+ LOGGER.warning(
"dumpContentsOfResource: no resource found in classpath or archive named "
+ resource);
return null;
@@ -155,7 +156,7 @@
try {
reader.close();
} catch (Exception e) {
- System.err.println("exception closing stream: " + e);
+ LOGGER.warning("exception closing stream: " + e);
}
}
return sb.toString();
@@ -170,7 +171,7 @@
InputStream iStream = JSONP_Util.class
.getResourceAsStream("/" + resource);
if (iStream == null)
- System.err.println(
+ LOGGER.warning(
"getReaderFromResource: no resource found in classpath or archive named "
+ resource);
else
@@ -189,7 +190,7 @@
try {
InputStream iStream = new ByteArrayInputStream(contents.getBytes(UTF_8));
if (iStream == null)
- System.err.println("getReaderFromString: no input stream");
+ LOGGER.warning("getReaderFromString: no input stream");
else
reader = new InputStreamReader(iStream);
} catch (Exception e) {
@@ -206,7 +207,7 @@
try {
iStream = JSONP_Util.class.getResourceAsStream("/" + resource);
if (iStream == null)
- System.err.println(
+ LOGGER.warning(
"getInputStreamFromResource: no resource found in classpath or archive named "
+ resource);
} catch (Exception e) {
@@ -223,7 +224,7 @@
try {
iStream = new ByteArrayInputStream(contents.getBytes(UTF_8));
if (iStream == null)
- System.err.println("getInputStreamFromString: no input stream");
+ LOGGER.warning("getInputStreamFromString: no input stream");
} catch (Exception e) {
e.printStackTrace();
}
@@ -239,7 +240,7 @@
try {
iStream = new ByteArrayInputStream(baos.toByteArray());
if (iStream == null)
- System.err.println("getInputStreamFromOutputStream: no input stream");
+ LOGGER.warning("getInputStreamFromOutputStream: no input stream");
} catch (Exception e) {
e.printStackTrace();
}
@@ -325,35 +326,35 @@
* void dumpJsonString(JsonString val)
*********************************************************************************/
public static void dumpJsonString(JsonString value) {
- System.out.println("dumpJsonString->" + toStringJsonString(value));
+ LOGGER.info("dumpJsonString->" + toStringJsonString(value));
}
/*********************************************************************************
* void dumpJsonArray(JsonArray value)
*********************************************************************************/
public static void dumpJsonArray(JsonArray value) {
- System.out.println("dumpJsonArray->" + toStringJsonArray(value));
+ LOGGER.info("dumpJsonArray->" + toStringJsonArray(value));
}
/*********************************************************************************
* void dumpJsonObject(JsonObject value)
*********************************************************************************/
public static void dumpJsonObject(JsonObject value) {
- System.out.println("dumpJsonObject->" + toStringJsonObject(value));
+ LOGGER.info("dumpJsonObject->" + toStringJsonObject(value));
}
/*********************************************************************************
* void dumpJsonConstant(JsonValue value)
*********************************************************************************/
public static void dumpJsonConstant(JsonValue value) {
- System.out.println("dumpJsonConstant->" + toStringJsonConstant(value));
+ LOGGER.info("dumpJsonConstant->" + toStringJsonConstant(value));
}
/*********************************************************************************
* void dumpJsonNumber(JsonNumber value)
*********************************************************************************/
public static void dumpJsonNumber(JsonNumber value) {
- System.out.println("dumpJsonNumber->" + toStringJsonNumber(value));
+ LOGGER.info("dumpJsonNumber->" + toStringJsonNumber(value));
}
/*********************************************************************************
@@ -467,16 +468,16 @@
* void dumpSet(Set<String> set, String msg)
*********************************************************************************/
public static void dumpSet(Set<String> set, String msg) {
- System.out.println("*** Beg: Dumping List contents ***");
+ LOGGER.info("*** Beg: Dumping List contents ***");
if (msg != null)
- System.out.println("*** Message: " + msg);
+ LOGGER.info("*** Message: " + msg);
Iterator iterator = set.iterator();
- System.out.println("Set: (");
+ LOGGER.info("Set: (");
while (iterator.hasNext()) {
- System.out.println((String) iterator.next());
+ LOGGER.info((String) iterator.next());
}
- System.out.println(")");
- System.out.println("*** End: Dumping Set contents ***");
+ LOGGER.info(")");
+ LOGGER.info("*** End: Dumping Set contents ***");
}
/*********************************************************************************
@@ -508,14 +509,14 @@
public static boolean assertEqualsSet(Set<String> expSet,
Set<String> actSet) {
if (actSet.equals(expSet)) {
- System.out.println("Sets are equal - match (Success)");
- System.out.println("Expected: " + toStringSet(expSet));
- System.out.println("Actual: " + toStringSet(actSet));
+ LOGGER.info("Sets are equal - match (Success)");
+ LOGGER.info("Expected: " + toStringSet(expSet));
+ LOGGER.info("Actual: " + toStringSet(actSet));
return true;
} else {
- System.out.println("Sets are not equal - mismatch (Failure)");
- System.err.println("Expected: " + toStringSet(expSet));
- System.err.println("Actual: " + toStringSet(actSet));
+ LOGGER.info("Sets are not equal - mismatch (Failure)");
+ LOGGER.warning("Expected: " + toStringSet(expSet));
+ LOGGER.warning("Actual: " + toStringSet(actSet));
return false;
}
}
@@ -524,16 +525,16 @@
* void dumpMap(Map<String,JsonValue> map, String msg)
*********************************************************************************/
public static void dumpMap(Map<String, JsonValue> map, String msg) {
- System.out.println("*** Beg: Dumping Map contents ***");
+ LOGGER.info("*** Beg: Dumping Map contents ***");
if (msg != null)
- System.out.println("*** Message: " + msg);
- System.out.println("Map: {");
+ LOGGER.info("*** Message: " + msg);
+ LOGGER.info("Map: {");
for (Map.Entry<String, JsonValue> entry : map.entrySet()) {
- System.out.println(
+ LOGGER.info(
"\"" + entry.getKey() + "\":" + toStringJsonValue(entry.getValue()));
}
- System.out.println("}");
- System.out.println("*** End: Dumping Map contents ***");
+ LOGGER.info("}");
+ LOGGER.info("*** End: Dumping Map contents ***");
}
/*********************************************************************************
@@ -567,14 +568,14 @@
public static boolean assertEqualsMap(Map<String, JsonValue> expMap,
Map<String, JsonValue> actMap) {
if (actMap.equals(expMap)) {
- System.out.println("Maps are equal - match (Success)");
- System.out.println("Expected: " + toStringMap(expMap));
- System.out.println("Actual: " + toStringMap(actMap));
+ LOGGER.info("Maps are equal - match (Success)");
+ LOGGER.info("Expected: " + toStringMap(expMap));
+ LOGGER.info("Actual: " + toStringMap(actMap));
return true;
} else {
- System.out.println("Maps are not equal - mismatch (Failure)");
- System.err.println("Expected: " + toStringMap(expMap));
- System.err.println("Actual: " + toStringMap(actMap));
+ LOGGER.info("Maps are not equal - mismatch (Failure)");
+ LOGGER.warning("Expected: " + toStringMap(expMap));
+ LOGGER.warning("Actual: " + toStringMap(actMap));
return false;
}
}
@@ -584,33 +585,33 @@
*********************************************************************************/
public static boolean assertEqualsMap2(Map<String, JsonValue> expMap,
Map<String, JsonValue> actMap) {
- System.out.println("*** Comparing Map expMap and Map actMap for equality ***");
- System.out.println("Expected: " + toStringMap(expMap));
- System.out.println("Actual: " + toStringMap(actMap));
- System.out.println("Map expMap size should equal Map actMap size");
+ LOGGER.info("*** Comparing Map expMap and Map actMap for equality ***");
+ LOGGER.info("Expected: " + toStringMap(expMap));
+ LOGGER.info("Actual: " + toStringMap(actMap));
+ LOGGER.info("Map expMap size should equal Map actMap size");
if (expMap.size() != actMap.size()) {
- System.err.println("Map sizes are not equal: expMap size " + expMap.size()
+ LOGGER.warning("Map sizes are not equal: expMap size " + expMap.size()
+ ", actMap size " + actMap.size());
return false;
} else {
- System.out.println("Map sizes are equal with size of " + expMap.size());
+ LOGGER.info("Map sizes are equal with size of " + expMap.size());
}
for (Map.Entry<String, ?> entry : expMap.entrySet()) {
String key = entry.getKey();
if (actMap.containsKey(key)) {
if (expMap.get(key) != null && actMap.get(key) != null) {
if (!expMap.get(key).equals(actMap.get(key))) {
- System.err.println("key=" + key + ", expMap value " + expMap.get(key)
+ LOGGER.warning("key=" + key + ", expMap value " + expMap.get(key)
+ " does not equal actMap value " + actMap.get(key));
return false;
}
}
} else {
- System.err.println("actMap does not contain key " + key);
+ LOGGER.warning("actMap does not contain key " + key);
return false;
}
}
- System.out.println("Maps expMap and actMap are equal.");
+ LOGGER.info("Maps expMap and actMap are equal.");
return true;
}
@@ -618,16 +619,16 @@
* void dumpList(List<JsonValue> list, String msg)
*********************************************************************************/
public static void dumpList(List<JsonValue> list, String msg) {
- System.out.println("*** Beg: Dumping List contents ***");
+ LOGGER.info("*** Beg: Dumping List contents ***");
if (msg != null)
- System.out.println("*** Message: " + msg);
+ LOGGER.info("*** Message: " + msg);
Iterator<JsonValue> iter = list.iterator();
- System.out.println("List: [");
+ LOGGER.info("List: [");
while (iter.hasNext()) {
- System.out.println("" + toStringJsonValue(iter.next()));
+ LOGGER.info("" + toStringJsonValue(iter.next()));
}
- System.out.println("]");
- System.out.println("*** End: Dumping List contents ***");
+ LOGGER.info("]");
+ LOGGER.info("*** End: Dumping List contents ***");
}
/*********************************************************************************
@@ -660,14 +661,14 @@
public static boolean assertEqualsList(List<JsonValue> expList,
List<JsonValue> actList) {
if (actList.equals(expList)) {
- System.out.println("Lists are equal - match (Success)");
- System.out.println("Expected: " + toStringList(expList));
- System.out.println("Actual: " + toStringList(actList));
+ LOGGER.info("Lists are equal - match (Success)");
+ LOGGER.info("Expected: " + toStringList(expList));
+ LOGGER.info("Actual: " + toStringList(actList));
return true;
} else {
- System.out.println("Lists are not equal - mismatch (Failure)");
- System.err.println("Expected: " + toStringList(expList));
- System.err.println("Actual: " + toStringList(actList));
+ LOGGER.info("Lists are not equal - mismatch (Failure)");
+ LOGGER.warning("Expected: " + toStringList(expList));
+ LOGGER.warning("Actual: " + toStringList(actList));
return false;
}
}
@@ -677,29 +678,29 @@
*********************************************************************************/
public static boolean assertEqualsList2(List<JsonValue> expList,
List<JsonValue> actList) {
- System.out.println(
+ LOGGER.info(
"*** Comparing contents of List expList and List actList for equality ***");
- System.out.println("Expected: " + toStringList(expList));
- System.out.println("Actual: " + toStringList(actList));
- System.out.println("List expList size should equal List actList size");
+ LOGGER.info("Expected: " + toStringList(expList));
+ LOGGER.info("Actual: " + toStringList(actList));
+ LOGGER.info("List expList size should equal List actList size");
if (expList.size() != actList.size()) {
- System.err.println("List sizes are not equal: expList size " + expList.size()
+ LOGGER.warning("List sizes are not equal: expList size " + expList.size()
+ ", actList size " + actList.size());
return false;
}
- System.out.println("Compare Lists (all elements should MATCH)");
+ LOGGER.info("Compare Lists (all elements should MATCH)");
for (int i = 0; i < expList.size(); i++) {
if (expList.get(i).equals(actList.get(i))) {
- System.out.println("expList element " + i + " matches actList element " + i);
+ LOGGER.info("expList element " + i + " matches actList element " + i);
} else {
- System.err.println(
+ LOGGER.warning(
"expList element " + i + " does not match actList element " + i);
- System.err.println("expList[" + i + "]=" + expList.get(i));
- System.err.println("actList[" + i + "]=" + actList.get(i));
+ LOGGER.warning("expList[" + i + "]=" + expList.get(i));
+ LOGGER.warning("actList[" + i + "]=" + actList.get(i));
return false;
}
}
- System.out.println("Lists are equal (Success)");
+ LOGGER.info("Lists are equal (Success)");
return true;
}
@@ -707,15 +708,15 @@
* void dumpIterator(Iterator<JsonValue> iterator, String msg)
*********************************************************************************/
public static void dumpIterator(Iterator<JsonValue> iterator, String msg) {
- System.out.println("*** Beg: Dumping Iterator contents ***");
+ LOGGER.info("*** Beg: Dumping Iterator contents ***");
if (msg != null)
- System.out.println("*** Message: " + msg);
- System.out.println("Iter: [");
+ LOGGER.info("*** Message: " + msg);
+ LOGGER.info("Iter: [");
while (iterator.hasNext()) {
- System.out.println("" + toStringJsonValue(iterator.next()));
+ LOGGER.info("" + toStringJsonValue(iterator.next()));
}
- System.out.println("]");
- System.out.println("*** End: Dumping Iterator contents ***");
+ LOGGER.info("]");
+ LOGGER.info("*** End: Dumping Iterator contents ***");
}
/*********************************************************************************
@@ -748,12 +749,12 @@
Iterator<JsonValue> actIt) {
boolean pass = true;
- System.out.println(
+ LOGGER.info(
"*** Comparing contents of Iterator expIt and Iterator actIt for equality ***");
int i = 0;
while (expIt.hasNext()) {
if (!actIt.hasNext()) {
- System.err.println(
+ LOGGER.warning(
"Iterator expIt contains more elements than Iterator actIt");
return false;
}
@@ -761,22 +762,22 @@
JsonValue value1 = expIt.next();
JsonValue value2 = actIt.next();
if (assertEqualsJsonValues(value1, value2)) {
- System.out.println("Iterator expIt element " + i
+ LOGGER.info("Iterator expIt element " + i
+ " matches Iterator actIt element " + i);
} else {
- System.err.println("Iterator expIt element " + i
+ LOGGER.warning("Iterator expIt element " + i
+ " does not match Iterator actIt element " + i);
pass = false;
}
}
if (actIt.hasNext()) {
- System.err.println("Iterator actIt contains more elements than Iterator expIt");
+ LOGGER.warning("Iterator actIt contains more elements than Iterator expIt");
return false;
}
if (pass)
- System.out.println("Iterators are equal (Success)");
+ LOGGER.info("Iterators are equal (Success)");
else
- System.out.println("Iterators are not equal (Failure)");
+ LOGGER.info("Iterators are not equal (Failure)");
return pass;
}
@@ -785,10 +786,10 @@
*********************************************************************************/
public static boolean assertEqualsEmptyArrayList(List<JsonValue> actual) {
if (actual.isEmpty()) {
- System.out.println("Array List is empty - expected");
+ LOGGER.info("Array List is empty - expected");
return true;
} else {
- System.err.println("Array List is not empty - unexpected");
+ LOGGER.warning("Array List is not empty - unexpected");
return false;
}
}
@@ -799,10 +800,10 @@
public static boolean assertEqualsEmptyObjectMap(
Map<String, JsonValue> actual) {
if (actual.isEmpty()) {
- System.out.println("Object Map is empty - expected");
+ LOGGER.info("Object Map is empty - expected");
return true;
} else {
- System.err.println("Object Map is not empty - unexpected");
+ LOGGER.warning("Object Map is not empty - unexpected");
return false;
}
}
@@ -812,10 +813,10 @@
*********************************************************************************/
public static boolean assertEqualsEmptyIterator(Iterator<JsonValue> actual) {
if (!actual.hasNext()) {
- System.out.println("Iterator is empty - expected");
+ LOGGER.info("Iterator is empty - expected");
return true;
} else {
- System.err.println("Iterator is not empty - unexpected");
+ LOGGER.warning("Iterator is not empty - unexpected");
return false;
}
}
@@ -825,14 +826,14 @@
*********************************************************************************/
public static boolean assertEqualsJsonText(String expected, String actual) {
if (actual.equals(expected)) {
- System.out.println("JSON text match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("JSON text match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("JSON text mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("JSON text mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -843,14 +844,14 @@
public static boolean assertEqualsJsonArrays(JsonArray expected,
JsonArray actual) {
if (actual.equals(expected)) {
- System.out.println("JsonArray match");
- System.out.println("Expected: " + toStringJsonArray(expected));
- System.out.println("Actual: " + toStringJsonArray(actual));
+ LOGGER.info("JsonArray match");
+ LOGGER.info("Expected: " + toStringJsonArray(expected));
+ LOGGER.info("Actual: " + toStringJsonArray(actual));
return true;
} else {
- System.err.println("JsonArray mismatch");
- System.err.println("Expected: " + toStringJsonArray(expected));
- System.err.println("Actual: " + toStringJsonArray(actual));
+ LOGGER.warning("JsonArray mismatch");
+ LOGGER.warning("Expected: " + toStringJsonArray(expected));
+ LOGGER.warning("Actual: " + toStringJsonArray(actual));
return false;
}
}
@@ -861,14 +862,14 @@
public static boolean assertEqualsJsonObjects(JsonObject expected,
JsonObject actual) {
if (actual.equals(expected)) {
- System.out.println("JsonObject match");
- System.out.println("Expected: " + toStringJsonObject(expected));
- System.out.println("Actual: " + toStringJsonObject(actual));
+ LOGGER.info("JsonObject match");
+ LOGGER.info("Expected: " + toStringJsonObject(expected));
+ LOGGER.info("Actual: " + toStringJsonObject(actual));
return true;
} else {
- System.err.println("JsonObject mismatch");
- System.err.println("Expected: " + toStringJsonObject(expected));
- System.err.println("Actual: " + toStringJsonObject(actual));
+ LOGGER.warning("JsonObject mismatch");
+ LOGGER.warning("Expected: " + toStringJsonObject(expected));
+ LOGGER.warning("Actual: " + toStringJsonObject(actual));
return false;
}
}
@@ -881,14 +882,14 @@
boolean pass = true;
if (actual.equals(expected)) {
- System.out.println("JsonNumber match");
- System.out.println("Expected: " + toStringJsonNumber(expected));
- System.out.println("Actual: " + toStringJsonNumber(actual));
+ LOGGER.info("JsonNumber match");
+ LOGGER.info("Expected: " + toStringJsonNumber(expected));
+ LOGGER.info("Actual: " + toStringJsonNumber(actual));
return true;
} else {
- System.err.println("JsonNumber mismatch");
- System.err.println("Expected: " + toStringJsonNumber(expected));
- System.err.println("Actual: " + toStringJsonNumber(actual));
+ LOGGER.warning("JsonNumber mismatch");
+ LOGGER.warning("Expected: " + toStringJsonNumber(expected));
+ LOGGER.warning("Actual: " + toStringJsonNumber(actual));
return false;
}
}
@@ -901,14 +902,14 @@
boolean pass = true;
if (actual.equals(expected)) {
- System.out.println("JsonString match");
- System.out.println("Expected: " + toStringJsonString(expected));
- System.out.println("Actual: " + toStringJsonString(actual));
+ LOGGER.info("JsonString match");
+ LOGGER.info("Expected: " + toStringJsonString(expected));
+ LOGGER.info("Actual: " + toStringJsonString(actual));
return true;
} else {
- System.err.println("JsonString mismatch");
- System.err.println("Expected: " + toStringJsonString(expected));
- System.err.println("Actual: " + toStringJsonString(actual));
+ LOGGER.warning("JsonString mismatch");
+ LOGGER.warning("Expected: " + toStringJsonString(expected));
+ LOGGER.warning("Actual: " + toStringJsonString(actual));
return false;
}
}
@@ -923,9 +924,9 @@
// Comparing JsonNumbers
if (expected instanceof JsonNumber) {
if (!(actual instanceof JsonNumber)) {
- System.err.println("expected type does not match actual type");
- System.err.println("expected=" + toStringJsonValue(expected));
- System.err.println("actual= " + toStringJsonValue(actual));
+ LOGGER.warning("expected type does not match actual type");
+ LOGGER.warning("expected=" + toStringJsonValue(expected));
+ LOGGER.warning("actual= " + toStringJsonValue(actual));
pass = false;
} else {
pass = assertEqualsJsonNumbers((JsonNumber) expected,
@@ -934,9 +935,9 @@
// Comparing JsonStrings
} else if (expected instanceof JsonString) {
if (!(actual instanceof JsonString)) {
- System.err.println("expected type does not match actual type");
- System.err.println("expected=" + toStringJsonValue(expected));
- System.err.println("actual= " + toStringJsonValue(actual));
+ LOGGER.warning("expected type does not match actual type");
+ LOGGER.warning("expected=" + toStringJsonValue(expected));
+ LOGGER.warning("actual= " + toStringJsonValue(actual));
pass = false;
} else {
pass = assertEqualsJsonStrings((JsonString) expected,
@@ -945,9 +946,9 @@
// Comparing JsonArrays
} else if (expected instanceof JsonArray) {
if (!(actual instanceof JsonArray)) {
- System.err.println("expected type does not match actual type");
- System.err.println("expected=" + toStringJsonValue(expected));
- System.err.println("actual= " + toStringJsonValue(actual));
+ LOGGER.warning("expected type does not match actual type");
+ LOGGER.warning("expected=" + toStringJsonValue(expected));
+ LOGGER.warning("actual= " + toStringJsonValue(actual));
pass = false;
} else {
pass = assertEqualsJsonArrays((JsonArray) expected, (JsonArray) actual);
@@ -955,9 +956,9 @@
// Comparing JsonObjects
} else if (expected instanceof JsonObject) {
if (!(actual instanceof JsonObject)) {
- System.err.println("expected type does not match actual type");
- System.err.println("expected=" + toStringJsonValue(expected));
- System.err.println("actual= " + toStringJsonValue(actual));
+ LOGGER.warning("expected type does not match actual type");
+ LOGGER.warning("expected=" + toStringJsonValue(expected));
+ LOGGER.warning("actual= " + toStringJsonValue(actual));
pass = false;
} else {
pass = assertEqualsJsonObjects((JsonObject) expected,
@@ -965,13 +966,13 @@
}
// Comparing JsonValues
} else if (expected.equals(actual)) {
- System.out.println("expected matches actual");
- System.out.println("expected=" + toStringJsonValue(expected));
- System.out.println("actual= " + toStringJsonValue(actual));
+ LOGGER.info("expected matches actual");
+ LOGGER.info("expected=" + toStringJsonValue(expected));
+ LOGGER.info("actual= " + toStringJsonValue(actual));
} else {
- System.err.println("expected does not match actual");
- System.err.println("expected=" + toStringJsonValue(expected));
- System.err.println("actual= " + toStringJsonValue(actual));
+ LOGGER.warning("expected does not match actual");
+ LOGGER.warning("expected=" + toStringJsonValue(expected));
+ LOGGER.warning("actual= " + toStringJsonValue(actual));
pass = false;
}
return pass;
@@ -984,14 +985,14 @@
public static boolean assertEqualsJsonValueType(JsonValue.ValueType expected,
JsonValue.ValueType actual) {
if (actual == expected) {
- System.out.println("JsonValue.ValueType match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("JsonValue.ValueType match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("JsonValue.ValueType mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("JsonValue.ValueType mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1002,14 +1003,14 @@
public static boolean assertEqualsJsonNumberType(boolean expected,
boolean actual) {
if (actual == expected) {
- System.out.println("Json NumberType match");
- System.out.println("Expected: " + toStringJsonNumberType(expected));
- System.out.println("Actual: " + toStringJsonNumberType(actual));
+ LOGGER.info("Json NumberType match");
+ LOGGER.info("Expected: " + toStringJsonNumberType(expected));
+ LOGGER.info("Actual: " + toStringJsonNumberType(actual));
return true;
} else {
- System.err.println("Json NumberType mismatch");
- System.err.println("Expected: " + toStringJsonNumberType(expected));
- System.err.println("Actual: " + toStringJsonNumberType(actual));
+ LOGGER.warning("Json NumberType mismatch");
+ LOGGER.warning("Expected: " + toStringJsonNumberType(expected));
+ LOGGER.warning("Actual: " + toStringJsonNumberType(actual));
return false;
}
}
@@ -1021,15 +1022,15 @@
boolean actual) {
for (int i = 0; i < expected.length; i++) {
if (actual == expected[i]) {
- System.out.println("Json NumberType match");
- System.out.println("Expected: " + toStringJsonNumberType(expected[i]));
- System.out.println("Actual: " + toStringJsonNumberType(actual));
+ LOGGER.info("Json NumberType match");
+ LOGGER.info("Expected: " + toStringJsonNumberType(expected[i]));
+ LOGGER.info("Actual: " + toStringJsonNumberType(actual));
return true;
}
}
- System.err.println("Json NumberType mismatch");
- System.err.println("Expected: " + toStringJsonNumberTypes(expected));
- System.err.println("Actual: " + toStringJsonNumberType(actual));
+ LOGGER.warning("Json NumberType mismatch");
+ LOGGER.warning("Expected: " + toStringJsonNumberTypes(expected));
+ LOGGER.warning("Actual: " + toStringJsonNumberType(actual));
return false;
}
@@ -1061,14 +1062,14 @@
*********************************************************************************/
public static boolean assertEquals(Object expected, Object actual) {
if (actual.equals(expected)) {
- System.out.println("Object match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("Object match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("Object mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("Object mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1078,14 +1079,14 @@
*********************************************************************************/
public static boolean assertEquals(boolean expected, boolean actual) {
if (actual == expected) {
- System.out.println("boolean match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("boolean match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("boolean mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("boolean mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1095,14 +1096,14 @@
*********************************************************************************/
public static boolean assertEquals(short expected, short actual) {
if (actual == expected) {
- System.out.println("short match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("short match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("short mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("short mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1112,14 +1113,14 @@
*********************************************************************************/
public static boolean assertEquals(int expected, int actual) {
if (actual == expected) {
- System.out.println("int match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("int match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("int mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("int mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1129,14 +1130,14 @@
*********************************************************************************/
public static boolean assertEquals(long expected, long actual) {
if (actual == expected) {
- System.out.println("long match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("long match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("long mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("long mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1146,14 +1147,14 @@
*********************************************************************************/
public static boolean assertEquals(float expected, float actual) {
if (actual == expected) {
- System.out.println("float match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("float match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("float mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("float mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1163,14 +1164,14 @@
*********************************************************************************/
public static boolean assertEquals(double expected, double actual) {
if (actual == expected) {
- System.out.println("double match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("double match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("double mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("double mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1180,14 +1181,14 @@
*********************************************************************************/
public static boolean assertEquals(BigDecimal expected, BigDecimal actual) {
if (actual.equals(expected)) {
- System.out.println("BigDecimal match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("BigDecimal match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("BigDecimal mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("BigDecimal mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1197,14 +1198,14 @@
*********************************************************************************/
public static boolean assertEquals(BigInteger expected, BigInteger actual) {
if (actual.equals(expected)) {
- System.out.println("BigInteger match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("BigInteger match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("BigInteger mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("BigInteger mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1214,14 +1215,14 @@
*********************************************************************************/
public static boolean assertEquals(String expected, String actual) {
if (actual.equals(expected)) {
- System.out.println("String match");
- System.out.println("Expected: " + expected);
- System.out.println("Actual: " + actual);
+ LOGGER.info("String match");
+ LOGGER.info("Expected: " + expected);
+ LOGGER.info("Actual: " + actual);
return true;
} else {
- System.err.println("String mismatch");
- System.err.println("Expected: " + expected);
- System.err.println("Actual: " + actual);
+ LOGGER.warning("String mismatch");
+ LOGGER.warning("Expected: " + expected);
+ LOGGER.warning("Actual: " + actual);
return false;
}
}
@@ -1231,14 +1232,14 @@
*********************************************************************************/
public static boolean assertEquals(JsonValue expected, JsonValue actual) {
if (actual.equals(expected)) {
- System.out.println("JsonValue match");
- System.out.println("Expected: " + toStringJsonValue(expected));
- System.out.println("Actual: " + toStringJsonValue(actual));
+ LOGGER.info("JsonValue match");
+ LOGGER.info("Expected: " + toStringJsonValue(expected));
+ LOGGER.info("Actual: " + toStringJsonValue(actual));
return true;
} else {
- System.err.println("JsonValue mismatch");
- System.err.println("Expected: " + toStringJsonValue(expected));
- System.err.println("Actual: " + toStringJsonValue(actual));
+ LOGGER.warning("JsonValue mismatch");
+ LOGGER.warning("Expected: " + toStringJsonValue(expected));
+ LOGGER.warning("Actual: " + toStringJsonValue(actual));
return false;
}
}
@@ -1313,7 +1314,7 @@
* void dumpEventType(JsonParser.Event eventType)
*********************************************************************************/
public static void dumpEventType(JsonParser.Event eventType) {
- System.out.println("JsonParser.Event=" + eventType);
+ LOGGER.info("JsonParser.Event=" + eventType);
}
/*********************************************************************************
@@ -1402,13 +1403,13 @@
* void dumpConfigMap(Map<String,?> map, String msg)
*********************************************************************************/
public static void dumpConfigMap(Map<String, ?> map, String msg) {
- System.out.println("*** Beg: Dumping Config Map contents ***");
+ LOGGER.info("*** Beg: Dumping Config Map contents ***");
if (msg != null)
- System.out.println("*** Message: " + msg);
+ LOGGER.info("*** Message: " + msg);
for (Map.Entry<String, ?> entry : map.entrySet()) {
- System.out.println("\"" + entry.getKey() + "\":" + entry.getValue());
+ LOGGER.info("\"" + entry.getKey() + "\":" + entry.getValue());
}
- System.out.println("*** End: Dumping Config Map contents ***");
+ LOGGER.info("*** End: Dumping Config Map contents ***");
}
/*********************************************************************************
@@ -1429,25 +1430,25 @@
String[] expectedProps) {
boolean pass = true;
dumpConfigMap(config);
- System.out.println("Checking factory configuration property size");
+ LOGGER.info("Checking factory configuration property size");
if (config.size() != expectedSize) {
- System.err.println("Expecting no of properties=" + expectedSize + ", got="
+ LOGGER.warning("Expecting no of properties=" + expectedSize + ", got="
+ config.size());
pass = false;
} else {
- System.out.println("Expecting no of properties=" + expectedSize + ", got="
+ LOGGER.info("Expecting no of properties=" + expectedSize + ", got="
+ config.size());
}
if (expectedSize != 0 && expectedProps != null) {
- System.out.println("Checking factory configuration property name and value");
+ LOGGER.info("Checking factory configuration property name and value");
for (int i = 0; i < expectedProps.length; i++) {
if (config.containsKey(expectedProps[i])) {
- System.out.println("Does contain key: " + expectedProps[i] + " - expected.");
+ LOGGER.info("Does contain key: " + expectedProps[i] + " - expected.");
if (!JSONP_Util.assertEquals(true, config.get(expectedProps[i]))) {
pass = false;
}
} else {
- System.err.println(
+ LOGGER.warning(
"Does not contain key: " + expectedProps[i] + " - unexpected.");
pass = false;
}
@@ -1460,7 +1461,7 @@
* boolean isEmptyConfig(Map<String, ?> config)
*********************************************************************************/
public boolean isEmptyConfig(Map<String, ?> config) {
- System.out.println("isEmptyConfig");
+ LOGGER.info("isEmptyConfig");
return config.isEmpty();
}
@@ -1468,7 +1469,7 @@
* Map<String, ?> getEmptyConfig()
*********************************************************************************/
public static Map<String, ?> getEmptyConfig() {
- System.out.println("getEmptyConfig");
+ LOGGER.info("getEmptyConfig");
Map<String, Object> config = new HashMap<String, Object>();
return config;
}
@@ -1477,9 +1478,9 @@
* Map<String, ?> getPrettyPrintingConfig()
*********************************************************************************/
public static Map<String, ?> getPrettyPrintingConfig() {
- System.out.println("getPrettyPrintConfig");
+ LOGGER.info("getPrettyPrintConfig");
Map<String, Object> config = new HashMap<String, Object>();
- System.out.println("Added property: JsonGenerator.PRETTY_PRINTING");
+ LOGGER.info("Added property: JsonGenerator.PRETTY_PRINTING");
config.put(JsonGenerator.PRETTY_PRINTING, true);
return config;
}
@@ -1488,9 +1489,9 @@
* Map<String, ?> getFooConfig()
*********************************************************************************/
public static Map<String, ?> getFooConfig() {
- System.out.println("getFooConfig");
+ LOGGER.info("getFooConfig");
Map<String, Object> config = new HashMap<String, Object>();
- System.out.println("Added property: JSONP_Util.FOO_CONFIG");
+ LOGGER.info("Added property: JSONP_Util.FOO_CONFIG");
config.put(JSONP_Util.FOO_CONFIG, true);
return config;
}
@@ -1499,11 +1500,11 @@
* Map<String, ?> getAllConfig()
*********************************************************************************/
public static Map<String, ?> getAllConfig() {
- System.out.println("getAllConfig");
+ LOGGER.info("getAllConfig");
Map<String, Object> config = new HashMap<String, Object>();
- System.out.println("Added property: JsonGenerator.PRETTY_PRINTING");
+ LOGGER.info("Added property: JsonGenerator.PRETTY_PRINTING");
config.put(JsonGenerator.PRETTY_PRINTING, true);
- System.out.println("Added property: JSONP_Util.FOO_CONFIG");
+ LOGGER.info("Added property: JSONP_Util.FOO_CONFIG");
config.put(JSONP_Util.FOO_CONFIG, true);
return config;
}
@@ -1554,7 +1555,7 @@
writer.writeObject(jsonObject);
writer.close();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
}
}
@@ -1568,7 +1569,7 @@
writer.writeArray(jsonArray);
writer.close();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
}
}
@@ -1582,37 +1583,37 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_STRING) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_STRING)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
}
String keyvalue = parser.getString();
if (!keyvalue.equals(value)) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -1626,39 +1627,39 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
int keyvalue = parser.getInt();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -1672,39 +1673,39 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
double keyvalue = parser.getBigDecimal().doubleValue();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -1718,39 +1719,39 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
long keyvalue = parser.getLong();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -1765,39 +1766,39 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
BigDecimal keyvalue = parser.getBigDecimal();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -1810,31 +1811,31 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_TRUE) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_TRUE)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -1847,31 +1848,31 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_FALSE) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_FALSE)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -1884,31 +1885,31 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.VALUE_NULL) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NULL)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -1921,31 +1922,31 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.START_OBJECT) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.START_OBJECT)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -1958,31 +1959,31 @@
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.KEY_NAME) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.KEY_NAME)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyname = parser.getString();
if (!name.equals(keyname)) {
- System.err.println("Expected keyname: " + name + ", got keyname: " + keyname);
+ LOGGER.warning("Expected keyname: " + name + ", got keyname: " + keyname);
parseErrs++;
} else {
- System.out.println("Got expected keyname: " + keyname);
+ LOGGER.info("Got expected keyname: " + keyname);
}
if (!checkNextParserEvent(parser))
return;
e = parser.next();
if (e != JsonParser.Event.START_ARRAY) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.START_ARRAY)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -1991,7 +1992,7 @@
*********************************************************************************/
public static boolean checkNextParserEvent(JsonParser parser) {
if (!parser.hasNext()) {
- System.err.println("no next parser event found - unexpected");
+ LOGGER.warning("no next parser event found - unexpected");
parseErrs++;
return false;
} else
@@ -2031,11 +2032,11 @@
return;
JsonParser.Event e = parser.next();
if (e != expEvent) {
- System.err.println("Expected event: " + getEventTypeString(expEvent)
+ LOGGER.warning("Expected event: " + getEventTypeString(expEvent)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
}
@@ -2047,20 +2048,20 @@
return;
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.VALUE_STRING) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_STRING)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
String keyvalue = parser.getString();
if (!keyvalue.equals(value)) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -2072,20 +2073,20 @@
return;
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
int keyvalue = parser.getInt();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -2097,20 +2098,20 @@
return;
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
double keyvalue = parser.getBigDecimal().doubleValue();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -2122,20 +2123,20 @@
return;
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
long keyvalue = parser.getLong();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -2147,20 +2148,20 @@
return;
JsonParser.Event e = parser.next();
if (e != JsonParser.Event.VALUE_NUMBER) {
- System.err.println(
+ LOGGER.warning(
"Expected event: " + getEventTypeString(JsonParser.Event.VALUE_NUMBER)
+ ", got event: " + getEventTypeString(e));
parseErrs++;
} else {
- System.out.println("Got expected event: " + getEventTypeString(e));
+ LOGGER.info("Got expected event: " + getEventTypeString(e));
}
BigDecimal keyvalue = parser.getBigDecimal();
if (keyvalue != value) {
- System.err.println(
+ LOGGER.warning(
"Expected keyvalue: " + value + ", got keyvalue: " + keyvalue);
parseErrs++;
} else {
- System.out.println("Got expected keyvalue: " + keyvalue);
+ LOGGER.info("Got expected keyvalue: " + keyvalue);
}
}
@@ -2389,11 +2390,11 @@
*********************************************************************************/
public static void dumpLocation(JsonLocation location) {
if (location != null) {
- System.out.println("JsonLocation info: lineNumber=" + location.getLineNumber()
+ LOGGER.info("JsonLocation info: lineNumber=" + location.getLineNumber()
+ ", columnNumber=" + location.getColumnNumber()
+ ", streamOffset=" + location.getStreamOffset());
} else {
- System.out.println("JsonLocation is null - no location info");
+ LOGGER.info("JsonLocation is null - no location info");
}
}
@@ -2411,23 +2412,23 @@
if (expLoc.getLineNumber() == actLoc.getLineNumber()
&& expLoc.getColumnNumber() == actLoc.getColumnNumber()
&& expLoc.getStreamOffset() == actLoc.getStreamOffset()) {
- System.out.println("JsonLocations equal - match (Success)");
- System.out.println(
+ LOGGER.info("JsonLocations equal - match (Success)");
+ LOGGER.info(
"Expected: JsonLocation info: lineNumber=" + expLoc.getLineNumber()
+ ", columnNumber=" + expLoc.getColumnNumber() + ", streamOffset="
+ expLoc.getStreamOffset());
- System.out.println(
+ LOGGER.info(
"Actual: JsonLocation info: lineNumber=" + actLoc.getLineNumber()
+ ", columnNumber=" + actLoc.getColumnNumber() + ", streamOffset="
+ actLoc.getStreamOffset());
return true;
} else {
- System.err.println("JsonLocations not equal - mismatch (Failure)");
- System.err.println(
+ LOGGER.warning("JsonLocations not equal - mismatch (Failure)");
+ LOGGER.warning(
"Expected: JsonLocation info: lineNumber=" + expLoc.getLineNumber()
+ ", columnNumber=" + expLoc.getColumnNumber() + ", streamOffset="
+ expLoc.getStreamOffset());
- System.err.println(
+ LOGGER.warning(
"Actual: JsonLocation info: lineNumber=" + actLoc.getLineNumber()
+ ", columnNumber=" + actLoc.getColumnNumber() + ", streamOffset="
+ actLoc.getStreamOffset());
@@ -2453,7 +2454,7 @@
* void addURLToClassPath(URL url)
*********************************************************************************/
public static void addURLToClassPath(URL url) throws Exception {
- System.out.println("addURLToClassPath-> " + url.toString());
+ LOGGER.info("addURLToClassPath-> " + url.toString());
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader
.getSystemClassLoader();
try {
@@ -2477,7 +2478,7 @@
.build();
return jsonArray;
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
@@ -2493,7 +2494,7 @@
.build();
return jsonObject;
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedInputStream.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedInputStream.java
index 7e59aaf..7a258fd 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedInputStream.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,7 @@
import java.io.*;
+import java.util.logging.Logger;
// A wrapper class to BufferedInputStream class used to inject IOException errors
// when the throwIOException instance variable is set. All methods delegate
@@ -30,6 +31,8 @@
public class MyBufferedInputStream extends BufferedInputStream {
+ private static final Logger LOGGER = Logger.getLogger(MyBufferedInputStream.class.getName());
+
private boolean throwIOException = false;
public MyBufferedInputStream(InputStream in) {
@@ -47,7 +50,7 @@
private void checkToTripIOException() throws IOException {
if (throwIOException) {
- System.out.println(
+ LOGGER.info(
"MyBufferedInputStream->checkToTripIOException: *** tripping an IOException ***");
throw new IOException("tripping an IOException");
}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedReader.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedReader.java
index 00c5145..bb9e3ae 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedReader.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,7 @@
import java.io.*;
+import java.util.logging.Logger;
// A wrapper class to BufferedReader class used to inject IOException errors
// when the throwIOException instance variable is set. All methods delegate
@@ -30,6 +31,8 @@
public class MyBufferedReader extends BufferedReader {
+ private static final Logger LOGGER = Logger.getLogger(MyBufferedReader.class.getName());
+
private boolean throwIOException;
public MyBufferedReader(Reader in) {
@@ -47,7 +50,7 @@
private void checkToTripIOException() throws IOException {
if (throwIOException) {
- System.out.println("*** tripping an IOException ***");
+ LOGGER.info("*** tripping an IOException ***");
throw new IOException("tripping an IOException");
}
}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedWriter.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedWriter.java
index a06c99a..d507bcc 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedWriter.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/common/MyBufferedWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,7 @@
import java.io.*;
+import java.util.logging.Logger;
// A wrapper class to BufferedWriter class used to inject IOException errors
// when the throwIOException instance variable is set. All methods delegate
@@ -30,6 +31,8 @@
public class MyBufferedWriter extends BufferedWriter {
+ private static final Logger LOGGER = Logger.getLogger(MyBufferedWriter.class.getName());
+
private boolean throwIOException;
public MyBufferedWriter(Writer out) {
@@ -47,7 +50,7 @@
private void checkToTripIOException() throws IOException {
if (throwIOException) {
- System.out.println("*** tripping an IOException ***");
+ LOGGER.info("*** tripping an IOException ***");
throw new IOException("tripping an IOException");
}
}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/lib/harness/Fault.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/lib/harness/Fault.java
deleted file mode 100644
index b7a83e0..0000000
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/lib/harness/Fault.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package jakarta.jsonp.tck.lib.harness;
-
-import junit.framework.AssertionFailedError;
-
-public class Fault extends AssertionFailedError {
-
- private static final long serialVersionUID = 1L;
-
- public Fault() {
- super();
- }
-
- public Fault(String message) {
- super(message);
- }
-
- public Fault(String message, Throwable cause) {
- super(message + cause);
- }
-
-}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/FileUTFConverter.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/FileUTFConverter.java
index fe03252..8d0497e 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/FileUTFConverter.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/FileUTFConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -49,22 +49,24 @@
package jakarta.jsonp.tck.util;
import java.io.*;
+import java.util.logging.Logger;
public class FileUTFConverter {
+ private static final Logger LOGGER = Logger.getLogger(FileUTFConverter.class.getName());
+
private static final String USAGE = "Usage : java FileUTFConverter [-toUTF|-fromUTF] encoding infile outfile";
public static void main(String args[]) {
try {
if (args.length != 4) {
- System.err.println(USAGE);
+ LOGGER.warning(USAGE);
System.exit(1);
}
// Convert UTF-8 input file to specified UTF encoded output file
if (args[0].equals("-toUTF")) {
- System.out
- .println("FileUTFConverter-> convert UTF-8 encoded input file ("
+ LOGGER.info("FileUTFConverter-> convert UTF-8 encoded input file ("
+ args[2] + "), to encoding (" + args[1]
+ ") and write to output file (" + args[3] + ")");
FileInputStream fis = new FileInputStream(args[2]);
@@ -81,7 +83,7 @@
br.close();
// Convert specified UTF encoded input file to UTF-8 encoded output file
} else if (args[0].equals("-fromUTF")) {
- System.out.println("FileUTFConverter-> convert UTF encoded input file ("
+ LOGGER.info("FileUTFConverter-> convert UTF encoded input file ("
+ args[2] + "), from encoding (" + args[1]
+ ") and write to UTF-8 encoded output file (" + args[3] + ")");
FileInputStream fis = new FileInputStream(args[2]);
@@ -97,7 +99,7 @@
bw.close();
br.close();
} else {
- System.err.println(USAGE);
+ LOGGER.warning(USAGE);
System.exit(1);
}
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/MyEncoder.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/MyEncoder.java
index 4ab6483..1d55f4c 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/MyEncoder.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/MyEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,6 +21,7 @@
package jakarta.jsonp.tck.util;
import java.io.*;
+import java.util.logging.Logger;
/*
* Used to generate an encoded file preceded by N null characters.
@@ -32,13 +33,15 @@
*/
public class MyEncoder {
+ private static final Logger LOGGER = Logger.getLogger(MyEncoder.class.getName());
+
private static final int NULL = '\0';
private static final String USAGE = "Usage : java MyEncoder #nulls infile outfile";
public static void main(String args[]) {
if (args.length != 3) {
- System.err.println(USAGE);
+ LOGGER.warning(USAGE);
System.exit(1);
}
@@ -50,12 +53,11 @@
inputStream = new FileReader(args[1]);
outputStream = new FileWriter(args[2]);
- System.out.println("Null chars: " + args[0]);
- System.out.println("Input file: " + args[1]);
- System.out.println("Output file: " + args[2]);
+ LOGGER.info("Null chars: " + args[0]);
+ LOGGER.info("Input file: " + args[1]);
+ LOGGER.info("Output file: " + args[2]);
- System.out
- .println("\nCreating an encoded file with each char preceded by " + n
+ LOGGER.info("\nCreating an encoded file with each char preceded by " + n
+ " null chars.\n");
int c;
diff --git a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/StringUTFConverter.java b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/StringUTFConverter.java
index cefd268..fb3475c 100644
--- a/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/StringUTFConverter.java
+++ b/tck/tck-common/src/main/java/jakarta/jsonp/tck/util/StringUTFConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -34,20 +34,23 @@
package jakarta.jsonp.tck.util;
import java.io.*;
+import java.util.logging.Logger;
public class StringUTFConverter {
+ private static final Logger LOGGER = Logger.getLogger(StringUTFConverter.class.getName());
+
private static final String USAGE = "Usage : java StringUTFConverter inputstring encoding outputfile";
public static void main(String args[]) {
try {
if (args.length != 3) {
- System.err.println(USAGE);
+ LOGGER.warning(USAGE);
System.exit(1);
}
// Convert string to specified UTF encoded output file
- System.out.println(
+ LOGGER.info(
"StringtoUTF-> convert string (" + args[0] + "), to encoding ("
+ args[1] + ") and write to output file (" + args[2] + ")");
FileOutputStream fos = new FileOutputStream(args[2]);
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/pluggability/jsonprovidertests/ClientTests.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/pluggability/jsonprovidertests/ClientTests.java
index 58310ed..b201a76 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/pluggability/jsonprovidertests/ClientTests.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/pluggability/jsonprovidertests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,44 +24,44 @@
import jakarta.json.stream.*;
import java.io.*;
-import java.nio.charset.Charset;
-import java.util.Properties;
import java.util.ServiceLoader;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
-import java.util.Map;
import java.util.HashMap;
+import java.util.logging.Logger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
import jakarta.jsonp.tck.provider.MyJsonProvider;
import jakarta.jsonp.tck.provider.MyJsonGenerator;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit5.ArquillianExtension;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+@ExtendWith(ArquillianExtension.class)
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
-
private static final String MY_JSONPROVIDER_CLASS = "jakarta.jsonp.tck.provider.MyJsonProvider";
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
private String providerPath = null;
+
+ @Deployment
+ public static WebArchive createTestArchive() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addPackages(true, ClientTests.class.getPackage().getName());
+ }
- @After
+ @AfterEach
public void after() {
MyJsonProvider.clearCalls();
MyJsonGenerator.clearCalls();
@@ -78,17 +78,17 @@
* static JsonProvider provider()
*/
@Test
- public void jsonProviderTest1() throws Fault {
+ public void jsonProviderTest1() {
boolean pass = true;
try {
// Load my provider
JsonProvider provider = JsonProvider.provider();
String providerClass = provider.getClass().getName();
- System.out.println("provider class=" + providerClass);
+ LOGGER.info("provider class=" + providerClass);
if (providerClass.equals(MY_JSONPROVIDER_CLASS))
- System.out.println("Current provider is my provider - expected.");
+ LOGGER.info("Current provider is my provider - expected.");
else {
- System.err.println("Current provider is not my provider - unexpected.");
+ LOGGER.warning("Current provider is not my provider - unexpected.");
pass = false;
ServiceLoader<JsonProvider> loader = ServiceLoader.load(JsonProvider.class);
Iterator<JsonProvider> it = loader.iterator();
@@ -96,13 +96,12 @@
while(it.hasNext()) {
providers.add(it.next());
}
- System.out.println("Providers: "+providers);
+ LOGGER.info("Providers: "+providers);
}
} catch (Exception e) {
- throw new Fault("jsonProviderTest1 Failed: ", e);
+ fail("jsonProviderTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest1 Failed");
+ assertTrue(pass, "jsonProviderTest1 Failed");
}
/*
@@ -114,25 +113,24 @@
* JsonGenerator createGenerator(Writer)
*/
@Test
- public void jsonProviderTest2() throws Fault {
+ public void jsonProviderTest2() {
boolean pass = true;
String expString = "public JsonGenerator createGenerator(Writer)";
String expString2 = "public JsonGenerator writeStartArray()";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonGenerator generator = Json.createGenerator(new StringWriter());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
pass = JSONP_Util.assertEquals(expString, actString);
generator.writeStartArray();
String actString2 = MyJsonGenerator.getCalls();
- System.out.println("Verify SPI generator method was called: " + expString2);
+ LOGGER.info("Verify SPI generator method was called: " + expString2);
pass = JSONP_Util.assertEquals(expString2, actString2);
} catch (Exception e) {
- throw new Fault("jsonProviderTest2 Failed: ", e);
+ fail("jsonProviderTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest2 Failed");
+ assertTrue(pass, "jsonProviderTest2 Failed");
}
/*
@@ -144,26 +142,25 @@
* JsonGenerator createGenerator(OutputStream)
*/
@Test
- public void jsonProviderTest3() throws Fault {
+ public void jsonProviderTest3() {
boolean pass = true;
String expString = "public JsonGenerator createGenerator(OutputStream)";
String expString2 = "public JsonGenerator writeStartObject()";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonGenerator generator = Json
.createGenerator(new ByteArrayOutputStream());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
pass = JSONP_Util.assertEquals(expString, actString);
generator.writeStartObject();
String actString2 = MyJsonGenerator.getCalls();
- System.out.println("Verify SPI generator method was called: " + expString2);
+ LOGGER.info("Verify SPI generator method was called: " + expString2);
pass = JSONP_Util.assertEquals(expString2, actString2);
} catch (Exception e) {
- throw new Fault("jsonProviderTest3 Failed: ", e);
+ fail("jsonProviderTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest3 Failed");
+ assertTrue(pass, "jsonProviderTest3 Failed");
}
/*
@@ -175,20 +172,17 @@
* JsonParser createParser(Reader)
*/
@Test
- public void jsonProviderTest4() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest4() {
String expString = "public JsonParser createParser(Reader)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonParser parser = Json.createParser(new StringReader("{}"));
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest4 Failed: ", e);
+ fail("jsonProviderTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest4 Failed");
}
/*
@@ -200,21 +194,18 @@
* JsonParser createParser(InputStream)
*/
@Test
- public void jsonProviderTest5() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest5() {
String expString = "public JsonParser createParser(InputStream)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonParser parser = Json
.createParser(JSONP_Util.getInputStreamFromString("{}"));
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest5 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest5 Failed: ", e);
+ fail("jsonProviderTest5 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest5 Failed");
}
/*
@@ -226,21 +217,18 @@
* JsonParserFactory createParserFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest6() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest6() {
String expString = "public JsonParserFactory createParserFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest5 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest6 Failed: ", e);
+ fail("jsonProviderTest6 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest6 Failed");
}
/*
@@ -252,21 +240,18 @@
* JsonParserFactory createParserFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest7() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest7() {
String expString = "public JsonParserFactory createParserFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonParserFactory parserFactory = Json
.createParserFactory(new HashMap<String, Object>());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest7 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest7 Failed: ", e);
+ fail("jsonProviderTest7 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest7 Failed");
}
/*
@@ -278,21 +263,18 @@
* JsonGeneratorFactory createGeneratorFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest8() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest8() {
String expString = "public JsonGeneratorFactory createGeneratorFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonGeneratorFactory generatorFactory = Json
.createGeneratorFactory(new HashMap<String, Object>());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest8 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest8 Failed: ", e);
+ fail("jsonProviderTest8 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest8 Failed");
}
/*
@@ -304,21 +286,18 @@
* JsonWriterFactory createWriterFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest9() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest9() {
String expString = "public JsonWriterFactory createWriterFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonWriterFactory factory = Json
.createWriterFactory(JSONP_Util.getEmptyConfig());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest9 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest9 Failed: ", e);
+ fail("jsonProviderTest9 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest9 Failed");
}
/*
@@ -332,21 +311,18 @@
* JsonException.
*/
@Test
- public void jsonProviderTest10() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest10() {
String expString = "public JsonParser createParser(InputStream)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
InputStream in = null;
JsonParser parser = Json.createParser(in);
- pass = false;
+ fail("jsonProviderTest10 Failed");
} catch (JsonException e) {
- System.out.println("Caught expected JsonException: " + e);
+ LOGGER.info("Caught expected JsonException: " + e);
} catch (Exception e) {
- throw new Fault("jsonProviderTest10 Failed: ", e);
+ fail("jsonProviderTest10 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest10 Failed");
}
/*
@@ -358,20 +334,17 @@
* JsonArrayBuilder createArrayBuilder()
*/
@Test
- public void jsonProviderTest11() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest11() {
String expString = "public JsonArrayBuilder createArrayBuilder()";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest11 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest11 Failed: ", e);
+ fail("jsonProviderTest11 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest11 Failed");
}
/*
@@ -383,20 +356,17 @@
* JsonObjectBuilder createObjectBuilder()
*/
@Test
- public void jsonProviderTest12() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest12() {
String expString = "public JsonObjectBuilder createObjectBuilder()";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest12 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest12 Failed: ", e);
+ fail("jsonProviderTest12 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest12 Failed");
}
/*
@@ -408,21 +378,18 @@
* JsonBuilderFactory createBuilderFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest13() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest13() {
String expString = "public JsonBuilderFactory createBuilderFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonBuilderFactory objectBuilder = Json
.createBuilderFactory(JSONP_Util.getEmptyConfig());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest13 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest13 Failed: ", e);
+ fail("jsonProviderTest13 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest13 Failed");
}
/*
@@ -434,20 +401,17 @@
* JsonReader createReader(Reader)
*/
@Test
- public void jsonProviderTest14() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest14() {
String expString = "public JsonReader createReader(Reader)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonReader reader = Json.createReader(new StringReader("{}"));
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest14 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest14 Failed: ", e);
+ fail("jsonProviderTest14 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest14 Failed");
}
/*
@@ -459,21 +423,18 @@
* JsonReader createReader(InputStream)
*/
@Test
- public void jsonProviderTest15() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest15() {
String expString = "public JsonReader createReader(InputStream)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonReader reader = Json
.createReader(JSONP_Util.getInputStreamFromString("{}"));
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest15 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest15 Failed: ", e);
+ fail("jsonProviderTest15 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest15 Failed");
}
/*
@@ -485,20 +446,17 @@
* JsonWriter createWriter(Writer)
*/
@Test
- public void jsonProviderTest16() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest16() {
String expString = "public JsonWriter createWriter(Writer)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonWriter writer = Json.createWriter(new StringWriter());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest16 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest16 Failed: ", e);
+ fail("jsonProviderTest16 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest16 Failed");
}
/*
@@ -510,20 +468,17 @@
* JsonWriter createWriter(OutputStream)
*/
@Test
- public void jsonProviderTest17() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest17() {
String expString = "public JsonWriter createWriter(OutputStream)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonWriter writer = Json.createWriter(new ByteArrayOutputStream());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest17 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest17 Failed: ", e);
+ fail("jsonProviderTest17 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest17 Failed");
}
/*
@@ -535,20 +490,17 @@
* JsonReaderFactory createReaderFactory(Map<String, ?>)
*/
@Test
- public void jsonProviderTest18() throws Fault {
- boolean pass = true;
+ public void jsonProviderTest18() {
String expString = "public JsonReaderFactory createReaderFactory(Map<String, ?>)";
try {
- System.out.println("Calling SPI provider method: " + expString);
+ LOGGER.info("Calling SPI provider method: " + expString);
JsonReaderFactory factory = Json
.createReaderFactory(JSONP_Util.getEmptyConfig());
String actString = MyJsonProvider.getCalls();
- System.out.println("Verify SPI provider method was called: " + expString);
- pass = JSONP_Util.assertEquals(expString, actString);
+ LOGGER.info("Verify SPI provider method was called: " + expString);
+ assertTrue(JSONP_Util.assertEquals(expString, actString), "jsonProviderTest18 Failed");
} catch (Exception e) {
- throw new Fault("jsonProviderTest18 Failed: ", e);
+ fail("jsonProviderTest18 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonProviderTest18 Failed");
}
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGenerator.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGenerator.java
index 9340070..aebe497 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGenerator.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.Charset;
+import java.util.logging.Logger;
+
import jakarta.json.*;
import jakarta.json.stream.*;
@@ -34,6 +36,9 @@
*/
public class MyJsonGenerator implements JsonGenerator {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonGenerator.class.getName());
+
private Writer writer = null;
private OutputStream out = null;
@@ -41,9 +46,9 @@
private final Charset charset = Charset.forName("UTF-8");
private void dumpInstanceVars() {
- System.out.println("writer=" + writer);
- System.out.println("out=" + out);
- System.out.println("charset=" + charset);
+ LOGGER.info("writer=" + writer);
+ LOGGER.info("out=" + out);
+ LOGGER.info("charset=" + charset);
}
// call methods
@@ -71,181 +76,181 @@
@Override
public void flush() {
- System.out.println("public void flush()");
+ LOGGER.info("public void flush()");
addCalls("public void flush()");
}
@Override
public JsonGenerator writeStartObject() {
- System.out.println("public JsonGenerator writeStartObject()");
+ LOGGER.info("public JsonGenerator writeStartObject()");
addCalls("public JsonGenerator writeStartObject()");
return null;
}
@Override
public JsonGenerator writeStartObject(String name) {
- System.out.println("public JsonGenerator writeStartObject(String)");
+ LOGGER.info("public JsonGenerator writeStartObject(String)");
addCalls("public JsonGenerator writeStartObject(String)");
return null;
}
@Override
public JsonGenerator write(String name, String value) {
- System.out.println("public JsonGenerator write(String,String)");
+ LOGGER.info("public JsonGenerator write(String,String)");
addCalls("public JsonGenerator write(String,String)");
return null;
}
@Override
public JsonGenerator write(String name, int value) {
- System.out.println("public JsonGenerator write(String,int)");
+ LOGGER.info("public JsonGenerator write(String,int)");
addCalls("public JsonGenerator write(String,int)");
return null;
}
@Override
public JsonGenerator write(String name, long value) {
- System.out.println("public JsonGenerator write(String,long)");
+ LOGGER.info("public JsonGenerator write(String,long)");
addCalls("public JsonGenerator write(String,long)");
return null;
}
@Override
public JsonGenerator write(String name, double value) {
- System.out.println("public JsonGenerator write(String,double)");
+ LOGGER.info("public JsonGenerator write(String,double)");
addCalls("public JsonGenerator write(String,double)");
return null;
}
@Override
public JsonGenerator write(String name, BigInteger value) {
- System.out.println("public JsonGenerator write(String,BigInteger)");
+ LOGGER.info("public JsonGenerator write(String,BigInteger)");
addCalls("public JsonGenerator write(String,BigInteger)");
return null;
}
@Override
public JsonGenerator write(String name, BigDecimal value) {
- System.out.println("public JsonGenerator write(String,BigDecimal)");
+ LOGGER.info("public JsonGenerator write(String,BigDecimal)");
addCalls("public JsonGenerator write(String,BigDecimal)");
return null;
}
@Override
public JsonGenerator write(String name, boolean value) {
- System.out.println("public JsonGenerator write(String,boolean)");
+ LOGGER.info("public JsonGenerator write(String,boolean)");
addCalls("public JsonGenerator write(String,boolean)");
return null;
}
@Override
public JsonGenerator write(String name, JsonValue value) {
- System.out.println("public JsonGenerator write(String,JsonValue)");
+ LOGGER.info("public JsonGenerator write(String,JsonValue)");
addCalls("public JsonGenerator write(String,JsonValue)");
return null;
}
@Override
public JsonGenerator writeNull(String name) {
- System.out.println("public JsonGenerator writeNull(String)");
+ LOGGER.info("public JsonGenerator writeNull(String)");
addCalls("public JsonGenerator writeNull(String)");
return null;
}
@Override
public JsonGenerator writeStartArray() {
- System.out.println("public JsonGenerator writeStartArray()");
+ LOGGER.info("public JsonGenerator writeStartArray()");
addCalls("public JsonGenerator writeStartArray()");
return null;
}
@Override
public JsonGenerator writeStartArray(String name) {
- System.out.println("public JsonGenerator writeStartArray(String)");
+ LOGGER.info("public JsonGenerator writeStartArray(String)");
addCalls("public JsonGenerator writeStartArray(String)");
return null;
}
@Override
public JsonGenerator write(String value) {
- System.out.println("public JsonGenerator write(String)");
+ LOGGER.info("public JsonGenerator write(String)");
addCalls("public JsonGenerator write(String)");
return null;
}
@Override
public JsonGenerator write(int value) {
- System.out.println("public JsonGenerator write(int)");
+ LOGGER.info("public JsonGenerator write(int)");
addCalls("public JsonGenerator write(int)");
return null;
}
@Override
public JsonGenerator write(long value) {
- System.out.println("public JsonGenerator write(long)");
+ LOGGER.info("public JsonGenerator write(long)");
addCalls("public JsonGenerator write(long)");
return null;
}
@Override
public JsonGenerator write(double value) {
- System.out.println("public JsonGenerator write(double)");
+ LOGGER.info("public JsonGenerator write(double)");
addCalls("public JsonGenerator write(double)");
return null;
}
@Override
public JsonGenerator write(BigInteger value) {
- System.out.println("public JsonGenerator write(BigInteger)");
+ LOGGER.info("public JsonGenerator write(BigInteger)");
addCalls("public JsonGenerator write(BigInteger)");
return null;
}
@Override
public JsonGenerator write(BigDecimal value) {
- System.out.println("public JsonGenerator write(BigDecimal)");
+ LOGGER.info("public JsonGenerator write(BigDecimal)");
addCalls("public JsonGenerator write(BigDecimal)");
return null;
}
@Override
public JsonGenerator write(boolean value) {
- System.out.println("public JsonGenerator write(boolean)");
+ LOGGER.info("public JsonGenerator write(boolean)");
addCalls("public JsonGenerator write(boolean)");
return null;
}
@Override
public JsonGenerator write(JsonValue value) {
- System.out.println("public JsonGenerator write(JsonValue)");
+ LOGGER.info("public JsonGenerator write(JsonValue)");
addCalls("public JsonGenerator write(JsonValue)");
return null;
}
@Override
public JsonGenerator writeNull() {
- System.out.println("public JsonGenerator writeNull()");
+ LOGGER.info("public JsonGenerator writeNull()");
addCalls("public JsonGenerator writeNull()");
return null;
}
@Override
public JsonGenerator writeEnd() {
- System.out.println("public JsonGenerator writeEnd()");
+ LOGGER.info("public JsonGenerator writeEnd()");
addCalls("public JsonGenerator writeEnd()");
return null;
}
@Override
public JsonGenerator writeKey(String name) {
- System.out.println("public JsonGenerator writeKey()");
+ LOGGER.info("public JsonGenerator writeKey()");
addCalls("public JsonGenerator writeKey()");
return null;
}
@Override
public void close() {
- System.out.println("public void close()");
+ LOGGER.info("public void close()");
addCalls("public void close()");
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGeneratorFactory.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGeneratorFactory.java
index d5ae3dd..d3e1365 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGeneratorFactory.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonGeneratorFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,11 +20,11 @@
package jakarta.jsonp.tck.provider;
-import jakarta.json.*;
import jakarta.json.stream.*;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonGeneratorFactory is a Json Test GeneratorFactory used by the pluggability tests
@@ -33,6 +33,9 @@
*/
public class MyJsonGeneratorFactory implements JsonGeneratorFactory {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonGeneratorFactory.class.getName());
+
private OutputStream out = null;
private Writer writer = null;
@@ -42,10 +45,10 @@
private Map<String, ?> config = null;
private void dumpInstanceVars() {
- System.out.println("writer=" + writer);
- System.out.println("out=" + out);
- System.out.println("charset=" + charset);
- System.out.println("config=" + config);
+ LOGGER.info("writer=" + writer);
+ LOGGER.info("out=" + out);
+ LOGGER.info("charset=" + charset);
+ LOGGER.info("config=" + config);
}
// call methods
@@ -68,20 +71,20 @@
}
public Map<String, ?> getConfigInUse() {
- System.out.println("public Map<String, ?> getConfigInUse()");
+ LOGGER.info("public Map<String, ?> getConfigInUse()");
addCalls("public Map<String, ?> getConfigInUse()");
return config;
}
public JsonGenerator createGenerator(OutputStream out) {
- System.out.println("public JsonGenerator createGenerator(OutputStream)");
+ LOGGER.info("public JsonGenerator createGenerator(OutputStream)");
addCalls("public JsonGenerator createGenerator(OutputStream)");
this.out = out;
return null;
}
public JsonGenerator createGenerator(OutputStream out, Charset charset) {
- System.out.println(
+ LOGGER.info(
"public JsonGenerator createGenerator(OutputStream, Charset)");
addCalls("public JsonGenerator createGenerator(OutputStream, Charset)");
this.out = out;
@@ -90,7 +93,7 @@
}
public JsonGenerator createGenerator(Writer writer) {
- System.out.println("public JsonGenerator createGenerator(Writer)");
+ LOGGER.info("public JsonGenerator createGenerator(Writer)");
addCalls("public JsonGenerator createGenerator(Writer)");
this.writer = writer;
return null;
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParser.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParser.java
index 5df3fc5..c75800a 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParser.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,14 +21,10 @@
package jakarta.jsonp.tck.provider;
-import jakarta.json.*;
import jakarta.json.stream.*;
-import jakarta.json.spi.JsonProvider;
import java.io.*;
import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.Charset;
-import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonParser is a Json Test Parser used by the pluggability tests
@@ -37,13 +33,16 @@
*/
public class MyJsonParser implements JsonParser {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonParser.class.getName());
+
private InputStream in = null;
private Reader reader = null;
private void dumpInstanceVars() {
- System.out.println("reader=" + reader);
- System.out.println("in=" + in);
+ LOGGER.info("reader=" + reader);
+ LOGGER.info("in=" + in);
}
// call methods
@@ -70,54 +69,54 @@
}
public void close() {
- System.out.println("public void close()");
+ LOGGER.info("public void close()");
addCalls("public void close()");
}
public BigDecimal getBigDecimal() {
- System.out.println("public BigDecimal getBigDecimal()");
+ LOGGER.info("public BigDecimal getBigDecimal()");
addCalls("public BigDecimal getBigDecimal()");
return null;
}
public int getInt() {
- System.out.println("public int getInt()");
+ LOGGER.info("public int getInt()");
addCalls("public int getInt()");
return -1;
}
public JsonLocation getLocation() {
- System.out.println("public JsonLocation getLocation()");
+ LOGGER.info("public JsonLocation getLocation()");
addCalls("public JsonLocation getLocation()");
return null;
}
public long getLong() {
- System.out.println("public long getLong()");
+ LOGGER.info("public long getLong()");
addCalls("public long getLong()");
return -1;
}
public boolean isIntegralNumber() {
- System.out.println("public boolean isIntegralNumber()");
+ LOGGER.info("public boolean isIntegralNumber()");
addCalls("public boolean isIntegralNumber()");
return false;
}
public String getString() {
- System.out.println("public String getString()");
+ LOGGER.info("public String getString()");
addCalls("public String getString()");
return null;
}
public boolean hasNext() {
- System.out.println("public boolean hasNext()");
+ LOGGER.info("public boolean hasNext()");
addCalls("public boolean hasNext()");
return false;
}
public JsonParser.Event next() {
- System.out.println("public JsonParser.Event next()");
+ LOGGER.info("public JsonParser.Event next()");
addCalls("public JsonParser.Event next()");
return null;
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParserFactory.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParserFactory.java
index 0d06523..c83f24a 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParserFactory.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonParserFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -25,6 +25,7 @@
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonParserFactory is a Json Test ParserFactory used by the pluggability tests
@@ -33,6 +34,9 @@
*/
public class MyJsonParserFactory implements JsonParserFactory {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonParserFactory.class.getName());
+
private InputStream in = null;
private Charset charset = null;
@@ -42,10 +46,10 @@
private Map<String, ?> config = null;
private void dumpInstanceVars() {
- System.out.println("reader=" + reader);
- System.out.println("in=" + in);
- System.out.println("charset=" + charset);
- System.out.println("config=" + config);
+ LOGGER.info("reader=" + reader);
+ LOGGER.info("in=" + in);
+ LOGGER.info("charset=" + charset);
+ LOGGER.info("config=" + config);
}
// call methods
@@ -68,20 +72,20 @@
}
public Map<String, ?> getConfigInUse() {
- System.out.println("public Map<String, ?> getConfigInUse()");
+ LOGGER.info("public Map<String, ?> getConfigInUse()");
addCalls("public Map<String, ?> getConfigInUse()");
return config;
}
public JsonParser createParser(InputStream in) {
- System.out.println("public JsonParser createParser(InputStream)");
+ LOGGER.info("public JsonParser createParser(InputStream)");
addCalls("public JsonParser createParser(InputStream)");
this.in = in;
return null;
}
public JsonParser createParser(InputStream in, Charset charset) {
- System.out.println("public JsonParser createParser(InputStream, Charset)");
+ LOGGER.info("public JsonParser createParser(InputStream, Charset)");
addCalls("public JsonParser createParser(InputStream, Charset)");
this.in = in;
this.charset = charset;
@@ -89,20 +93,20 @@
}
public JsonParser createParser(Reader reader) {
- System.out.println("public JsonParser createParser(Reader)");
+ LOGGER.info("public JsonParser createParser(Reader)");
addCalls("public JsonParser createParser(Reader)");
this.reader = reader;
return null;
}
public JsonParser createParser(JsonArray jsonArray) {
- System.out.println("public JsonParser createParser(JsonArray)");
+ LOGGER.info("public JsonParser createParser(JsonArray)");
addCalls("public JsonParser createParser(JsonArray)");
return null;
}
public JsonParser createParser(JsonObject jsonObject) {
- System.out.println("public JsonParser createParser(JsonObject)");
+ LOGGER.info("public JsonParser createParser(JsonObject)");
addCalls("public JsonParser createParser(JsonObject)");
return null;
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonProvider.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonProvider.java
index c7d1680..9752652 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonProvider.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,6 +18,8 @@
import java.io.*;
import java.util.*;
+import java.util.logging.Logger;
+
import jakarta.json.*;
import jakarta.json.spi.JsonProvider;
import jakarta.json.stream.*;
@@ -30,6 +32,8 @@
*/
public class MyJsonProvider extends JsonProvider {
+ private static final Logger LOGGER = Logger.getLogger(MyJsonProvider.class.getName());
+
// Exception thrown when encoding or i/o error
private final JsonException exception = new JsonException(
"encoding or i/o error");
@@ -51,14 +55,14 @@
@Override
public JsonArrayBuilder createArrayBuilder() {
- System.out.println("public JsonArrayBuilder createArrayBuilder()");
+ LOGGER.info("public JsonArrayBuilder createArrayBuilder()");
addCalls("public JsonArrayBuilder createArrayBuilder()");
return null;
}
@Override
public JsonBuilderFactory createBuilderFactory(Map<String, ?> config) {
- System.out.println(
+ LOGGER.info(
"public JsonBuilderFactory createBuilderFactory(Map<String, ?>)");
addCalls("public JsonBuilderFactory createBuilderFactory(Map<String, ?>)");
return null;
@@ -66,28 +70,28 @@
@Override
public JsonObjectBuilder createObjectBuilder() {
- System.out.println("public JsonObjectBuilder createObjectBuilder()");
+ LOGGER.info("public JsonObjectBuilder createObjectBuilder()");
addCalls("public JsonObjectBuilder createObjectBuilder()");
return null;
}
@Override
public JsonReader createReader(Reader reader) {
- System.out.println("public JsonReader createReader(Reader)");
+ LOGGER.info("public JsonReader createReader(Reader)");
addCalls("public JsonReader createReader(Reader)");
return new MyJsonReader(reader);
}
@Override
public JsonReader createReader(InputStream in) {
- System.out.println("public JsonReader createReader(InputStream)");
+ LOGGER.info("public JsonReader createReader(InputStream)");
addCalls("public JsonReader createReader(InputStream)");
return new MyJsonReader(in);
}
@Override
public JsonReaderFactory createReaderFactory(Map<String, ?> config) {
- System.out.println(
+ LOGGER.info(
"public JsonReaderFactory createReaderFactory(Map<String, ?>)");
addCalls("public JsonReaderFactory createReaderFactory(Map<String, ?>)");
return null;
@@ -95,21 +99,21 @@
@Override
public JsonWriter createWriter(Writer writer) {
- System.out.println("public JsonWriter createWriter(Writer)");
+ LOGGER.info("public JsonWriter createWriter(Writer)");
addCalls("public JsonWriter createWriter(Writer)");
return new MyJsonWriter(writer);
}
@Override
public JsonWriter createWriter(OutputStream out) {
- System.out.println("public JsonWriter createWriter(OutputStream)");
+ LOGGER.info("public JsonWriter createWriter(OutputStream)");
addCalls("public JsonWriter createWriter(OutputStream)");
return new MyJsonWriter(out);
}
@Override
public JsonWriterFactory createWriterFactory(Map<String, ?> config) {
- System.out.println(
+ LOGGER.info(
"public JsonWriterFactory createWriterFactory(Map<String, ?>)");
addCalls("public JsonWriterFactory createWriterFactory(Map<String, ?>)");
return null;
@@ -117,28 +121,28 @@
@Override
public JsonGenerator createGenerator(Writer writer) {
- System.out.println("public JsonGenerator createGenerator(Writer)");
+ LOGGER.info("public JsonGenerator createGenerator(Writer)");
addCalls("public JsonGenerator createGenerator(Writer)");
return new MyJsonGenerator(writer);
}
@Override
public JsonGenerator createGenerator(OutputStream out) {
- System.out.println("public JsonGenerator createGenerator(OutputStream)");
+ LOGGER.info("public JsonGenerator createGenerator(OutputStream)");
addCalls("public JsonGenerator createGenerator(OutputStream)");
return new MyJsonGenerator(out);
}
@Override
public JsonParser createParser(Reader reader) {
- System.out.println("public JsonParser createParser(Reader)");
+ LOGGER.info("public JsonParser createParser(Reader)");
addCalls("public JsonParser createParser(Reader)");
return new MyJsonParser(reader);
}
@Override
public JsonParser createParser(InputStream in) {
- System.out.println("public JsonParser createParser(InputStream)");
+ LOGGER.info("public JsonParser createParser(InputStream)");
addCalls("public JsonParser createParser(InputStream)");
if (in == null)
throw exception;
@@ -148,7 +152,7 @@
@Override
public JsonParserFactory createParserFactory(Map<String, ?> config) {
- System.out.println(
+ LOGGER.info(
"public JsonParserFactory createParserFactory(Map<String, ?>)");
addCalls("public JsonParserFactory createParserFactory(Map<String, ?>)");
return null;
@@ -156,7 +160,7 @@
@Override
public JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config) {
- System.out.println(
+ LOGGER.info(
"public JsonGeneratorFactory createGeneratorFactory(Map<String, ?>)");
addCalls(
"public JsonGeneratorFactory createGeneratorFactory(Map<String, ?>)");
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReader.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReader.java
index a74c203..52c31b1 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReader.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -26,6 +26,7 @@
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonReader is a Json Test Reader used by the pluggability tests
@@ -34,13 +35,16 @@
*/
public class MyJsonReader implements JsonReader {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonReader.class.getName());
+
private InputStream in = null;
private Reader reader = null;
private void dumpInstanceVars() {
- System.out.println("reader=" + reader);
- System.out.println("in=" + in);
+ LOGGER.info("reader=" + reader);
+ LOGGER.info("in=" + in);
}
// call methods
@@ -70,24 +74,24 @@
}
public void close() {
- System.out.println("public void close()");
+ LOGGER.info("public void close()");
addCalls("public void close()");
}
public JsonStructure read() {
- System.out.println("public void read()");
+ LOGGER.info("public void read()");
addCalls("public void read()");
return null;
}
public JsonArray readArray() {
- System.out.println("public void readArray()");
+ LOGGER.info("public void readArray()");
addCalls("public void readArray()");
return null;
}
public JsonObject readObject() {
- System.out.println("public void readObject()");
+ LOGGER.info("public void readObject()");
addCalls("public void readObject()");
return null;
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReaderFactory.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReaderFactory.java
index d58b9a2..e1eefa6 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReaderFactory.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonReaderFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,7 @@
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonReaderFactory is a Json Test ReaderFactory used by the pluggability tests
@@ -31,6 +32,9 @@
* methods are invoked within the parser when Json API methods are called.
*/
public class MyJsonReaderFactory implements JsonReaderFactory {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonReaderFactory.class.getName());
+
private InputStream in = null;
private Charset charset = null;
@@ -40,10 +44,10 @@
private Map<String, ?> config = null;
private void dumpInstanceVars() {
- System.out.println("reader=" + reader);
- System.out.println("in=" + in);
- System.out.println("charset=" + charset);
- System.out.println("config=" + config);
+ LOGGER.info("reader=" + reader);
+ LOGGER.info("in=" + in);
+ LOGGER.info("charset=" + charset);
+ LOGGER.info("config=" + config);
}
// call methods
@@ -66,20 +70,20 @@
}
public Map<String, ?> getConfigInUse() {
- System.out.println("public Map<String, ?> getConfigInUse()");
+ LOGGER.info("public Map<String, ?> getConfigInUse()");
addCalls("public Map<String, ?> getConfigInUse()");
return config;
}
public JsonReader createReader(InputStream in) {
- System.out.println("public JsonReader createReader(InputStream)");
+ LOGGER.info("public JsonReader createReader(InputStream)");
addCalls("public JsonReader createReader(InputStream)");
this.in = in;
return null;
}
public JsonReader createReader(InputStream in, Charset charset) {
- System.out.println("public JsonReader createReader(InputStream, Charset)");
+ LOGGER.info("public JsonReader createReader(InputStream, Charset)");
addCalls("public JsonReader createReader(InputStream, Charset)");
this.in = in;
this.charset = charset;
@@ -87,7 +91,7 @@
}
public JsonReader createReader(Reader reader) {
- System.out.println("public JsonReader createReader(Reader)");
+ LOGGER.info("public JsonReader createReader(Reader)");
addCalls("public JsonReader createReader(Reader)");
this.reader = reader;
return null;
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriter.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriter.java
index a3321f0..d7d1206 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriter.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,11 +21,9 @@
package jakarta.jsonp.tck.provider;
import jakarta.json.*;
-import jakarta.json.stream.*;
-import jakarta.json.spi.JsonProvider;
import java.io.*;
import java.nio.charset.Charset;
-import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonWriter is a Json Test Writer used by the pluggability tests
@@ -33,6 +31,9 @@
* methods are invoked within the parser when Json API methods are called.
*/
public class MyJsonWriter implements JsonWriter {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonWriter.class.getName());
+
private OutputStream out = null;
private Writer writer = null;
@@ -40,9 +41,9 @@
private Charset charset = Charset.forName("UTF-8");
private void dumpInstanceVars() {
- System.out.println("writer=" + writer);
- System.out.println("out=" + out);
- System.out.println("charset=" + charset);
+ LOGGER.info("writer=" + writer);
+ LOGGER.info("out=" + out);
+ LOGGER.info("charset=" + charset);
}
// call methods
@@ -72,22 +73,22 @@
}
public void close() {
- System.out.println("public void close()");
+ LOGGER.info("public void close()");
addCalls("public void close()");
}
public void write(JsonStructure value) {
- System.out.println("public void write(JsonStructure)");
+ LOGGER.info("public void write(JsonStructure)");
addCalls("public void write(JsonStructure)");
}
public void writeArray(JsonArray array) {
- System.out.println("public void writeArray(JsonArray)");
+ LOGGER.info("public void writeArray(JsonArray)");
addCalls("public void writeArray(JsonArray)");
}
public void writeObject(JsonObject object) {
- System.out.println("public void writeObject(JsonObject)");
+ LOGGER.info("public void writeObject(JsonObject)");
addCalls("public void writeObject(JsonObject)");
}
}
diff --git a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriterFactory.java b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriterFactory.java
index f15cfbd..7d8409e 100644
--- a/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriterFactory.java
+++ b/tck/tck-tests-plugability/src/main/java/jakarta/jsonp/tck/provider/MyJsonWriterFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -25,6 +25,7 @@
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.logging.Logger;
/*
* MyJsonWriterFactory is a Json Test WriterFactory used by the pluggability tests
@@ -32,6 +33,9 @@
* methods are invoked within the parser when Json API methods are called.
*/
public class MyJsonWriterFactory implements JsonWriterFactory {
+
+ private static final Logger LOGGER = Logger.getLogger(MyJsonWriterFactory.class.getName());
+
private OutputStream out = null;
private Writer writer = null;
@@ -41,10 +45,10 @@
private Map<String, ?> config = null;
private void dumpInstanceVars() {
- System.out.println("writer=" + writer);
- System.out.println("out=" + out);
- System.out.println("charset=" + charset);
- System.out.println("config=" + config);
+ LOGGER.info("writer=" + writer);
+ LOGGER.info("out=" + out);
+ LOGGER.info("charset=" + charset);
+ LOGGER.info("config=" + config);
}
// call methods
@@ -67,20 +71,20 @@
}
public Map<String, ?> getConfigInUse() {
- System.out.println("public Map<String, ?> getConfigInUse()");
+ LOGGER.info("public Map<String, ?> getConfigInUse()");
addCalls("public Map<String, ?> getConfigInUse()");
return config;
}
public JsonWriter createWriter(OutputStream out) {
- System.out.println("public JsonWriter createWriter(OutputStream)");
+ LOGGER.info("public JsonWriter createWriter(OutputStream)");
addCalls("public JsonWriter createWriter(OutputStream)");
this.out = out;
return null;
}
public JsonWriter createWriter(OutputStream out, Charset charset) {
- System.out.println("public JsonWriter createWriter(OutputStream, Charset)");
+ LOGGER.info("public JsonWriter createWriter(OutputStream, Charset)");
addCalls("public JsonWriter createWriter(OutputStream, Charset)");
this.out = out;
this.charset = charset;
@@ -88,7 +92,7 @@
}
public JsonWriter createWriter(Writer writer) {
- System.out.println("public JsonWriter createWriter(Writer)");
+ LOGGER.info("public JsonWriter createWriter(Writer)");
addCalls("public JsonWriter createWriter(Writer)");
this.writer = writer;
return null;
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/CollectorTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/CollectorTests.java
index a15bc5e..08d73e4 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/CollectorTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/CollectorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,33 +17,20 @@
package jakarta.jsonp.tck.api.collectortests;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.jsonp.tck.lib.harness.Fault;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
// $Id$
/**
* JavaScript Object Notation (JSON) Pointer compatibility tests.<br>
* Test {@link jakarta.json.stream.JsonCollectors} class implementation.
*/
-@RunWith(Arquillian.class)
public class CollectorTests {
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, CollectorTests.class.getPackage().getName());
- }
/**
* Test JSON-P {@link jakarta.json.stream.JsonCollectors} class implementation.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonCollectorTest
@@ -52,7 +39,7 @@
* @test_Strategy: Test all collectors returned by API.
*/
@Test
- public void jsonCollectorTest() throws Fault {
+ public void jsonCollectorTest() {
Collectors collectorTest = new Collectors();
final TestResult result = collectorTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/Collectors.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/Collectors.java
index bffc445..e0993fd 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/Collectors.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/collectortests/Collectors.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,7 @@
import java.util.Map;
import java.util.TreeSet;
import java.util.function.Function;
+import java.util.logging.Logger;
import java.util.stream.Collector;
import jakarta.json.Json;
import jakarta.json.JsonArray;
@@ -45,6 +46,8 @@
*/
public class Collectors {
+ private static final Logger LOGGER = Logger.getLogger(Collectors.class.getName());
+
/** Tests input data with JsonArray instances. */
private static final JsonArray[] ARRAY_VALUES = new JsonArray[] {
createSimpleStringArray5(), // JsonArray with String
@@ -92,7 +95,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonCollectors class implementation");
- System.out.println("JsonCollectors class implementation");
+ LOGGER.info("JsonCollectors class implementation");
testToJsonArrayCollector(result);
// testSimpleToJsonObjectCollector(result);
testToJsonObjectCollector(result);
@@ -111,9 +114,9 @@
* Tests result record.
*/
private void testToJsonArrayCollector(final TestResult result) {
- System.out.println(" - Collector returned by toJsonArray()");
+ LOGGER.info(" - Collector returned by toJsonArray()");
for (final JsonArray in : ARRAY_VALUES) {
- System.out.println(" - Input: " + valueToString(in));
+ LOGGER.info(" - Input: " + valueToString(in));
final Collector<JsonValue, JsonArrayBuilder, JsonArray> col = JsonCollectors
.toJsonArray();
final JsonArray out = in.getValuesAs(JsonObject.class).stream()
@@ -137,9 +140,9 @@
// * @param result Tests result record.
// */
// private void testSimpleToJsonObjectCollector(final TestResult result) {
- // System.out.println(" - Collector returned by toJsonObject()");
+ // LOGGER.info(" - Collector returned by toJsonObject()");
// for (final JsonObject in : OBJ_VALUES) {
- // System.out.println(" - Input: " + valueToString(in));
+ // LOGGER.info(" - Input: " + valueToString(in));
// final Collector<Map.Entry<String,JsonValue>, JsonObjectBuilder, JsonObject>
// col = JsonCollectors.toJsonObject();
// final JsonObject out = (in.entrySet()).stream().collect(col);
@@ -166,7 +169,7 @@
* Tests result record.
*/
private void testToJsonObjectCollector(final TestResult result) {
- System.out.println(" - Collector returned by toJsonObject(Function,Function)");
+ LOGGER.info(" - Collector returned by toJsonObject(Function,Function)");
final JsonArray in = Json.createArrayBuilder()
.add(Json.createObjectBuilder().add("key", STR_NAME).add("value",
STR_VALUE))
@@ -180,7 +183,7 @@
final JsonObject check = Json.createObjectBuilder().add(STR_NAME, STR_VALUE)
.add(INT_NAME, INT_VALUE).add(BOOL_NAME, BOOL_VALUE)
.add(OBJ_NAME, OBJ_VALUE).build();
- System.out.println(" Input: " + valueToString(in));
+ LOGGER.info(" Input: " + valueToString(in));
final Collector<JsonValue, JsonObjectBuilder, JsonObject> col = JsonCollectors
.toJsonObject(
// Build key from stream value.
@@ -215,7 +218,7 @@
* Tests result record.
*/
private void testSimpleGroupingByCollector(final TestResult result) {
- System.out.println(" - Collector returned by groupingBy(Function)");
+ LOGGER.info(" - Collector returned by groupingBy(Function)");
final JsonObject check = Json.createObjectBuilder().add("Red", Json
.createArrayBuilder()
.add(
@@ -242,7 +245,7 @@
.add("office", "Green"))
.build())
.build();
- System.out.println(" Input: " + valueToString(OBJ_ARRAY_GROUP));
+ LOGGER.info(" Input: " + valueToString(OBJ_ARRAY_GROUP));
final Collector<JsonValue, Map<String, JsonArrayBuilder>, JsonObject> col = JsonCollectors
.groupingBy((JsonValue v) -> {
if (v.getValueType() == JsonValue.ValueType.OBJECT)
@@ -453,7 +456,7 @@
* Tests result record.
*/
private void testSortingGroupingByCollector(final TestResult result) {
- System.out.println(" - Collector returned by groupingBy(Function,Collector)");
+ LOGGER.info(" - Collector returned by groupingBy(Function,Collector)");
final JsonObject check = Json.createObjectBuilder().add("Red", Json
.createArrayBuilder()
.add(
@@ -483,7 +486,7 @@
Collector<JsonValue, JsonArrayBuilder, JsonArray> toArray = Collector.of(
ValueBuilder::new, JsonArrayBuilder::add, JsonArrayBuilder::addAll,
JsonArrayBuilder::build);
- System.out.println(" Input: " + valueToString(OBJ_ARRAY_GROUP));
+ LOGGER.info(" Input: " + valueToString(OBJ_ARRAY_GROUP));
final Collector<JsonValue, Map<String, JsonArrayBuilder>, JsonObject> col = JsonCollectors
.groupingBy((JsonValue v) -> {
if (v.getValueType() == JsonValue.ValueType.OBJECT)
@@ -510,7 +513,7 @@
*/
protected boolean operationFailed(final JsonValue check,
final JsonValue out) {
- System.out.println(" Checking " + valueToString(out));
+ LOGGER.info(" Checking " + valueToString(out));
return out == null || !assertEquals(check, out);
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/JsonAssert.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/JsonAssert.java
index 6afd391..4eefdde 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/JsonAssert.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/JsonAssert.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import java.io.StringReader;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonNumber;
@@ -36,14 +38,16 @@
*/
public class JsonAssert {
+ private static final Logger LOGGER = Logger.getLogger(JsonAssert.class.getName());
+
private static boolean assertEquals(final JsonObject expected,
final JsonObject actual, final String message) {
if (actual.equals(expected)) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + toStringJsonObject(expected));
- System.out.println(" Actual: " + toStringJsonObject(actual));
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + toStringJsonObject(expected));
+ LOGGER.info(" Actual: " + toStringJsonObject(actual));
return false;
}
}
@@ -53,9 +57,9 @@
if (actual.equals(expected)) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + toStringJsonArray(expected));
- System.out.println(" Actual: " + toStringJsonArray(actual));
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + toStringJsonArray(expected));
+ LOGGER.info(" Actual: " + toStringJsonArray(actual));
return false;
}
}
@@ -65,9 +69,9 @@
if (actual.equals(expected)) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + expected.getString());
- System.out.println(" Actual: " + actual.getString());
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + expected.getString());
+ LOGGER.info(" Actual: " + actual.getString());
return false;
}
}
@@ -77,9 +81,9 @@
if (actual.equals(expected)) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + expected.toString());
- System.out.println(" Actual: " + actual.toString());
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + expected.toString());
+ LOGGER.info(" Actual: " + actual.toString());
return false;
}
}
@@ -100,18 +104,18 @@
if (expected == actual) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + expected.toString());
- System.out.println(" Actual: " + actual.toString());
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + expected.toString());
+ LOGGER.info(" Actual: " + actual.toString());
return false;
}
default:
if (actual.equals(expected)) {
return true;
} else {
- System.out.println(" " + message);
- System.out.println(" Expected: " + expected.toString());
- System.out.println(" Actual: " + actual.toString());
+ LOGGER.info(" " + message);
+ LOGGER.info(" Expected: " + expected.toString());
+ LOGGER.info(" Actual: " + actual.toString());
return false;
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/SimpleValues.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/SimpleValues.java
index 7ebe2b5..326cdcf 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/SimpleValues.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/SimpleValues.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonArrayBuilder;
@@ -38,6 +40,8 @@
*/
public class SimpleValues {
+ private static final Logger LOGGER = Logger.getLogger(SimpleValues.class.getName());
+
/** Name of JSON {@code String} value used in tests. */
public static final String STR_NAME = "address";
@@ -1104,7 +1108,7 @@
try (final JsonWriter writer = Json.createWriter(strWriter)) {
writer.write(value);
} catch (JsonException ex) {
- System.out.println(
+ LOGGER.info(
"Could not initialize JSON data: " + ex.getLocalizedMessage());
throw ex;
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/TestResult.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/TestResult.java
index 69309f2..a883085 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/TestResult.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/common/TestResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,8 +16,7 @@
package jakarta.jsonp.tck.api.common;
-import jakarta.jsonp.tck.api.common.TestFail;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.opentest4j.AssertionFailedError;
import java.util.LinkedList;
@@ -58,10 +57,10 @@
/**
* Evaluate test results.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when any test failed.
*/
- public void eval() throws Fault {
+ public void eval() {
if (fails.isEmpty()) {
return;
}
@@ -72,7 +71,7 @@
sb.append('\n');
sb.append(fail.toString());
}
- throw new Fault(sb.toString());
+ throw new AssertionFailedError(sb.toString());
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/exceptiontests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/exceptiontests/ClientTests.java
index 4ee38c9..e4e8b7f 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/exceptiontests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/exceptiontests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,25 +22,17 @@
import jakarta.json.*;
import jakarta.json.stream.*;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.*;
+
public class ClientTests {
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -51,29 +43,20 @@
* @test_Strategy: Test API: JsonException ret = new JsonException(String)
*/
@Test
- public void jsonExceptionConstructorTest1() throws Fault {
- boolean pass = true;
-
+ public void jsonExceptionConstructorTest1() {
try {
String message = "This JSON is incorrect.";
- System.out.println("Test JsonException(String)");
+ LOGGER.info("Test JsonException(String)");
JsonException exception = new JsonException(message);
try {
throw exception;
} catch (JsonException e) {
- if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
- + e.getMessage());
- pass = false;
- }
+ assertEquals(message, e.getMessage(), "jsonExceptionConstructorTest1 failed");
}
} catch (Exception e) {
- throw new Fault("jsonExceptionConstructorTest1 Failed: ", e);
+ fail("jsonExceptionConstructorTest1 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonExceptionConstructorTest1 Failed:");
}
/*
@@ -85,37 +68,23 @@
* Throwable)
*/
@Test
- public void jsonExceptionConstructorTest2() throws Fault {
- boolean pass = true;
-
+ public void jsonExceptionConstructorTest2() {
try {
String message = "This JSON is incorrect due to foo.";
Exception foo = new Exception("This is a foo exception");
- System.out.println("Test JsonException(String, Throwable)");
+ LOGGER.info("Test JsonException(String, Throwable)");
JsonException exception = new JsonException(message, foo);
try {
throw exception;
} catch (JsonException e) {
- if (!e.getCause().equals(foo)) {
- System.err.println("Incorrect cause: expected " + foo + ", received "
- + e.getCause());
- pass = false;
- }
- if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
- + e.getMessage());
- pass = false;
- }
+ assertTrue(isPass(foo, e, message), "jsonExceptionConstructorTest2 failed");
}
} catch (Exception e) {
- throw new Fault("jsonExceptionConstructorTest2 Failed: ", e);
+ fail("jsonExceptionConstructorTest2 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonExceptionConstructorTest2 Failed:");
}
/*
@@ -128,38 +97,36 @@
* JsonParsingException(String, JsonLocation)
*/
@Test
- public void jsonParsingExceptionConstructorTest1() throws Fault {
+ public void jsonParsingExceptionConstructorTest1() {
boolean pass = true;
try {
String message = "This JSON is incorrect.";
MyJsonLocation expLoc = new MyJsonLocation(10, 20, 30);
- System.out.println("MyJsonLocation");
+ LOGGER.info("MyJsonLocation");
JSONP_Util.dumpLocation(expLoc);
- System.out.println("Test JsonParsingException(String, JsonLocation)");
+ LOGGER.info("Test JsonParsingException(String, JsonLocation)");
JsonParsingException exception = new JsonParsingException(message,
expLoc);
try {
throw exception;
} catch (JsonParsingException e) {
if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
+ LOGGER.warning("Incorrect message: expected " + message + ", received "
+ e.getMessage());
pass = false;
}
}
JsonLocation actLoc = exception.getLocation();
- System.out.println("JsonParsingException.getLocation()");
+ LOGGER.info("JsonParsingException.getLocation()");
JSONP_Util.dumpLocation(actLoc);
if (!JSONP_Util.assertEquals(expLoc, actLoc))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonParsingExceptionConstructorTest1 Failed: ", e);
+ fail("jsonParsingExceptionConstructorTest1 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonParsingExceptionConstructorTest1 Failed:");
+ assertTrue(pass, "jsonParsingExceptionConstructorTest1 failed");
}
/*
@@ -172,45 +139,34 @@
* JsonParsingException(String, Throwable, JsonLocation)
*/
@Test
- public void jsonParsingExceptionConstructorTest2() throws Fault {
+ public void jsonParsingExceptionConstructorTest2() {
boolean pass = true;
try {
String message = "This JSON is incorrect due to foo.";
Exception foo = new Exception("This is a foo exception");
MyJsonLocation expLoc = new MyJsonLocation(10, 20, 30);
- System.out.println("MyJsonLocation");
+ LOGGER.info("MyJsonLocation");
JSONP_Util.dumpLocation(expLoc);
- System.out.println("Test JsonParsingException(String, Throwable)");
+ LOGGER.info("Test JsonParsingException(String, Throwable)");
JsonParsingException exception = new JsonParsingException(message, foo,
expLoc);
try {
throw exception;
} catch (JsonParsingException e) {
- if (!e.getCause().equals(foo)) {
- System.err.println("Incorrect cause: expected " + foo + ", received "
- + e.getCause());
- pass = false;
- }
- if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
- + e.getMessage());
- pass = false;
- }
+ pass = isPass(foo, e, message);
}
JsonLocation actLoc = exception.getLocation();
- System.out.println("JsonParsingException.getLocation()");
+ LOGGER.info("JsonParsingException.getLocation()");
JSONP_Util.dumpLocation(actLoc);
if (!JSONP_Util.assertEquals(expLoc, actLoc))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonParsingExceptionConstructorTest2 Failed: ", e);
+ fail("jsonParsingExceptionConstructorTest2 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonParsingExceptionConstructorTest2 Failed:");
+ assertTrue(pass, "jsonParsingExceptionConstructorTest2 failed");
}
/*
@@ -222,29 +178,20 @@
* JsonGenerationException(String)
*/
@Test
- public void jsonGenerationExceptionConstructorTest1() throws Fault {
- boolean pass = true;
-
+ public void jsonGenerationExceptionConstructorTest1() {
try {
String message = "This JSON is incorrect.";
- System.out.println("Test JsonGenerationException(String)");
+ LOGGER.info("Test JsonGenerationException(String)");
JsonGenerationException exception = new JsonGenerationException(message);
try {
throw exception;
} catch (JsonGenerationException e) {
- if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
- + e.getMessage());
- pass = false;
- }
+ assertEquals(message, e.getMessage(), "jsonGenerationExceptionConstructorTest1 failed: Incorrect message");
}
} catch (Exception e) {
- throw new Fault("jsonGenerationExceptionConstructorTest1 Failed: ", e);
+ fail("jsonGenerationExceptionConstructorTest1 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonGenerationExceptionConstructorTest1 Failed:");
}
/*
@@ -256,37 +203,39 @@
* JsonGenerationException(String, Throwable)
*/
@Test
- public void jsonGenerationExceptionConstructorTest2() throws Fault {
- boolean pass = true;
-
+ public void jsonGenerationExceptionConstructorTest2() {
try {
String message = "This JSON is incorrect due to foo.";
Exception foo = new Exception("This is a foo exception");
- System.out.println("Test JsonGenerationException(String, Throwable)");
+ LOGGER.info("Test JsonGenerationException(String, Throwable)");
JsonGenerationException exception = new JsonGenerationException(message,
foo);
try {
throw exception;
} catch (JsonGenerationException e) {
- if (!e.getCause().equals(foo)) {
- System.err.println("Incorrect cause: expected " + foo + ", received "
- + e.getCause());
- pass = false;
- }
- if (!e.getMessage().equals(message)) {
- System.err.println("Incorrect message: expected " + message + ", received "
- + e.getMessage());
- pass = false;
- }
+ assertTrue(isPass(foo, e, message), "jsonGenerationExceptionConstructorTest2 failed");
}
} catch (Exception e) {
- throw new Fault("jsonGenerationExceptionConstructorTest2 Failed: ", e);
+ fail("jsonGenerationExceptionConstructorTest2 Failed: ", e);
}
-
- if (!pass)
- throw new Fault("jsonGenerationExceptionConstructorTest2 Failed:");
}
+
+ private boolean isPass(Exception toCompare, Exception actual, String errorMessage) {
+ boolean pass = true;
+ if (!actual.getCause().equals(toCompare)) {
+ LOGGER.warning("Incorrect cause: expected " + toCompare + ", received "
+ + actual.getCause());
+ pass = false;
+ }
+ if (!actual.getMessage().equals(errorMessage)) {
+ LOGGER.warning("Incorrect message: expected " + errorMessage + ", received "
+ + actual.getMessage());
+ pass = false;
+ }
+ return pass;
+ }
+
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildAdd.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildAdd.java
index 3c6f463..be7439c 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildAdd.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildAdd.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,6 +27,8 @@
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -37,6 +39,8 @@
*/
public class ArrayBuildAdd extends ArrayCommon {
+ private static final Logger LOGGER = Logger.getLogger(ArrayBuildAdd.class.getName());
+
/**
* Creates an instance of {@link JsonArrayBuilder} API add() methods added in
* JSON-P 1.1 test.
@@ -53,7 +57,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonArrayBuilder API add() methods added in JSON-P 1.1.");
- System.out.println("JsonArrayBuilder API add() methods added in JSON-P 1.1.");
+ LOGGER.info("JsonArrayBuilder API add() methods added in JSON-P 1.1.");
testAdd(result);
testAddNullBuilder(result);
testAddOutOfBounds(result);
@@ -92,7 +96,7 @@
};
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - add(int," + typeName + ")");
+ LOGGER.info(" - add(int," + typeName + ")");
final String json = "[" + JsonValueType.toStringValue(value) + "]";
final JsonValue check = JsonIO.read(json);
final JsonArrayBuilder builder = createArrayBuilder(0, value);
@@ -125,7 +129,7 @@
final int[] indexes = new int[] { -1, 2, 3 };
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - add(int," + typeName + ")");
+ LOGGER.info(" - add(int," + typeName + ")");
final String json = "[" + JsonValueType.toStringValue(value) + "]";
// Add value into the array for the first time to het array of size 1.
JsonArrayBuilder builder = createArrayBuilder(value);
@@ -137,7 +141,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("add(int,(" + typeName + ")null)",
@@ -164,13 +168,13 @@
};
for (JsonValueType type : types) {
final String typeName = type.name();
- System.out.println(" - add(int,(" + typeName + ")null)");
+ LOGGER.info(" - add(int,(" + typeName + ")null)");
try {
ArrayBuilder.add(Json.createArrayBuilder(), 0, type);
result.fail("add(int,(" + typeName + ")null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("add(int,(" + typeName + ")null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -186,7 +190,7 @@
* Test suite result.
*/
private void testAddNull(final TestResult result) {
- System.out.println(" - addNull(int)");
+ LOGGER.info(" - addNull(int)");
final Object value = null;
final String json = "[" + JsonValueType.toStringValue(value) + "]";
final JsonValue check = JsonIO.read(json);
@@ -207,7 +211,7 @@
*/
private void testAddNullOutOfBounds(final TestResult result) {
final int[] indexes = new int[] { -1, 2, 3 };
- System.out.println(" - addNull(int)");
+ LOGGER.info(" - addNull(int)");
final Object value = null;
JsonArrayBuilder builder = createArrayBuilder(value);
for (int index : indexes) {
@@ -217,7 +221,7 @@
result.fail("addNull(int)", "Calling method with out of bounds index="
+ index + " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("addNull(int)",
@@ -236,7 +240,7 @@
* Test suite result.
*/
private void testAddArrayBuilder(final TestResult result) {
- System.out.println(" - add(int,JsonArrayBuilder)");
+ LOGGER.info(" - add(int,JsonArrayBuilder)");
final JsonValue checkBeg = JsonIO
.read("[[" + JsonValueType.toStringValue(STR_VALUE_1) + ","
+ JsonValueType.toStringValue(STR_VALUE_2) + ","
@@ -267,7 +271,7 @@
* Test suite result.
*/
private void testAddArrayBuilderNull(final TestResult result) {
- System.out.println(" - add(int,(JsonArrayBuilder)null)");
+ LOGGER.info(" - add(int,(JsonArrayBuilder)null)");
final JsonArrayBuilder in = createArrayBuilder(DEF_VALUE);
final JsonArrayBuilder arg = null;
try {
@@ -275,7 +279,7 @@
result.fail("add(int,(JsonArrayBuilder)null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("add(int,(JsonArrayBuilder)null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -292,7 +296,7 @@
* Test suite result.
*/
private void testAddArrayBuilderOutOfBounds(final TestResult result) {
- System.out.println(" - add(int,JsonArrayBuilder)");
+ LOGGER.info(" - add(int,JsonArrayBuilder)");
final int[] indexes = new int[] { -1, 5, 6 };
final JsonArrayBuilder in = createArrayBuilder(STR_VALUE_1).add(STR_VALUE_2)
.add(STR_VALUE_3).add(STR_VALUE_4);
@@ -305,7 +309,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("add(int,JsonArrayBuilder)",
@@ -324,7 +328,7 @@
* Test suite result.
*/
private void testAddObjectBuilder(final TestResult result) {
- System.out.println(" - add(int,JsonObjectBuilder)");
+ LOGGER.info(" - add(int,JsonObjectBuilder)");
final JsonValue checkBeg = JsonIO
.read("[{" + JsonValueType.toStringValue(STR_NAME) + ":"
+ JsonValueType.toStringValue(STR_VALUE) + "},"
@@ -351,7 +355,7 @@
* Test suite result.
*/
private void testAddObjectBuilderNull(final TestResult result) {
- System.out.println(" - add(int,(JsonObjectBuilder)null)");
+ LOGGER.info(" - add(int,(JsonObjectBuilder)null)");
final JsonArrayBuilder in = createArrayBuilder(DEF_VALUE);
final JsonObjectBuilder arg = null;
try {
@@ -359,7 +363,7 @@
result.fail("add(int,(JsonObjectBuilder)null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("add(int,(JsonObjectBuilder)null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -376,7 +380,7 @@
* Test suite result.
*/
private void testAddObjectBuilderOutOfBounds(final TestResult result) {
- System.out.println(" - add(int,JsonObjectBuilder)");
+ LOGGER.info(" - add(int,JsonObjectBuilder)");
final int[] indexes = new int[] { -1, 5, 6 };
final JsonArrayBuilder in = createArrayBuilder(STR_VALUE_1).add(STR_VALUE_2)
.add(STR_VALUE_3).add(STR_VALUE_4);
@@ -390,7 +394,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("add(int,JsonObjectBuilder)",
@@ -409,7 +413,7 @@
* Test suite result.
*/
private void testAddAllString(final TestResult result) {
- System.out.println(" - addAll(JsonArrayBuilder) for String array");
+ LOGGER.info(" - addAll(JsonArrayBuilder) for String array");
final JsonArray check = createSimpleStringArray5();
final String[] strings = new String[] { STR_VALUE_1, STR_VALUE_2,
STR_VALUE_3, STR_VALUE_4, STR_VALUE_5 };
@@ -421,7 +425,7 @@
* {@code int) array. @param result Test suite result.
*/
private void testAddAllInt(final TestResult result) {
- System.out.println(" - addAll(JsonArrayBuilder) for int array");
+ LOGGER.info(" - addAll(JsonArrayBuilder) for int array");
final JsonArray check = createSimpleIntArray5();
final Integer[] ints = new Integer[] { INT_VALUE_1, INT_VALUE_2,
INT_VALUE_3, INT_VALUE_4, INT_VALUE_5 };
@@ -433,7 +437,7 @@
* {@code boolean) array. @param result Test suite result.
*/
private void testAddAllBool(final TestResult result) {
- System.out.println(" - addAll(JsonArrayBuilder) for boolean array");
+ LOGGER.info(" - addAll(JsonArrayBuilder) for boolean array");
final JsonArray check = createSimpleBoolArray5();
final Boolean[] bools = new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
BOOL_FALSE, BOOL_TRUE };
@@ -445,7 +449,7 @@
* {@code JsonObject) array. @param result Test suite result.
*/
private void testAddAllObject(final TestResult result) {
- System.out.println(" - addAll(JsonArrayBuilder) for JsonObject array");
+ LOGGER.info(" - addAll(JsonArrayBuilder) for JsonObject array");
final JsonArray check = createSimpleObjectArray5();
final JsonObject[] bools = new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2,
OBJ_VALUE_3, OBJ_VALUE_4, OBJ_VALUE_5 };
@@ -460,14 +464,14 @@
* Test suite result.
*/
private void testAddAllNull(final TestResult result) {
- System.out.println(" - addAll(JsonArrayBuilder) for null builder argument");
+ LOGGER.info(" - addAll(JsonArrayBuilder) for null builder argument");
JsonArrayBuilder builder = Json.createArrayBuilder();
try {
builder.addAll((JsonArrayBuilder) null);
result.fail("addAll(null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("addAll(null)",
"Calling method with null argument shall throw NullPointerException, not "
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildRemove.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildRemove.java
index 2f5b061..9a9daaf 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildRemove.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -34,6 +36,8 @@
*/
public class ArrayBuildRemove extends ArrayCommon {
+ private static final Logger LOGGER = Logger.getLogger(ArrayBuildRemove.class.getName());
+
/**
* Creates an instance of {@link JsonArrayBuilder} API remove() methods added
* in JSON-P 1.1 test.
@@ -50,7 +54,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonArrayBuilder API remove() methods added in JSON-P 1.1.");
- System.out.println("JsonArrayBuilder API remove() methods added in JSON-P 1.1.");
+ LOGGER.info("JsonArrayBuilder API remove() methods added in JSON-P 1.1.");
testRemove(result);
testRemoveOutOfBounds(result);
return result;
@@ -75,7 +79,7 @@
};
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - remove(int," + typeName + ")");
+ LOGGER.info(" - remove(int," + typeName + ")");
final String json = "[]";
final JsonValue check = JsonIO.read(json);
JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(),
@@ -110,7 +114,7 @@
final int[] indexes = new int[] { -1, 2, 3 };
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - remove(int," + typeName + ")");
+ LOGGER.info(" - remove(int," + typeName + ")");
final String json = "[" + JsonValueType.toStringValue(value) + "]";
// Add value into the array for the first time to het array of size 1.
JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(),
@@ -123,7 +127,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("remove(int,(" + typeName + ")null)",
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildSet.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildSet.java
index e41ebe1..8fa5680 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildSet.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuildSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -26,6 +26,8 @@
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -36,6 +38,8 @@
*/
public class ArrayBuildSet extends ArrayCommon {
+ private static final Logger LOGGER = Logger.getLogger(ArrayBuildSet.class.getName());
+
/**
* Creates an instance of {@link JsonArrayBuilder} API set() methods added in
* JSON-P 1.1 test.
@@ -52,7 +56,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonArrayBuilder API set() methods added in JSON-P 1.1.");
- System.out.println("JsonArrayBuilder API set() methods added in JSON-P 1.1.");
+ LOGGER.info("JsonArrayBuilder API set() methods added in JSON-P 1.1.");
testSet(result);
testSetOutOfBounds(result);
testSetNullBuilder(result);
@@ -86,7 +90,7 @@
};
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - set(int," + typeName + ")");
+ LOGGER.info(" - set(int," + typeName + ")");
final String json = "[" + JsonValueType.toStringValue(value) + "]";
final JsonValue check = JsonIO.read(json);
final JsonArrayBuilder builder = updateOperationBuilder(
@@ -120,7 +124,7 @@
final int[] indexes = new int[] { -1, 2, 3 };
for (Object value : values) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - set(int," + typeName + ")");
+ LOGGER.info(" - set(int," + typeName + ")");
final String json = "[" + JsonValueType.toStringValue(value) + "]";
JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(),
DEF_OBJ_VALUE);
@@ -129,7 +133,7 @@
builder = updateOperationBuilder(
Json.createArrayBuilder().add(DEF_OBJ_VALUE), index, value);
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("set(int," + typeName + ")",
@@ -156,13 +160,13 @@
};
for (JsonValueType type : types) {
final String typeName = type.name();
- System.out.println(" - set(int,(" + typeName + ")null)");
+ LOGGER.info(" - set(int,(" + typeName + ")null)");
try {
ArrayBuilder.set(Json.createArrayBuilder(), 0, type);
result.fail("set(int,(" + typeName + ")null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("set(int,(" + typeName + ")null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -179,7 +183,7 @@
* Test suite result.
*/
private void testSetNull(final TestResult result) {
- System.out.println(" - setNull(int)");
+ LOGGER.info(" - setNull(int)");
final Object value = null;
final String json = "[" + JsonValueType.toStringValue(null) + "]";
final JsonValue check = JsonIO.read(json);
@@ -202,7 +206,7 @@
*/
private void testSetNullOutOfBounds(final TestResult result) {
final int[] indexes = new int[] { -1, 2, 3 };
- System.out.println(" - setNull(int)");
+ LOGGER.info(" - setNull(int)");
final Object value = null;
JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(),
value);
@@ -213,7 +217,7 @@
result.fail("setNull(int)", "Calling method with out of bounds index="
+ index + " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("setNull(int)",
@@ -232,7 +236,7 @@
* Test suite result.
*/
private void testSetArrayBuilder(final TestResult result) {
- System.out.println(" - set(int,JsonArrayBuilder)");
+ LOGGER.info(" - set(int,JsonArrayBuilder)");
final JsonValue check = JsonIO
.read("[[" + JsonValueType.toStringValue(STR_VALUE_1) + ","
+ JsonValueType.toStringValue(STR_VALUE_2) + ","
@@ -252,7 +256,7 @@
* Test suite result.
*/
private void testSetArrayBuilderNull(final TestResult result) {
- System.out.println(" - set(int,(JsonArrayBuilder)null)");
+ LOGGER.info(" - set(int,(JsonArrayBuilder)null)");
final JsonArrayBuilder in = Json.createArrayBuilder().add(DEF_VALUE);
final JsonArrayBuilder arg = null;
try {
@@ -260,7 +264,7 @@
result.fail("set(int,(JsonArrayBuilder)null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("set(int,(JsonArrayBuilder)null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -277,7 +281,7 @@
* Test suite result.
*/
private void testSetArrayBuilderOutOfBounds(final TestResult result) {
- System.out.println(" - set(int,JsonArrayBuilder)");
+ LOGGER.info(" - set(int,JsonArrayBuilder)");
final int[] indexes = new int[] { -1, 5, 6 };
final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_1)
.add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4);
@@ -290,7 +294,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("set(int,JsonArrayBuilder)",
@@ -309,7 +313,7 @@
* Test suite result.
*/
private void testSetObjectBuilder(final TestResult result) {
- System.out.println(" - set(int,JsonObjectBuilder)");
+ LOGGER.info(" - set(int,JsonObjectBuilder)");
final JsonValue check = JsonIO
.read("[{" + JsonValueType.toStringValue(STR_NAME) + ":"
+ JsonValueType.toStringValue(STR_VALUE) + "}]");
@@ -327,7 +331,7 @@
* Test suite result.
*/
private void testSetObjectBuilderNull(final TestResult result) {
- System.out.println(" - set(int,(JsonObjectBuilder)null)");
+ LOGGER.info(" - set(int,(JsonObjectBuilder)null)");
final JsonArrayBuilder in = Json.createArrayBuilder().add(DEF_VALUE);
final JsonObjectBuilder arg = null;
try {
@@ -335,7 +339,7 @@
result.fail("set(int,(JsonObjectBuilder)null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("set(int,(JsonObjectBuilder)null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -352,7 +356,7 @@
* Test suite result.
*/
private void testSetObjectBuilderOutOfBounds(final TestResult result) {
- System.out.println(" - set(int,JsonObjectBuilder)");
+ LOGGER.info(" - set(int,JsonObjectBuilder)");
final int[] indexes = new int[] { -1, 5, 6 };
final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_1)
.add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4);
@@ -366,7 +370,7 @@
"Calling method with out of bounds index=" + index
+ " argument shall throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println(" - Expected exception for index=" + index + ": "
+ LOGGER.info(" - Expected exception for index=" + index + ": "
+ e.getMessage());
} catch (Throwable t) {
result.fail("set(int,JsonObjectBuilder)",
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuilders.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuilders.java
index 9a71d27..ef3889e 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuilders.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ArrayBuilders.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -28,6 +28,8 @@
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
import java.util.Iterator;
import java.util.List;
+import java.util.logging.Logger;
+
import jakarta.json.JsonNumber;
// $Id$
@@ -37,6 +39,8 @@
*/
public class ArrayBuilders {
+ private static final Logger LOGGER = Logger.getLogger(ArrayBuilders.class.getName());
+
/**
* Creates an instance of {@link JsonArrayBuilder} API factory methods added
* in JSON-P 1.1 test.
@@ -53,7 +57,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonArrayBuilder API factory methods added in JSON-P 1.1.");
- System.out.println("JsonArrayBuilder API factory methods added in JSON-P 1.1.");
+ LOGGER.info("JsonArrayBuilder API factory methods added in JSON-P 1.1.");
testCreateFromCollection(result);
testCreateFromJsonArray(result);
testGetStringValuesAs(result);
@@ -68,7 +72,7 @@
* Test suite result.
*/
private void testCreateFromCollection(final TestResult result) {
- System.out.println(" - Json#createArrayBuilder(Collection<Object>)");
+ LOGGER.info(" - Json#createArrayBuilder(Collection<Object>)");
final JsonArray check = createSimpleStringArray5();
final ArrayList<Object> values = new ArrayList<>(check.size());
for (final JsonValue value : check) {
@@ -89,7 +93,7 @@
* Test suite result.
*/
private void testCreateFromJsonArray(final TestResult result) {
- System.out.println(" - Json#createArrayBuilder(JsonArray)");
+ LOGGER.info(" - Json#createArrayBuilder(JsonArray)");
final JsonArray check = createSimpleStringArray5();
final JsonArrayBuilder builder = Json.createArrayBuilder(check);
final JsonArray out = builder.build();
@@ -107,7 +111,7 @@
* Test suite result.
*/
private void testGetStringValuesAs(final TestResult result) {
- System.out.println(" - getValuesAs(Function<K,T> on String array");
+ LOGGER.info(" - getValuesAs(Function<K,T> on String array");
final JsonArray in = createStringArray2();
final List<String> out = in.getValuesAs(JsonString::getString);
boolean failed = in.size() != out.size();
@@ -134,7 +138,7 @@
* Test suite result.
*/
private void testGetIntValuesAs(final TestResult result) {
- System.out.println(" - getValuesAs(Function<K,T> on int array");
+ LOGGER.info(" - getValuesAs(Function<K,T> on int array");
final JsonArray in = createIntArray2();
final List<Integer> out = in.getValuesAs(JsonNumber::intValue);
boolean failed = in.size() != out.size();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ClientTests.java
index 0fa1978..6078003 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonarraytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,34 +18,26 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
//$Id$
-@RunWith(Arquillian.class)
public class ClientTests {
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -62,16 +54,15 @@
* values matches the expected list of JsonArray values.
*/
@Test
- public void jsonArrayTest1() throws Fault {
- boolean pass = true;
+ public void jsonArrayTest1() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
- System.out.println("Create the expected list of JsonArray values");
+ LOGGER.info("Create the expected list of JsonArray values");
List<JsonValue> expList = new ArrayList<>();
expList.add(JsonValue.FALSE);
expList.add(JsonValue.TRUE);
@@ -90,7 +81,7 @@
expList.add(array);
JSONP_Util.dumpList(expList, "Expected List");
- System.out.println("Create JsonArray using all JsonArrayBuilder API's");
+ LOGGER.info("Create JsonArray using all JsonArrayBuilder API's");
JsonArray myJsonArray = Json.createArrayBuilder() // Indices
.add(JsonValue.FALSE) // 0
.add(JsonValue.TRUE) // 1
@@ -110,14 +101,12 @@
List<JsonValue> actualList = myJsonArray;
JSONP_Util.dumpList(actualList, "Actual List");
- System.out.println(
+ LOGGER.info(
"Compare actual list of JsonArray values with expected list of JsonArray values");
- pass = JSONP_Util.assertEqualsList(expList, actualList);
+ assertTrue(JSONP_Util.assertEqualsList(expList, actualList), "jsonArrayTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonArrayTest1 Failed: ", e);
+ fail("jsonArrayTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonArrayTest1 Failed");
}
/*
@@ -137,16 +126,15 @@
* JsonWriter and then read back using the JsonReader are equal.
*/
@Test
- public void jsonArrayTest2() throws Fault {
- boolean pass = true;
+ public void jsonArrayTest2() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
- System.out.println(
+ LOGGER.info(
"Create JsonArray 'myJsonArray1' using all JsonArrayBuilder API's");
JsonArray myJsonArray1 = Json.createArrayBuilder() // Indices
.add(JsonValue.FALSE) // 0
@@ -165,31 +153,29 @@
.add(array) // 13
.build();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
StringWriter sw = new StringWriter();
try (JsonWriter writer = Json.createWriter(sw)) {
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sw.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
- System.out.println("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
+ LOGGER.info("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
JsonArray myJsonArray2;
try (JsonReader reader = Json.createReader(new StringReader(contents))) {
myJsonArray2 = reader.readArray();
}
- System.out.println("Dump contents of JsonArray read from String Contents");
+ LOGGER.info("Dump contents of JsonArray read from String Contents");
JSONP_Util.dumpJsonValue(myJsonArray2);
- System.out.println("Compare myJsonArray1 and myJsonArray2 for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2);
+ LOGGER.info("Compare myJsonArray1 and myJsonArray2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2), "jsonArrayTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonArrayTest2 Failed: ", e);
+ fail("jsonArrayTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonArrayTest2 Failed");
}
/*
@@ -224,13 +210,13 @@
*/
@SuppressWarnings("SuspiciousIndentAfterControlStatement")
@Test
- public void jsonArrayTest3() throws Fault {
+ public void jsonArrayTest3() {
boolean pass = true;
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
int expInt[] = { -1, 1, 1, -1000, 1000, 1000, -2000, 2000, 2000,
@@ -240,7 +226,7 @@
double expDouble[] = { Double.MAX_VALUE, Double.MIN_VALUE };
- System.out.println("Create myArray Jsonarray of 23 elements");
+ LOGGER.info("Create myArray Jsonarray of 23 elements");
JsonArray myArray = Json.createArrayBuilder() // Indices
.add(-1).add(+1).add(1) // 0,1,2
.add(-1e3).add(+1e3).add(1e3) // 3,4,5
@@ -261,7 +247,7 @@
.add(array) // 22
.build();
- System.out.println("Array size=" + myArray.size());
+ LOGGER.info("Array size=" + myArray.size());
// Following array is used to test for Ints that could be one of following
// types:
@@ -269,24 +255,24 @@
JSONP_Util.NON_INTEGRAL };
// Verify JsonValueType=NUMBER and integer value equals expectedIntValue
for (int i = 0; i < 11; i++) {
- System.out.println("Checking getValue(" + i + ") for correctness");
- System.out.println("Retrieve and verify (JsonValueType=NUMBER)");
+ LOGGER.info("Checking getValue(" + i + ") for correctness");
+ LOGGER.info("Retrieve and verify (JsonValueType=NUMBER)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER,
myArray.getJsonNumber(i).getValueType()))
pass = false;
- System.out.println("Retrieve and (expect JsonNumber NumberType be one of "
+ LOGGER.info("Retrieve and (expect JsonNumber NumberType be one of "
+ JSONP_Util.toStringJsonNumberTypes(expectedIntTypes) + ")");
if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedIntTypes,
myArray.getJsonNumber(i).isIntegral()))
pass = false;
- System.out.println("Retrieve and verify integer value via JsonNumber.intValue()");
+ LOGGER.info("Retrieve and verify integer value via JsonNumber.intValue()");
if (!JSONP_Util.assertEquals(expInt[i],
myArray.getJsonNumber(i).intValue()))
pass = false;
- System.out.println("Retrieve and verify integer value via JsonArray.getInt");
+ LOGGER.info("Retrieve and verify integer value via JsonArray.getInt");
if (!JSONP_Util.assertEquals(expInt[i], myArray.getInt(i)))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify integer value via JsonNumber.intValueExact()");
if (!JSONP_Util.assertEquals(expInt[i],
myArray.getJsonNumber(i).intValueExact()))
@@ -295,20 +281,20 @@
// Verify JsonValueType=NUMBER and long value equals expectedLongValue
for (int i = 11, j = 0; i < 13; i++, j++) {
- System.out.println("Checking getValue(" + i + ") for correctness");
- System.out.println("Retrieve and verify (JsonValueType=NUMBER)");
+ LOGGER.info("Checking getValue(" + i + ") for correctness");
+ LOGGER.info("Retrieve and verify (JsonValueType=NUMBER)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER,
myArray.getJsonNumber(i).getValueType()))
pass = false;
- System.out.println("Retrieve and (expect JsonNumber NumberType be INTEGRAL)");
+ LOGGER.info("Retrieve and (expect JsonNumber NumberType be INTEGRAL)");
if (!JSONP_Util.assertEqualsJsonNumberType(JSONP_Util.INTEGRAL,
myArray.getJsonNumber(i).isIntegral()))
pass = false;
- System.out.println("Retrieve and verify long value via JsonNumber.longValue()");
+ LOGGER.info("Retrieve and verify long value via JsonNumber.longValue()");
if (!JSONP_Util.assertEquals(expLong[j],
myArray.getJsonNumber(i).longValue()))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify long value via JsonNumber.longValueExact()");
if (!JSONP_Util.assertEquals(expLong[j],
myArray.getJsonNumber(i).longValueExact()))
@@ -322,17 +308,17 @@
// Verify JsonValueType=NUMBER and double value equals expectedDoubleValue
for (int i = 13, j = 0; i < 15; i++, j++) {
- System.out.println("Checking getValue(" + i + ") for correctness");
- System.out.println("Retrieve and verify (JsonValueType=NUMBER)");
+ LOGGER.info("Checking getValue(" + i + ") for correctness");
+ LOGGER.info("Retrieve and verify (JsonValueType=NUMBER)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER,
myArray.getJsonNumber(i).getValueType()))
pass = false;
- System.out.println("Retrieve and (expect JsonNumber NumberType be one of "
+ LOGGER.info("Retrieve and (expect JsonNumber NumberType be one of "
+ JSONP_Util.toStringJsonNumberTypes(expectedDoubleTypes) + ")");
if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedDoubleTypes,
myArray.getJsonNumber(i).isIntegral()))
pass = false;
- System.out.println("Retrieve and verify double value via JsonNumber.doubleValue()");
+ LOGGER.info("Retrieve and verify double value via JsonNumber.doubleValue()");
if (!JSONP_Util.assertEquals(expDouble[j],
myArray.getJsonNumber(i).doubleValue()))
pass = false;
@@ -340,17 +326,17 @@
// Verify JsonValueType=NUMBER and BigDecimalValue equals
// expectedBigDecimal
- System.out.println("Checking getValue(15) for correctness");
- System.out.println("Retrieve and verify (JsonValueType=NUMBER)");
+ LOGGER.info("Checking getValue(15) for correctness");
+ LOGGER.info("Retrieve and verify (JsonValueType=NUMBER)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER,
myArray.getJsonNumber(15).getValueType()))
pass = false;
- System.out.println("Retrieve and (expect JsonNumber NumberType be one of "
+ LOGGER.info("Retrieve and (expect JsonNumber NumberType be one of "
+ JSONP_Util.toStringJsonNumberTypes(expectedDoubleTypes) + ")");
if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedDoubleTypes,
myArray.getJsonNumber(15).isIntegral()))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify BigDecimal value via JsonNumber.bigDecimalValue()");
if (!JSONP_Util.assertEquals(BigDecimal.valueOf(123456789.123456789),
myArray.getJsonNumber(15).bigDecimalValue()))
@@ -358,80 +344,80 @@
// Verify JsonValueType=NUMBER and BigIntegerValue equals
// expectedBigInteger
- System.out.println("Checking getValue(16) for correctness");
- System.out.println("Retrieve and verify (JsonValueType=NUMBER)");
+ LOGGER.info("Checking getValue(16) for correctness");
+ LOGGER.info("Retrieve and verify (JsonValueType=NUMBER)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER,
myArray.getJsonNumber(16).getValueType()))
pass = false;
- System.out.println("Retrieve and (expect JsonNumber NumberType be INTEGRAL)");
+ LOGGER.info("Retrieve and (expect JsonNumber NumberType be INTEGRAL)");
if (!JSONP_Util.assertEqualsJsonNumberType(JSONP_Util.INTEGRAL,
myArray.getJsonNumber(16).isIntegral()))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify BigInteger value via JsonNumber.bigIntegerValue()");
if (!JSONP_Util.assertEquals(new BigInteger("123456789"),
myArray.getJsonNumber(16).bigIntegerValue()))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify BigInteger value via JsonNumber.bigIntegerValueExact()");
if (!JSONP_Util.assertEquals(new BigInteger("123456789"),
myArray.getJsonNumber(16).bigIntegerValueExact()))
pass = false;
// Verify getBoolean(int)=true
- System.out.println("Retrieve and verify true value via JsonArray.getBoolean(int)");
+ LOGGER.info("Retrieve and verify true value via JsonArray.getBoolean(int)");
if (!JSONP_Util.assertEquals(true, myArray.getBoolean(17)))
pass = false;
// Verify getBoolean(int)=false
- System.out.println("Retrieve and verify false value via JsonArray.getBoolean(int)");
+ LOGGER.info("Retrieve and verify false value via JsonArray.getBoolean(int)");
if (!JSONP_Util.assertEquals(false, myArray.getBoolean(18)))
pass = false;
// Verify isNull(int)=true
- System.out.println("Retrieve and verify null value via JsonArray.isNull(int)");
+ LOGGER.info("Retrieve and verify null value via JsonArray.isNull(int)");
if (!JSONP_Util.assertEquals(true, myArray.isNull(19)))
pass = false;
// Verify isNull(int)=false
- System.out.println("Retrieve and verify non-null value via JsonArray.isNull(int)");
+ LOGGER.info("Retrieve and verify non-null value via JsonArray.isNull(int)");
if (!JSONP_Util.assertEquals(false, myArray.isNull(20)))
pass = false;
// Verify JsonValueType=STRING and getJsonString()=expectedString
- System.out.println("Checking getValue(20) for correctness");
- System.out.println("Retrieve and (expect JsonValueType=STRING)");
+ LOGGER.info("Checking getValue(20) for correctness");
+ LOGGER.info("Retrieve and (expect JsonValueType=STRING)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.STRING,
myArray.getJsonString(20).getValueType()))
pass = false;
- System.out.println("Retrieve and verify string value via JsonString.getString()");
+ LOGGER.info("Retrieve and verify string value via JsonString.getString()");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myArray.getJsonString(20).getString()))
pass = false;
- System.out.println("Retrieve and verify string value via JsonArray.getString()");
+ LOGGER.info("Retrieve and verify string value via JsonArray.getString()");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myArray.getString(20)))
pass = false;
// Verify JsonValueType=OBJECT and getJsonObject()=expectedObject
- System.out.println("Checking getJsonObject(21) for correctness");
- System.out.println("Retrieve and (expect JsonValueType=OBJECT)");
+ LOGGER.info("Checking getJsonObject(21) for correctness");
+ LOGGER.info("Retrieve and (expect JsonValueType=OBJECT)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.OBJECT,
myArray.getJsonObject(21).getValueType()))
pass = false;
- System.out.println(
+ LOGGER.info(
"Retrieve and verify object value via JsonArray.getJsonObject(int)");
if (!JSONP_Util.assertEqualsJsonObjects(object,
myArray.getJsonObject(21)))
pass = false;
// Verify JsonValueType=ARRAY and getJsonArray()=expectedArray
- System.out.println("Checking getJsonArray(22) for correctness");
- System.out.println("Retrieve and (expect JsonValueType=ARRAY)");
+ LOGGER.info("Checking getJsonArray(22) for correctness");
+ LOGGER.info("Retrieve and (expect JsonValueType=ARRAY)");
if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.ARRAY,
myArray.getJsonArray(22).getValueType()))
pass = false;
- System.out.println("Retrieve and verify array value via JsonArray.getJsonArray(int)");
+ LOGGER.info("Retrieve and verify array value via JsonArray.getJsonArray(int)");
if (!JSONP_Util.assertEqualsJsonArrays(array, myArray.getJsonArray(22)))
pass = false;
@@ -442,7 +428,7 @@
pass = false;
// Verify calls to JsonArray.getBoolean(int, boolean)
- System.out.println(
+ LOGGER.info(
"Testing JsonArray.getBoolean(int, boolean) with/without default value setting.");
if (!JSONP_Util.assertEquals(true, myArray.getBoolean(17, false)))
pass = false;
@@ -458,7 +444,7 @@
pass = false;
// Verify calls to JsonArray.getInt(int, int)
- System.out.println(
+ LOGGER.info(
"Testing JsonArray.getInt(int, int) with/without default value setting.");
if (!JSONP_Util.assertEquals(-1, myArray.getInt(0, 10)))
pass = false;
@@ -474,7 +460,7 @@
pass = false;
// Verify calls to JsonArray.getString(int, String)
- System.out.println(
+ LOGGER.info(
"Testing JsonArray.getString(int, String) with/without default value setting.");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myArray.getString(20, "foo")))
@@ -491,10 +477,9 @@
pass = false;
} catch (Exception e) {
- throw new Fault("jsonArrayTest3 Failed: ", e);
+ fail("jsonArrayTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonArrayTest3 Failed");
+ assertTrue(pass, "jsonArrayTest3 Failed");
}
/*
@@ -510,32 +495,30 @@
* expected based on the JsonArray.
*/
@Test
- public void jsonArrayTest4() throws Fault {
- boolean pass = true;
+ public void jsonArrayTest4() {
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
StringWriter sw = new StringWriter();
try (JsonWriter writer = Json.createWriter(sw)) {
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sw.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
- System.out.println("Remove whitespace from contents.");
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
+ LOGGER.info("Remove whitespace from contents.");
String actJsonText = JSONP_Util.removeWhitespace(contents);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonArray text with actual JsonArray text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonText),
+ "jsonArrayTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonArrayTest4 Failed: ", e);
+ fail("jsonArrayTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonArrayTest4 Failed");
}
/*
@@ -553,36 +536,36 @@
*/
@SuppressWarnings("SuspiciousIndentAfterControlStatement")
@Test
- public void jsonArrayGetValuesAsTest() throws Fault {
+ public void jsonArrayGetValuesAsTest() {
boolean pass = true;
try {
- System.out.println("Create sample JsonArray of JsonNumber types for testing");
+ LOGGER.info("Create sample JsonArray of JsonNumber types for testing");
JsonArray jsonArr = Json.createArrayBuilder().add(100).add(500).build();
- System.out.println("Create the expected list of JsonArray values");
+ LOGGER.info("Create the expected list of JsonArray values");
List<JsonValue> expList = new ArrayList<>();
expList.add(JSONP_Util.createJsonNumber(100));
expList.add(JSONP_Util.createJsonNumber(500));
JSONP_Util.dumpList(expList, "Expected List");
- System.out.println("Create the JsonNumber list of JsonArray values");
+ LOGGER.info("Create the JsonNumber list of JsonArray values");
List<JsonNumber> numList = jsonArr.getValuesAs(JsonNumber.class);
- System.out.println("Create the actual list of JsonArray values");
+ LOGGER.info("Create the actual list of JsonArray values");
List<JsonValue> actList = new ArrayList<>();
for (JsonNumber num : numList)
actList.add(num);
- System.out.println("Compare actual list with expected list for equality");
+ LOGGER.info("Compare actual list with expected list for equality");
pass = JSONP_Util.assertEqualsList(expList, actList);
- System.out.println("Create sample JsonArray of JsonString types for testing");
+ LOGGER.info("Create sample JsonArray of JsonString types for testing");
jsonArr = Json.createArrayBuilder().add("hello").add("world").build();
- System.out.println("Create the list of JsonString values");
+ LOGGER.info("Create the list of JsonString values");
List<JsonString> strList = jsonArr.getValuesAs(JsonString.class);
- System.out.println("Comparing JsonString list elements to expected values.");
+ LOGGER.info("Comparing JsonString list elements to expected values.");
if (!JSONP_Util.assertEquals(jsonArr.getString(0),
strList.get(0).getString()))
pass = false;
@@ -592,10 +575,9 @@
pass = false;
} catch (Exception e) {
- throw new Fault("jsonArrayGetValuesAsTest Failed: ", e);
+ fail("jsonArrayGetValuesAsTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonArrayGetValuesAsTest Failed");
+ assertTrue(pass, "jsonArrayGetValuesAsTest Failed");
}
/*
@@ -615,531 +597,531 @@
* java.lang.UnsupportedOperationException
*/
@Test
- public void jsonArrayExceptionTests() throws Fault {
+ public void jsonArrayExceptionTests() {
boolean pass = true;
JsonObject testObject = null;
JsonArray testArray = null;
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
testObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
testArray = JSONP_Util.createSampleJsonArray();
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonNumber via getJsonNumber(int)");
JsonNumber value = testArray.getJsonNumber(0);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonNumber via getJsonNumber(int)");
JsonNumber value = testArray.getJsonNumber(15);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonNumber to JsonString via getJsonString(int)");
JsonString value = testArray.getJsonString(4);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to JsonNumber via getJsonNumber(int)");
JsonNumber value = testArray.getJsonNumber(6);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonValue.TRUE to JsonNumber via getJsonNumber(int)");
JsonNumber value = testArray.getJsonNumber(1);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonArray via getJsonArray(int)");
JsonArray value = testArray.getJsonArray(0);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonObject via getJsonObject(int)");
JsonObject value = testArray.getJsonObject(15);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonNumber via getInt(int)");
int value = testArray.getInt(0);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonString via getString(int)");
String value = testArray.getString(0);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonString via getString(int)");
String value = testArray.getString(15);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to boolean via getBoolean(int)");
boolean value = testArray.getBoolean(0);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to boolean via getBoolean(int)");
boolean value = testArray.getBoolean(13);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to boolean via getBoolean(int)");
boolean value = testArray.getBoolean(6);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonNumber to boolean via getBoolean(int)");
boolean value = testArray.getBoolean(4);
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getJsonNumber(int)");
int myInt = testArray.getJsonNumber(-1).intValue();
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getJsonNumber(int)");
JsonValue myJsonValue = testArray.getJsonNumber(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getJsonArray(int)");
JsonValue myJsonValue = testArray.getJsonArray(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getJsonArray(int)");
JsonValue myJsonValue = testArray.getJsonArray(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getJsonObject(int)");
JsonValue myJsonValue = testArray.getJsonObject(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getJsonObject(int)");
JsonValue myJsonValue = testArray.getJsonObject(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getJsonString(int)");
JsonValue myJsonValue = testArray.getJsonString(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getJsonString(int)");
JsonValue myJsonValue = testArray.getJsonString(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getInt(int)");
int myInt = testArray.getInt(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getInt(int)");
int myInt = testArray.getInt(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getString(int)");
String myString = testArray.getString(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getString(int)");
String myString = testArray.getString(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to getBoolean(int)");
boolean myBoolean = testArray.getBoolean(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to getBoolean(int)");
boolean myBoolean = testArray.getBoolean(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing -1 as index to isNull(int)");
boolean myBoolean = testArray.isNull(-1);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip IndexOutOfBoundsException
try {
- System.out.println(
+ LOGGER.info(
"Trip IndexOutOfBoundsException passing 10000 as index to isNull(int)");
boolean myBoolean = testArray.isNull(10000);
pass = false;
- System.err.println("Failed to throw IndexOutOfBoundsException");
+ LOGGER.warning("Failed to throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
- System.out.println("Got expected IndexOutOfBoundsException");
+ LOGGER.info("Got expected IndexOutOfBoundsException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NumberFormatException calling add(Double.NaN)
try {
- System.out.println("Trip NumberFormatException calling add(Double.NaN)");
+ LOGGER.info("Trip NumberFormatException calling add(Double.NaN)");
JsonArray array = Json.createArrayBuilder().add(Double.NaN).build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NumberFormatException calling add(Double.NEGATIVE_INFINITY)
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException calling add(Double.NEGATIVE_INFINITY)");
JsonArray array = Json.createArrayBuilder().add(Double.NEGATIVE_INFINITY)
.build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NumberFormatException calling add(Double.POSITIVE_INFINITY)
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException calling add(Double.POSITIVE_INFINITY)");
JsonArray array = Json.createArrayBuilder().add(Double.POSITIVE_INFINITY)
.build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact integer value");
JsonArray array = Json.createArrayBuilder().add(12345.12345).build();
- System.out.println("Call JsonArray.getJsonNumber(0).intValueExact()");
+ LOGGER.info("Call JsonArray.getJsonNumber(0).intValueExact()");
int value = array.getJsonNumber(0).intValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact long value");
JsonArray array = Json.createArrayBuilder().add(12345.12345).build();
- System.out.println("Call JsonArray.getJsonNumber(0).longValueExact()");
+ LOGGER.info("Call JsonArray.getJsonNumber(0).longValueExact()");
long value = array.getJsonNumber(0).longValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact biginteger value");
JsonArray array = Json.createArrayBuilder().add(12345.12345).build();
- System.out.println("Call JsonArray.getJsonNumber(0).bigIntegerValueExact()");
+ LOGGER.info("Call JsonArray.getJsonNumber(0).bigIntegerValueExact()");
BigInteger value = array.getJsonNumber(0).bigIntegerValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Tests for UnsupportedOperationException using Collection methods to
@@ -1147,118 +1129,117 @@
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.add(E) trying to modify JsonArray list which should be immutable");
testArray.add(JsonValue.FALSE);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.add(int,E) trying to modify JsonArray list which should be immutable");
testArray.add(0, JsonValue.FALSE);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.addAll(C) trying to modify JsonArray list which should be immutable");
testArray.addAll(testArray);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.addAll(int, C) trying to modify JsonArray list which should be immutable");
testArray.addAll(0, testArray);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.clear() trying to modify JsonArray list which should be immutable");
testArray.clear();
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.remove(int) trying to modify JsonArray list which should be immutable");
testArray.remove(0);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonArray.removeAll(C) trying to modify JsonArray list which should be immutable");
testArray.removeAll(testArray);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException trying to modify JsonArray list which should be immutable");
testArray.remove(JsonValue.TRUE);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonArrayExceptionTests Failed");
+ assertTrue(pass, "jsonArrayExceptionTests Failed");
}
/*
@@ -1271,92 +1252,91 @@
* specified value that is null.
*/
@Test
- public void jsonArrayNullValueExceptionTests() throws Fault {
+ public void jsonArrayNullValueExceptionTests() {
boolean pass = true;
JsonArrayBuilder jab = Json.createArrayBuilder();
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(JsonValue) when JsonValue is null.");
jab.add((JsonValue) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(BigInteger) when BigInteger is null.");
jab.add((BigInteger) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(JsonArrayBuilder) when JsonArrayBuilder is null.");
jab.add((JsonArrayBuilder) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(JsonObjectBuilder) when JsonObjectBuilder is null.");
jab.add((JsonObjectBuilder) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(BigDecimal) when BigDecimal is null.");
jab.add((BigDecimal) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(String) when String is null.");
jab.add((String) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonArrayNullValueExceptionTests Failed");
+ assertTrue(pass, "jsonArrayNullValueExceptionTests Failed");
}
/*
@@ -1369,7 +1349,7 @@
* 1.1.
*/
@Test
- public void jsonCreateArrayBuilder11Test() throws Fault {
+ public void jsonCreateArrayBuilder11Test() {
ArrayBuilders createTest = new ArrayBuilders();
final TestResult result = createTest.test();
result.eval();
@@ -1387,7 +1367,7 @@
* 1.1.
*/
@Test
- public void jsonArrayBuilder11AddTest() throws Fault {
+ public void jsonArrayBuilder11AddTest() {
ArrayBuildAdd addTest = new ArrayBuildAdd();
final TestResult result = addTest.test();
result.eval();
@@ -1404,7 +1384,7 @@
* 1.1.
*/
@Test
- public void jsonArrayBuilder11SetTest() throws Fault {
+ public void jsonArrayBuilder11SetTest() {
ArrayBuildSet setTest = new ArrayBuildSet();
final TestResult result = setTest.test();
result.eval();
@@ -1419,7 +1399,7 @@
* 1.1.
*/
@Test
- public void jsonArrayBuilder11RemoveTest() throws Fault {
+ public void jsonArrayBuilder11RemoveTest() {
ArrayBuildRemove removeTest = new ArrayBuildRemove();
final TestResult result = removeTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/BuilderFactory.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/BuilderFactory.java
index 0ba5076..0955a04 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/BuilderFactory.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/BuilderFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -26,6 +26,8 @@
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -36,6 +38,7 @@
*/
public class BuilderFactory {
+ private static final Logger LOGGER = Logger.getLogger(BuilderFactory.class.getName());
/**
* {@link JsonBuilderFactory} API methods added in JSON-P 1.1.
@@ -45,7 +48,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonBuilderFactory API methods added in JSON-P 1.1.");
- System.out.println("JsonBuilderFactory API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonBuilderFactory API methods added in JSON-P 1.1.");
testCreateArrayBuilderString(result);
testCreateArrayBuilderInt(result);
testCreateArrayBuilderBool(result);
@@ -67,7 +70,7 @@
* Test suite result.
*/
private void testCreateArrayBuilderString(final TestResult result) {
- System.out.println(" - createArrayBuilder(JsonArray) for String");
+ LOGGER.info(" - createArrayBuilder(JsonArray) for String");
final JsonArray in = createStringArray2();
final JsonArray check = createStringArray2();
verifyCreateArrayBuilder(result, check, in);
@@ -81,7 +84,7 @@
* Test suite result.
*/
private void testCreateArrayBuilderInt(final TestResult result) {
- System.out.println(" - createArrayBuilder(JsonArray) for int");
+ LOGGER.info(" - createArrayBuilder(JsonArray) for int");
final JsonArray in = createIntArray2();
final JsonArray check = createIntArray2();
verifyCreateArrayBuilder(result, check, in);
@@ -95,7 +98,7 @@
* Test suite result.
*/
private void testCreateArrayBuilderBool(final TestResult result) {
- System.out.println(" - createArrayBuilder(JsonArray) for boolean");
+ LOGGER.info(" - createArrayBuilder(JsonArray) for boolean");
final JsonArray in = createBoolArray2();
final JsonArray check = createBoolArray2();
verifyCreateArrayBuilder(result, check, in);
@@ -109,7 +112,7 @@
* Test suite result.
*/
private void testCreateArrayBuilderObject(final TestResult result) {
- System.out.println(" - createArrayBuilder(JsonArray) for JsonObject");
+ LOGGER.info(" - createArrayBuilder(JsonArray) for JsonObject");
final JsonArray in = createObjectArray2();
final JsonArray check = createObjectArray2();
verifyCreateArrayBuilder(result, check, in);
@@ -123,7 +126,7 @@
* Test suite result.
*/
private void testCreateArrayBuilderNull(final TestResult result) {
- System.out.println(" - createArrayBuilder(JsonArray) for null");
+ LOGGER.info(" - createArrayBuilder(JsonArray) for null");
final JsonArray in = null;
final JsonBuilderFactory factory = Json.createBuilderFactory(null);
try {
@@ -131,7 +134,7 @@
result.fail("createArrayBuilder(JsonArray)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(
+ LOGGER.info(
" - Expected exception for null argument: " + e.getMessage());
} catch (Throwable t) {
result.fail("createObjectBuilder(JsonObject)",
@@ -148,7 +151,7 @@
* Test suite result.
*/
private void testCreateObjectBuilderString(final TestResult result) {
- System.out.println(" - createObjectBuilder(JsonObject) for String");
+ LOGGER.info(" - createObjectBuilder(JsonObject) for String");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createSimpleObjectStr();
verifyCreateObjectBuilder(result, check, in);
@@ -162,7 +165,7 @@
* Test suite result.
*/
private void testCreateObjectBuilderInt(final TestResult result) {
- System.out.println(" - createObjectBuilder(JsonObject) for int");
+ LOGGER.info(" - createObjectBuilder(JsonObject) for int");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createSimpleObjectInt();
verifyCreateObjectBuilder(result, check, in);
@@ -176,7 +179,7 @@
* Test suite result.
*/
private void testCreateObjectBuilderBool(final TestResult result) {
- System.out.println(" - createObjectBuilder(JsonObject) for boolean");
+ LOGGER.info(" - createObjectBuilder(JsonObject) for boolean");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createSimpleObjectBool();
verifyCreateObjectBuilder(result, check, in);
@@ -190,7 +193,7 @@
* Test suite result.
*/
private void testCreateObjectBuilderObject(final TestResult result) {
- System.out.println(" - createObjectBuilder(JsonObject) for JsonObject");
+ LOGGER.info(" - createObjectBuilder(JsonObject) for JsonObject");
final JsonObject in = createSimpleObjectObject();
final JsonObject check = createSimpleObjectObject();
verifyCreateObjectBuilder(result, check, in);
@@ -232,7 +235,7 @@
*/
private void verifyCreateObjectBuilder(final TestResult result,
final JsonObject check, final JsonObject in) {
- System.out.println(" - IN: " + valueToString(in));
+ LOGGER.info(" - IN: " + valueToString(in));
final JsonBuilderFactory factory = Json.createBuilderFactory(null);
final JsonObjectBuilder builder = factory.createObjectBuilder(in);
final JsonObject out = builder.build();
@@ -250,7 +253,7 @@
* Test suite result.
*/
private void testCreateObjectBuilderNull(final TestResult result) {
- System.out.println(" - createObjectBuilder(JsonObject) for null");
+ LOGGER.info(" - createObjectBuilder(JsonObject) for null");
final JsonObject in = null;
final JsonBuilderFactory factory = Json.createBuilderFactory(null);
try {
@@ -258,7 +261,7 @@
result.fail("createObjectBuilder(JsonObject)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(
+ LOGGER.info(
" - Expected exception for null argument: " + e.getMessage());
} catch (Throwable t) {
result.fail("createObjectBuilder(JsonObject)",
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/ClientTests.java
index 94ad80c..aa0b72f 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonbuilderfactorytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,28 +21,20 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.*;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -58,31 +50,31 @@
* object = builderFactory.createObjectBuilder()
*/
@Test
- public void jsonBuilderFactoryTest1() throws Fault {
+ public void jsonBuilderFactoryTest1() {
boolean pass = true;
try {
- System.out.println("Create JsonBuilderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonBuilderFactory with Map<String, ?> with EMPTY config");
JsonBuilderFactory builderFactory = Json
.createBuilderFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = builderFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("---------------------------------------------------");
- System.out.println("TEST CASE [JsonBuilderFactory.createArrayBuilder()]");
- System.out.println("---------------------------------------------------");
- System.out.println("Create JsonArrayBuilder using JsonBuilderFactory");
+ LOGGER.info("---------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonBuilderFactory.createArrayBuilder()]");
+ LOGGER.info("---------------------------------------------------");
+ LOGGER.info("Create JsonArrayBuilder using JsonBuilderFactory");
JsonArray expJsonArray = JSONP_Util.createJsonArrayFromString("[0,2]");
JsonArray actJsonArray = builderFactory.createArrayBuilder().add(0).add(2)
.build();
if (!JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray))
pass = false;
- System.out.println("----------------------------------------------------");
- System.out.println("TEST CASE [JsonBuilderFactory.createObjectBuilder()]");
- System.out.println("----------------------------------------------------");
- System.out.println("Create JsonObjectBuilder using JsonBuilderFactory");
+ LOGGER.info("----------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonBuilderFactory.createObjectBuilder()]");
+ LOGGER.info("----------------------------------------------------");
+ LOGGER.info("Create JsonObjectBuilder using JsonBuilderFactory");
JsonObject expJsonObject = JSONP_Util
.createJsonObjectFromString("{\"foo\":\"bar\"}");
JsonObject actJsonObject = builderFactory.createObjectBuilder()
@@ -91,10 +83,9 @@
pass = false;
} catch (Exception e) {
- throw new Fault("jsonBuilderFactoryTest1 Failed: ", e);
+ fail("jsonBuilderFactoryTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonBuilderFactoryTest1 Failed");
+ assertTrue(pass, "jsonBuilderFactoryTest1 Failed");
}
/*
@@ -111,33 +102,32 @@
* (empty config) 2) non supported provider property
*/
@Test
- public void jsonBuilderFactoryTest2() throws Fault {
+ public void jsonBuilderFactoryTest2() {
boolean pass = true;
JsonBuilderFactory builderFactory;
Map<String, ?> config;
try {
- System.out.println("----------------------------------------------");
- System.out.println("Test scenario1: no supported provider property");
- System.out.println("----------------------------------------------");
- System.out.println("Create JsonBuilderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test scenario1: no supported provider property");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Create JsonBuilderFactory with Map<String, ?> with EMPTY config");
builderFactory = Json.createBuilderFactory(JSONP_Util.getEmptyConfig());
config = builderFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-----------------------------------------------");
- System.out.println("Test scenario2: non supported provider property");
- System.out.println("-----------------------------------------------");
- System.out.println("Create JsonBuilderFactory with Map<String, ?> with FOO config");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Test scenario2: non supported provider property");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Create JsonBuilderFactory with Map<String, ?> with FOO config");
builderFactory = Json.createBuilderFactory(JSONP_Util.getFooConfig());
config = builderFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonBuilderFactoryTest2 Failed: ", e);
+ fail("jsonBuilderFactoryTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonBuilderFactoryTest2 Failed");
+ assertTrue(pass, "jsonBuilderFactoryTest2 Failed");
}
/*
@@ -148,7 +138,7 @@
* @test_Strategy: Tests JsonBuilderFactory API methods added in JSON-P 1.1.
*/
@Test
- public void jsonBuilderFactory11Test() throws Fault {
+ public void jsonBuilderFactory11Test() {
BuilderFactory factoryTest = new BuilderFactory();
final TestResult result = factoryTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsoncoding/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsoncoding/ClientTests.java
index cecc832..97a6493 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsoncoding/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsoncoding/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,24 +19,17 @@
*/
package jakarta.jsonp.tck.api.jsoncoding;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import jakarta.json.Json;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.*;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -47,26 +40,25 @@
* @test_Strategy: Encode and decode Json Pointer as defined by RFC 6901
*/
@Test
- public void jsonEncodeTest() throws Fault {
+ public void jsonEncodeTest() {
String DECODED = "/a/~b/c";
String ENCODED = "~1a~1~0b~1c";
StringBuilder error = new StringBuilder();
- System.out.println("----------------------------------------------");
- System.out.println("Test encode " + DECODED);
- System.out.println("----------------------------------------------");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test encode " + DECODED);
+ LOGGER.info("----------------------------------------------");
String encoded = Json.encodePointer(DECODED);
if (!ENCODED.equals(encoded))
error.append("The pointer ").append(DECODED)
.append(" has been encoded as ").append(encoded).append('\n');
- System.out.println("----------------------------------------------");
- System.out.println("Test decode " + ENCODED);
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test decode " + ENCODED);
String decoded = Json.decodePointer(ENCODED);
if (!DECODED.equals(decoded))
error.append("The pointer ").append(ENCODED)
.append(" has been decoded as ").append(decoded).append('\n');
- if (error.length() != 0)
- throw new Fault(error.toString());
- System.out.println("----------------------------------------------");
+ assertEquals(0, error.length(), error.toString());
+ LOGGER.info("----------------------------------------------");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratorfactorytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratorfactorytests/ClientTests.java
index af39a34..69715f4 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratorfactorytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratorfactorytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,33 +23,20 @@
import jakarta.json.stream.*;
import java.io.*;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.Map;
-import java.util.ArrayList;
+import java.util.logging.Logger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -65,62 +52,61 @@
* generatorFactory.createGenerator(Writer)
*/
@Test
- public void jsonGeneratorFactoryTest1() throws Fault {
+ public void jsonGeneratorFactoryTest1() {
boolean pass = true;
JsonGenerator generator1 = null;
JsonGenerator generator2 = null;
String expString;
String actString;
try {
- System.out.println(
+ LOGGER.info(
"Create JsonGeneratorFactory with Map<String, ?> with PRETTY_PRINTING config");
JsonGeneratorFactory generatorFactory = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = generatorFactory.getConfigInUse();
String[] props = { JsonGenerator.PRETTY_PRINTING, };
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
- System.out.println("--------------------------------------------------------");
- System.out.println("TEST CASE [JsonGeneratorFactory.createGenerator(Writer)]");
- System.out.println("--------------------------------------------------------");
- System.out.println("Create 1st JsonGenerator using JsonGeneratorFactory");
+ LOGGER.info("--------------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonGeneratorFactory.createGenerator(Writer)]");
+ LOGGER.info("--------------------------------------------------------");
+ LOGGER.info("Create 1st JsonGenerator using JsonGeneratorFactory");
StringWriter sWriter1 = new StringWriter();
generator1 = generatorFactory.createGenerator(sWriter1);
if (generator1 == null) {
- System.err.println("GeneratorFactory failed to create generator1");
+ LOGGER.warning("GeneratorFactory failed to create generator1");
pass = false;
} else {
generator1.writeStartObject().writeEnd();
generator1.close();
}
- System.out.println("sWriter1=" + sWriter1.toString());
+ LOGGER.info("sWriter1=" + sWriter1.toString());
expString = "{}";
actString = JSONP_Util.removeWhitespace(sWriter1.toString());
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println("Create 2nd JsonGenerator using JsonGeneratorFactory");
+ LOGGER.info("Create 2nd JsonGenerator using JsonGeneratorFactory");
StringWriter sWriter2 = new StringWriter();
generator2 = generatorFactory.createGenerator(sWriter2);
if (generator2 == null) {
- System.err.println("GeneratorFactory failed to create generator2");
+ LOGGER.warning("GeneratorFactory failed to create generator2");
pass = false;
} else {
generator2.writeStartArray().writeEnd();
generator2.close();
}
- System.out.println("sWriter2=" + sWriter2.toString());
+ LOGGER.info("sWriter2=" + sWriter2.toString());
expString = "[]";
actString = JSONP_Util.removeWhitespace(sWriter2.toString());
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonGeneratorFactoryTest1 Failed: ", e);
+ fail("jsonGeneratorFactoryTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorFactoryTest1 Failed");
+ assertTrue(pass, "jsonGeneratorFactoryTest1 Failed");
}
/*
@@ -138,67 +124,66 @@
* Create generator with both UTF-8 and UTF-16BE.
*/
@Test
- public void jsonGeneratorFactoryTest2() throws Fault {
+ public void jsonGeneratorFactoryTest2() {
boolean pass = true;
JsonGenerator generator1 = null;
JsonGenerator generator2 = null;
String expString, actString;
try {
- System.out.println(
+ LOGGER.info(
"Create JsonGeneratorFactory with Map<String, ?> with PRETTY_PRINTING config");
JsonGeneratorFactory generatorFactory = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = generatorFactory.getConfigInUse();
String[] props = { JsonGenerator.PRETTY_PRINTING, };
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [JsonGeneratorFactory.createGenerator(OutputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create 1st JsonGenerator using JsonGeneratorFactory with UTF-8 encoding");
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
generator1 = generatorFactory.createGenerator(baos1, JSONP_Util.UTF_8);
if (generator1 == null) {
- System.err.println("GeneratorFactory failed to create generator1");
+ LOGGER.warning("GeneratorFactory failed to create generator1");
pass = false;
} else {
generator1.writeStartObject().writeEnd();
generator1.close();
}
- System.out.println("baos1=" + baos1.toString("UTF-8"));
+ LOGGER.info("baos1=" + baos1.toString("UTF-8"));
expString = "{}";
actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonGenerator using JsonGeneratorFactory with UTF-16BE encoding");
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
generator2 = generatorFactory.createGenerator(baos2, JSONP_Util.UTF_16BE);
if (generator2 == null) {
- System.err.println("GeneratorFactory failed to create generator2");
+ LOGGER.warning("GeneratorFactory failed to create generator2");
pass = false;
} else {
generator2.writeStartArray().writeEnd();
generator2.close();
}
- System.out.println("baos2=" + baos2.toString("UTF-16BE"));
+ LOGGER.info("baos2=" + baos2.toString("UTF-16BE"));
expString = "[]";
actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-16BE"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonGeneratorFactoryTest2 Failed: ", e);
+ fail("jsonGeneratorFactoryTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorFactoryTest2 Failed");
+ assertTrue(pass, "jsonGeneratorFactoryTest2 Failed");
}
/*
@@ -214,65 +199,64 @@
* generatorFactory.createGenerator(OutputStream)
*/
@Test
- public void jsonGeneratorFactoryTest3() throws Fault {
+ public void jsonGeneratorFactoryTest3() {
boolean pass = true;
JsonGenerator generator1 = null;
JsonGenerator generator2 = null;
String expString;
String actString;
try {
- System.out.println(
+ LOGGER.info(
"Create JsonGeneratorFactory with Map<String, ?> with PRETTY_PRINTING config");
JsonGeneratorFactory generatorFactory = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = generatorFactory.getConfigInUse();
String[] props = { JsonGenerator.PRETTY_PRINTING, };
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [JsonGeneratorFactory.createGenerator(OutputStream os)]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------");
- System.out.println("Create 1st JsonGenerator using JsonGeneratorFactory");
+ LOGGER.info("Create 1st JsonGenerator using JsonGeneratorFactory");
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
generator1 = generatorFactory.createGenerator(baos1);
if (generator1 == null) {
- System.err.println("GeneratorFactory failed to create generator1");
+ LOGGER.warning("GeneratorFactory failed to create generator1");
pass = false;
} else {
generator1.writeStartObject().writeEnd();
generator1.close();
}
- System.out.println("baos1=" + baos1.toString("UTF-8"));
+ LOGGER.info("baos1=" + baos1.toString("UTF-8"));
expString = "{}";
actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println("Create 2nd JsonGenerator using JsonGeneratorFactory");
+ LOGGER.info("Create 2nd JsonGenerator using JsonGeneratorFactory");
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
generator2 = generatorFactory.createGenerator(baos2);
if (generator2 == null) {
- System.err.println("GeneratorFactory failed to create generator2");
+ LOGGER.warning("GeneratorFactory failed to create generator2");
pass = false;
} else {
generator2.writeStartArray().writeEnd();
generator2.close();
}
- System.out.println("baos2=" + baos2.toString("UTF-8"));
+ LOGGER.info("baos2=" + baos2.toString("UTF-8"));
expString = "[]";
actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonGeneratorFactoryTest3 Failed: ", e);
+ fail("jsonGeneratorFactoryTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorFactoryTest3 Failed");
+ assertTrue(pass, "jsonGeneratorFactoryTest3 Failed");
}
/*
@@ -291,15 +275,15 @@
* supported provider property
*/
@Test
- public void jsonGeneratorFactoryTest4() throws Fault {
+ public void jsonGeneratorFactoryTest4() {
boolean pass = true;
JsonGeneratorFactory generatorFactory;
Map<String, ?> config;
try {
- System.out.println("----------------------------------------------");
- System.out.println("Test scenario1: no supported provider property");
- System.out.println("----------------------------------------------");
- System.out.println(
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test scenario1: no supported provider property");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info(
"Create JsonGeneratorFactory with Map<String, ?> with EMPTY config");
generatorFactory = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig());
@@ -307,10 +291,10 @@
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-------------------------------------------");
- System.out.println("Test scenario2: supported provider property");
- System.out.println("-------------------------------------------");
- System.out.println(
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info("Test scenario2: supported provider property");
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info(
"Create JsonGeneratorFactory with Map<String, ?> with PRETTY_PRINTING config");
generatorFactory = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig());
@@ -319,18 +303,17 @@
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
- System.out.println("-------------------------------------------------------------");
- System.out.println("Test scenario3: supported and non supported provider property");
- System.out.println("-------------------------------------------------------------");
- System.out.println("Create JsonGeneratorFactory with Map<String, ?> with all config");
+ LOGGER.info("-------------------------------------------------------------");
+ LOGGER.info("Test scenario3: supported and non supported provider property");
+ LOGGER.info("-------------------------------------------------------------");
+ LOGGER.info("Create JsonGeneratorFactory with Map<String, ?> with all config");
generatorFactory = Json.createGeneratorFactory(JSONP_Util.getAllConfig());
config = generatorFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonGeneratorFactoryTest4 Failed: ", e);
+ fail("jsonGeneratorFactoryTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorFactoryTest4 Failed");
+ assertTrue(pass, "jsonGeneratorFactoryTest4 Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/ClientTests.java
index fc47578..02332c5 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/ClientTests.java
@@ -21,31 +21,24 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.*;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.*;
import jakarta.json.stream.*;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* private Utility methods */
/*********************************************************************************
@@ -61,7 +54,7 @@
.write(JsonValue.NULL).writeEnd().writeEnd();
generator.close();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
}
}
@@ -78,7 +71,7 @@
.writeEnd().writeEnd();
generator.close();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
}
}
@@ -87,7 +80,7 @@
*********************************************************************************/
private String generateJsonObject() {
try {
- System.out.println("Generate a JsonObject");
+ LOGGER.info("Generate a JsonObject");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("emptyString", "")
@@ -123,7 +116,7 @@
generator.close();
return sWriter.toString();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
@@ -133,7 +126,7 @@
*********************************************************************************/
private JsonObject buildJsonObject() {
try {
- System.out.println("Build a JsonObject");
+ LOGGER.info("Build a JsonObject");
JsonObject jsonObject = Json.createObjectBuilder().add("emptyString", "")
.add("emptyArray", Json.createArrayBuilder())
.add("emptyObject", Json.createObjectBuilder())
@@ -172,7 +165,7 @@
.build();
return jsonObject;
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
@@ -182,7 +175,7 @@
*********************************************************************************/
private String generateJsonArray() {
try {
- System.out.println("Generate a JsonArray");
+ LOGGER.info("Generate a JsonArray");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("").writeStartArray().writeEnd()
@@ -215,7 +208,7 @@
generator.close();
return sWriter.toString();
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
@@ -225,7 +218,7 @@
*********************************************************************************/
private JsonArray buildJsonArray() {
try {
- System.out.println("Build a JsonArray");
+ LOGGER.info("Build a JsonArray");
JsonArray jsonArray = Json.createArrayBuilder().add("")
.add(Json.createArrayBuilder()).add(Json.createObjectBuilder())
.add("string").add(Integer.MIN_VALUE).add(Integer.MAX_VALUE)
@@ -259,7 +252,7 @@
.build();
return jsonArray;
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
+ LOGGER.warning("Exception occurred: " + e);
return null;
}
}
@@ -282,25 +275,22 @@
* null}, "array":["string", 1, true, false, null] }
*/
@Test
- public void jsonGeneratorObjectTest1() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectTest1() {
try {
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generateSimpleJsonObject(generator);
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(sWriter.toString());
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectTest1 Failed: ", e);
+ fail("jsonGeneratorObjectTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectTest1 Failed");
}
/*
@@ -327,8 +317,7 @@
* }
*/
@Test
- public void jsonGeneratorObjectTest2() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectTest2() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json.createGenerator(baos);
@@ -355,10 +344,10 @@
.writeEnd();
generator.close();
- System.out.println("Dump of string: " + baos.toString("UTF-8"));
+ LOGGER.info("Dump of string: " + baos.toString("UTF-8"));
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"emptyString\":\"\",\"emptyArray\":[],\"emptyObject\":{},\"string\":\"string\","
+ "\"intMin\":" + Integer.MIN_VALUE + "," + "\"intMax\":"
+ Integer.MAX_VALUE + "," + "\"longMin\":" + Long.MIN_VALUE + ","
@@ -372,15 +361,13 @@
+ "\"\\\\\\\"\\\\\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM\""
+ "}";
- System.out.println("Read the JSON text back from OutputStream removing whitespace");
+ LOGGER.info("Read the JSON text back from OutputStream removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectTest2 Failed: ", e);
+ fail("jsonGeneratorObjectTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectTest2 Failed");
}
/*
@@ -414,8 +401,7 @@
* }
*/
@Test
- public void jsonGeneratorObjectTest3() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectTest3() {
try {
JsonObject expJsonObject = buildJsonObject();
String jsonText = generateJsonObject();
@@ -424,14 +410,14 @@
JsonObject actJsonObject = (JsonObject) reader.read();
// Do comparison
- System.out.println("Compare expJsonObject and actJsonObject for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject);
+ LOGGER.info("Compare expJsonObject and actJsonObject for equality");
+ assertTrue(
+ JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject),
+ "jsonGeneratorObjectTest3 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectTest3 Failed: ", e);
+ fail("jsonGeneratorObjectTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectTest3 Failed");
}
/*
@@ -456,10 +442,9 @@
* Charset);
*/
@Test
- public void jsonGeneratorObjectTest4() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectTest4() {
try {
- System.out.println("Create generator output in UTF-16BE encoding.");
+ LOGGER.info("Create generator output in UTF-16BE encoding.");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -467,18 +452,16 @@
generateSimpleJsonObject(generator);
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println(
+ LOGGER.info(
"Read the JSON text back encoding from OutputStream using UTF-16BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectTest4 Failed: ", e);
+ fail("jsonGeneratorObjectTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectTest4 Failed");
}
/*
@@ -497,8 +480,7 @@
* {"unicodechars":"\u0000\u000f\u001f\u00ff\uff00\uffff"}
*/
@Test
- public void jsonGeneratorObjectTest5() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectTest5() {
JsonReader reader = null;
String expUnicodeChars = "\u0000\u000f\u001f\u00ff\uff00\uffff";
try {
@@ -511,21 +493,18 @@
generator.close();
sWriter.close();
- System.out.println("Testing read of " + sWriter.toString());
+ LOGGER.info("Testing read of " + sWriter.toString());
reader = Json.createReader(new StringReader(sWriter.toString()));
JsonObject jsonObject = reader.readObject();
String actUnicodeChars = jsonObject.getJsonString("unicodechars")
.getString();
reader.close();
- System.out.println("actUnicodeChars=" + actUnicodeChars);
+ LOGGER.info("actUnicodeChars=" + actUnicodeChars);
- pass = JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars);
+ assertTrue(JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars), "jsonGeneratorObjectTest5 Failed");
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
- pass = false;
+ fail("Exception occurred: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectTest5 Failed");
}
/*
@@ -544,25 +523,22 @@
*
*/
@Test
- public void jsonGeneratorArrayTest1() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorArrayTest1() {
try {
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generateSimpleJsonArray(generator);
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "[{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},[\"string\",1,true,false,null]]";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(sWriter.toString());
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorArrayTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorArrayTest1 Failed: ", e);
+ fail("jsonGeneratorArrayTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorArrayTest1 Failed");
}
/*
@@ -587,8 +563,7 @@
* ]
*/
@Test
- public void jsonGeneratorArrayTest2() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorArrayTest2() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json.createGenerator(baos);
@@ -613,10 +588,10 @@
.writeEnd();
generator.close();
- System.out.println("Dump of string: " + baos.toString("UTF-8"));
+ LOGGER.info("Dump of string: " + baos.toString("UTF-8"));
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "[\"\",[],{},\"string\"," + Integer.MIN_VALUE + ","
+ Integer.MAX_VALUE + "," + Long.MIN_VALUE + "," + Long.MAX_VALUE
+ "," + "true,false,null,{\"emptyString\":\"\",\"emptyArray\":[],"
@@ -628,15 +603,13 @@
+ "\"\\\\\\\"\\\\\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM\""
+ "]";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorArrayTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorArrayTest2 Failed: ", e);
+ fail("jsonGeneratorArrayTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorArrayTest2 Failed");
}
/*
@@ -665,25 +638,22 @@
* ]
*/
@Test
- public void jsonGeneratorArrayTest3() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorArrayTest3() {
try {
JsonArray expJsonArray = buildJsonArray();
String jsonText = generateJsonArray();
- System.out.println("generator json text: " + jsonText);
+ LOGGER.info("generator json text: " + jsonText);
JsonReader reader = Json.createReader(new StringReader(jsonText));
JsonArray actJsonArray = (JsonArray) reader.read();
// Do comparison
- System.out.println("Compare expJsonArray and actJsonArray for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray);
+ LOGGER.info("Compare expJsonArray and actJsonArray for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray), "jsonGeneratorArrayTest3 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorArrayTest3 Failed: ", e);
+ fail("jsonGeneratorArrayTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorArrayTest3 Failed");
}
/*
@@ -704,10 +674,9 @@
*
*/
@Test
- public void jsonGeneratorArrayTest4() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorArrayTest4() {
try {
- System.out.println("Create generator output in UTF-16BE encoding.");
+ LOGGER.info("Create generator output in UTF-16BE encoding.");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -715,18 +684,16 @@
generateSimpleJsonArray(generator);
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "[{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},[\"string\",1,true,false,null]]";
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorArrayTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorArrayTest4 Failed: ", e);
+ fail("jsonGeneratorArrayTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorArrayTest4 Failed");
}
/*
@@ -745,8 +712,7 @@
* ["\u0000\u000f\u001f\u00ff\uff00\uffff"]
*/
@Test
- public void jsonGeneratorArrayTest5() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorArrayTest5() {
JsonReader reader = null;
String expUnicodeChars = "\u0000\u000f\u001f\u00ff\uff00\uffff";
try {
@@ -758,20 +724,17 @@
generator.close();
sWriter.close();
- System.out.println("Testing read of " + sWriter.toString());
+ LOGGER.info("Testing read of " + sWriter.toString());
reader = Json.createReader(new StringReader(sWriter.toString()));
JsonArray jsonArray = reader.readArray();
String actUnicodeChars = jsonArray.getJsonString(0).getString();
reader.close();
- System.out.println("actUnicodeChars=" + actUnicodeChars);
+ LOGGER.info("actUnicodeChars=" + actUnicodeChars);
- pass = JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars);
+ assertTrue(JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars), "jsonGeneratorArrayTest5 Failed");
} catch (Exception e) {
- System.err.println("Exception occurred: " + e);
- pass = false;
+ fail("JsonGeneratorArrayTest5 Failed. Exception occurred:", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorArrayTest5 Failed");
}
/*
@@ -794,10 +757,9 @@
* ?>).createGenerator(Writer)
*/
@Test
- public void jsonGeneratorObjectConfigTest1() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectConfigTest1() {
try {
- System.out.println("Create JsonGenerator using configuration with PRETTY_PRINTING");
+ LOGGER.info("Create JsonGenerator using configuration with PRETTY_PRINTING");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig())
@@ -805,20 +767,18 @@
generateSimpleJsonObject(generator);
// Dump JsonText output with PRETTY_PRINTING feature
- System.out.println("PRETTY_PRINTING feature\n" + sWriter.toString());
+ LOGGER.info("PRETTY_PRINTING feature\n" + sWriter.toString());
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(sWriter.toString());
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectConfigTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectConfigTest1 Failed: ", e);
+ fail("jsonGeneratorObjectConfigTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectConfigTest1 Failed");
}
/*
@@ -841,10 +801,9 @@
* ?>).createGenerator(OutputStream)
*/
@Test
- public void jsonGeneratorObjectConfigTest2() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectConfigTest2() {
try {
- System.out.println("Create JsonGenerator using configuration with PRETTY_PRINTING");
+ LOGGER.info("Create JsonGenerator using configuration with PRETTY_PRINTING");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig())
@@ -852,20 +811,18 @@
generateSimpleJsonObject(generator);
// Dump JsonText output with PRETTY_PRINTING feature
- System.out.println("PRETTY_PRINTING feature\n" + baos.toString("UTF-8"));
+ LOGGER.info("PRETTY_PRINTING feature\n" + baos.toString("UTF-8"));
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectConfigTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectConfigTest2 Failed: ", e);
+ fail("jsonGeneratorObjectConfigTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectConfigTest2 Failed");
}
/*
@@ -885,10 +842,9 @@
* null}, "array":["string", 1, true, false, null] }
*/
@Test
- public void jsonGeneratorObjectEncodingTest1() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectEncodingTest1() {
try {
- System.out.println("Create JsonGenerator using UTF-8 encoding");
+ LOGGER.info("Create JsonGenerator using UTF-8 encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -896,21 +852,19 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generator Output=" + baos.toString("UTF-8"));
+ LOGGER.info("Generator Output=" + baos.toString("UTF-8"));
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectEncodingTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectEncodingTest1 Failed: ", e);
+ fail("jsonGeneratorObjectEncodingTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectEncodingTest1 Failed");
}
/*
@@ -935,10 +889,9 @@
* ?>).createGenerator(OutputStream, Charset);
*/
@Test
- public void jsonGeneratorObjectEncodingTest2() throws Fault {
- boolean pass = true;
+ public void jsonGeneratorObjectEncodingTest2() {
try {
- System.out.println(
+ LOGGER.info(
"Create JsonGenerator using configuration with PRETTY_PRINTING using UTF-16BE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
@@ -947,21 +900,19 @@
generateSimpleJsonObject(generator);
// Dump JsonText output with PRETTY_PRINTING feature
- System.out.println("PRETTY_PRINTING feature\n" + baos.toString("UTF-16BE"));
+ LOGGER.info("PRETTY_PRINTING feature\n" + baos.toString("UTF-16BE"));
// Do comparison
- System.out.println("Create expected JSON text with no whitespace");
+ LOGGER.info("Create expected JSON text with no whitespace");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE"));
- pass = JSONP_Util.assertEqualsJsonText(expJson, actJson);
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJson, actJson), "jsonGeneratorObjectEncodingTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonGeneratorObjectEncodingTest2 Failed: ", e);
+ fail("jsonGeneratorObjectEncodingTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonGeneratorObjectEncodingTest2 Failed");
}
/*
@@ -984,19 +935,19 @@
* null}, "array":["string", 1, true, false, null] }
*/
@Test
- public void jsonGeneratorUTFEncodedTests() throws Fault {
+ public void jsonGeneratorUTFEncodedTests() {
boolean pass = true;
- System.out.println(
+ LOGGER.info(
"Create expected JSON text with no whitespace for use with comparison");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
try {
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-8]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-8 encoding");
+ LOGGER.info("Create JsonGenerator using UTF-8 encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1004,10 +955,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-8"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-8"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1015,16 +966,16 @@
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing generation to UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing generation to UTF-8 encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-16]");
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-16 encoding");
+ LOGGER.info("Create JsonGenerator using UTF-16 encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1032,10 +983,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16 encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1043,16 +994,16 @@
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing generation to UTF-16 encoding: " + e);
+ LOGGER.warning("Exception occurred testing generation to UTF-16 encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-16LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-16LE encoding");
+ LOGGER.info("Create JsonGenerator using UTF-16LE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1060,10 +1011,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16LE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16LE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16LE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16LE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1071,17 +1022,17 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-16LE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-16BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-16BE encoding");
+ LOGGER.info("Create JsonGenerator using UTF-16BE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1089,10 +1040,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16BE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16BE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1100,17 +1051,17 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-16BE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-32LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-32LE encoding");
+ LOGGER.info("Create JsonGenerator using UTF-32LE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1118,10 +1069,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-32LE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-32LE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-32LE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32LE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1129,17 +1080,17 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-32LE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createGeneratorFactory(Map<String,?>).createGenerator(OutputStream, Charset) as UTF-32BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonGenerator using UTF-32BE encoding");
+ LOGGER.info("Create JsonGenerator using UTF-32BE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json
.createGeneratorFactory(JSONP_Util.getEmptyConfig())
@@ -1147,10 +1098,10 @@
generateSimpleJsonObject(generator);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-32BE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-32BE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-32BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32BE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -1158,11 +1109,10 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-32BE encoding: " + e);
}
- if (!pass)
- throw new Fault("jsonGeneratorUTFEncodedTests Failed");
+ assertTrue(pass, "jsonGeneratorUTFEncodedTests Failed");
}
/*
@@ -1185,834 +1135,833 @@
*
*/
@Test
- public void jsonGeneratorExceptionTests() throws Fault {
+ public void jsonGeneratorExceptionTests() {
boolean pass = true;
// Test NumberFormatException for write(double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write(Double.NaN);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test NumberFormatException for write(double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write(Double.NEGATIVE_INFINITY);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test NumberFormatException for write(double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write(Double.POSITIVE_INFINITY);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test NumberFormatException for write(String,double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("badnumber", Double.NaN);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test NumberFormatException for write(String,double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("badnumber", Double.NEGATIVE_INFINITY);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test NumberFormatException for write(String,double) if value is
// Not-a-Number(NaN) or infinity
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("badnumber", Double.POSITIVE_INFINITY);
- System.err.println("Did not get expected NumberFormatException");
+ LOGGER.warning("Did not get expected NumberFormatException");
pass = false;
} catch (NumberFormatException e) {
- System.out.println("Caught expected NumberFormatException");
+ LOGGER.info("Caught expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonGenerationExceptipn if an incomplete JSON is generated.
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationExceptipn if an incomplete JSON is generated.");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("name", "value");
generator.close();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonGenerationExceptipn if an incomplete JSON is generated.
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationExceptipn if an incomplete JSON is generated.");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string");
generator.close();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(JsonValue) if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(JsonValue) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(JsonValue.TRUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String) if not called within array
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("name");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(BigInteger) if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(BigInteger) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject()
.write(new BigInteger(new Integer(Integer.MAX_VALUE).toString()));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(BigDecimal) if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(BigDecimal) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(BigDecimal.valueOf(Integer.MIN_VALUE));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(int) if not called within array
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(int) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(Integer.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(long) if not called within array
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(long) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(Long.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(double) if not called within array
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(double) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(Double.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(boolean) if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(boolean) if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write(true);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeNull() if not called within array
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeNull() if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeNull();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeStartArray() if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeStartArray() if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeStartArray();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeStartObject() if not called within
// array context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeStartObject() if not called within array context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeStartObject();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,JsonValue) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,JsonValue) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", JsonValue.TRUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,String) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,String) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", "name");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,BigInteger) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,BigInteger) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string",
new BigInteger(new Integer(Integer.MAX_VALUE).toString()));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,BigDecimal) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,BigDecimal) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string",
BigDecimal.valueOf(Integer.MIN_VALUE));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,int) if not called within
// object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,int) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", Integer.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,long) if not called within
// object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,long) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", Long.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,double) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,double) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", Double.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,boolean) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,boolean) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write("string", true);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeNull(String) if not called within
// object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeNull(String) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeNull("string");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeStartArray(String) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeStartArray(String) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeStartArray("string");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeStartObject(String) if not called
// within object context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeStartObject(String) if not called within object context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeStartObject("string");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,JsonValue) when invoked
// after the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,JsonValue) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name", "value");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeEnd() when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeEnd() when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().writeEnd();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,BigInteger) when invoked
// after the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,BigInteger) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name",
new BigInteger(new Integer(Integer.MAX_VALUE).toString()));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,BigDecimal) when invoked
// after the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,BigDecimal) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name",
BigDecimal.valueOf(Integer.MIN_VALUE));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,int) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,int) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name", Integer.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,long) when invoked after
// the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,long) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name", Long.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,double) when invoked after
// the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,double) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name", Double.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String,boolean) when invoked after
// the writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String,boolean) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().write("name", false);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for writeNull(String) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for writeNull(String) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeEnd().writeNull("name");
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(JsonValue) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(JsonValue) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(JsonValue.TRUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(String) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(String) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(JsonValue.TRUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(BigDecimal) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(BigDecimal) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd()
.write(BigDecimal.valueOf(Integer.MIN_VALUE));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(BigInteger) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(BigInteger) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd()
.write(new BigInteger(new Integer(Integer.MAX_VALUE).toString()));
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(int) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(int) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(Integer.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(long) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(long) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(Long.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(double) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(double) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(Double.MAX_VALUE);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for write(boolean) when invoked after the
// writeEnd method is called
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for write(boolean) when invoked after the writeEnd method is called");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().write(true);
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test JsonGenerationException for for writeNull() when invoked with no
// context
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonGenerationException for for writeNull() when invoked with no context");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().writeEnd().writeNull();
- System.err.println("Did not get expected JsonGenerationException");
+ LOGGER.warning("Did not get expected JsonGenerationException");
pass = false;
} catch (JsonGenerationException e) {
- System.out.println("Caught expected JsonGenerationException");
+ LOGGER.info("Caught expected JsonGenerationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonGeneratorExceptionTests Failed");
+ assertTrue(pass, "jsonGeneratorExceptionTests Failed");
}
/*
@@ -2028,29 +1977,29 @@
* {"object":{},"array":[]}
*/
@Test
- public void flushTest() throws Fault {
+ public void flushTest() {
boolean pass = true;
try {
- System.out.println("Generate some partial Json and flush output.");
+ LOGGER.info("Generate some partial Json and flush output.");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().writeStartObject("object").writeEnd()
.flush();
// Do comparison 1
- System.out.println("Create expected partial JSON text with no whitespace");
+ LOGGER.info("Create expected partial JSON text with no whitespace");
String expJson = "{\"object\":{}";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
String actJson = JSONP_Util.removeWhitespace(sWriter.toString());
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
pass = false;
- System.out.println("Generate additional Json to complete and flush output.");
+ LOGGER.info("Generate additional Json to complete and flush output.");
generator.writeStartArray("array").writeEnd().writeEnd().flush();
// Do comparison 2
expJson = "{\"object\":{},\"array\":[]}";
- System.out.println("Read the JSON text back from Writer removing whitespace");
+ LOGGER.info("Read the JSON text back from Writer removing whitespace");
actJson = JSONP_Util.removeWhitespace(sWriter.toString());
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
pass = false;
@@ -2058,10 +2007,9 @@
generator.close();
} catch (Exception e) {
- throw new Fault("flushTest Failed: ", e);
+ fail("flushTest Failed: ", e);
}
- if (!pass)
- throw new Fault("flushTest Failed");
+ assertTrue(pass, "flushTest Failed");
}
/*
@@ -2073,49 +2021,48 @@
*
*/
@Test
- public void jsonGeneratorIOErrorTests() throws Fault {
+ public void jsonGeneratorIOErrorTests() {
boolean pass = true;
// Trip JsonException if there is an i/o error on JsonGenerator.close()
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonGenerator.close().");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
JsonGenerator generator = Json.createGenerator(mbw);
generator.writeStartObject().writeEnd();
mbw.setThrowIOException(true);
- System.out.println("Calling JsonGenerator.close()");
+ LOGGER.info("Calling JsonGenerator.close()");
generator.close();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on JsonGenerator.flush()
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonGenerator.flush().");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
JsonGenerator generator = Json.createGenerator(mbw);
generator.writeStartObject().writeEnd();
mbw.setThrowIOException(true);
- System.out.println("Calling JsonGenerator.flush()");
+ LOGGER.info("Calling JsonGenerator.flush()");
generator.flush();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonGeneratorIOErrorTests Failed");
+ assertTrue(pass, "jsonGeneratorIOErrorTests Failed");
}
/*
@@ -2133,7 +2080,7 @@
* "value = false / null / true / object / array / number / string"}
*/
@Test
- public void jsonGeneratorDocumentRootTest() throws Fault {
+ public void jsonGeneratorDocumentRootTest() {
Generator genTest = new Generator();
final TestResult result = genTest.test();
result.eval();
@@ -2143,7 +2090,7 @@
* @testName: jsonGeneratorStreamNotClosedTest
*/
@Test
- public void jsonGeneratorStreamNotClosedTest() throws Fault {
+ public void jsonGeneratorStreamNotClosedTest() {
ByteArrayOutputStreamCloseChecker stream = new ByteArrayOutputStreamCloseChecker();
JsonGenerator gen = Json.createGenerator(stream);
try {
@@ -2151,11 +2098,11 @@
gen.write("foo", "bar");
// no end object
gen.close();
- throw new Fault("It is expected a JsonGenerationException");
+ throw new AssertionFailedError("It is expected a JsonGenerationException");
} catch (JsonGenerationException e) {
if (stream.closed) {
// Stream should not be closed
- throw new Fault("The underlying stream is closed but it shouldn't because JSON object was not completed");
+ throw new AssertionFailedError("The underlying stream is closed but it shouldn't because JSON object was not completed");
}
}
}
@@ -2164,7 +2111,7 @@
* @testName: jsonGeneratorStreamClosedTest
*/
@Test
- public void jsonGeneratorStreamClosedTest() throws Fault {
+ public void jsonGeneratorStreamClosedTest() {
ByteArrayOutputStreamCloseChecker stream = new ByteArrayOutputStreamCloseChecker();
JsonGenerator gen = Json.createGenerator(stream);
gen.writeStartObject();
@@ -2173,7 +2120,7 @@
gen.close();
if (!stream.closed) {
// Stream should be closed
- throw new Fault("The underlying stream has to be closed because JSON object was completed");
+ throw new AssertionFailedError("The underlying stream has to be closed because JSON object was completed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/Generator.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/Generator.java
index 0064716..03dde1b 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/Generator.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsongeneratortests/Generator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,8 @@
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonReader;
import jakarta.json.JsonValue;
@@ -38,6 +40,8 @@
*/
public class Generator {
+ private static final Logger LOGGER = Logger.getLogger(Generator.class.getName());
+
/** Tests input data. */
private static final Object[] VALUES = new Object[] { OBJ_VALUE, // write(JsonValue)
// for
@@ -61,7 +65,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonGenerator API methods for RFC 7159 grammar changes.");
- System.out.println("JsonGenerator API methods for RFC 7159 grammar changes.");
+ LOGGER.info("JsonGenerator API methods for RFC 7159 grammar changes.");
testPrimitiveTypesInRoot(result);
testWrittingObjectByParts(result);
return result;
@@ -75,7 +79,7 @@
private void testPrimitiveTypesInRoot(final TestResult result) {
for (Object value : VALUES) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - write(JsonValue) for " + typeName + " as an argument");
+ LOGGER.info(" - write(JsonValue) for " + typeName + " as an argument");
verifyJsonGeneratorForJsonValue(result, value);
verifyJsonGeneratorForSimpleType(result, value);
}
@@ -87,7 +91,7 @@
* and {@code write(String)}.
*/
private void testWrittingObjectByParts(final TestResult result) {
- System.out.println(" - generate JSON object");
+ LOGGER.info(" - generate JSON object");
final StringWriter strWriter = new StringWriter();
try (JsonGenerator generator = Json.createGenerator(strWriter)) {
generator.writeStartObject();
@@ -99,12 +103,12 @@
final JsonObject check = createSimpleObjectStr();
if (operationFailed(check, out)) {
final String checkStr = check.toString();
- System.out.println(
+ LOGGER.info(
" Generated JSON object " + out + " shall be " + checkStr);
result.fail("generate JSON object",
"Generated value " + out + " shall be " + checkStr);
} else {
- System.out.println(" Output: " + out);
+ LOGGER.info(" Output: " + out);
}
}
@@ -122,11 +126,11 @@
final String out = strWriter.toString();
if (operationFailed(jsonValue, out)) {
final String check = jsonValue.toString();
- System.out.println(" Generated JSON value " + out + " shall be " + check);
+ LOGGER.info(" Generated JSON value " + out + " shall be " + check);
result.fail("write(JsonValue)",
"Generated value " + out + " shall be " + check);
} else {
- System.out.println(" Output (JsonValue): " + out);
+ LOGGER.info(" Output (JsonValue): " + out);
}
}
@@ -175,11 +179,11 @@
final String out = strWriter.toString();
if (operationFailed(value, out)) {
final String check = toJsonValue(value).toString();
- System.out.println(" Generated simple value " + out + " shall be " + check);
+ LOGGER.info(" Generated simple value " + out + " shall be " + check);
result.fail("write(JsonValue)",
"Generated value " + out + " shall be " + check);
} else {
- System.out.println(" Output (simple): " + out);
+ LOGGER.info(" Output (simple): " + out);
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonnumbertests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonnumbertests/ClientTests.java
index 6c79b66..c3fa387 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonnumbertests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonnumbertests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,36 +20,19 @@
package jakarta.jsonp.tck.api.jsonnumbertests;
import jakarta.json.*;
-import jakarta.json.stream.*;
-
-import java.io.*;
-
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.math.BigDecimal;
-import java.math.BigInteger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -62,47 +45,46 @@
* JsonNumbers and compare them for equality and expect false.
*/
@Test
- public void jsonNumberEqualsTest() throws Fault {
+ public void jsonNumberEqualsTest() {
boolean pass = true;
try {
- System.out.println("Create sample JsonNumber 1 for testing");
+ LOGGER.info("Create sample JsonNumber 1 for testing");
JsonNumber number1 = JSONP_Util.createJsonNumber(10);
- System.out.println("number1=" + JSONP_Util.toStringJsonNumber(number1));
+ LOGGER.info("number1=" + JSONP_Util.toStringJsonNumber(number1));
- System.out.println("Create sample JsonNumber 2 for testing");
+ LOGGER.info("Create sample JsonNumber 2 for testing");
JsonNumber number2 = JSONP_Util.createJsonNumber(10);
- System.out.println("number2=" + JSONP_Util.toStringJsonNumber(number2));
+ LOGGER.info("number2=" + JSONP_Util.toStringJsonNumber(number2));
- System.out.println(
+ LOGGER.info(
"Call JsonNumber.equals() to compare 2 equal JsonNumbers and expect true");
if (number1.equals(number2)) {
- System.out.println("JsonNumbers are equal - expected.");
+ LOGGER.info("JsonNumbers are equal - expected.");
} else {
pass = false;
- System.err.println("JsonNumbers are not equal - unexpected.");
+ LOGGER.warning("JsonNumbers are not equal - unexpected.");
}
- System.out.println("Create sample JsonNumber 1 for testing");
+ LOGGER.info("Create sample JsonNumber 1 for testing");
number1 = JSONP_Util.createJsonNumber(10);
- System.out.println("number1=" + JSONP_Util.toStringJsonNumber(number1));
+ LOGGER.info("number1=" + JSONP_Util.toStringJsonNumber(number1));
- System.out.println("Create sample JsonNumber 2 for testing");
+ LOGGER.info("Create sample JsonNumber 2 for testing");
number2 = JSONP_Util.createJsonNumber((double) 10.25);
- System.out.println("number2=" + JSONP_Util.toStringJsonNumber(number2));
+ LOGGER.info("number2=" + JSONP_Util.toStringJsonNumber(number2));
- System.out.println(
+ LOGGER.info(
"Call JsonNumber.equals() to compare 2 equal JsonNumbers and expect false");
if (!number1.equals(number2)) {
- System.out.println("JsonNumbers are not equal - expected.");
+ LOGGER.info("JsonNumbers are not equal - expected.");
} else {
pass = false;
- System.err.println("JsonNumbers are equal - unexpected.");
+ LOGGER.warning("JsonNumbers are equal - unexpected.");
}
} catch (Exception e) {
- throw new Fault("jsonNumberEqualsTest Failed: ", e);
+ fail("jsonNumberEqualsTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonNumberEqualsTest Failed");
+ assertTrue(pass, "jsonNumberEqualsTest Failed");
}
/*
@@ -115,51 +97,50 @@
* JsonNumbers and compare them for hashcode and expect false.
*/
@Test
- public void jsonNumberHashCodeTest() throws Fault {
+ public void jsonNumberHashCodeTest() {
boolean pass = true;
try {
- System.out.println("Create sample JsonNumber 1 for testing");
+ LOGGER.info("Create sample JsonNumber 1 for testing");
JsonNumber number1 = JSONP_Util.createJsonNumber(10);
- System.out.println("number1=" + JSONP_Util.toStringJsonNumber(number1));
- System.out.println("number1.hashCode()=" + number1.hashCode());
+ LOGGER.info("number1=" + JSONP_Util.toStringJsonNumber(number1));
+ LOGGER.info("number1.hashCode()=" + number1.hashCode());
- System.out.println("Create sample JsonNumber 2 for testing");
+ LOGGER.info("Create sample JsonNumber 2 for testing");
JsonNumber number2 = JSONP_Util.createJsonNumber(10);
- System.out.println("number2=" + JSONP_Util.toStringJsonNumber(number2));
- System.out.println("number2.hashCode()=" + number2.hashCode());
+ LOGGER.info("number2=" + JSONP_Util.toStringJsonNumber(number2));
+ LOGGER.info("number2.hashCode()=" + number2.hashCode());
- System.out.println(
+ LOGGER.info(
"Call JsonNumber.hashCode() to compare 2 equal JsonNumbers and expect true");
if (number1.hashCode() == number2.hashCode()) {
- System.out.println("JsonNumbers hashCode are equal - expected.");
+ LOGGER.info("JsonNumbers hashCode are equal - expected.");
} else {
pass = false;
- System.err.println("JsonNumbers hashCode are not equal - unexpected.");
+ LOGGER.warning("JsonNumbers hashCode are not equal - unexpected.");
}
- System.out.println("Create sample JsonNumber 1 for testing");
+ LOGGER.info("Create sample JsonNumber 1 for testing");
number1 = JSONP_Util.createJsonNumber(10);
- System.out.println("number1=" + JSONP_Util.toStringJsonNumber(number1));
- System.out.println("number1.hashCode()=" + number1.hashCode());
+ LOGGER.info("number1=" + JSONP_Util.toStringJsonNumber(number1));
+ LOGGER.info("number1.hashCode()=" + number1.hashCode());
- System.out.println("Create sample JsonNumber 2 for testing");
+ LOGGER.info("Create sample JsonNumber 2 for testing");
number2 = JSONP_Util.createJsonNumber((double) 10.25);
- System.out.println("number2=" + JSONP_Util.toStringJsonNumber(number2));
- System.out.println("number2.hashCode()=" + number2.hashCode());
+ LOGGER.info("number2=" + JSONP_Util.toStringJsonNumber(number2));
+ LOGGER.info("number2.hashCode()=" + number2.hashCode());
- System.out.println(
+ LOGGER.info(
"Call JsonNumber.hashCode() to compare 2 equal JsonNumbers and expect false");
if (number1.hashCode() != number2.hashCode()) {
- System.out.println("JsonNumbers hashCode are not equal - expected.");
+ LOGGER.info("JsonNumbers hashCode are not equal - expected.");
} else {
pass = false;
- System.err.println("JsonNumbers hashCode are equal - unexpected.");
+ LOGGER.warning("JsonNumbers hashCode are equal - unexpected.");
}
} catch (Exception e) {
- throw new Fault("jsonNumberHashCodeTest Failed: ", e);
+ fail("jsonNumberHashCodeTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonNumberHashCodeTest Failed");
+ assertTrue(pass, "jsonNumberHashCodeTest Failed");
}
/*
@@ -170,7 +151,7 @@
* @test_Strategy: Test JsonNumber.isIntegral() method.
*/
@Test
- public void jsonNumberIsIntegralTest() throws Fault {
+ public void jsonNumberIsIntegralTest() {
boolean pass = true;
JsonNumber jsonNumber = null;
try {
@@ -194,10 +175,9 @@
}
} catch (Exception e) {
- throw new Fault("jsonNumberIsIntegralTest Failed: ", e);
+ fail("jsonNumberIsIntegralTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonNumberIsIntegralTest Failed");
+ assertTrue(pass, "jsonNumberIsIntegralTest Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ClientTests.java
index 503e66c..95a4aad 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ClientTests.java
@@ -19,8 +19,7 @@
*/
package jakarta.jsonp.tck.api.jsonobjecttests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import jakarta.jsonp.tck.api.common.TestResult;
import java.io.StringReader;
import java.io.StringWriter;
@@ -28,13 +27,7 @@
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.Json;
import jakarta.json.JsonArray;
@@ -46,20 +39,19 @@
import jakarta.json.JsonString;
import jakarta.json.JsonValue;
import jakarta.json.JsonWriter;
-import jakarta.jsonp.tck.api.common.ObjectBuilder;
-import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.JSONP_Data;
import jakarta.jsonp.tck.common.JSONP_Util;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -76,16 +68,15 @@
* JsonObject values matches the expected Map of JsonObject values.
*/
@Test
- public void jsonObjectTest1() throws Fault {
- boolean pass = true;
+ public void jsonObjectTest1() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
- System.out.println("Create the expected map of JsonObject values");
+ LOGGER.info("Create the expected map of JsonObject values");
Map<String, JsonValue> expMap = new HashMap<>();
expMap.put("false", JsonValue.FALSE);
expMap.put("true", JsonValue.TRUE);
@@ -108,7 +99,7 @@
expMap.put("array", array);
JSONP_Util.dumpMap(expMap, "Expected Map");
- System.out.println("Create JsonObject using all JsonObjectBuilder API's");
+ LOGGER.info("Create JsonObject using all JsonObjectBuilder API's");
JsonObject myJsonObject = Json.createObjectBuilder()
.add("false", JsonValue.FALSE).add("true", JsonValue.TRUE)
.add("null", JsonValue.NULL).add("doublemin", Double.MIN_VALUE)
@@ -122,14 +113,12 @@
Map<String, JsonValue> actMap = myJsonObject;
JSONP_Util.dumpMap(actMap, "Actual Map");
- System.out.println(
+ LOGGER.info(
"Compare actual Map of JsonObject values with expected Map of JsonObject values");
- pass = JSONP_Util.assertEqualsMap(expMap, actMap);
+ assertTrue(JSONP_Util.assertEqualsMap(expMap, actMap), "jsonObjectTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonObjectTest1 Failed: ", e);
+ fail("jsonObjectTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonObjectTest1 Failed");
}
/*
@@ -148,16 +137,15 @@
* equal.
*/
@Test
- public void jsonObjectTest2() throws Fault {
- boolean pass = true;
+ public void jsonObjectTest2() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
- System.out.println(
+ LOGGER.info(
"Create JsonObject 'myJsonObject1' using all JsonObjectBuilder API's");
JsonObject myJsonObject1 = Json.createObjectBuilder()
.add("false", JsonValue.FALSE).add("true", JsonValue.TRUE)
@@ -170,34 +158,32 @@
.add("string", "string1").add("false2", false).add("true2", true)
.addNull("null2").add("object", object).add("array", array).build();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
StringWriter sw = new StringWriter();
try (JsonWriter writer = Json.createWriter(sw)) {
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sw.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
- System.out.println(
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
+ LOGGER.info(
"Read the JsonObject back into 'myJsonObject2' using a JsonReader");
JsonObject myJsonObject2;
try (JsonReader reader = Json.createReader(new StringReader(contents))) {
myJsonObject2 = reader.readObject();
- System.out.println("Save contents of the JsonReader as a String");
+ LOGGER.info("Save contents of the JsonReader as a String");
contents = reader.toString();
}
- System.out.println("Dump contents of JsonReader as a String");
- System.out.println("JsonReaderContents=" + contents);
+ LOGGER.info("Dump contents of JsonReader as a String");
+ LOGGER.info("JsonReaderContents=" + contents);
- System.out.println("Compare myJsonObject1 and myJsonObject2 for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2);
+ LOGGER.info("Compare myJsonObject1 and myJsonObject2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2), "jsonObjectTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonObjectTest2 Failed: ", e);
+ fail("jsonObjectTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonObjectTest2 Failed");
}
/*
@@ -222,16 +208,16 @@
* JsonObject.getString(String, String)
*/
@Test
- public void jsonObjectTest3() throws Fault {
+ public void jsonObjectTest3() {
boolean pass = true;
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject object = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray array = JSONP_Util.createSampleJsonArray();
- System.out.println("Create myObject JsonObject with 22 name/value pairs");
+ LOGGER.info("Create myObject JsonObject with 22 name/value pairs");
JsonObject myObject = Json.createObjectBuilder().add("key0", -1)
.add("key1", +1).add("key2", 1).add("key3", -1e3).add("key4", +1e3)
.add("key5", 1e3).add("key6", -2E3).add("key7", +2E3).add("key8", 2E3)
@@ -244,140 +230,140 @@
.add("key19", JsonValue.NULL).add("key20", JSONP_Data.asciiCharacters)
.add("key21", false).add("key22", true).addNull("key23")
.add("key24", object).add("key25", array).build();
- System.out.println("Checking intValue of key0 for correctness");
+ LOGGER.info("Checking intValue of key0 for correctness");
if (!JSONP_Util.assertEquals(-1,
myObject.getJsonNumber("key0").intValue()))
pass = false;
- System.out.println("key0 via JsonNumber.toString()="
+ LOGGER.info("key0 via JsonNumber.toString()="
+ myObject.getJsonNumber("key0").toString());
- System.out.println("Checking intValue of key1 for correctness");
+ LOGGER.info("Checking intValue of key1 for correctness");
if (!JSONP_Util.assertEquals(1, myObject.getInt("key1")))
pass = false;
- System.out.println("key1 via JsonNumber.toString()=" + myObject.getInt("key1"));
- System.out.println("Checking intValue of key2 for correctness");
+ LOGGER.info("key1 via JsonNumber.toString()=" + myObject.getInt("key1"));
+ LOGGER.info("Checking intValue of key2 for correctness");
if (!JSONP_Util.assertEquals(1,
myObject.getJsonNumber("key2").intValue()))
pass = false;
- System.out.println("key2 via JsonNumber.toString()="
+ LOGGER.info("key2 via JsonNumber.toString()="
+ myObject.getJsonNumber("key2").toString());
- System.out.println("Checking intValue of key3 for correctness");
+ LOGGER.info("Checking intValue of key3 for correctness");
if (!JSONP_Util.assertEquals(-1000, myObject.getInt("key3")))
pass = false;
- System.out.println("key3 via JsonNumber.toString()="
+ LOGGER.info("key3 via JsonNumber.toString()="
+ myObject.getJsonNumber("key3").toString());
- System.out.println("Checking intValue of key4 for correctness");
+ LOGGER.info("Checking intValue of key4 for correctness");
if (!JSONP_Util.assertEquals(1000,
myObject.getJsonNumber("key4").intValue()))
pass = false;
- System.out.println("key4 via JsonNumber.toString()="
+ LOGGER.info("key4 via JsonNumber.toString()="
+ myObject.getJsonNumber("key4").toString());
- System.out.println("Checking intValue of key5 for correctness");
+ LOGGER.info("Checking intValue of key5 for correctness");
if (!JSONP_Util.assertEquals(1000,
myObject.getJsonNumber("key5").intValue()))
pass = false;
- System.out.println("key5 via JsonNumber.toString()="
+ LOGGER.info("key5 via JsonNumber.toString()="
+ myObject.getJsonNumber("key5").toString());
- System.out.println("Checking intValue of key6 for correctness");
+ LOGGER.info("Checking intValue of key6 for correctness");
if (!JSONP_Util.assertEquals(-2000,
myObject.getJsonNumber("key6").intValue()))
pass = false;
- System.out.println("key6 via JsonNumber.toString()="
+ LOGGER.info("key6 via JsonNumber.toString()="
+ myObject.getJsonNumber("key6").toString());
- System.out.println("Checking intValue of key7 for correctness");
+ LOGGER.info("Checking intValue of key7 for correctness");
if (!JSONP_Util.assertEquals(2000,
myObject.getJsonNumber("key7").intValue()))
pass = false;
- System.out.println("key7 via JsonNumber.toString()="
+ LOGGER.info("key7 via JsonNumber.toString()="
+ myObject.getJsonNumber("key7").toString());
- System.out.println("Checking intValue of key8 for correctness");
+ LOGGER.info("Checking intValue of key8 for correctness");
if (!JSONP_Util.assertEquals(2000,
myObject.getJsonNumber("key8").intValue()))
pass = false;
- System.out.println("key8 via JsonNumber.toString()="
+ LOGGER.info("key8 via JsonNumber.toString()="
+ myObject.getJsonNumber("key8").toString());
- System.out.println("Checking longValue of key9 for correctness");
+ LOGGER.info("Checking longValue of key9 for correctness");
if (!JSONP_Util.assertEquals(Long.MAX_VALUE,
myObject.getJsonNumber("key9").longValue()))
pass = false;
- System.out.println("LongMax via JsonNumber.toString()="
+ LOGGER.info("LongMax via JsonNumber.toString()="
+ myObject.getJsonNumber("key9").toString());
if (!JSONP_Util.assertEquals("" + Long.MAX_VALUE,
myObject.getJsonNumber("key9").toString()))
pass = false;
- System.out.println("Checking longValue of key10 for correctness");
+ LOGGER.info("Checking longValue of key10 for correctness");
if (!JSONP_Util.assertEquals(Long.MIN_VALUE,
myObject.getJsonNumber("key10").longValue()))
pass = false;
- System.out.println("LongMin via JsonNumber.toString()="
+ LOGGER.info("LongMin via JsonNumber.toString()="
+ myObject.getJsonNumber("key10").toString());
if (!JSONP_Util.assertEquals("" + Long.MIN_VALUE,
myObject.getJsonNumber("key10").toString()))
pass = false;
- System.out.println("Checking intValue of key11 for correctness");
+ LOGGER.info("Checking intValue of key11 for correctness");
if (!JSONP_Util.assertEquals(Integer.MAX_VALUE,
myObject.getJsonNumber("key11").intValue()))
pass = false;
- System.out.println("IntMax via JsonNumber.toString()="
+ LOGGER.info("IntMax via JsonNumber.toString()="
+ myObject.getJsonNumber("key11").toString());
if (!JSONP_Util.assertEquals("" + Integer.MAX_VALUE,
myObject.getJsonNumber("key11").toString()))
pass = false;
- System.out.println("Checking intValue of key12 for correctness");
+ LOGGER.info("Checking intValue of key12 for correctness");
if (!JSONP_Util.assertEquals(Integer.MIN_VALUE,
myObject.getJsonNumber("key12").intValue()))
pass = false;
- System.out.println("IntMin via JsonNumber.toString()="
+ LOGGER.info("IntMin via JsonNumber.toString()="
+ myObject.getJsonNumber("key12").toString());
if (!JSONP_Util.assertEquals("" + Integer.MIN_VALUE,
myObject.getJsonNumber("key12").toString()))
pass = false;
- System.out.println("Checking doubleValue of key13 for correctness");
+ LOGGER.info("Checking doubleValue of key13 for correctness");
if (!JSONP_Util.assertEquals(Double.MAX_VALUE,
myObject.getJsonNumber("key13").doubleValue()))
pass = false;
- System.out.println("Checking doubleValue of key14 for correctness");
+ LOGGER.info("Checking doubleValue of key14 for correctness");
if (!JSONP_Util.assertEquals(Double.MIN_VALUE,
myObject.getJsonNumber("key14").doubleValue()))
pass = false;
- System.out.println("Checking bigDecimalValue of key15 for correctness");
+ LOGGER.info("Checking bigDecimalValue of key15 for correctness");
if (!JSONP_Util.assertEquals(BigDecimal.valueOf(123456789.123456789),
myObject.getJsonNumber("key15").bigDecimalValue()))
pass = false;
- System.out.println("Checking bigIntegerValue of key16 for correctness");
+ LOGGER.info("Checking bigIntegerValue of key16 for correctness");
if (!JSONP_Util.assertEquals(new BigInteger("123456789"),
myObject.getJsonNumber("key16").bigIntegerValue()))
pass = false;
- System.out.println("Checking getBoolean of key17 for correctness");
+ LOGGER.info("Checking getBoolean of key17 for correctness");
if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key17")))
pass = false;
- System.out.println("Checking getBoolean of key18 for correctness");
+ LOGGER.info("Checking getBoolean of key18 for correctness");
if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key18")))
pass = false;
- System.out.println("Checking isNull of key19 for correctness");
+ LOGGER.info("Checking isNull of key19 for correctness");
if (!JSONP_Util.assertEquals(true, myObject.isNull("key19")))
pass = false;
- System.out.println("Checking getJsonString of key20 for correctness");
+ LOGGER.info("Checking getJsonString of key20 for correctness");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myObject.getJsonString("key20").getString()))
pass = false;
- System.out.println("Checking getString of key20 for correctness");
+ LOGGER.info("Checking getString of key20 for correctness");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myObject.getString("key20")))
pass = false;
- System.out.println("Checking getBoolean of key21 for correctness");
+ LOGGER.info("Checking getBoolean of key21 for correctness");
if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key21")))
pass = false;
- System.out.println("Checking getBoolean of key22 for correctness");
+ LOGGER.info("Checking getBoolean of key22 for correctness");
if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key22")))
pass = false;
- System.out.println("Checking isNull of key23 for correctness");
+ LOGGER.info("Checking isNull of key23 for correctness");
if (!JSONP_Util.assertEquals(true, myObject.isNull("key23")))
pass = false;
- System.out.println("Checking getJsonObject of key24 for correctness");
+ LOGGER.info("Checking getJsonObject of key24 for correctness");
if (!JSONP_Util.assertEqualsJsonObjects(object,
myObject.getJsonObject("key24")))
pass = false;
- System.out.println("Checking getJsonArray of key25 for correctness");
+ LOGGER.info("Checking getJsonArray of key25 for correctness");
if (!JSONP_Util.assertEqualsJsonArrays(array,
myObject.getJsonArray("key25")))
pass = false;
@@ -389,7 +375,7 @@
pass = false;
// Verify calls to JsonObject.getBoolean(String, boolean)
- System.out.println(
+ LOGGER.info(
"Testing JsonObject.getBoolean(String, boolean) with/without default value setting.");
if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key17", false)))
pass = false;
@@ -407,7 +393,7 @@
pass = false;
// Verify calls to JsonObject.getInt(String, int)
- System.out.println(
+ LOGGER.info(
"Testing JsonObject.getInt(String, int) with/without default value setting.");
if (!JSONP_Util.assertEquals(-1, myObject.getInt("key0", 10)))
pass = false;
@@ -423,7 +409,7 @@
pass = false;
// Verify calls to JsonObject.getString(String, String)
- System.out.println(
+ LOGGER.info(
"Testing JsonObject.getString(String, String) with/without default value setting.");
if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters,
myObject.getString("key20", "foo")))
@@ -440,10 +426,9 @@
pass = false;
} catch (Exception e) {
- throw new Fault("jsonObjectTest3 Failed: ", e);
+ fail("jsonObjectTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonObjectTest3 Failed");
+ assertTrue(pass, "jsonObjectTest3 Failed");
}
/*
@@ -458,32 +443,30 @@
* expected based on the JsonObject.
*/
@Test
- public void jsonObjectTest4() throws Fault {
- boolean pass = true;
+ public void jsonObjectTest4() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
StringWriter sw = new StringWriter();
try (JsonWriter writer = Json.createWriter(sw)) {
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sw.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
- System.out.println("Remove whitespace from contents.");
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
+ LOGGER.info("Remove whitespace from contents.");
String actJsonText = JSONP_Util.removeWhitespace(contents);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonObject text with actual JsonObject text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonText),
+ "jsonObjectTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonObjectTest4 Failed: ", e);
+ fail("jsonObjectTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonObjectTest4 Failed");
}
/*
@@ -500,468 +483,468 @@
* java.lang.NullPointerException
*/
@Test
- public void jsonObjectExceptionTests() throws Fault {
+ public void jsonObjectExceptionTests() {
boolean pass = true;
JsonObject testObject = null;
JsonArray testArray = null;
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
testObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
testArray = JSONP_Util.createSampleJsonArray();
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonNumber via getJsonNumber(String)");
JsonNumber value = testObject.getJsonNumber("address");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonString via getJsonString(String)");
JsonString value = testObject.getJsonString("address");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to JsonArray via getJsonArray(String)");
JsonArray value = testObject.getJsonArray("address");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonNumber via getNumber(String)");
JsonNumber value = testObject.getJsonNumber("phoneNumber");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonString via getJsonString(String)");
JsonString value = testObject.getJsonString("phoneNumber");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to String via getString(String)");
String value = testObject.getString("address");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to String via getString(String)");
String value = testObject.getString("phoneNumber");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonObject to int via getInt(String)");
int value = testObject.getInt("address");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to int via getInt(String)");
int value = testObject.getInt("phoneNumber");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonArray to JsonObject via getJsonObject(String)");
JsonObject value = testObject.getJsonObject("phoneNumber");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonNumber to JsonString via getJsonString(String)");
JsonString value = testObject.getJsonString("age");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonNumber to JsonObject via getJsonNumber(String)");
JsonObject value = testObject.getJsonObject("age");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonNumber to JsonArray via getJsonArray(String)");
JsonArray value = testObject.getJsonArray("age");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to JsonNumber via getJsonNumber(String)");
JsonNumber value = testObject.getJsonNumber("firstName");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to int via getInt(String)");
int value = testObject.getInt("firstName");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to JsonObject via getJsonString(String)");
JsonObject value = testObject.getJsonObject("firstName");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonString to JsonArray via getJsonArray(String)");
JsonArray value = testObject.getJsonArray("firstName");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonValue.FALSE to JsonNumber via getJsonNumber(String)");
JsonNumber value = testObject.getJsonNumber("elderly");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonValue.FALSE to JsonString via getJsonString(String)");
JsonString value = testObject.getJsonString("elderly");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonValue.FALSE to JsonObject via getJsonObject(String)");
JsonObject value = testObject.getJsonObject("elderly");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a JsonValue.FALSE to JsonArray via getJsonArray(String)");
JsonArray value = testObject.getJsonArray("elderly");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)");
boolean value = testObject.getBoolean("firstName");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)");
boolean value = testObject.getBoolean("age");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)");
boolean value = testObject.getBoolean("objectOfFooBar");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip ClassCastException
try {
- System.out.println(
+ LOGGER.info(
"Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)");
boolean value = testObject.getBoolean("arrayOfFooBar");
pass = false;
- System.err.println("Failed to throw ClassCastException");
+ LOGGER.warning("Failed to throw ClassCastException");
} catch (ClassCastException e) {
- System.out.println("Got expected ClassCastException");
+ LOGGER.info("Got expected ClassCastException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Testing NumberFormatException calling add(String, Double.NaN)
try {
- System.out.println("Trip NumberFormatException calling add(String, Double.NaN)");
+ LOGGER.info("Trip NumberFormatException calling add(String, Double.NaN)");
JsonObject object = Json.createObjectBuilder().add("double", Double.NaN)
.build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Testing NumberFormatException calling add(String,
// Double.NEGATIVE_INFINITY)
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException calling add(String, Double.NEGATIVE_INFINITY)");
JsonObject object = Json.createObjectBuilder()
.add("double", Double.NEGATIVE_INFINITY).build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Testing NumberFormatException calling add(String,
// Double.POSITIVE_INFINITY)
try {
- System.out.println(
+ LOGGER.info(
"Trip NumberFormatException calling add(String, Double.POSITIVE_INFINITY)");
JsonObject object = Json.createObjectBuilder()
.add("double", Double.POSITIVE_INFINITY).build();
pass = false;
- System.err.println("Failed to throw NumberFormatException");
+ LOGGER.warning("Failed to throw NumberFormatException");
} catch (NumberFormatException e) {
- System.out.println("Got expected NumberFormatException");
+ LOGGER.info("Got expected NumberFormatException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact integer value");
JsonObject object = Json.createObjectBuilder().add("number", 12345.12345)
.build();
- System.out.println("Call JsonObject.getJsonNumber(\"number\").intValueExact()");
+ LOGGER.info("Call JsonObject.getJsonNumber(\"number\").intValueExact()");
int value = object.getJsonNumber("number").intValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact long value");
JsonObject object = Json.createObjectBuilder().add("number", 12345.12345)
.build();
- System.out.println("Call JsonObject.getJsonNumber(\"number\").longValueExact()");
+ LOGGER.info("Call JsonObject.getJsonNumber(\"number\").longValueExact()");
long value = object.getJsonNumber("number").longValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Test for ArithmeticException
try {
- System.out.println(
+ LOGGER.info(
"Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact biginteger value");
JsonObject object = Json.createObjectBuilder().add("number", 12345.12345)
.build();
- System.out.println(
+ LOGGER.info(
"Call JsonObject.getJsonNumber(\"number\").bigIntegerValueExact()");
BigInteger value = object.getJsonNumber("number").bigIntegerValueExact();
pass = false;
- System.err.println("Failed to throw ArithmeticException");
+ LOGGER.warning("Failed to throw ArithmeticException");
} catch (ArithmeticException e) {
- System.out.println("Got expected ArithmeticException");
+ LOGGER.info("Got expected ArithmeticException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Tests for UnsupportedOperationException using Collection methods to
@@ -969,118 +952,117 @@
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonObject.put(K,V) trying to modify JsonObject map which should be immutable");
testObject.put("foo", JsonValue.FALSE);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonObject.putAll(Map) trying to modify JsonObject map which should be immutable");
testObject.putAll(testObject);
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonObject.clear() trying to modify JsonObject map which should be immutable");
testObject.clear();
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip UnsupportedOperationException
try {
- System.out.println(
+ LOGGER.info(
"Trip UnsupportedOperationException JsonObject.remove(K) trying to modify JsonObject map which should be immutable");
testObject.remove("firstName");
pass = false;
- System.err.println("Failed to throw UnsupportedOperationException");
+ LOGGER.warning("Failed to throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- System.out.println("Got expected UnsupportedOperationException");
+ LOGGER.info("Got expected UnsupportedOperationException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.getBoolean(String) when no mapping exists for name.");
boolean value = testObject.getBoolean("foo");
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.getInt(String) when no mapping exists for name.");
int value = testObject.getInt("foo");
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.getString(String) when no mapping exists for name.");
String value = testObject.getString("foo");
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.isNull(String) when no mapping exists for name.");
boolean value = testObject.isNull("foo");
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonObjectExceptionTests Failed");
+ assertTrue(pass, "jsonObjectExceptionTests Failed");
}
/*
@@ -1094,250 +1076,249 @@
* specified name or value that is null.
*/
@Test
- public void jsonObjectNullNameValueExceptionTests() throws Fault {
+ public void jsonObjectNullNameValueExceptionTests() {
boolean pass = true;
JsonObjectBuilder job = Json.createObjectBuilder();
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, JsonValue) when name is null.");
job.add(null, JsonValue.TRUE);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, JsonValue) when value is null.");
job.add("name", (JsonValue) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, String) when name is null.");
job.add(null, "value");
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, String) when value is null.");
job.add("name", (String) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, BigInteger) when name is null.");
job.add(null, new BigInteger("123456789"));
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, BigInteger) when value is null.");
job.add("name", (BigInteger) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, BigDecimal) when name is null.");
job.add(null, new BigDecimal("123456789"));
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, BigDecimal) when value is null.");
job.add("name", (BigDecimal) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, int) when name is null.");
job.add(null, 123456789);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, long) when name is null.");
job.add(null, 123456789L);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, double) when name is null.");
job.add(null, 123456.789);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.add(String, boolean) when name is null.");
job.add(null, true);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObject.addNull(String) when name is null.");
job.addNull(null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, JsonObjectBuilder) when name is null.");
job.add(null, Json.createObjectBuilder());
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonObjectBuilder.add(String, JsonObjectBuilder) when value is null.");
job.add("name", (JsonObjectBuilder) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(String, JsonArrayBuilder) when name is null.");
job.add(null, Json.createArrayBuilder());
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NullPointerException
try {
- System.out.println(
+ LOGGER.info(
"Trip NullPointerException for JsonArrayBuilder.add(String, JsonArrayBuilder) when value is null.");
job.add("name", (JsonArrayBuilder) null);
pass = false;
- System.err.println("Failed to throw NullPointerException");
+ LOGGER.warning("Failed to throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonObjectNullNameValueExceptionTests Failed");
+ assertTrue(pass, "jsonObjectNullNameValueExceptionTests Failed");
}
/*
@@ -1350,7 +1331,7 @@
* 1.1.
*/
@Test
- public void jsonCreateObjectBuilder11Test() throws Fault {
+ public void jsonCreateObjectBuilder11Test() {
CreateObjectBuilder createTest = new CreateObjectBuilder();
final TestResult result = createTest.test();
result.eval();
@@ -1364,7 +1345,7 @@
* @test_Strategy: Tests JsonObjectBuilder API methods added in JSON-P 1.1.
*/
@Test
- public void jsonObjectBuilder11Test() throws Fault {
+ public void jsonObjectBuilder11Test() {
ObjectBuild buildTest = new ObjectBuild();
final TestResult result = buildTest.test();
result.eval();
@@ -1372,7 +1353,7 @@
/*
* @testName: jsonObjectBuilderBuildTest
- *
+ *
* @test_Strategy: Tests JsonObjectBuilder#build clears the builder.
*/
@Test
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/CreateObjectBuilder.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/CreateObjectBuilder.java
index f4b370c..f3cca7e 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/CreateObjectBuilder.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/CreateObjectBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
@@ -34,6 +36,8 @@
*/
public class CreateObjectBuilder {
+ private static final Logger LOGGER = Logger.getLogger(CreateObjectBuilder.class.getName());
+
/**
* Test {@link JsonObjectBuilder} factory method added in JSON-P 1.1.
*
@@ -42,7 +46,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonObjectBuilder API factory methods added in JSON-P 1.1.");
- System.out.println("JsonObjectBuilder API factory methods added in JSON-P 1.1.");
+ LOGGER.info("JsonObjectBuilder API factory methods added in JSON-P 1.1.");
testCreateFromMap(result);
testCreateFromJsonObject(result);
return result;
@@ -55,7 +59,7 @@
* Test suite result.
*/
private void testCreateFromMap(final TestResult result) {
- System.out.println(" - Json#createObjectBuilder(Map<String,Object>)");
+ LOGGER.info(" - Json#createObjectBuilder(Map<String,Object>)");
final JsonObject check = createSimpleObjectWithStr();
Map<String, Object> values = new HashMap<>(2);
values.put(DEF_NAME, DEF_VALUE);
@@ -75,7 +79,7 @@
* Test suite result.
*/
private void testCreateFromJsonObject(final TestResult result) {
- System.out.println(" - Json#createObjectBuilder(JsonObject)");
+ LOGGER.info(" - Json#createObjectBuilder(JsonObject)");
final JsonObject check = createSimpleObjectWithStr();
final JsonObjectBuilder builder = Json.createObjectBuilder(check);
final JsonObject out = builder.build();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ObjectBuild.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ObjectBuild.java
index 88f7127..b569140 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ObjectBuild.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonobjecttests/ObjectBuild.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -34,6 +36,8 @@
*/
public class ObjectBuild {
+ private static final Logger LOGGER = Logger.getLogger(ObjectBuild.class.getName());
+
/**
* {@link JsonArrayBuilder} API remove() methods added in JSON-P 1.1.
*
@@ -42,7 +46,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonObjectBuilder API methods added in JSON-P 1.1.");
- System.out.println("JsonObjectBuilder API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonObjectBuilder API methods added in JSON-P 1.1.");
testAddString(result);
testAddInt(result);
testAddBool(result);
@@ -64,7 +68,7 @@
* Test suite result.
*/
private void testAddString(final TestResult result) {
- System.out.println(" - addAll(JsonObjectBuilder) for String");
+ LOGGER.info(" - addAll(JsonObjectBuilder) for String");
final JsonObjectBuilder target = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE);
final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(),
@@ -81,7 +85,7 @@
* Test suite result.
*/
private void testAddInt(final TestResult result) {
- System.out.println(" - addAll(JsonObjectBuilder) for int");
+ LOGGER.info(" - addAll(JsonObjectBuilder) for int");
final JsonObjectBuilder target = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE);
final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(),
@@ -98,7 +102,7 @@
* Test suite result.
*/
private void testAddBool(final TestResult result) {
- System.out.println(" - addAll(JsonObjectBuilder) for boolean");
+ LOGGER.info(" - addAll(JsonObjectBuilder) for boolean");
final JsonObjectBuilder target = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE);
final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(),
@@ -115,7 +119,7 @@
* Test suite result.
*/
private void testAddObject(final TestResult result) {
- System.out.println(" - addAll(JsonObjectBuilder) for JsonObject");
+ LOGGER.info(" - addAll(JsonObjectBuilder) for JsonObject");
final JsonObjectBuilder target = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE)
.add(DEF_OBJ_NAME, DEF_OBJ_VALUE);
@@ -133,14 +137,14 @@
* Test suite result.
*/
private void testAddAllNull(final TestResult result) {
- System.out.println(" - addAll(JsonObjectBuilder) for null builder argument");
+ LOGGER.info(" - addAll(JsonObjectBuilder) for null builder argument");
JsonObjectBuilder builder = Json.createObjectBuilder();
try {
builder.addAll((JsonObjectBuilder) null);
result.fail("addAll(null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("addAll(null)",
"Calling method with null argument shall throw NullPointerException, not "
@@ -156,7 +160,7 @@
* Test suite result.
*/
private void testRemoveString(final TestResult result) {
- System.out.println(" - remove(String) for String");
+ LOGGER.info(" - remove(String) for String");
final JsonObjectBuilder in = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE)
.add(STR_NAME, STR_VALUE);
@@ -172,7 +176,7 @@
* Test suite result.
*/
private void testRemoveInt(final TestResult result) {
- System.out.println(" - remove(String) for int");
+ LOGGER.info(" - remove(String) for int");
final JsonObjectBuilder in = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE)
.add(INT_NAME, INT_VALUE);
@@ -189,7 +193,7 @@
* Test suite result.
*/
private void testRemoveBool(final TestResult result) {
- System.out.println(" - remove(String) for boolean");
+ LOGGER.info(" - remove(String) for boolean");
final JsonObjectBuilder in = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE)
.add(BOOL_NAME, BOOL_VALUE);
@@ -206,7 +210,7 @@
* Test suite result.
*/
private void testRemoveObject(final TestResult result) {
- System.out.println(" - remove(String) for JsonObject");
+ LOGGER.info(" - remove(String) for JsonObject");
final JsonObjectBuilder in = ObjectBuilder
.add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE)
.add(DEF_OBJ_NAME, DEF_OBJ_VALUE).add(OBJ_NAME, OBJ_VALUE);
@@ -223,14 +227,14 @@
* Test suite result.
*/
private void testRemoveNull(final TestResult result) {
- System.out.println(" - remove(String) for null name argument");
+ LOGGER.info(" - remove(String) for null name argument");
JsonObjectBuilder builder = Json.createObjectBuilder();
try {
builder.remove((String) null);
result.fail("remove(null)",
"Calling method with null argument shall throw NullPointerException");
} catch (NullPointerException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("remove(null)",
"Calling method with null argument shall throw NullPointerException, not "
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsereventtests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsereventtests/ClientTests.java
index 2da56f5..cc20fbd 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsereventtests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsereventtests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,27 +21,18 @@
import jakarta.json.stream.*;
-import java.io.*;
-import java.util.*;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -54,7 +45,7 @@
*
*/
@Test
- public void jsonValueOfTest() throws Fault {
+ public void jsonValueOfTest() {
boolean pass = true;
String eventTypeStrings[] = { "END_ARRAY", "END_OBJECT", "KEY_NAME",
@@ -64,44 +55,43 @@
for (String eventTypeString : eventTypeStrings) {
JsonParser.Event eventType;
try {
- System.out.println(
+ LOGGER.info(
"Testing enum value for string constant name " + eventTypeString);
eventType = JsonParser.Event.valueOf(eventTypeString);
- System.out.println("Got enum type " + eventType + " for enum string constant named "
+ LOGGER.info("Got enum type " + eventType + " for enum string constant named "
+ eventTypeString);
} catch (Exception e) {
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
pass = false;
}
}
- System.out.println("Testing negative test case for NullPointerException");
+ LOGGER.info("Testing negative test case for NullPointerException");
try {
JsonParser.Event.valueOf(null);
- System.err.println("did not get expected NullPointerException");
+ LOGGER.warning("did not get expected NullPointerException");
pass = false;
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
- System.err.println("Got unexpected exception " + e);
+ LOGGER.warning("Got unexpected exception " + e);
pass = false;
}
- System.out.println("Testing negative test case for IllegalArgumentException");
+ LOGGER.info("Testing negative test case for IllegalArgumentException");
try {
JsonParser.Event.valueOf("INVALID");
- System.err.println("did not get expected IllegalArgumentException");
+ LOGGER.warning("did not get expected IllegalArgumentException");
pass = false;
} catch (IllegalArgumentException e) {
- System.out.println("Got expected IllegalArgumentException");
+ LOGGER.info("Got expected IllegalArgumentException");
} catch (Exception e) {
- System.err.println("Got unexpected exception " + e);
+ LOGGER.warning("Got unexpected exception " + e);
pass = false;
}
- if (!pass)
- throw new Fault("jsonValueOfTest Failed");
+ assertTrue(pass, "jsonValueOfTest Failed");
}
/*
@@ -114,23 +104,18 @@
*
*/
@Test
- public void jsonValuesTest() throws Fault {
- boolean pass = true;
+ public void jsonValuesTest() {
- System.out.println(
+ LOGGER.info(
"Testing API method JsonParser.Event.values() to return array of enums.");
JsonParser.Event[] values = JsonParser.Event.values();
for (JsonParser.Event eventType : values) {
String eventString = JSONP_Util.getEventTypeString(eventType);
if (eventString == null) {
- System.err.println("Got no value for enum " + eventType);
- pass = false;
+ fail("jsonValuesTest Failed. Got no value for enum " + eventType);
} else
- System.out.println("Got " + eventString + " for enum " + eventType);
+ LOGGER.info("Got " + eventString + " for enum " + eventType);
}
-
- if (!pass)
- throw new Fault("jsonValuesTest Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparserfactorytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparserfactorytests/ClientTests.java
index d8a2b7a..e3eac62 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparserfactorytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparserfactorytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,34 +22,20 @@
import jakarta.json.*;
import jakarta.json.stream.*;
import java.io.*;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.Map;
-import java.util.ArrayList;
+import java.util.logging.Logger;
-import jakarta.json.stream.JsonParser.Event.*;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -64,64 +50,64 @@
* = parserFactory.createParser(Reader)
*/
@Test
- public void jsonParserFactoryTest1() throws Fault {
+ public void jsonParserFactoryTest1() {
boolean pass = true;
JsonParser parser1 = null;
JsonParser parser2 = null;
JsonParser.Event event = null;
try {
- System.out.println("Create JsonParserFactory with a configuration");
+ LOGGER.info("Create JsonParserFactory with a configuration");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("--------------------------------------------------");
- System.out.println("TEST CASE [JsonParserFactory.createParser(Reader)]");
- System.out.println("--------------------------------------------------");
+ LOGGER.info("--------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonParserFactory.createParser(Reader)]");
+ LOGGER.info("--------------------------------------------------");
String jsonObjectString = "{\"foo\":\"bar\"}";
- System.out.println("Create 1st JsonParser from the Reader using JsonParserFactory");
+ LOGGER.info("Create 1st JsonParser from the Reader using JsonParserFactory");
parser1 = parserFactory.createParser(new StringReader(jsonObjectString));
if (parser1 == null) {
- System.err.println("ParserFactory failed to create parser1 from Reader");
+ LOGGER.warning("ParserFactory failed to create parser1 from Reader");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser1, "foo", "bar");
JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
- System.out.println("Create 2nd JsonParser from the Reader using JsonParserFactory");
+ LOGGER.info("Create 2nd JsonParser from the Reader using JsonParserFactory");
parser2 = parserFactory.createParser(new StringReader(jsonObjectString));
if (parser2 == null) {
- System.err.println("ParserFactory failed to create parser2 from Reader");
+ LOGGER.warning("ParserFactory failed to create parser2 from Reader");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser2, "foo", "bar");
JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest1 Failed: ", e);
+ fail("jsonParserFactoryTest1 Failed: ", e);
} finally {
try {
parser1.close();
@@ -129,8 +115,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest1 Failed");
+ assertTrue(pass, "jsonParserFactoryTest1 Failed");
}
/*
@@ -145,68 +130,68 @@
* parser2 = parserFactory.createParser(JsonObject)
*/
@Test
- public void jsonParserFactoryTest2() throws Fault {
+ public void jsonParserFactoryTest2() {
boolean pass = true;
JsonParser parser1 = null;
JsonParser parser2 = null;
JsonParser.Event event = null;
try {
- System.out.println("Create JsonParserFactory with a configuration");
+ LOGGER.info("Create JsonParserFactory with a configuration");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("------------------------------------------------------");
- System.out.println("TEST CASE [JsonParserFactory.createParser(JsonObject)]");
- System.out.println("------------------------------------------------------");
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonParserFactory.createParser(JsonObject)]");
+ LOGGER.info("------------------------------------------------------");
String jsonObjectString = "{\"foo\":\"bar\"}";
JsonObject jsonObj = JSONP_Util
.createJsonObjectFromString(jsonObjectString);
- System.out.println(
+ LOGGER.info(
"Create 1st JsonParser from the JsonObject using JsonParserFactory");
parser1 = parserFactory.createParser(jsonObj);
if (parser1 == null) {
- System.err.println("ParserFactory failed to create parser1 from JsonObject");
+ LOGGER.warning("ParserFactory failed to create parser1 from JsonObject");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser1, "foo", "bar");
JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonParser from the JsonObject using JsonParserFactory");
parser2 = parserFactory.createParser(jsonObj);
if (parser2 == null) {
- System.err.println("ParserFactory failed to create parser2 from JsonObject");
+ LOGGER.warning("ParserFactory failed to create parser2 from JsonObject");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser2, "foo", "bar");
JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest2 Failed: ", e);
+ fail("jsonParserFactoryTest2 Failed: ", e);
} finally {
try {
parser1.close();
@@ -214,8 +199,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest2 Failed");
+ assertTrue(pass, "jsonParserFactoryTest2 Failed");
}
/*
@@ -230,34 +214,34 @@
* parser2 = parserFactory.createParser(JsonArray)
*/
@Test
- public void jsonParserFactoryTest3() throws Fault {
+ public void jsonParserFactoryTest3() {
boolean pass = true;
JsonParser parser1 = null;
JsonParser parser2 = null;
JsonParser.Event event = null;
try {
- System.out.println("Create JsonParserFactory with a configuration");
+ LOGGER.info("Create JsonParserFactory with a configuration");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-----------------------------------------------------");
- System.out.println("TEST CASE [JsonParserFactory.createParser(JsonArray)]");
- System.out.println("-----------------------------------------------------");
+ LOGGER.info("-----------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonParserFactory.createParser(JsonArray)]");
+ LOGGER.info("-----------------------------------------------------");
String jsonArrayString = "[\"foo\",\"bar\"]";
JsonArray jsonArr = JSONP_Util.createJsonArrayFromString(jsonArrayString);
- System.out.println(
+ LOGGER.info(
"Create 1st JsonParser from the JsonArray using JsonParserFactory");
parser1 = parserFactory.createParser(jsonArr);
if (parser1 == null) {
- System.err.println("ParserFactory failed to create parser1 from JsonArray");
+ LOGGER.warning("ParserFactory failed to create parser1 from JsonArray");
pass = false;
} else {
- System.out.println("Parsing " + jsonArrayString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonArrayString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser1, JsonParser.Event.START_ARRAY);
JSONP_Util.testStringValue(parser1, "foo");
@@ -265,20 +249,20 @@
JSONP_Util.testEventType(parser1, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonParser from the JsonArray using JsonParserFactory");
parser2 = parserFactory.createParser(jsonArr);
if (parser2 == null) {
- System.err.println("ParserFactory failed to create parser2 from JsonArray");
+ LOGGER.warning("ParserFactory failed to create parser2 from JsonArray");
pass = false;
} else {
- System.out.println("Parsing " + jsonArrayString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonArrayString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser2, JsonParser.Event.START_ARRAY);
JSONP_Util.testStringValue(parser2, "foo");
@@ -286,12 +270,12 @@
JSONP_Util.testEventType(parser2, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest3 Failed: ", e);
+ fail("jsonParserFactoryTest3 Failed: ", e);
} finally {
try {
parser1.close();
@@ -299,8 +283,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest3 Failed");
+ assertTrue(pass, "jsonParserFactoryTest3 Failed");
}
/*
@@ -315,68 +298,68 @@
* parser2 = parserFactory.createParser(InputStream)
*/
@Test
- public void jsonParserFactoryTest4() throws Fault {
+ public void jsonParserFactoryTest4() {
boolean pass = true;
JsonParser parser1 = null;
JsonParser parser2 = null;
JsonParser.Event event = null;
try {
- System.out.println("Create JsonParserFactory with a configuration");
+ LOGGER.info("Create JsonParserFactory with a configuration");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-------------------------------------------------------");
- System.out.println("TEST CASE [JsonParserFactory.createParser(InputStream)]");
- System.out.println("-------------------------------------------------------");
+ LOGGER.info("-------------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonParserFactory.createParser(InputStream)]");
+ LOGGER.info("-------------------------------------------------------");
String jsonObjectString = "{\"foo\":\"bar\"}";
- System.out.println(
+ LOGGER.info(
"Create 1st JsonParser from the InputStream using JsonParserFactory");
parser1 = parserFactory.createParser(new ByteArrayInputStream(
jsonObjectString.getBytes(JSONP_Util.UTF_8)));
if (parser1 == null) {
- System.err.println("ParserFactory failed to create parser1 from InputStream");
+ LOGGER.warning("ParserFactory failed to create parser1 from InputStream");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser1, "foo", "bar");
JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonParser from the InputStream using JsonParserFactory");
parser2 = parserFactory.createParser(new ByteArrayInputStream(
jsonObjectString.getBytes(JSONP_Util.UTF_8)));
if (parser2 == null) {
- System.err.println("ParserFactory failed to create parser2 from InputStream");
+ LOGGER.warning("ParserFactory failed to create parser2 from InputStream");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser2, "foo", "bar");
JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest4 Failed: ", e);
+ fail("jsonParserFactoryTest4 Failed: ", e);
} finally {
try {
parser1.close();
@@ -384,8 +367,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest4 Failed");
+ assertTrue(pass, "jsonParserFactoryTest4 Failed");
}
/*
@@ -400,73 +382,73 @@
* JsonParser parser2 = parserFactory.createParser(InputStream, Charset)
*/
@Test
- public void jsonParserFactoryTest5() throws Fault {
+ public void jsonParserFactoryTest5() {
boolean pass = true;
JsonParser parser1 = null;
JsonParser parser2 = null;
JsonParser.Event event = null;
try {
- System.out.println("Create JsonParserFactory with a configuration");
+ LOGGER.info("Create JsonParserFactory with a configuration");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [JsonParserFactory.createParser(InputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------");
String jsonObjectString = "{\"foo\":\"bar\"}";
- System.out.println(
+ LOGGER.info(
"Create 1st JsonParser from the InputStream using JsonParserFactory");
parser1 = parserFactory.createParser(
new ByteArrayInputStream(jsonObjectString.getBytes(JSONP_Util.UTF_8)),
JSONP_Util.UTF_8);
if (parser1 == null) {
- System.err.println("ParserFactory failed to create parser1 from InputStream");
+ LOGGER.warning("ParserFactory failed to create parser1 from InputStream");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser1, "foo", "bar");
JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonParser from the InputStream using JsonParserFactory");
parser2 = parserFactory.createParser(
new ByteArrayInputStream(jsonObjectString.getBytes(JSONP_Util.UTF_8)),
JSONP_Util.UTF_8);
if (parser2 == null) {
- System.err.println("ParserFactory failed to create parser2 from InputStream");
+ LOGGER.warning("ParserFactory failed to create parser2 from InputStream");
pass = false;
} else {
- System.out.println("Parsing " + jsonObjectString);
- System.out.println("Verify that JSON Parser Events/Data matches");
+ LOGGER.info("Parsing " + jsonObjectString);
+ LOGGER.info("Verify that JSON Parser Events/Data matches");
JSONP_Util.resetParseErrs();
JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT);
JSONP_Util.testKeyStringValue(parser2, "foo", "bar");
JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
}
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest5 Failed: ", e);
+ fail("jsonParserFactoryTest5 Failed: ", e);
} finally {
try {
parser1.close();
@@ -474,8 +456,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest5 Failed");
+ assertTrue(pass, "jsonParserFactoryTest5 Failed");
}
/*
@@ -492,33 +473,32 @@
* (empty config) 2) non supported provider property
*/
@Test
- public void jsonParserFactoryTest6() throws Fault {
+ public void jsonParserFactoryTest6() {
boolean pass = true;
JsonParserFactory parserFactory;
Map<String, ?> config;
try {
- System.out.println("----------------------------------------------");
- System.out.println("Test scenario1: no supported provider property");
- System.out.println("----------------------------------------------");
- System.out.println("Create JsonParserFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test scenario1: no supported provider property");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Create JsonParserFactory with Map<String, ?> with EMPTY config");
parserFactory = Json.createParserFactory(JSONP_Util.getEmptyConfig());
config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-----------------------------------------------");
- System.out.println("Test scenario2: non supported provider property");
- System.out.println("-----------------------------------------------");
- System.out.println("Create JsonParserFactory with Map<String, ?> with FOO config");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Test scenario2: non supported provider property");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Create JsonParserFactory with Map<String, ?> with FOO config");
parserFactory = Json.createParserFactory(JSONP_Util.getFooConfig());
config = parserFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonParserFactoryTest6 Failed: ", e);
+ fail("jsonParserFactoryTest6 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonParserFactoryTest6 Failed");
+ assertTrue(pass, "jsonParserFactoryTest6 Failed");
}
/*
@@ -532,49 +512,48 @@
* jakarta.json.JsonException
*/
@Test
- public void jsonParserFactoryExceptionTest() throws Fault {
+ public void jsonParserFactoryExceptionTest() {
boolean pass = true;
// Tests JsonParserFactory.createParser(InputStream) for JsonException if
// i/o error
try {
- System.out.println(
+ LOGGER.info(
"Tests JsonParserFactory.createParser(InputStream) for JsonException if i/o error.");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
MyBufferedInputStream mbi = new MyBufferedInputStream(
JSONP_Util.getInputStreamFromString("{}"), true);
JsonParser parser = parserFactory.createParser(mbi);
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Tests JsonParserFactory.createParser(InputStream) for JsonException if
// unknown encoding
try {
- System.out.println(
+ LOGGER.info(
"Tests JsonParserFactory.createParser(InputStream) for JsonException if unknown encoding.");
JsonParserFactory parserFactory = Json
.createParserFactory(JSONP_Util.getEmptyConfig());
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectUnknownEncoding.json");
JsonParser parser = parserFactory.createParser(is);
- System.out.println("parser=" + parser);
- System.err.println("Did not get expected JsonException");
+ LOGGER.info("parser=" + parser);
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonParserFactoryExceptionTest Failed");
+ assertTrue(pass, "jsonParserFactoryExceptionTest Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/ClientTests.java
index 9035143..6836aee 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/ClientTests.java
@@ -19,22 +19,11 @@
*/
package jakarta.jsonp.tck.api.jsonparsertests;
-import static jakarta.jsonp.tck.api.common.JsonAssert.valueToString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import java.io.InputStream;
import java.io.StringReader;
import java.math.BigDecimal;
import java.util.NoSuchElementException;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.Json;
import jakarta.json.JsonArray;
@@ -47,16 +36,14 @@
import jakarta.jsonp.tck.common.JSONP_Data;
import jakarta.jsonp.tck.common.JSONP_Util;
import jakarta.jsonp.tck.common.MyBufferedInputStream;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.*;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/*
* Utitity method to parse various JsonObjectUTF encoded files
*/
@@ -79,7 +66,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -158,7 +145,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -187,7 +174,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -219,7 +206,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -254,7 +241,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -298,7 +285,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -376,7 +363,7 @@
JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -410,7 +397,7 @@
JSONP_Util.dumpLocation(parser);
int parseErrs = JSONP_Util.getParseErrs();
if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
+ LOGGER.warning("There were " + parseErrs + " parser errors that occurred.");
pass = false;
}
} catch (Exception e) {
@@ -435,32 +422,29 @@
* JsonParser parser = Json.createParser(Reader)
*/
@Test
- public void jsonParserTest1() throws Fault {
- boolean pass = true;
+ public void jsonParserTest1() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println("-------------------------------------");
- System.out.println("TEST CASE [Json.createParser(Reader)]");
- System.out.println("-------------------------------------");
- System.out.println("Create Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)");
+ LOGGER.info("-------------------------------------");
+ LOGGER.info("TEST CASE [Json.createParser(Reader)]");
+ LOGGER.info("-------------------------------------");
+ LOGGER.info("Create Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)");
StringReader reader = new StringReader(
JSONP_Data.jsonObjectWithAllTypesOfData);
- System.out.println("Create JsonParser from the Reader");
+ LOGGER.info("Create JsonParser from the Reader");
parser = Json.createParser(reader);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)");
- pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser);
+ assertTrue(parseAndVerify_JsonObjectWithAllTypesOfData(parser), "jsonParserTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest1 Failed: ", e);
+ fail("jsonParserTest1 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest1 Failed");
}
/*
@@ -478,39 +462,36 @@
* Json.createParserFactory(Map<String,?>).createParser(JsonObject)
*/
@Test
- public void jsonParserTest2() throws Fault {
- boolean pass = true;
+ public void jsonParserTest2() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(JsonObject)]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create JsonObject from (JSONP_Data.jsonObjectWithAllTypesOfData)");
JsonObject jsonObj = JSONP_Util
.createJsonObjectFromString(JSONP_Data.jsonObjectWithAllTypesOfData);
JSONP_Util.dumpJsonObject(jsonObj);
- System.out.println("Create JsonParser from the JsonObject");
+ LOGGER.info("Create JsonParser from the JsonObject");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(jsonObj);
- System.out.println("parser=" + parser);
- System.out.println(
+ LOGGER.info("parser=" + parser);
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)");
- pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser);
+ assertTrue(parseAndVerify_JsonObjectWithAllTypesOfData(parser), "jsonParserTest2 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest2 Failed: ", e);
+ fail("jsonParserTest2 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest2 Failed");
}
/*
@@ -526,33 +507,30 @@
* JsonParser parser = Json.createParser(Reader)
*/
@Test
- public void jsonParserTest3() throws Fault {
- boolean pass = true;
+ public void jsonParserTest3() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println("-------------------------------------------");
- System.out.println("TEST CASE [Json.createParser(Reader) again]");
- System.out.println("-------------------------------------------");
- System.out.println(
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createParser(Reader) again]");
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info(
"Create Reader from (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)");
StringReader reader = new StringReader(
JSONP_Data.jsonObjectWithLotsOfNestedObjectsData);
- System.out.println("Create JsonParser from the Reader");
+ LOGGER.info("Create JsonParser from the Reader");
parser = Json.createParser(reader);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)");
- pass = parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser);
+ assertTrue(parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser), "jsonParserTest3 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest3 Failed: ", e);
+ fail("jsonParserTest3 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest3 Failed");
}
/*
@@ -569,38 +547,35 @@
* Json.createParserFactory(Map<String,?>).createParser(JsonObject)
*/
@Test
- public void jsonParserTest4() throws Fault {
- boolean pass = true;
+ public void jsonParserTest4() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(JsonObject object) again]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create JsonObject from (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)");
JsonObject jsonObj = JSONP_Util.createJsonObjectFromString(
JSONP_Data.jsonObjectWithLotsOfNestedObjectsData);
JSONP_Util.dumpJsonObject(jsonObj);
- System.out.println("Create JsonParser from the JsonObject");
+ LOGGER.info("Create JsonParser from the JsonObject");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(jsonObj);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)");
- pass = parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser);
+ assertTrue(parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser), "jsonParserTest4 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest4 Failed: ", e);
+ fail("jsonParserTest4 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest4 Failed");
}
/*
@@ -618,38 +593,35 @@
* Json.createParserFactory(Map<String,?>).createParser(JsonArray)
*/
@Test
- public void jsonParserTest5() throws Fault {
- boolean pass = true;
+ public void jsonParserTest5() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(JsonArray)]");
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create JsonArray from (JSONP_Data.jsonArrayWithMultipleArraysData)");
JsonArray jsonArr = JSONP_Util.createJsonArrayFromString(
JSONP_Data.jsonArrayWithMultipleArraysData);
JSONP_Util.dumpJsonArray(jsonArr);
- System.out.println("Create JsonParser from the JsonArray");
+ LOGGER.info("Create JsonParser from the JsonArray");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(jsonArr);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithMultipleArraysData)");
- pass = parseAndVerify_JsonArrayWithMultipleArraysData(parser);
+ assertTrue(parseAndVerify_JsonArrayWithMultipleArraysData(parser), "jsonParserTest5 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest5 Failed: ", e);
+ fail("jsonParserTest5 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest5 Failed");
}
/*
@@ -667,33 +639,30 @@
* JsonParser parser = Json.createParser(InputStream)
*/
@Test
- public void jsonParserTest6() throws Fault {
- boolean pass = true;
+ public void jsonParserTest6() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println("------------------------------------------");
- System.out.println("TEST CASE [Json.createParser(InputStream)]");
- System.out.println("------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createParser(InputStream)]");
+ LOGGER.info("------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonArrayWithAllTypesOfData.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonArrayWithAllTypesOfData.json");
- System.out.println("Create JsonParser from the InputStream");
+ LOGGER.info("Create JsonParser from the InputStream");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonArrayWithAllTypesOfData.json)");
- pass = parseAndVerify_JsonArrayWithAllTypesOfData(parser);
+ assertTrue(parseAndVerify_JsonArrayWithAllTypesOfData(parser), "jsonParserTest6 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest6 Failed: ", e);
+ fail("jsonParserTest6 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest6 Failed");
}
/*
@@ -712,39 +681,35 @@
* ?>).createParser(Reader)
*/
@Test
- public void jsonParserTest7() throws Fault {
- boolean pass = true;
+ public void jsonParserTest7() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(Reader)]");
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------------");
- System.out.println("Create a Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)");
+ LOGGER.info("Create a Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)");
StringReader reader = new StringReader(
JSONP_Data.jsonObjectWithAllTypesOfData);
- System.out.println("Create JsonParser using Reader and a configuration");
+ LOGGER.info("Create JsonParser using Reader and a configuration");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(reader);
- System.out.println("Call JsonParser.toString() to print the JsonObject");
+ LOGGER.info("Call JsonParser.toString() to print the JsonObject");
parser.toString();
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)");
- if (!parseAndVerify_JsonObjectWithAllTypesOfData(parser))
- pass = false;
+ assertTrue(parseAndVerify_JsonObjectWithAllTypesOfData(parser), "jsonParserTest7 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest7 Failed: ", e);
+ fail("jsonParserTest7 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest7 Failed");
}
/*
@@ -762,41 +727,37 @@
* ?>).createParser(JsonArray)
*/
@Test
- public void jsonParserTest8() throws Fault {
- boolean pass = true;
+ public void jsonParserTest8() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(JsonArray)]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create a JsonArray from (JSONP_Data.jsonArrayWithLotsOfNestedObjectsData)");
JsonArray jsonArr = JSONP_Util.createJsonArrayFromString(
JSONP_Data.jsonArrayWithLotsOfNestedObjectsData);
JSONP_Util.dumpJsonArray(jsonArr);
- System.out.println("Create JsonParser using JsonArray and a configuration");
+ LOGGER.info("Create JsonParser using JsonArray and a configuration");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(jsonArr);
- System.out.println("Call JsonParser.toString() to print the JsonObject");
+ LOGGER.info("Call JsonParser.toString() to print the JsonObject");
parser.toString();
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithLotsOfNestedObjectsData)");
- if (!parseAndVerify_JsonArrayWithLotsOfNestedObjectsData(parser))
- pass = false;
+ assertTrue(parseAndVerify_JsonArrayWithLotsOfNestedObjectsData(parser), "jsonParserTest8 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest8 Failed: ", e);
+ fail("jsonParserTest8 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest8 Failed");
}
/*
@@ -815,41 +776,37 @@
* ?>).createParser(JsonArray)
*/
@Test
- public void jsonParserTest9() throws Fault {
- boolean pass = true;
+ public void jsonParserTest9() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(JsonArray)]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create JsonArray from (JSONP_Data.jsonArrayWithMultipleArraysData)");
JsonArray jsonArr = JSONP_Util.createJsonArrayFromString(
JSONP_Data.jsonArrayWithMultipleArraysData);
JSONP_Util.dumpJsonArray(jsonArr);
- System.out.println("Create JsonParser using JsonArray and a configuration");
+ LOGGER.info("Create JsonParser using JsonArray and a configuration");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(jsonArr);
- System.out.println("Call JsonParser.toString() to print the JsonArray");
+ LOGGER.info("Call JsonParser.toString() to print the JsonArray");
parser.toString();
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithMultipleArraysData)");
- if (!parseAndVerify_JsonArrayWithMultipleArraysData(parser))
- pass = false;
+ assertTrue(parseAndVerify_JsonArrayWithMultipleArraysData(parser), "jsonParserTest9 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest9 Failed: ", e);
+ fail("jsonParserTest9 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest9 Failed");
}
/*
@@ -867,38 +824,34 @@
* ?>).createParser(InputStream)
*/
@Test
- public void jsonParserTest10() throws Fault {
- boolean pass = true;
+ public void jsonParserTest10() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(InputStream)]");
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------");
- System.out.println("Create JsonParser using InputStream and a configuration");
+ LOGGER.info("Create JsonParser using InputStream and a configuration");
InputStream istream = JSONP_Util.getInputStreamFromResource(
"jsonObjectWithLotsOfNestedObjectsData.json");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream);
- System.out.println("Call JsonParser.toString() to print the JsonObject");
+ LOGGER.info("Call JsonParser.toString() to print the JsonObject");
parser.toString();
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectWithLotsOfNestedObjectsData.json)");
- if (!parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser))
- pass = false;
+ assertTrue(parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser), "jsonParserTest10 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest10 Failed: ", e);
+ fail("jsonParserTest10 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest10 Failed");
}
/*
@@ -918,38 +871,35 @@
* Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset)
*/
@Test
- public void jsonParserTest11() throws Fault {
- boolean pass = true;
+ public void jsonParserTest11() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonArrayWithAllTypesOfDataUTF16BE.json)");
InputStream istream = JSONP_Util.getInputStreamFromResource(
"jsonArrayWithAllTypesOfDataUTF16BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-16BE");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_16BE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonArrayWithAllTypesOfDataUTF16BE.json)");
- pass = parseAndVerify_JsonArrayWithAllTypesOfData(parser);
+ assertTrue(parseAndVerify_JsonArrayWithAllTypesOfData(parser), "jsonParserTest11 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest11 Failed: ", e);
+ fail("jsonParserTest11 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest11 Failed");
}
/*
@@ -968,39 +918,35 @@
* ?>).createParser(InputStream, Charset)
*/
@Test
- public void jsonParserTest12() throws Fault {
- boolean pass = true;
+ public void jsonParserTest12() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(InputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonArrayWithLotsOfNestedArraysData.json)");
InputStream istream = JSONP_Util.getInputStreamFromResource(
"jsonArrayWithLotsOfNestedArraysData.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-8 and a configuration");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_8);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonArrayWithLotsOfNestedArraysData.json)");
- if (!parseAndVerify_JsonArrayWithLotsOfNestedArraysData(parser))
- pass = false;
+ assertTrue(parseAndVerify_JsonArrayWithLotsOfNestedArraysData(parser), "jsonParserTest12 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest12 Failed: ", e);
+ fail("jsonParserTest12 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest12 Failed");
}
/*
@@ -1020,37 +966,34 @@
* ?>).createParser(InputStream, Charset)
*/
@Test
- public void jsonParserTest13() throws Fault {
- boolean pass = true;
+ public void jsonParserTest13() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String, ?>).createParser(InputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"---------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectWithAllTypesOfDataUTF16LE.json)");
InputStream istream = JSONP_Util.getInputStreamFromResource(
"jsonObjectWithAllTypesOfDataUTF16LE.json");
- System.out.println("Create JsonParser from the InputStream using UTF-16LE encoding");
+ LOGGER.info("Create JsonParser from the InputStream using UTF-16LE encoding");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_16LE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectWithAllTypesOfDataUTF16LE.json)");
- pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser);
+ assertTrue(parseAndVerify_JsonObjectWithAllTypesOfData(parser), "jsonParserTest13 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest13 Failed: ", e);
+ fail("jsonParserTest13 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest13 Failed");
}
/*
@@ -1067,33 +1010,30 @@
* JsonParser parser = Json.createParser(InputStream)
*/
@Test
- public void jsonParserTest14() throws Fault {
- boolean pass = true;
+ public void jsonParserTest14() {
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println("------------------------------------------");
- System.out.println("TEST CASE [Json.createParser(InputStream)]");
- System.out.println("------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createParser(InputStream)]");
+ LOGGER.info("------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonHelloWorld.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonHelloWorld.json");
- System.out.println("Create JsonParser from the InputStream");
+ LOGGER.info("Create JsonParser from the InputStream");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonHelloWorld.json)");
- pass = parseAndVerify_JsonHelloWorld(parser);
+ assertTrue(parseAndVerify_JsonHelloWorld(parser), "jsonParserTest14 Failed");
} catch (Exception e) {
- throw new Fault("jsonParserTest14 Failed: ", e);
+ fail("jsonParserTest14 Failed: ", e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("jsonParserTest14 Failed");
}
/*
@@ -1119,32 +1059,32 @@
* argument for each encoding type tested.
*/
@Test
- public void parseUTFEncodedTests() throws Fault {
+ public void parseUTFEncodedTests() {
boolean pass = true;
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-8]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF8.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-8");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_8);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF8.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-8 encoding: " + e);
} finally {
try {
parser.close();
@@ -1152,27 +1092,27 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-16]");
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-16");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_16);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-16 encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-16 encoding: " + e);
} finally {
try {
parser.close();
@@ -1180,27 +1120,27 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-16LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-16LE");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_16LE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16LE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-16LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-16LE encoding: " + e);
} finally {
try {
parser.close();
@@ -1208,27 +1148,27 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-16BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-16BE");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_16BE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16BE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-16BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-16BE encoding: " + e);
} finally {
try {
parser.close();
@@ -1236,27 +1176,27 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-32LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-32LE");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_32LE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32LE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-32LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-32LE encoding: " + e);
} finally {
try {
parser.close();
@@ -1264,35 +1204,34 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParserFactory(Map<String,?>).createParser(InputStream, Charset) as UTF-32BE]");
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream with character encoding UTF-32BE");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(istream, JSONP_Util.UTF_32BE);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32BE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-32BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-32BE encoding: " + e);
} finally {
try {
parser.close();
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("parseUTFEncodedTests Failed");
+ assertTrue(pass, "parseUTFEncodedTests Failed");
}
/*
@@ -1317,31 +1256,31 @@
* auto-detect the encoding and verify we get the expected results.
*/
@Test
- public void parseUTFEncodedTests2() throws Fault {
+ public void parseUTFEncodedTests2() {
boolean pass = true;
JsonParser parser = null;
JsonParser.Event event = null;
try {
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-8]");
- System.out.println(
+ LOGGER.info(
"-------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF8.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream and auto-detect character encoding UTF-8");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF8.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-8 encoding: " + e);
} finally {
try {
parser.close();
@@ -1349,26 +1288,26 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-16LE]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream and auto-detect character encoding UTF-16LE");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16LE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-16LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-16LE encoding: " + e);
} finally {
try {
parser.close();
@@ -1376,26 +1315,26 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-16BE]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream and auto-detect character encoding UTF-16BE");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16BE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-16BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-16BE encoding: " + e);
} finally {
try {
parser.close();
@@ -1403,26 +1342,26 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-32LE]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream and auto-detect character encoding UTF-32LE");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32LE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-32LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-32LE encoding: " + e);
} finally {
try {
parser.close();
@@ -1430,26 +1369,26 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-32BE]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)");
InputStream istream = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonParser from the InputStream and auto-detect character encoding UTF-32BE");
parser = Json.createParser(istream);
- System.out.println(
+ LOGGER.info(
"Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32BE.json)");
if (!parseAndVerify_JsonObjectUTF(parser))
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing parsing of UTF-32BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing parsing of UTF-32BE encoding: " + e);
} finally {
try {
parser.close();
@@ -1457,8 +1396,7 @@
}
}
- if (!pass)
- throw new Fault("parseUTFEncodedTests2 Failed");
+ assertTrue(pass, "parseUTFEncodedTests2 Failed");
}
/*
@@ -1470,12 +1408,12 @@
* @test_Strategy: Test JsonParser.isIntegralNumber() method.
*/
@Test
- public void jsonParserIsIntegralNumberTest() throws Fault {
+ public void jsonParserIsIntegralNumberTest() {
boolean pass = true;
JsonParser parser = null;
String jsonTestString = "[123, 12345.45]";
try {
- System.out.println("Create JsonParser");
+ LOGGER.info("Create JsonParser");
parser = Json.createParser(new StringReader(jsonTestString));
// INTEGRAL NUMBER TEST
JsonParser.Event event = JSONP_Util.getNextSpecificParserEvent(parser,
@@ -1502,7 +1440,7 @@
}
} catch (Exception e) {
- throw new Fault("jsonParserIsIntegralNumberTest Failed: ", e);
+ fail("jsonParserIsIntegralNumberTest Failed: ", e);
} finally {
try {
parser.close();
@@ -1510,8 +1448,7 @@
}
}
- if (!pass)
- throw new Fault("jsonParserIsIntegralNumberTest Failed");
+ assertTrue(pass, "jsonParserIsIntegralNumberTest Failed");
}
private boolean tripIllegalStateException(JsonParser parser,
@@ -1520,97 +1457,97 @@
// Check in case event is null
if (event == null) {
- System.err.println("event is null - unexpected.");
+ LOGGER.warning("event is null - unexpected.");
return false;
}
- System.out.println("Event=" + JSONP_Util.getEventTypeString(event));
- System.out.println("Testing call to JsonParser.getString()");
+ LOGGER.info("Event=" + JSONP_Util.getEventTypeString(event));
+ LOGGER.info("Testing call to JsonParser.getString()");
if (event != JsonParser.Event.VALUE_STRING
&& event != JsonParser.Event.VALUE_NUMBER
&& event != JsonParser.Event.KEY_NAME) {
try {
- System.out.println("Trip IllegalStateException by calling JsonParser.getString()");
+ LOGGER.info("Trip IllegalStateException by calling JsonParser.getString()");
String string = parser.getString();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
} else {
- System.out.println("No testing for IllegalStateException for this scenario.");
+ LOGGER.info("No testing for IllegalStateException for this scenario.");
}
- System.out.println("Testing call to JsonParser.isIntegralNumber()");
+ LOGGER.info("Testing call to JsonParser.isIntegralNumber()");
if (event != JsonParser.Event.VALUE_NUMBER) {
try {
- System.out.println(
+ LOGGER.info(
"Trip IllegalStateException by calling JsonParser.isIntegralNumber()");
boolean numberType = parser.isIntegralNumber();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
} else {
- System.out.println("No testing for IllegalStateException for this scenario.");
+ LOGGER.info("No testing for IllegalStateException for this scenario.");
}
- System.out.println("Testing call to JsonParser.getBigDecimal()");
+ LOGGER.info("Testing call to JsonParser.getBigDecimal()");
if (event != JsonParser.Event.VALUE_NUMBER) {
try {
- System.out.println(
+ LOGGER.info(
"Trip IllegalStateException by calling JsonParser.getBigDecimal()");
BigDecimal number = parser.getBigDecimal();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
} else {
- System.out.println("No testing for IllegalStateException for this scenario.");
+ LOGGER.info("No testing for IllegalStateException for this scenario.");
}
- System.out.println("Testing call to JsonParser.getInt()");
+ LOGGER.info("Testing call to JsonParser.getInt()");
if (event != JsonParser.Event.VALUE_NUMBER) {
try {
- System.out.println("Trip IllegalStateException by calling JsonParser.getInt()");
+ LOGGER.info("Trip IllegalStateException by calling JsonParser.getInt()");
int number = parser.getInt();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
} else {
- System.out.println("No testing for IllegalStateException for this scenario.");
+ LOGGER.info("No testing for IllegalStateException for this scenario.");
}
- System.out.println("Testing call to JsonParser.getLong()");
+ LOGGER.info("Testing call to JsonParser.getLong()");
if (event != JsonParser.Event.VALUE_NUMBER) {
try {
- System.out.println("Trip IllegalStateException by calling JsonParser.getLong()");
+ LOGGER.info("Trip IllegalStateException by calling JsonParser.getLong()");
long number = parser.getLong();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
} else {
- System.out.println("No testing for IllegalStateException for this scenario.");
+ LOGGER.info("No testing for IllegalStateException for this scenario.");
}
return pass;
}
@@ -1627,12 +1564,12 @@
* java.lang.IllegalStateException
*/
@Test
- public void jsonParserIllegalExceptionTests() throws Fault {
+ public void jsonParserIllegalExceptionTests() {
boolean pass = true;
JsonParser parser = null;
String jsonTestString = "[\"string\",100,false,null,true,{\"foo\":\"bar\"}]";
try {
- System.out.println("Create JsonParser");
+ LOGGER.info("Create JsonParser");
parser = Json.createParserFactory(JSONP_Util.getEmptyConfig())
.createParser(new StringReader(jsonTestString));
JsonParser.Event event = JSONP_Util
@@ -1680,7 +1617,7 @@
if (!tripIllegalStateException(parser, event))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonParserIllegalExceptionTests Failed: ", e);
+ fail("jsonParserIllegalExceptionTests Failed: ", e);
} finally {
try {
parser.close();
@@ -1688,8 +1625,7 @@
}
}
- if (!pass)
- throw new Fault("jsonParserIllegalExceptionTests Failed");
+ assertTrue(pass, "jsonParserIllegalExceptionTests Failed");
}
/*
@@ -1702,7 +1638,7 @@
*/
@SuppressWarnings("ConvertToTryWithResources")
@Test
- public void jsonParserIOErrorTests() throws Fault {
+ public void jsonParserIOErrorTests() {
boolean pass = true;
String jsonText = "{\"name1\":\"value1\",\"name2\":\"value2\"}";
@@ -1710,63 +1646,62 @@
// Trip JsonException if there is an i/o error on
// Json.createParser(InputStream)
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on Json.createParser(InputStream).");
- System.out.println("Parsing " + jsonText);
+ LOGGER.info("Parsing " + jsonText);
InputStream is = JSONP_Util.getInputStreamFromString(jsonText);
MyBufferedInputStream mbi = new MyBufferedInputStream(is, true);
- System.out.println("Calling Json.createParser(InputStream)");
+ LOGGER.info("Calling Json.createParser(InputStream)");
JsonParser parser = Json.createParser(mbi);
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on JsonParser.next()
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonParser.next().");
- System.out.println("Parsing " + jsonText);
+ LOGGER.info("Parsing " + jsonText);
InputStream is = JSONP_Util.getInputStreamFromString(jsonText);
MyBufferedInputStream mbi = new MyBufferedInputStream(is, true);
JsonParser parser = Json.createParser(mbi);
- System.out.println("Calling JsonParser.next()");
+ LOGGER.info("Calling JsonParser.next()");
parser.next();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on JsonParser.close()
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonParser.close().");
- System.out.println("Parsing " + jsonText);
+ LOGGER.info("Parsing " + jsonText);
InputStream is = JSONP_Util.getInputStreamFromString(jsonText);
MyBufferedInputStream mbi = new MyBufferedInputStream(is);
JsonParser parser = Json.createParser(mbi);
mbi.setThrowIOException(true);
- System.out.println("Calling JsonParser.close()");
+ LOGGER.info("Calling JsonParser.close()");
parser.close();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonParserIOErrorTests Failed");
+ assertTrue(pass, "jsonParserIOErrorTests Failed");
}
/*
@@ -1782,47 +1717,46 @@
*
*/
@Test
- public void jsonParserExceptionTests() throws Fault {
+ public void jsonParserExceptionTests() {
boolean pass = true;
// Trip JsonParsingException for JsonParser.next() if incorrect JSON is
// encountered
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonParser.next() if incorrect JSON is encountered");
InputStream is = JSONP_Util.getInputStreamFromString("}{");
JsonParser parser = Json.createParser(is);
parser.next();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip NoSuchElementException for JsonParser.next() if no more parsing
// states
try {
- System.out.println(
+ LOGGER.info(
"Trip NoSuchElementException for JsonParser.next() if no more parsing states");
InputStream is = JSONP_Util.getInputStreamFromString("{}");
JsonParser parser = Json.createParser(is);
parser.next(); // Event -> START_OBJECT {
parser.next(); // Event -> END_OBJECT }
parser.next(); // Event -> NoSuchElementException should be thrown
- System.err.println("Did not get expected NoSuchElementException");
+ LOGGER.warning("Did not get expected NoSuchElementException");
pass = false;
} catch (NoSuchElementException e) {
- System.out.println("Caught expected NoSuchElementException");
+ LOGGER.info("Caught expected NoSuchElementException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonParserExceptionTests Failed");
+ assertTrue(pass, "jsonParserExceptionTests Failed");
}
/*
@@ -1836,65 +1770,64 @@
*
*/
@Test
- public void invalidLiteralNamesTest() throws Fault {
+ public void invalidLiteralNamesTest() {
boolean pass = true;
// Trip JsonParsingException for JsonParser.next() if invalid liternal TRUE
// instead of true
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonParser.next() if invalid liternal TRUE instead of true.");
- System.out.println("Reading " + "[TRUE]");
+ LOGGER.info("Reading " + "[TRUE]");
JsonParser parser = Json.createParser(new StringReader("[TRUE]"));
parser.next(); // Event -> START_OBJECT {
parser.next(); // Event -> JsonParsingException (invalid literal TRUE)
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonParser.next() if invalid liternal FALSE
// instead of false
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonParser.next() if invalid liternal FALSE instead of false.");
- System.out.println("Reading " + "[FALSE]");
+ LOGGER.info("Reading " + "[FALSE]");
JsonParser parser = Json.createParser(new StringReader("[FALSE]"));
parser.next(); // Event -> START_OBJECT {
parser.next(); // Event -> JsonParsingException (invalid literal FALSE)
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonParser.next() if invalid liternal NULL
// instead of null
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonParser.next() if invalid liternal NULL instead of null.");
- System.out.println("Reading " + "[NULL]");
+ LOGGER.info("Reading " + "[NULL]");
JsonParser parser = Json.createParser(new StringReader("[NULL]"));
parser.next(); // Event -> START_OBJECT {
parser.next(); // Event -> JsonParsingException (invalid literal NULL)
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("invalidLiteralNamesTest Failed");
+ assertTrue(pass, "invalidLiteralNamesTest Failed");
}
/*
@@ -1910,7 +1843,7 @@
* @test_Strategy: Tests JsonParser API methods added in JSON-P 1.1.
*/
@Test
- public void jsonParser11Test() throws Fault {
+ public void jsonParser11Test() {
Parser parserTest = new Parser();
final TestResult result = parserTest.test();
result.eval();
@@ -1918,7 +1851,7 @@
/*
* @testName: jsonParserCurrentEvent
- *
+ *
* @test_Strategy: Tests JsonParser API methods added in JSON-P 2.1.
*/
@Test
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/Parser.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/Parser.java
index 3e5e988..3f9eaf3 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/Parser.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonparsertests/Parser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
import java.util.stream.Stream;
import jakarta.json.Json;
import jakarta.json.JsonArray;
@@ -41,6 +42,8 @@
*/
public class Parser {
+ private static final Logger LOGGER = Logger.getLogger(Parser.class.getName());
+
/** Tests input data with various JsonValue instances. */
private static final JsonValue[] VALUES = new JsonValue[] {
toJsonValue(STR_VALUE), // Non JsonObject with String
@@ -153,7 +156,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonParser API methods added in JSON-P 1.1.");
- System.out.println("JsonParser API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonParser API methods added in JSON-P 1.1.");
testGetObject(result);
testGetNonObject(result);
testGetArray(result);
@@ -179,7 +182,7 @@
private void testGetObject(final TestResult result) {
for (JsonObject value : OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getObject() on " + data);
+ LOGGER.info(" - getObject() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -189,7 +192,7 @@
+ " shall be " + valueToString(value));
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("getObject()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -202,7 +205,7 @@
private void testGetNonObject(final TestResult result) {
for (JsonValue value : NON_OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getObject() on " + data);
+ LOGGER.info(" - getObject() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -210,7 +213,7 @@
result.fail("getObject()",
"Calling method on non object value shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getObject()",
"Calling method on non object value shall throw IllegalStateException, not "
@@ -225,7 +228,7 @@
private void testGetArray(final TestResult result) {
for (JsonArray value : ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getArray() on " + data);
+ LOGGER.info(" - getArray() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -235,7 +238,7 @@
+ " shall be " + valueToString(value));
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("getArray()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -248,7 +251,7 @@
private void testGetNonArray(final TestResult result) {
for (JsonValue value : NON_ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getArray() on " + data);
+ LOGGER.info(" - getArray() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -256,7 +259,7 @@
result.fail("getArray()",
"Calling method on non array value shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getArray()",
"Calling method on non array value shall throw IllegalStateException, not "
@@ -271,7 +274,7 @@
private void testGetValue(final TestResult result) {
for (JsonValue value : VALUES) {
final String data = jsonData(value);
- System.out.println(" - getValue() on " + data);
+ LOGGER.info(" - getValue() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -281,7 +284,7 @@
+ " shall be " + valueToString(value));
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("getValue()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -295,7 +298,7 @@
private void testGetIllegalValue(final TestResult result) {
for (JsonValue value : EMPTY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getValue() on 2nd lexical element of " + data);
+ LOGGER.info(" - getValue() on 2nd lexical element of " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next(); // Skip to START ELEMENT
@@ -304,7 +307,7 @@
result.fail("getValue()",
"Calling method on END_OBJECT and END_ARRAY lexical elements shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getValue()",
"Calling method on END_OBJECT and END_ARRAY lexical elements shall throw IllegalStateException, not "
@@ -319,7 +322,7 @@
private void testGetObjectStream(final TestResult result) {
for (JsonObject value : OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getObjectStream() on " + data);
+ LOGGER.info(" - getObjectStream() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -329,7 +332,7 @@
"Output Stream shall contain " + valueToString(value));
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("getObjectStream()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -342,7 +345,7 @@
private void testGetNonObjectStream(final TestResult result) {
for (JsonValue value : NON_OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getObjectStream() on " + data);
+ LOGGER.info(" - getObjectStream() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -350,7 +353,7 @@
result.fail("getObjectStream()",
"Calling method on non object value shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getObjectStream()",
"Calling method on non object value shall throw IllegalStateException, not "
@@ -365,7 +368,7 @@
private void testGetArrayStream(final TestResult result) {
for (JsonArray value : ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getArrayStream() on " + data);
+ LOGGER.info(" - getArrayStream() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -375,7 +378,7 @@
"Output Stream shall contain " + valueToString(value));
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("getArrayStream()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -388,7 +391,7 @@
private void testGetNonArrayStream(final TestResult result) {
for (JsonValue value : NON_ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getArrayStream() on " + data);
+ LOGGER.info(" - getArrayStream() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -396,7 +399,7 @@
result.fail("getArrayStream()",
"Calling method on non array value shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getArrayStream()",
"Calling method on non array value shall throw IllegalStateException, not "
@@ -412,7 +415,7 @@
private void testGetValueStream(final TestResult result) {
for (final JsonValue value : VALUES) {
final String data = jsonData(value);
- System.out.println(" - getValueStream() on " + data);
+ LOGGER.info(" - getValueStream() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
final Stream<JsonValue> outStream = parser.getValueStream();
@@ -426,7 +429,7 @@
count++;
}
if (count != 1) {
- System.out.println(" Output Stream contains "
+ LOGGER.info(" Output Stream contains "
+ Integer.toString(count) + " values, not 1");
result.fail("getValueStream()",
"Output Stream does not contain exactly 1 JSON value");
@@ -442,7 +445,7 @@
private void testGetCompoundValueStream(final TestResult result) {
for (final JsonValue value : COMPOUND_VALUES) {
final String data = jsonData(value);
- System.out.println(" - getValueStream() inside " + data);
+ LOGGER.info(" - getValueStream() inside " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -450,7 +453,7 @@
result.fail("getValueStream()",
"Calling method on non object value shall throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println(" Expected exception: " + e.getMessage());
+ LOGGER.info(" Expected exception: " + e.getMessage());
} catch (Throwable t) {
result.fail("getValueStream()",
"Calling method on non object value shall throw IllegalStateException, not "
@@ -467,7 +470,7 @@
private void testSkipArray(final TestResult result) {
for (final JsonArray value : ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - skipArray() on " + data);
+ LOGGER.info(" - skipArray() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -477,7 +480,7 @@
"Parser did not davance to the end of the array");
}
} catch (Throwable t) {
- System.out.println(
+ LOGGER.info(
" " + t.getClass().getSimpleName() + ": " + t.getMessage());
result.fail("skipArray()",
t.getClass().getSimpleName() + ": " + t.getMessage());
@@ -494,7 +497,7 @@
private void testSkipNonArray(final TestResult result) {
for (final JsonValue value : NON_ARRAY_VALUES) {
final String data = jsonData(value);
- System.out.println(" - skipArray() on " + data);
+ LOGGER.info(" - skipArray() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -506,7 +509,7 @@
+ valueToString(value) + " even after skipArray()");
}
} catch (Throwable t) {
- System.out.println(
+ LOGGER.info(
" " + t.getClass().getSimpleName() + ": " + t.getMessage());
result.fail("skipArray()",
t.getClass().getSimpleName() + ": " + t.getMessage());
@@ -522,7 +525,7 @@
private void testSkipObject(final TestResult result) {
for (final JsonObject value : OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - skipObject() on " + data);
+ LOGGER.info(" - skipObject() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -532,7 +535,7 @@
"Parser did not davance to the end of the object");
}
} catch (Throwable t) {
- System.out.println(
+ LOGGER.info(
" " + t.getClass().getSimpleName() + ": " + t.getMessage());
result.fail("skipObject()",
t.getClass().getSimpleName() + ": " + t.getMessage());
@@ -549,7 +552,7 @@
private void testSkipNonObject(final TestResult result) {
for (final JsonValue value : NON_OBJ_VALUES) {
final String data = jsonData(value);
- System.out.println(" - skipObject() on " + data);
+ LOGGER.info(" - skipObject() on " + data);
final StringReader strReader = new StringReader(data);
try (final JsonParser parser = Json.createParser(strReader)) {
parser.next();
@@ -561,7 +564,7 @@
+ valueToString(value) + " even after skipObject()");
}
} catch (Throwable t) {
- System.out.println(
+ LOGGER.info(
" " + t.getClass().getSimpleName() + ": " + t.getMessage());
result.fail("skipObject()",
t.getClass().getSimpleName() + ": " + t.getMessage());
@@ -581,7 +584,7 @@
*/
protected boolean operationFailed(final JsonValue check,
final JsonValue out) {
- System.out.println(" Checking " + valueToString(out));
+ LOGGER.info(" Checking " + valueToString(out));
return out == null || !assertEquals(check, out);
}
@@ -599,7 +602,7 @@
final Stream<Map.Entry<String, JsonValue>> out) {
// Operation failed for null.
if (out == null) {
- System.out.println(" Output is null");
+ LOGGER.info(" Output is null");
return true;
}
final Set<String> keys = new HashSet<>(check.size());
@@ -611,10 +614,10 @@
.hasNext();) {
final Map.Entry<String, JsonValue> item = i.next();
final JsonValue checkValue = check.get(item.getKey());
- System.out.println(" Checking " + valueToString(item.getValue()));
+ LOGGER.info(" Checking " + valueToString(item.getValue()));
// Operation failed if values with the same key are not equal.
if (!item.getValue().equals(checkValue)) {
- System.out.println(" check: " + valueToString(checkValue)
+ LOGGER.info(" check: " + valueToString(checkValue)
+ " stream: " + valueToString(checkValue));
return true;
}
@@ -638,7 +641,7 @@
final Stream<JsonValue> out) {
// Operation failed for null.
if (out == null) {
- System.out.println(" Output is null");
+ LOGGER.info(" Output is null");
return true;
}
final Iterator<JsonValue> ci = check.iterator();
@@ -647,21 +650,21 @@
while (ci.hasNext() && oi.hasNext()) {
final JsonValue checkValue = ci.next();
final JsonValue outValue = oi.next();
- System.out.println(" Checking " + valueToString(outValue));
+ LOGGER.info(" Checking " + valueToString(outValue));
if (!checkValue.equals(outValue)) {
- System.out.println(" check: " + valueToString(checkValue)
+ LOGGER.info(" check: " + valueToString(checkValue)
+ " stream: " + valueToString(checkValue));
return true;
}
}
// Check still has values, something was missing in output.
if (ci.hasNext()) {
- System.out.println(" Output contains less values than expected");
+ LOGGER.info(" Output contains less values than expected");
return true;
}
// Output still has values, it contains more than expected.
if (oi.hasNext()) {
- System.out.println(" Output contains more values than expected");
+ LOGGER.info(" Output contains more values than expected");
return true;
}
return false;
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreaderfactorytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreaderfactorytests/ClientTests.java
index ccb99bb..225f411 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreaderfactorytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreaderfactorytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,44 +21,30 @@
import jakarta.json.*;
-import jakarta.json.stream.*;
import java.io.*;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.Map;
-import java.util.ArrayList;
+import java.util.logging.Logger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
* @testName: jsonReaderFactoryTest1
- *
+ *
* @assertion_ids: JSONP:JAVADOC:419; JSONP:JAVADOC:449; JSONP:JAVADOC:185;
* JSONP:JAVADOC:459;
- *
+ *
* @test_Strategy: Tests the JsonReaderFactory API.
*
* JsonReaderFactory readerFactory = Json.createReaderFactory(Map<String, ?>);
@@ -66,27 +52,27 @@
* = readerFactory.createReader(Reader)
*/
@Test
- public void jsonReaderFactoryTest1() throws Fault {
+ public void jsonReaderFactoryTest1() {
boolean pass = true;
JsonReader reader1 = null;
JsonReader reader2 = null;
JsonObject jsonObject = null;
String jsonObjectText = "{\"foo\":\"bar\"}";
try {
- System.out.println("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
JsonReaderFactory readerFactory = Json
.createReaderFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = readerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("--------------------------------------------------");
- System.out.println("TEST CASE [JsonReaderFactory.createReader(Reader)]");
- System.out.println("--------------------------------------------------");
- System.out.println("Create 1st JsonReader using JsonReaderFactory");
+ LOGGER.info("--------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonReaderFactory.createReader(Reader)]");
+ LOGGER.info("--------------------------------------------------");
+ LOGGER.info("Create 1st JsonReader using JsonReaderFactory");
reader1 = readerFactory.createReader(new StringReader(jsonObjectText));
if (reader1 == null) {
- System.err.println("ReaderFactory failed to create reader1");
+ LOGGER.warning("ReaderFactory failed to create reader1");
pass = false;
} else {
jsonObject = reader1.readObject();
@@ -97,10 +83,10 @@
pass = false;
}
- System.out.println("Create 2nd JsonReader using JsonReaderFactory");
+ LOGGER.info("Create 2nd JsonReader using JsonReaderFactory");
reader2 = readerFactory.createReader(new StringReader(jsonObjectText));
if (reader2 == null) {
- System.err.println("ReaderFactory failed to create reader2");
+ LOGGER.warning("ReaderFactory failed to create reader2");
pass = false;
} else {
jsonObject = reader2.readObject();
@@ -112,18 +98,17 @@
}
} catch (Exception e) {
- throw new Fault("jsonReaderFactoryTest1 Failed: ", e);
+ fail("jsonReaderFactoryTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonReaderFactoryTest1 Failed");
+ assertTrue(pass, "jsonReaderFactoryTest1 Failed");
}
/*
* @testName: jsonReaderFactoryTest2
- *
+ *
* @assertion_ids: JSONP:JAVADOC:420; JSONP:JAVADOC:449; JSONP:JAVADOC:185;
* JSONP:JAVADOC:459;
- *
+ *
* @test_Strategy: Tests the JsonReaderFactory API.
*
* JsonReaderFactory readerFactory = Json.createReaderFactory(Map<String,?>);
@@ -133,33 +118,33 @@
* Create reader with both UTF-8 and UTF-16BE.
*/
@Test
- public void jsonReaderFactoryTest2() throws Fault {
+ public void jsonReaderFactoryTest2() {
boolean pass = true;
JsonReader reader1 = null;
JsonReader reader2 = null;
JsonObject jsonObject = null;
String jsonObjectText = "{\"foo\":\"bar\"}";
try {
- System.out.println("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
JsonReaderFactory readerFactory = Json
.createReaderFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = readerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [JsonReaderFactory.createReader(InputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create 1st JsonReader using JsonReaderFactory with UTF-8 encoding");
InputStream is1 = JSONP_Util.getInputStreamFromString(jsonObjectText);
reader1 = readerFactory.createReader(is1, JSONP_Util.UTF_8);
if (reader1 == null) {
- System.err.println("ReaderFactory failed to create reader1");
+ LOGGER.warning("ReaderFactory failed to create reader1");
pass = false;
} else {
jsonObject = reader1.readObject();
@@ -170,12 +155,12 @@
pass = false;
}
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonReader using JsonReaderFactory with UTF-8 encoding");
InputStream is2 = JSONP_Util.getInputStreamFromString(jsonObjectText);
reader2 = readerFactory.createReader(is2, JSONP_Util.UTF_8);
if (reader2 == null) {
- System.err.println("ReaderFactory failed to create reader2");
+ LOGGER.warning("ReaderFactory failed to create reader2");
pass = false;
} else {
jsonObject = reader2.readObject();
@@ -187,18 +172,17 @@
}
} catch (Exception e) {
- throw new Fault("jsonReaderFactoryTest2 Failed: ", e);
+ fail("jsonReaderFactoryTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonReaderFactoryTest2 Failed");
+ assertTrue(pass, "jsonReaderFactoryTest2 Failed");
}
/*
* @testName: jsonReaderFactoryTest3
- *
+ *
* @assertion_ids: JSONP:JAVADOC:429; JSONP:JAVADOC:449; JSONP:JAVADOC:185;
* JSONP:JAVADOC:459;
- *
+ *
* @test_Strategy: Tests the JsonReaderFactory API.
*
* JsonReaderFactory readerFactory = Json.createReaderFactory(Map<String, ?>);
@@ -206,29 +190,29 @@
* reader2 = readerFactory.createReader(InputStream)
*/
@Test
- public void jsonReaderFactoryTest3() throws Fault {
+ public void jsonReaderFactoryTest3() {
boolean pass = true;
JsonReader reader1 = null;
JsonReader reader2 = null;
JsonObject jsonObject = null;
String jsonObjectText = "{\"foo\":\"bar\"}";
try {
- System.out.println("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
JsonReaderFactory readerFactory = Json
.createReaderFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = readerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-------------------------------------------------------");
- System.out.println("TEST CASE [JsonReaderFactory.createReader(InputStream)]");
- System.out.println("-------------------------------------------------------");
- System.out.println("Create 1st JsonReader using JsonReaderFactory");
+ LOGGER.info("-------------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonReaderFactory.createReader(InputStream)]");
+ LOGGER.info("-------------------------------------------------------");
+ LOGGER.info("Create 1st JsonReader using JsonReaderFactory");
InputStream is1 = JSONP_Util.getInputStreamFromString(jsonObjectText);
reader1 = readerFactory.createReader(is1);
if (reader1 == null) {
- System.err.println("ReaderFactory failed to create reader1");
+ LOGGER.warning("ReaderFactory failed to create reader1");
pass = false;
} else {
jsonObject = reader1.readObject();
@@ -239,11 +223,11 @@
pass = false;
}
- System.out.println("Create 2nd JsonReader using JsonReaderFactory");
+ LOGGER.info("Create 2nd JsonReader using JsonReaderFactory");
InputStream is2 = JSONP_Util.getInputStreamFromString(jsonObjectText);
reader2 = readerFactory.createReader(is2);
if (reader2 == null) {
- System.err.println("ReaderFactory failed to create reader2");
+ LOGGER.warning("ReaderFactory failed to create reader2");
pass = false;
} else {
jsonObject = reader2.readObject();
@@ -255,17 +239,16 @@
}
} catch (Exception e) {
- throw new Fault("jsonReaderFactoryTest3 Failed: ", e);
+ fail("jsonReaderFactoryTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonReaderFactoryTest3 Failed");
+ assertTrue(pass, "jsonReaderFactoryTest3 Failed");
}
/*
* @testName: jsonReaderFactoryTest4
- *
+ *
* @assertion_ids: JSONP:JAVADOC:449; JSONP:JAVADOC:459;
- *
+ *
* @test_Strategy: Tests the JsonReaderFactory API.
*
* JsonReaderFactory readerFactory = Json.createReaderFactory(Map<String, ?>);
@@ -275,32 +258,31 @@
* (empty config) 2) non supported provider property
*/
@Test
- public void jsonReaderFactoryTest4() throws Fault {
+ public void jsonReaderFactoryTest4() {
boolean pass = true;
JsonReaderFactory readerFactory;
Map<String, ?> config;
try {
- System.out.println("----------------------------------------------");
- System.out.println("Test scenario1: no supported provider property");
- System.out.println("----------------------------------------------");
- System.out.println("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test scenario1: no supported provider property");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Create JsonReaderFactory with Map<String, ?> with EMPTY config");
readerFactory = Json.createReaderFactory(JSONP_Util.getEmptyConfig());
config = readerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-----------------------------------------------");
- System.out.println("Test scenario2: non supported provider property");
- System.out.println("-----------------------------------------------");
- System.out.println("Create JsonReaderFactory with Map<String, ?> with FOO config");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Test scenario2: non supported provider property");
+ LOGGER.info("-----------------------------------------------");
+ LOGGER.info("Create JsonReaderFactory with Map<String, ?> with FOO config");
readerFactory = Json.createReaderFactory(JSONP_Util.getFooConfig());
config = readerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonReaderFactoryTest4 Failed: ", e);
+ fail("jsonReaderFactoryTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonReaderFactoryTest4 Failed");
+ assertTrue(pass, "jsonReaderFactoryTest4 Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/ClientTests.java
index b532084..38fa1b0 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,33 +18,24 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import java.io.*;
import java.util.*;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.*;
import jakarta.json.stream.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
// $Id$
-@RunWith(Arquillian.class)
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Utility Methods */
/*
@@ -52,7 +43,7 @@
*/
private boolean compareJsonObjectForUTFEncodedTests(JsonObject jsonObject) {
boolean pass = true;
- System.out.println("Comparing JsonObject values to expected results.");
+ LOGGER.info("Comparing JsonObject values to expected results.");
String expString = "stringValue";
String actString = jsonObject.getJsonString("stringName").getString();
if (!JSONP_Util.assertEquals(expString, actString))
@@ -82,23 +73,20 @@
*
*/
@Test
- public void readEmptyArrayTest() throws Fault {
- boolean pass = true;
+ public void readEmptyArrayTest() {
JsonReader reader = null;
try {
String expJsonText = "[]";
- System.out.println("Testing read of " + expJsonText);
+ LOGGER.info("Testing read of " + expJsonText);
reader = Json.createReader(new StringReader(expJsonText));
JsonArray array = reader.readArray();
- pass = JSONP_Util.assertEqualsEmptyArrayList(array);
+ assertTrue(JSONP_Util.assertEqualsEmptyArrayList(array), "readEmptyArrayTest Failed");
} catch (Exception e) {
- throw new Fault("readEmptyArrayTest Failed: ", e);
+ fail("readEmptyArrayTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEmptyArrayTest Failed");
}
/*
@@ -119,59 +107,58 @@
*
*/
@Test
- public void readEscapeCharsInArrayTest() throws Fault {
+ public void readEscapeCharsInArrayTest() {
boolean pass = true;
JsonReader reader = null;
String resourceFile = "jsonArrayWithEscapeCharsData.json";
String expString = "popeye" + JSONP_Data.escapeCharsAsString + "olive";
try {
- System.out.println("Reading contents of resource file " + resourceFile);
+ LOGGER.info("Reading contents of resource file " + resourceFile);
String readerContents = JSONP_Util
.getContentsOfResourceAsString(resourceFile);
- System.out.println("readerContents=" + readerContents);
+ LOGGER.info("readerContents=" + readerContents);
- System.out.println("Testing read of resource contents: " + readerContents);
+ LOGGER.info("Testing read of resource contents: " + readerContents);
reader = Json.createReader(new StringReader(readerContents));
JsonArray expJsonArray = reader.readArray();
- System.out.println("Dump of expJsonArray");
+ LOGGER.info("Dump of expJsonArray");
JSONP_Util.dumpJsonArray(expJsonArray);
- System.out.println("Comparing JsonArray values with expected results.");
+ LOGGER.info("Comparing JsonArray values with expected results.");
String actString = expJsonArray.getJsonString(0).getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
- System.out.println("Write the JsonArray 'expJsonArray' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'expJsonArray' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(expJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Create actJsonArray from read of writer contents: "
+ LOGGER.info("Create actJsonArray from read of writer contents: "
+ writerContents);
reader = Json.createReader(new StringReader(writerContents));
JsonArray actJsonArray = reader.readArray();
- System.out.println("Dump of actJsonArray");
+ LOGGER.info("Dump of actJsonArray");
JSONP_Util.dumpJsonArray(actJsonArray);
- System.out.println("Compare expJsonArray and actJsonArray for equality");
+ LOGGER.info("Compare expJsonArray and actJsonArray for equality");
if (!JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray))
pass = false;
} catch (Exception e) {
- throw new Fault("readEscapeCharsInArrayTest Failed: ", e);
+ fail("readEscapeCharsInArrayTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeCharsInArrayTest Failed");
+ assertTrue(pass, "readEscapeCharsInArrayTest Failed");
}
/*
@@ -190,25 +177,22 @@
*
*/
@Test
- public void readEscapeUnicodeCharsInArrayTest() throws Fault {
- boolean pass = true;
+ public void readEscapeUnicodeCharsInArrayTest() {
JsonReader reader = null;
String unicodeTextString = "[\"\\u0000\u00ff\\uff00\uffff\"]";
String expResult = "\u0000\u00ff\uff00\uffff";
try {
- System.out.println("Reading array of escaped and non escaped unicode chars.");
+ LOGGER.info("Reading array of escaped and non escaped unicode chars.");
reader = Json.createReader(new StringReader(unicodeTextString));
JsonArray array = reader.readArray();
String actResult = array.getJsonString(0).getString();
- pass = JSONP_Util.assertEquals(expResult, actResult);
+ assertTrue(JSONP_Util.assertEquals(expResult, actResult), "readEscapeUnicodeCharsInArrayTest Failed");
} catch (Exception e) {
- throw new Fault("readEscapeUnicodeCharsInArrayTest Failed: ", e);
+ fail("readEscapeUnicodeCharsInArrayTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeUnicodeCharsInArrayTest Failed");
}
/*
@@ -224,26 +208,23 @@
*
*/
@Test
- public void readEscapeUnicodeControlCharsInArrayTest() throws Fault {
- boolean pass = true;
+ public void readEscapeUnicodeControlCharsInArrayTest() {
JsonReader reader = null;
String unicodeTextString = "[\"" + JSONP_Data.unicodeControlCharsEscaped
+ "\"]";
String expResult = JSONP_Data.unicodeControlCharsNonEscaped;
try {
- System.out.println("Reading array of escaped and non escaped unicode chars.");
+ LOGGER.info("Reading array of escaped and non escaped unicode chars.");
reader = Json.createReader(new StringReader(unicodeTextString));
JsonArray array = reader.readArray();
String actResult = array.getJsonString(0).getString();
- pass = JSONP_Util.assertEquals(expResult, actResult);
+ assertTrue(JSONP_Util.assertEquals(expResult, actResult), "readEscapeUnicodeControlCharsInArrayTest Failed");
} catch (Exception e) {
- throw new Fault("readEscapeUnicodeControlCharsInArrayTest Failed: ", e);
+ fail("readEscapeUnicodeControlCharsInArrayTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeUnicodeControlCharsInArrayTest Failed");
}
/*
@@ -256,23 +237,20 @@
*
*/
@Test
- public void readEmptyObjectTest() throws Fault {
- boolean pass = true;
+ public void readEmptyObjectTest() {
JsonReader reader = null;
try {
String expJsonText = "{}";
- System.out.println("Testing read of " + expJsonText);
+ LOGGER.info("Testing read of " + expJsonText);
reader = Json.createReader(new StringReader(expJsonText));
JsonObject object = reader.readObject();
- pass = JSONP_Util.assertEqualsEmptyObjectMap(object);
+ assertTrue(JSONP_Util.assertEqualsEmptyObjectMap(object), "readEmptyObjectTest Failed");
} catch (Exception e) {
- throw new Fault("readEmptyObjectTest Failed: ", e);
+ fail("readEmptyObjectTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEmptyObjectTest Failed");
}
/*
@@ -293,59 +271,58 @@
*
*/
@Test
- public void readEscapeCharsInObjectTest() throws Fault {
+ public void readEscapeCharsInObjectTest() {
boolean pass = true;
JsonReader reader = null;
String resourceFile = "jsonObjectWithEscapeCharsData.json";
String expString = "popeye" + JSONP_Data.escapeCharsAsString + "olive";
try {
- System.out.println("Reading contents of resource file " + resourceFile);
+ LOGGER.info("Reading contents of resource file " + resourceFile);
String readerContents = JSONP_Util
.getContentsOfResourceAsString(resourceFile);
- System.out.println("readerContents=" + readerContents);
+ LOGGER.info("readerContents=" + readerContents);
- System.out.println("Testing read of resource contents: " + readerContents);
+ LOGGER.info("Testing read of resource contents: " + readerContents);
reader = Json.createReader(new StringReader(readerContents));
JsonObject expJsonObject = reader.readObject();
- System.out.println("Dump of expJsonObject");
+ LOGGER.info("Dump of expJsonObject");
JSONP_Util.dumpJsonObject(expJsonObject);
- System.out.println("Comparing JsonArray values with expected results.");
+ LOGGER.info("Comparing JsonArray values with expected results.");
String actString = expJsonObject.getJsonString("escapeChars").getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
- System.out.println("Write the JsonObject 'expJsonObject' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'expJsonObject' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(expJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Create actJsonObject from read of writer contents: "
+ LOGGER.info("Create actJsonObject from read of writer contents: "
+ writerContents);
reader = Json.createReader(new StringReader(writerContents));
JsonObject actJsonObject = reader.readObject();
- System.out.println("Dump of actJsonObject");
+ LOGGER.info("Dump of actJsonObject");
JSONP_Util.dumpJsonObject(actJsonObject);
- System.out.println("Compare expJsonObject and actJsonObject for equality");
+ LOGGER.info("Compare expJsonObject and actJsonObject for equality");
if (!JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject))
pass = false;
} catch (Exception e) {
- throw new Fault("readEscapeCharsInObjectTest Failed: ", e);
+ fail("readEscapeCharsInObjectTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeCharsInObjectTest Failed");
+ assertTrue(pass, "readEscapeCharsInObjectTest Failed");
}
/*
@@ -364,25 +341,22 @@
*
*/
@Test
- public void readEscapeUnicodeCharsInObjectTest() throws Fault {
- boolean pass = true;
+ public void readEscapeUnicodeCharsInObjectTest() {
JsonReader reader = null;
String unicodeTextString = "{\"unicodechars\":\"\\u0000\u00ff\\uff00\uffff\"}";
String expResult = "\u0000\u00ff\uff00\uffff";
try {
- System.out.println("Reading object of escaped and non escaped unicode chars.");
+ LOGGER.info("Reading object of escaped and non escaped unicode chars.");
reader = Json.createReader(new StringReader(unicodeTextString));
JsonObject object = reader.readObject();
String actResult = object.getJsonString("unicodechars").getString();
- pass = JSONP_Util.assertEquals(expResult, actResult);
+ assertTrue(JSONP_Util.assertEquals(expResult, actResult), "readEscapeUnicodeCharsInObjectTest Failed");
} catch (Exception e) {
- throw new Fault("readEscapeUnicodeCharsInObjectTest Failed: ", e);
+ fail("readEscapeUnicodeCharsInObjectTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeUnicodeCharsInObjectTest Failed");
}
/*
@@ -398,26 +372,23 @@
*
*/
@Test
- public void readEscapeUnicodeControlCharsInObjectTest() throws Fault {
- boolean pass = true;
+ public void readEscapeUnicodeControlCharsInObjectTest() {
JsonReader reader = null;
String unicodeTextString = "{\"unicodechars\":\""
+ JSONP_Data.unicodeControlCharsEscaped + "\"}";
String expResult = JSONP_Data.unicodeControlCharsNonEscaped;
try {
- System.out.println("Reading array of escaped and non escaped unicode chars.");
+ LOGGER.info("Reading array of escaped and non escaped unicode chars.");
reader = Json.createReader(new StringReader(unicodeTextString));
JsonObject object = reader.readObject();
String actResult = object.getJsonString("unicodechars").getString();
- pass = JSONP_Util.assertEquals(expResult, actResult);
+ assertTrue(JSONP_Util.assertEquals(expResult, actResult), "readEscapeUnicodeControlCharsInObjectTest Failed");
} catch (Exception e) {
- throw new Fault("readEscapeUnicodeControlCharsInObjectTest Failed: ", e);
+ fail("readEscapeUnicodeControlCharsInObjectTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readEscapeUnicodeControlCharsInObjectTest Failed");
}
/*
@@ -437,8 +408,7 @@
*
*/
@Test
- public void readArrayTest() throws Fault {
- boolean pass = true;
+ public void readArrayTest() {
JsonReader reader = null;
try {
String jsonText = "[true,false,null,\"booyah\",2147483647,9223372036854775807,1.7976931348623157E308,"
@@ -446,7 +416,7 @@
+ "{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1,"
+ "\"double\":10.4}]";
- System.out.println("Create the expected list of JsonArray values");
+ LOGGER.info("Create the expected list of JsonArray values");
List<JsonValue> expList = new ArrayList<>();
expList.add(JsonValue.TRUE);
expList.add(JsonValue.FALSE);
@@ -465,22 +435,20 @@
expList.add(array);
expList.add(object);
- System.out.println("Testing read of " + jsonText);
+ LOGGER.info("Testing read of " + jsonText);
reader = Json.createReader(new StringReader(jsonText));
JsonArray myJsonArray = reader.readArray();
List<JsonValue> actList = myJsonArray;
- System.out.println(
+ LOGGER.info(
"Compare actual list of JsonArray values with expected list of JsonArray values");
- pass = JSONP_Util.assertEqualsList(expList, actList);
+ assertTrue(JSONP_Util.assertEqualsList(expList, actList), "readArrayTest Failed");
} catch (Exception e) {
- throw new Fault("readArrayTest Failed: ", e);
+ fail("readArrayTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayTest Failed");
}
/*
@@ -502,11 +470,10 @@
*
*/
@Test
- public void readArrayTest2() throws Fault {
- boolean pass = true;
+ public void readArrayTest2() {
JsonReader reader = null;
try {
- System.out.println("Create the expected list of JsonArray values");
+ LOGGER.info("Create the expected list of JsonArray values");
JsonArray expJsonArray = Json.createArrayBuilder().add(JsonValue.TRUE)
.add(JsonValue.FALSE).add(JsonValue.NULL).add("booyah")
.add(Integer.MAX_VALUE).add(Long.MAX_VALUE).add(Double.MAX_VALUE)
@@ -518,33 +485,31 @@
.add("bonga", "boo").add("int", 1).add("double", 10.4))
.build();
- System.out.println("Write the JsonArray 'expJsonArray' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'expJsonArray' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(expJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String jsonText = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + jsonText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + jsonText);
- System.out.println("Testing read of " + jsonText);
+ LOGGER.info("Testing read of " + jsonText);
reader = Json.createReader(JSONP_Util.getInputStreamFromString(jsonText));
JsonArray actJsonArray = reader.readArray();
- System.out.println("Compare expJsonArray and actJsonArray for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray);
+ LOGGER.info("Compare expJsonArray and actJsonArray for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray), "readArrayTest2 Failed");
} catch (Exception e) {
- throw new Fault("readArrayTest2 Failed: ", e);
+ fail("readArrayTest2 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayTest2 Failed");
}
/*
@@ -569,39 +534,36 @@
*
*/
@Test
- public void readArrayTest3() throws Fault {
- boolean pass = true;
+ public void readArrayTest3() {
JsonReader reader = null;
try {
String expJsonText = "[true,false,null,\"booyah\",2147483647,9223372036854775807,"
+ "[true,false,null,\"bingo\",-2147483648,-9223372036854775808],"
+ "{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1}]";
- System.out.println("Testing read of " + expJsonText);
+ LOGGER.info("Testing read of " + expJsonText);
reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig())
.createReader(new StringReader(expJsonText));
JsonArray myJsonArray = reader.readArray();
- System.out.println("Write the JsonArray 'myJsonArray' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(myJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonText = sWriter.toString();
- System.out.println("Compare actual JSON text with expected JSON text");
- pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText);
+ LOGGER.info("Compare actual JSON text with expected JSON text");
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText), "readArrayTest3 Failed");
} catch (Exception e) {
- throw new Fault("readArrayTest3 Failed: ", e);
+ fail("readArrayTest3 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayTest3 Failed");
}
/*
@@ -620,12 +582,11 @@
*
*/
@Test
- public void readArrayTest4() throws Fault {
- boolean pass = true;
+ public void readArrayTest4() {
JsonReader reader = null;
String resourceFile = "jsonArrayWithAllTypesOfData.json";
try {
- System.out.println(
+ LOGGER.info(
"Read contents of InputStream from resource file: " + resourceFile);
Map<String, ?> config = JSONP_Util.getEmptyConfig();
reader = Json.createReaderFactory(config).createReader(
@@ -633,37 +594,35 @@
JSONP_Util.UTF_8);
JsonArray expJsonArray = reader.readArray();
- System.out.println("Dump of expJsonArray");
+ LOGGER.info("Dump of expJsonArray");
JSONP_Util.dumpJsonArray(expJsonArray);
- System.out.println("Write the JsonArray 'expJsonArray' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'expJsonArray' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(expJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Create actJsonArray from read of writer contents: "
+ LOGGER.info("Create actJsonArray from read of writer contents: "
+ writerContents);
reader = Json.createReader(new StringReader(writerContents));
JsonArray actJsonArray = reader.readArray();
- System.out.println("Dump of actJsonArray");
+ LOGGER.info("Dump of actJsonArray");
JSONP_Util.dumpJsonArray(actJsonArray);
- System.out.println("Compare expJsonArray and actJsonArray for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray);
+ LOGGER.info("Compare expJsonArray and actJsonArray for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray), "readArrayTest4 Failed");
} catch (Exception e) {
- throw new Fault("readArrayTest4 Failed: ", e);
+ fail("readArrayTest4 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayTest4 Failed");
}
/*
@@ -687,54 +646,51 @@
*
*/
@Test
- public void readArrayTest5() throws Fault {
- boolean pass = true;
+ public void readArrayTest5() {
JsonReader reader = null;
String resourceFile = "jsonArrayWithLotsOfNestedObjectsData.json";
try {
- System.out.println("Reading contents of resource file " + resourceFile);
+ LOGGER.info("Reading contents of resource file " + resourceFile);
String readerContents = JSONP_Util
.getContentsOfResourceAsString(resourceFile);
- System.out.println("readerContents=" + readerContents);
+ LOGGER.info("readerContents=" + readerContents);
// Create expected JSON text from resource contents filtered of whitespace
// for comparison
- System.out.println("Filter readerContents of whitespace for comparison");
+ LOGGER.info("Filter readerContents of whitespace for comparison");
String expJsonText = JSONP_Util.removeWhitespace(readerContents);
- System.out.println(
+ LOGGER.info(
"Read contents of InputStream from resource file: " + resourceFile);
reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig())
.createReader(JSONP_Util.getInputStreamFromResource(resourceFile),
JSONP_Util.UTF_8);
JsonArray myJsonArray = (JsonArray) reader.read();
- System.out.println("Write the JsonArray 'myJsonArray' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(myJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Dump contents of the JsonWriter as a String");
- System.out.println("writerContents=" + writerContents);
+ LOGGER.info("Dump contents of the JsonWriter as a String");
+ LOGGER.info("writerContents=" + writerContents);
- System.out.println("Filter writerContents of whitespace for comparison");
+ LOGGER.info("Filter writerContents of whitespace for comparison");
String actJsonText = JSONP_Util.removeWhitespace(writerContents);
- System.out.println("Compare actual JSON text with expected JSON text");
- pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText);
+ LOGGER.info("Compare actual JSON text with expected JSON text");
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText), "readArrayTest5 Failed");
} catch (Exception e) {
- throw new Fault("readArrayTest5 Failed: ", e);
+ fail("readArrayTest5 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayTest5 Failed");
}
/*
@@ -751,7 +707,7 @@
* of the JsonString. Compare expected string with actual string for equality.
*/
@Test
- public void readArrayEncodingTest() throws Fault {
+ public void readArrayEncodingTest() {
boolean pass = true;
JsonReader reader = null;
String expString = "a\u65e8\u452c\u8b9e\u6589\u5c57\u5217z";
@@ -759,42 +715,41 @@
String resourceFileUTF16BE = "jsonArrayUTF16BE.json";
Map<String, ?> config = JSONP_Util.getEmptyConfig();
try {
- System.out.println("Reading contents of resource file using UTF-8 encoding "
+ LOGGER.info("Reading contents of resource file using UTF-8 encoding "
+ resourceFileUTF8);
InputStream is = JSONP_Util.getInputStreamFromResource(resourceFileUTF8);
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_8);
JsonArray jsonArray = reader.readArray();
- System.out.println("Comparing JsonArray values with expected results.");
+ LOGGER.info("Comparing JsonArray values with expected results.");
String actString = jsonArray.getJsonString(0).getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("readArrayEncodingTest Failed: ", e);
+ fail("readArrayEncodingTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
try {
- System.out.println("Reading contents of resource file using UTF-16BE encoding "
+ LOGGER.info("Reading contents of resource file using UTF-16BE encoding "
+ resourceFileUTF16BE);
InputStream is = JSONP_Util
.getInputStreamFromResource(resourceFileUTF16BE);
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_16BE);
JsonArray jsonArray = reader.readArray();
- System.out.println("Comparing JsonArray values with expected results.");
+ LOGGER.info("Comparing JsonArray values with expected results.");
String actString = jsonArray.getJsonString(0).getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("readArrayEncodingTest Failed: ", e);
+ fail("readArrayEncodingTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readArrayEncodingTest Failed");
+ assertTrue(pass, "readArrayEncodingTest Failed");
}
/*
@@ -815,8 +770,7 @@
*
*/
@Test
- public void readObjectTest() throws Fault {
- boolean pass = true;
+ public void readObjectTest() {
JsonReader reader = null;
try {
String expJsonText = "{\"true\":true,\"false\":false,\"null\":null,\"booyah\":\"booyah\",\"int\":2147483647,"
@@ -825,7 +779,7 @@
+ "\"object\":{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1,"
+ "\"double\":10.4}}";
- System.out.println("Create the expected map of JsonObject values");
+ LOGGER.info("Create the expected map of JsonObject values");
Map<String, JsonValue> expMap = new HashMap<>();
expMap.put("true", JsonValue.TRUE);
expMap.put("false", JsonValue.FALSE);
@@ -844,22 +798,20 @@
expMap.put("array", array);
expMap.put("object", object);
- System.out.println("Testing read of " + expJsonText);
+ LOGGER.info("Testing read of " + expJsonText);
reader = Json.createReader(new StringReader(expJsonText));
JsonObject myJsonObject = reader.readObject();
Map<String, JsonValue> actMap = myJsonObject;
- System.out.println(
+ LOGGER.info(
"Compare actual map of JsonObject values with expected map of JsonObject values");
- pass = JSONP_Util.assertEqualsMap(expMap, actMap);
+ assertTrue(JSONP_Util.assertEqualsMap(expMap, actMap), "readObjectTest Failed");
} catch (Exception e) {
- throw new Fault("readObjectTest Failed: ", e);
+ fail("readObjectTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectTest Failed");
}
/*
@@ -881,11 +833,10 @@
*
*/
@Test
- public void readObjectTest2() throws Fault {
- boolean pass = true;
+ public void readObjectTest2() {
JsonReader reader = null;
try {
- System.out.println("Create the expected list of JsonObject values");
+ LOGGER.info("Create the expected list of JsonObject values");
JsonObject expJsonObject = Json.createObjectBuilder()
.add("true", JsonValue.TRUE).add("false", JsonValue.FALSE)
.add("null", JsonValue.NULL).add("booyah", "booyah")
@@ -901,33 +852,31 @@
.add("bonga", "boo").add("int", 1).add("double", 10.4))
.build();
- System.out.println("Write the JsonObject 'expJsonObject' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'expJsonObject' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(expJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String jsonText = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + jsonText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + jsonText);
- System.out.println("Testing read of " + jsonText);
+ LOGGER.info("Testing read of " + jsonText);
reader = Json.createReader(JSONP_Util.getInputStreamFromString(jsonText));
JsonObject actJsonObject = reader.readObject();
- System.out.println("Compare expJsonObject and actJsonObject for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject);
+ LOGGER.info("Compare expJsonObject and actJsonObject for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject), "readObjectTest2 Failed");
} catch (Exception e) {
- throw new Fault("readObjectTest2 Failed: ", e);
+ fail("readObjectTest2 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectTest2 Failed");
}
/*
@@ -954,39 +903,36 @@
*
*/
@Test
- public void readObjectTest3() throws Fault {
- boolean pass = true;
+ public void readObjectTest3() {
JsonReader reader = null;
try {
String expJsonText = "{\"true\":true,\"false\":false,\"null\":null,\"booyah\":\"booyah\",\"int\":2147483647,\"long\":9223372036854775807,"
+ "\"array\":[true,false,null,\"bingo\",-2147483648,-9223372036854775808],"
+ "\"object\":{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1}}";
- System.out.println("Testing read of " + expJsonText);
+ LOGGER.info("Testing read of " + expJsonText);
reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig())
.createReader(new StringReader(expJsonText));
JsonObject myJsonObject = reader.readObject();
- System.out.println("Write the JsonObject 'myJsonObject' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(myJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonText = sWriter.toString();
- System.out.println("Compare actual JSON text with expected JSON text");
- pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText);
+ LOGGER.info("Compare actual JSON text with expected JSON text");
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText), "readObjectTest3 Failed");
} catch (Exception e) {
- throw new Fault("readObjectTest3 Failed: ", e);
+ fail("readObjectTest3 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectTest3 Failed");
}
/*
@@ -1005,12 +951,11 @@
*
*/
@Test
- public void readObjectTest4() throws Fault {
- boolean pass = true;
+ public void readObjectTest4() {
JsonReader reader = null;
String resourceFile = "jsonObjectWithAllTypesOfData.json";
try {
- System.out.println(
+ LOGGER.info(
"Read contents of InputStream from resource file: " + resourceFile);
Map<String, ?> config = JSONP_Util.getEmptyConfig();
reader = Json.createReaderFactory(config).createReader(
@@ -1018,37 +963,35 @@
JSONP_Util.UTF_8);
JsonObject expJsonObject = reader.readObject();
- System.out.println("Dump of expJsonObject");
+ LOGGER.info("Dump of expJsonObject");
JSONP_Util.dumpJsonObject(expJsonObject);
- System.out.println("Write the JsonObject 'expJsonObject' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'expJsonObject' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(expJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Create actJsonObject from read of writer contents: "
+ LOGGER.info("Create actJsonObject from read of writer contents: "
+ writerContents);
reader = Json.createReader(new StringReader(writerContents));
JsonObject actJsonObject = reader.readObject();
- System.out.println("Dump of actJsonObject");
+ LOGGER.info("Dump of actJsonObject");
JSONP_Util.dumpJsonObject(actJsonObject);
- System.out.println("Compare expJsonObject and actJsonObject for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject);
+ LOGGER.info("Compare expJsonObject and actJsonObject for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject), "readObjectTest4 Failed");
} catch (Exception e) {
- throw new Fault("readObjectTest4 Failed: ", e);
+ fail("readObjectTest4 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectTest4 Failed");
}
/*
@@ -1072,54 +1015,51 @@
*
*/
@Test
- public void readObjectTest5() throws Fault {
- boolean pass = true;
+ public void readObjectTest5() {
JsonReader reader = null;
String resourceFile = "jsonObjectWithLotsOfNestedObjectsData.json";
try {
- System.out.println("Reading contents of resource file " + resourceFile);
+ LOGGER.info("Reading contents of resource file " + resourceFile);
String readerContents = JSONP_Util
.getContentsOfResourceAsString(resourceFile);
- System.out.println("readerContents=" + readerContents);
+ LOGGER.info("readerContents=" + readerContents);
// Create expected JSON text from resource contents filtered of whitespace
// for comparison
- System.out.println("Filter readerContents of whitespace for comparison");
+ LOGGER.info("Filter readerContents of whitespace for comparison");
String expJsonText = JSONP_Util.removeWhitespace(readerContents);
- System.out.println(
+ LOGGER.info(
"Read contents of InputStream from resource file: " + resourceFile);
reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig())
.createReader(JSONP_Util.getInputStreamFromResource(resourceFile),
JSONP_Util.UTF_8);
JsonObject myJsonObject = (JsonObject) reader.read();
- System.out.println("Write the JsonObject 'myJsonObject' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(myJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("Dump contents of the JsonWriter as a String");
- System.out.println("writerContents=" + writerContents);
+ LOGGER.info("Dump contents of the JsonWriter as a String");
+ LOGGER.info("writerContents=" + writerContents);
- System.out.println("Filter writerContents of whitespace for comparison");
+ LOGGER.info("Filter writerContents of whitespace for comparison");
String actJsonText = JSONP_Util.removeWhitespace(writerContents);
- System.out.println("Compare actual JSON text with expected JSON text");
- pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText);
+ LOGGER.info("Compare actual JSON text with expected JSON text");
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText), "readObjectTest5 Failed");
} catch (Exception e) {
- throw new Fault("readObjectTest5 Failed: ", e);
+ fail("readObjectTest5 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectTest5 Failed");
}
/*
@@ -1136,32 +1076,32 @@
* of the JsonString. Compare expected string with actual string for equality.
*/
@Test
- public void readObjectEncodingTest() throws Fault {
+ public void readObjectEncodingTest() {
boolean pass = true;
JsonReader reader = null;
String expString = "a\u65e8\u452c\u8b9e\u6589\u5c57\u5217z";
String resourceFileUTF8 = "jsonObjectUTF8.json";
String resourceFileUTF16LE = "jsonObjectUTF16LE.json";
try {
- System.out.println("Reading contents of resource file using UTF-8 encoding "
+ LOGGER.info("Reading contents of resource file using UTF-8 encoding "
+ resourceFileUTF8);
InputStream is = JSONP_Util.getInputStreamFromResource(resourceFileUTF8);
Map<String, ?> config = JSONP_Util.getEmptyConfig();
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_8);
JsonObject jsonObject = reader.readObject();
- System.out.println("Comparing JsonObject values with expected results.");
+ LOGGER.info("Comparing JsonObject values with expected results.");
String actString = jsonObject.getJsonString("unicodeChars").getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("readObjectEncodingTest Failed: ", e);
+ fail("readObjectEncodingTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
try {
- System.out.println("Reading contents of resource file using UTF-16LE encoding "
+ LOGGER.info("Reading contents of resource file using UTF-16LE encoding "
+ resourceFileUTF16LE);
InputStream is = JSONP_Util
.getInputStreamFromResource(resourceFileUTF16LE);
@@ -1169,18 +1109,17 @@
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_16LE);
JsonObject jsonObject = reader.readObject();
- System.out.println("Comparing JsonObject values with expected results.");
+ LOGGER.info("Comparing JsonObject values with expected results.");
String actString = jsonObject.getJsonString("unicodeChars").getString();
if (!JSONP_Util.assertEquals(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("readObjectEncodingTest Failed: ", e);
+ fail("readObjectEncodingTest Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("readObjectEncodingTest Failed");
+ assertTrue(pass, "readObjectEncodingTest Failed");
}
/*
@@ -1206,22 +1145,22 @@
* argument for each encoding type read.
*/
@Test
- public void readUTFEncodedTests() throws Fault {
+ public void readUTFEncodedTests() {
boolean pass = true;
JsonReader reader = null;
Map<String, ?> config = JSONP_Util.getEmptyConfig();
try {
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-8]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF8.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-8");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_8);
@@ -1230,7 +1169,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-8 encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1239,17 +1178,17 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-16]");
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-16");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_16);
@@ -1258,7 +1197,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-16 encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-16 encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1267,17 +1206,17 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-16LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-16LE");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_16LE);
@@ -1286,7 +1225,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-16LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-16LE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1295,17 +1234,17 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-16BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-16BE");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_16BE);
@@ -1314,7 +1253,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-16BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-16BE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1323,17 +1262,17 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-32LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-32LE");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_32LE);
@@ -1342,7 +1281,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-32LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-32LE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1351,17 +1290,17 @@
}
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createReaderFactory(Map<String,?>).createReader(InputStream, Charset) as UTF-32BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream with character encoding UTF-32BE");
reader = Json.createReaderFactory(config).createReader(is,
JSONP_Util.UTF_32BE);
@@ -1370,7 +1309,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-32BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-32BE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1378,8 +1317,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("readUTFEncodedTests Failed");
+ assertTrue(pass, "readUTFEncodedTests Failed");
}
/*
@@ -1403,18 +1341,18 @@
* auto-detected and determined as per the RFC.
*/
@Test
- public void readUTFEncodedTests2() throws Fault {
+ public void readUTFEncodedTests2() {
boolean pass = true;
JsonReader reader = null;
try {
- System.out.println("---------------------------------------------------");
- System.out.println("TEST CASE [Json.createReader(InputStream) as UTF-8]");
- System.out.println("---------------------------------------------------");
- System.out.println(
+ LOGGER.info("---------------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createReader(InputStream) as UTF-8]");
+ LOGGER.info("---------------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF8.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream and auto-detect character encoding UTF-8");
reader = Json.createReader(is);
JsonObject jsonObject = reader.readObject();
@@ -1422,7 +1360,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-8 encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1431,14 +1369,14 @@
}
}
try {
- System.out.println("------------------------------------------------------");
- System.out.println("TEST CASE [Json.createReader(InputStream) as UTF-16LE]");
- System.out.println("------------------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createReader(InputStream) as UTF-16LE]");
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream and auto-detect character encoding UTF-16LE");
reader = Json.createReader(is);
JsonObject jsonObject = reader.readObject();
@@ -1446,7 +1384,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-16LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-16LE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1455,14 +1393,14 @@
}
}
try {
- System.out.println("------------------------------------------------------");
- System.out.println("TEST CASE [Json.createReader(InputStream) as UTF-16BE]");
- System.out.println("------------------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createReader(InputStream) as UTF-16BE]");
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF16BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream and auto-detect character encoding UTF-16BE");
reader = Json.createReader(is);
JsonObject jsonObject = reader.readObject();
@@ -1470,7 +1408,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-16BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-16BE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1479,14 +1417,14 @@
}
}
try {
- System.out.println("------------------------------------------------------");
- System.out.println("TEST CASE [Json.createReader(InputStream) as UTF-32LE]");
- System.out.println("------------------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createReader(InputStream) as UTF-32LE]");
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32LE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream and auto-detect character encoding UTF-32LE");
reader = Json.createReader(is);
JsonObject jsonObject = reader.readObject();
@@ -1494,7 +1432,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-32LE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-32LE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1503,14 +1441,14 @@
}
}
try {
- System.out.println("------------------------------------------------------");
- System.out.println("TEST CASE [Json.createReader(InputStream) as UTF-32BE]");
- System.out.println("------------------------------------------------------");
- System.out.println(
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info("TEST CASE [Json.createReader(InputStream) as UTF-32BE]");
+ LOGGER.info("------------------------------------------------------");
+ LOGGER.info(
"Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)");
InputStream is = JSONP_Util
.getInputStreamFromResource("jsonObjectEncodingUTF32BE.json");
- System.out.println(
+ LOGGER.info(
"Create JsonReader from the InputStream and auto-detect character encoding UTF-32BE");
reader = Json.createReader(is);
JsonObject jsonObject = reader.readObject();
@@ -1518,7 +1456,7 @@
pass = false;
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing reading of UTF-32BE encoding: " + e);
+ LOGGER.warning("Exception occurred testing reading of UTF-32BE encoding: " + e);
} finally {
try {
if (reader != null)
@@ -1526,8 +1464,7 @@
} catch (Exception e) {
}
}
- if (!pass)
- throw new Fault("readUTFEncodedTests2 Failed");
+ assertTrue(pass, "readUTFEncodedTests2 Failed");
}
/*
@@ -1541,23 +1478,23 @@
*
*/
@Test
- public void negativeObjectTests() throws Fault {
+ public void negativeObjectTests() {
boolean pass = true;
JsonReader reader = null;
// Not an object []
try {
- System.out.println("Testing for not an object '[]'");
+ LOGGER.info("Testing for not an object '[]'");
reader = Json.createReader(new StringReader("[]"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonException");
+ LOGGER.warning("Failed to throw JsonException");
} catch (JsonException e) {
- System.out.println("Got expected JsonException");
+ LOGGER.info("Got expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1566,34 +1503,34 @@
// Trip JsonParsingException for JsonReader.readObject() if incorrect
// representation for object
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if incorrect representation for object.");
- System.out.println("Reading " + "{\"name\":\"value\",1,2,3}");
+ LOGGER.info("Reading " + "{\"name\":\"value\",1,2,3}");
reader = Json
.createReader(new StringReader("{\"name\":\"value\",1,2,3}"));
JsonObject jsonObject = reader.readObject();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Missing [
try {
- System.out.println("Testing for missing '['");
+ LOGGER.info("Testing for missing '['");
reader = Json.createReader(new StringReader("{1,2]}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1602,16 +1539,16 @@
// Missing ]
try {
- System.out.println("Testing for missing ']'");
+ LOGGER.info("Testing for missing ']'");
reader = Json.createReader(new StringReader("{[1,2}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1620,16 +1557,16 @@
// Missing {
try {
- System.out.println("Testing for missing '{'");
+ LOGGER.info("Testing for missing '{'");
reader = Json.createReader(new StringReader("}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1638,16 +1575,16 @@
// Missing }
try {
- System.out.println("Testing for missing '}'");
+ LOGGER.info("Testing for missing '}'");
reader = Json.createReader(new StringReader("{"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1656,16 +1593,16 @@
// Missing , between array elements test case 1
try {
- System.out.println("Testing for missing ',' between array elements test case 1");
+ LOGGER.info("Testing for missing ',' between array elements test case 1");
reader = Json.createReader(new StringReader("{[5\"foo\"]}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1674,16 +1611,16 @@
// Missing , between array elements test case 2
try {
- System.out.println("Testing for missing ',' between array elements test case 2");
+ LOGGER.info("Testing for missing ',' between array elements test case 2");
reader = Json.createReader(new StringReader("{[5{}]}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1692,16 +1629,16 @@
// Missing , between object elements test case 1
try {
- System.out.println("Testing for missing ',' between object elements test case 1");
+ LOGGER.info("Testing for missing ',' between object elements test case 1");
reader = Json.createReader(new StringReader("{\"foo\":\"bar\"5}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1710,16 +1647,16 @@
// Missing , between object elements test case 2
try {
- System.out.println("Testing for missing ',' between object elements test case 2");
+ LOGGER.info("Testing for missing ',' between object elements test case 2");
reader = Json.createReader(new StringReader("{\"one\":1[]}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1728,16 +1665,16 @@
// Missing key name in object element
try {
- System.out.println("Testing for missing key name in object element");
+ LOGGER.info("Testing for missing key name in object element");
reader = Json.createReader(new StringReader("{:\"bar\"}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1746,16 +1683,16 @@
// Missing value name in object element
try {
- System.out.println("Testing for missing value name in object element");
+ LOGGER.info("Testing for missing value name in object element");
reader = Json.createReader(new StringReader("{\"foo\":}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1764,16 +1701,16 @@
// Missing double quote on a name
try {
- System.out.println("Test for missing double quote on a name");
+ LOGGER.info("Test for missing double quote on a name");
reader = Json.createReader(new StringReader("{name\" : \"value\"}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1782,16 +1719,16 @@
// Missing double quote on a value
try {
- System.out.println("Test for missing double quote on a value");
+ LOGGER.info("Test for missing double quote on a value");
reader = Json.createReader(new StringReader("{\"name\" : value\"}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1800,16 +1737,16 @@
// Incorrect digit value test case 1
try {
- System.out.println("Incorrect digit value -foo");
+ LOGGER.info("Incorrect digit value -foo");
reader = Json.createReader(new StringReader("{\"number\" : -foo}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1818,16 +1755,16 @@
// Incorrect digit value test case 2
try {
- System.out.println("Incorrect digit value +foo");
+ LOGGER.info("Incorrect digit value +foo");
reader = Json.createReader(new StringReader("{\"number\" : +foo}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1836,16 +1773,16 @@
// Incorrect digit value test case 3
try {
- System.out.println("Incorrect digit value -784foo");
+ LOGGER.info("Incorrect digit value -784foo");
reader = Json.createReader(new StringReader("{\"number\" : -784foo}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1854,16 +1791,16 @@
// Incorrect digit value test case 4
try {
- System.out.println("Incorrect digit value +784foo");
+ LOGGER.info("Incorrect digit value +784foo");
reader = Json.createReader(new StringReader("{\"number\" : +784foo}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1872,16 +1809,16 @@
// Incorrect digit value test case 5
try {
- System.out.println("Incorrect digit value 0.1E5E5");
+ LOGGER.info("Incorrect digit value 0.1E5E5");
reader = Json.createReader(new StringReader("{\"number\" : 0.1E5E5}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1890,16 +1827,16 @@
// Incorrect digit value test case 6
try {
- System.out.println("Incorrect digit value 0.F10");
+ LOGGER.info("Incorrect digit value 0.F10");
reader = Json.createReader(new StringReader("{\"number\" : 0.F10}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1908,16 +1845,16 @@
// Incorrect digit value test case 7
try {
- System.out.println("Incorrect digit value string");
+ LOGGER.info("Incorrect digit value string");
reader = Json.createReader(new StringReader("{\"number\" : string}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1926,16 +1863,16 @@
// Incorrect digit value test case 8 (hex numbers invalid per JSON RFC)
try {
- System.out.println("Incorrect digit value hex numbers invalid per JSON RFC");
+ LOGGER.info("Incorrect digit value hex numbers invalid per JSON RFC");
reader = Json.createReader(new StringReader("{\"number\" : 0x137a}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1944,23 +1881,22 @@
// Incorrect digit value test case 9 (octal numbers invalid per JSON RFC)
try {
- System.out.println("Incorrect digit value octal numbers invalid per JSON RFC");
+ LOGGER.info("Incorrect digit value octal numbers invalid per JSON RFC");
reader = Json.createReader(new StringReader("{\"number\" : 0137}"));
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("negativeObjectTests Failed");
+ assertTrue(pass, "negativeObjectTests Failed");
}
/*
@@ -1974,23 +1910,23 @@
*
*/
@Test
- public void negativeArrayTests() throws Fault {
+ public void negativeArrayTests() {
boolean pass = true;
JsonReader reader = null;
// Not an array {}
try {
- System.out.println("Testing for not an array '{}'");
+ LOGGER.info("Testing for not an array '{}'");
reader = Json.createReader(new StringReader("{}"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonException");
+ LOGGER.warning("Failed to throw JsonException");
} catch (JsonException e) {
- System.out.println("Got expected JsonException");
+ LOGGER.info("Got expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -1999,34 +1935,34 @@
// Trip JsonParsingException for JsonReader.readArray() if incorrect
// representation for array
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.readArray() if incorrect representation for array.");
- System.out.println("Reading " + "[foo,10,\"name\":\"value\"]");
+ LOGGER.info("Reading " + "[foo,10,\"name\":\"value\"]");
reader = Json
.createReader(new StringReader("[foo,10,\"name\":\"value\"]"));
JsonArray jsonArray = reader.readArray();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Missing [
try {
- System.out.println("Testing for missing '['");
+ LOGGER.info("Testing for missing '['");
reader = Json.createReader(new StringReader("]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2035,16 +1971,16 @@
// Missing ]
try {
- System.out.println("Testing for missing ']'");
+ LOGGER.info("Testing for missing ']'");
reader = Json.createReader(new StringReader("["));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2053,16 +1989,16 @@
// Missing {
try {
- System.out.println("Testing for missing '{'");
+ LOGGER.info("Testing for missing '{'");
reader = Json.createReader(new StringReader("[1,\"name\":\"value\"}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2071,16 +2007,16 @@
// Missing }
try {
- System.out.println("Testing for missing '}'");
+ LOGGER.info("Testing for missing '}'");
reader = Json.createReader(new StringReader("[1,{\"name\":\"value\"]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2089,16 +2025,16 @@
// Missing , between array elements test case 1
try {
- System.out.println("Testing for missing ',' between array elements test case 1");
+ LOGGER.info("Testing for missing ',' between array elements test case 1");
reader = Json.createReader(new StringReader("[5\"foo\"]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2107,16 +2043,16 @@
// Missing , between array elements test case 2
try {
- System.out.println("Testing for missing ',' between array elements test case 2");
+ LOGGER.info("Testing for missing ',' between array elements test case 2");
reader = Json.createReader(new StringReader("[5{}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2125,16 +2061,16 @@
// Missing , between object elements test case 1
try {
- System.out.println("Testing for missing ',' between object elements test case 1");
+ LOGGER.info("Testing for missing ',' between object elements test case 1");
reader = Json.createReader(new StringReader("[{\"foo\":\"bar\"5}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2143,16 +2079,16 @@
// Missing , between object elements test case 2
try {
- System.out.println("Testing for missing ',' between object elements test case 2");
+ LOGGER.info("Testing for missing ',' between object elements test case 2");
reader = Json.createReader(new StringReader("[{\"one\":1[]}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2161,16 +2097,16 @@
// Missing key name in object element
try {
- System.out.println("Testing for missing key name in object element");
+ LOGGER.info("Testing for missing key name in object element");
reader = Json.createReader(new StringReader("[{:\"bar\"}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2179,16 +2115,16 @@
// Missing value name in object element
try {
- System.out.println("Testing for missing value name in object element");
+ LOGGER.info("Testing for missing value name in object element");
reader = Json.createReader(new StringReader("[{\"foo\":}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2197,16 +2133,16 @@
// Missing double quote on a name
try {
- System.out.println("Test for missing double quote on a name");
+ LOGGER.info("Test for missing double quote on a name");
reader = Json.createReader(new StringReader("[{name\" : \"value\"}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2215,16 +2151,16 @@
// Missing double quote on a value
try {
- System.out.println("Test for missing double quote on a value");
+ LOGGER.info("Test for missing double quote on a value");
reader = Json.createReader(new StringReader("[{\"name\" : value\"}]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2233,16 +2169,16 @@
// Incorrect digit value test case 1
try {
- System.out.println("Incorrect digit value -foo");
+ LOGGER.info("Incorrect digit value -foo");
reader = Json.createReader(new StringReader("[-foo]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2251,16 +2187,16 @@
// Incorrect digit value test case 2
try {
- System.out.println("Incorrect digit value +foo");
+ LOGGER.info("Incorrect digit value +foo");
reader = Json.createReader(new StringReader("[+foo]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2269,16 +2205,16 @@
// Incorrect digit value test case 3
try {
- System.out.println("Incorrect digit value -784foo");
+ LOGGER.info("Incorrect digit value -784foo");
reader = Json.createReader(new StringReader("[-784foo]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2287,16 +2223,16 @@
// Incorrect digit value test case 4
try {
- System.out.println("Incorrect digit value +784foo");
+ LOGGER.info("Incorrect digit value +784foo");
reader = Json.createReader(new StringReader("[+784foo]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2305,16 +2241,16 @@
// Incorrect digit value test case 5
try {
- System.out.println("Incorrect digit value 0.1E5E5");
+ LOGGER.info("Incorrect digit value 0.1E5E5");
reader = Json.createReader(new StringReader("[0.1E5E5]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2323,16 +2259,16 @@
// Incorrect digit value test case 6
try {
- System.out.println("Incorrect digit value 0.F10");
+ LOGGER.info("Incorrect digit value 0.F10");
reader = Json.createReader(new StringReader("[0.F10]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2341,16 +2277,16 @@
// Incorrect digit value test case 7
try {
- System.out.println("Incorrect digit value string");
+ LOGGER.info("Incorrect digit value string");
reader = Json.createReader(new StringReader("[string]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2359,16 +2295,16 @@
// Incorrect digit value test case 8 (hex numbers invalid per JSON RFC)
try {
- System.out.println("Incorrect digit value hex numbers invalid per JSON RFC");
+ LOGGER.info("Incorrect digit value hex numbers invalid per JSON RFC");
reader = Json.createReader(new StringReader("[0x137a]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2377,23 +2313,22 @@
// Incorrect digit value test case 9 (octal numbers invalid per JSON RFC)
try {
- System.out.println("Incorrect digit value octal numbers invalid per JSON RFC");
+ LOGGER.info("Incorrect digit value octal numbers invalid per JSON RFC");
reader = Json.createReader(new StringReader("[0137]"));
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("negativeArrayTests Failed");
+ assertTrue(pass, "negativeArrayTests Failed");
}
/*
@@ -2406,7 +2341,7 @@
*
*/
@Test
- public void illegalStateExceptionTests() throws Fault {
+ public void illegalStateExceptionTests() {
boolean pass = true;
JsonReader reader = null;
@@ -2414,32 +2349,32 @@
try {
reader = Json.createReader(new StringReader("{}"));
reader.close();
- System.out.println(
+ LOGGER.info(
"Calling reader.read() after reader.close() is called is illegal.");
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if reader.read() called after reader.readObject()
try {
reader = Json.createReader(new StringReader("{}"));
JsonObject value = reader.readObject();
- System.out.println(
+ LOGGER.info(
"Calling reader.readObject() after reader.readObject() was called is illegal.");
value = (JsonObject) reader.read();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2449,16 +2384,16 @@
try {
reader = Json.createReader(new StringReader("[]"));
JsonArray value = reader.readArray();
- System.out.println(
+ LOGGER.info(
"Calling reader.read() after reader.readArray() was called is illegal.");
value = (JsonArray) reader.read();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2468,16 +2403,16 @@
try {
reader = Json.createReader(new StringReader("{}"));
reader.close();
- System.out.println(
+ LOGGER.info(
"Calling reader.readObject() after reader.close() is called is illegal.");
JsonObject value = reader.readObject();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if reader.readObject() called after
@@ -2485,16 +2420,16 @@
try {
reader = Json.createReader(new StringReader("{}"));
JsonObject value = reader.readObject();
- System.out.println(
+ LOGGER.info(
"Calling reader.readObject() after reader.readObject() was called is illegal.");
value = reader.readObject();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2505,16 +2440,16 @@
try {
reader = Json.createReader(new StringReader("{}"));
JsonObject obj = reader.readObject();
- System.out.println(
+ LOGGER.info(
"Calling reader.readArray() after reader.readObject() was called is illegal.");
JsonArray arr = reader.readArray();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2524,16 +2459,16 @@
try {
reader = Json.createReader(new StringReader("[]"));
reader.close();
- System.out.println(
+ LOGGER.info(
"Calling reader.readArray() after reader.close() is called is illegal.");
JsonArray value = reader.readArray();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if reader.readArray() called after
@@ -2541,16 +2476,16 @@
try {
reader = Json.createReader(new StringReader("[]"));
JsonArray value = reader.readArray();
- System.out.println(
+ LOGGER.info(
"Calling reader.readArray() after reader.readArray() was called is illegal.");
value = reader.readArray();
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2561,24 +2496,23 @@
try {
reader = Json.createReader(new StringReader("[]"));
JsonArray arr = reader.readArray();
- System.out.println(
+ LOGGER.info(
"Calling reader.readObject() after reader.readArray() was called is illegal.");
JsonObject obj = reader.readObject();
pass = false;
- System.out.println("obj=" + obj);
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.info("obj=" + obj);
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("illegalStateExceptionTests Failed");
+ assertTrue(pass, "illegalStateExceptionTests Failed");
}
/*
@@ -2592,75 +2526,75 @@
*
*/
@Test
- public void negativeJsonStructureTests() throws Fault {
+ public void negativeJsonStructureTests() {
boolean pass = true;
JsonReader reader = null;
// Trip JsonParsingException for JsonReader.read() if incorrect
// representation for array
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if incorrect representation for array.");
- System.out.println("Reading " + "[foo,10,\"name\":\"value\"]");
+ LOGGER.info("Reading " + "[foo,10,\"name\":\"value\"]");
reader = Json
.createReader(new StringReader("[foo,10,\"name\":\"value\"]"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if incorrect
// representation for object
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if incorrect representation for object.");
- System.out.println("Reading " + "{\"name\":\"value\",1,2,3}");
+ LOGGER.info("Reading " + "{\"name\":\"value\",1,2,3}");
reader = Json
.createReader(new StringReader("{\"name\":\"value\",1,2,3}"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// incorrect representation {]
try {
- System.out.println("Testing for incorrect representation '{]'");
+ LOGGER.info("Testing for incorrect representation '{]'");
reader = Json.createReader(new StringReader("{]"));
- System.out.println(
+ LOGGER.info(
"Calling reader.read() with incorrect representation should throw JsonParsingException");
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Missing [
try {
- System.out.println("Testing for missing '['");
+ LOGGER.info("Testing for missing '['");
reader = Json.createReader(new StringReader("{1,2]}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2669,16 +2603,16 @@
// Missing ]
try {
- System.out.println("Testing for missing ']'");
+ LOGGER.info("Testing for missing ']'");
reader = Json.createReader(new StringReader("{[1,2}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2687,16 +2621,16 @@
// Missing {
try {
- System.out.println("Testing for missing '{'");
+ LOGGER.info("Testing for missing '{'");
reader = Json.createReader(new StringReader("}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2705,16 +2639,16 @@
// Missing }
try {
- System.out.println("Testing for missing '}'");
+ LOGGER.info("Testing for missing '}'");
reader = Json.createReader(new StringReader("{"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2723,16 +2657,16 @@
// Missing , between array elements test case 1
try {
- System.out.println("Testing for missing ',' between array elements test case 1");
+ LOGGER.info("Testing for missing ',' between array elements test case 1");
reader = Json.createReader(new StringReader("{[5\"foo\"]}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2741,16 +2675,16 @@
// Missing , between array elements test case 2
try {
- System.out.println("Testing for missing ',' between array elements test case 2");
+ LOGGER.info("Testing for missing ',' between array elements test case 2");
reader = Json.createReader(new StringReader("{[5{}]}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2759,16 +2693,16 @@
// Missing , between object elements test case 1
try {
- System.out.println("Testing for missing ',' between object elements test case 1");
+ LOGGER.info("Testing for missing ',' between object elements test case 1");
reader = Json.createReader(new StringReader("{\"foo\":\"bar\"5}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2777,16 +2711,16 @@
// Missing , between object elements test case 2
try {
- System.out.println("Testing for missing ',' between object elements test case 2");
+ LOGGER.info("Testing for missing ',' between object elements test case 2");
reader = Json.createReader(new StringReader("{\"one\":1[]}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2795,16 +2729,16 @@
// Missing key name in object element
try {
- System.out.println("Testing for missing key name in object element");
+ LOGGER.info("Testing for missing key name in object element");
reader = Json.createReader(new StringReader("{:\"bar\"}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2813,16 +2747,16 @@
// Missing value name in object element
try {
- System.out.println("Testing for missing value name in object element");
+ LOGGER.info("Testing for missing value name in object element");
reader = Json.createReader(new StringReader("{\"foo\":}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2831,16 +2765,16 @@
// Missing double quote on a name
try {
- System.out.println("Test for missing double quote on a name");
+ LOGGER.info("Test for missing double quote on a name");
reader = Json.createReader(new StringReader("{name\" : \"value\"}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2849,16 +2783,16 @@
// Missing double quote on a value
try {
- System.out.println("Test for missing double quote on a value");
+ LOGGER.info("Test for missing double quote on a value");
reader = Json.createReader(new StringReader("{\"name\" : value\"}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2867,16 +2801,16 @@
// Incorrect digit value test case 1
try {
- System.out.println("Incorrect digit value -foo");
+ LOGGER.info("Incorrect digit value -foo");
reader = Json.createReader(new StringReader("{\"number\" : -foo}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2885,16 +2819,16 @@
// Incorrect digit value test case 2
try {
- System.out.println("Incorrect digit value +foo");
+ LOGGER.info("Incorrect digit value +foo");
reader = Json.createReader(new StringReader("{\"number\" : +foo}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2903,16 +2837,16 @@
// Incorrect digit value test case 3
try {
- System.out.println("Incorrect digit value -784foo");
+ LOGGER.info("Incorrect digit value -784foo");
reader = Json.createReader(new StringReader("{\"number\" : -784foo}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2921,16 +2855,16 @@
// Incorrect digit value test case 4
try {
- System.out.println("Incorrect digit value +784foo");
+ LOGGER.info("Incorrect digit value +784foo");
reader = Json.createReader(new StringReader("{\"number\" : +784foo}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2939,16 +2873,16 @@
// Incorrect digit value test case 5
try {
- System.out.println("Incorrect digit value 0.1E5E5");
+ LOGGER.info("Incorrect digit value 0.1E5E5");
reader = Json.createReader(new StringReader("{\"number\" : 0.1E5E5}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2957,16 +2891,16 @@
// Incorrect digit value test case 6
try {
- System.out.println("Incorrect digit value 0.F10");
+ LOGGER.info("Incorrect digit value 0.F10");
reader = Json.createReader(new StringReader("{\"number\" : 0.F10}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
@@ -2975,23 +2909,22 @@
// Incorrect digit value test case 7
try {
- System.out.println("Incorrect digit value string");
+ LOGGER.info("Incorrect digit value string");
reader = Json.createReader(new StringReader("{\"number\" : string}"));
JsonStructure value = reader.read();
pass = false;
- System.err.println("Failed to throw JsonParsingException");
+ LOGGER.warning("Failed to throw JsonParsingException");
} catch (JsonParsingException e) {
- System.out.println("Got expected JsonParsingException");
+ LOGGER.info("Got expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("negativeJsonStructureTests Failed");
+ assertTrue(pass, "negativeJsonStructureTests Failed");
}
/*
@@ -3004,7 +2937,7 @@
*
*/
@Test
- public void jsonReaderIOErrorTests() throws Fault {
+ public void jsonReaderIOErrorTests() {
boolean pass = true;
String jsonArrayText = "[\"name1\",\"value1\"]";
@@ -3012,86 +2945,85 @@
// Trip JsonException if there is an i/o error on JsonReader.close()
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonReader.close().");
- System.out.println("Reading object " + jsonObjectText);
+ LOGGER.info("Reading object " + jsonObjectText);
InputStream is = JSONP_Util.getInputStreamFromString(jsonObjectText);
MyBufferedInputStream mbi = new MyBufferedInputStream(is);
try (JsonReader reader = Json.createReader(mbi)) {
JsonObject jsonObject = reader.readObject();
- System.out.println("jsonObject=" + jsonObject);
+ LOGGER.info("jsonObject=" + jsonObject);
mbi.setThrowIOException(true);
- System.out.println("Calling JsonReader.close()");
+ LOGGER.info("Calling JsonReader.close()");
mbi.setThrowIOException(true);
}
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException for JsonReader.read() if i/o error
try {
- System.out.println("Trip JsonException for JsonReader.read() if i/o error.");
- System.out.println("Reading array " + jsonArrayText);
+ LOGGER.info("Trip JsonException for JsonReader.read() if i/o error.");
+ LOGGER.info("Reading array " + jsonArrayText);
MyBufferedReader mbr = new MyBufferedReader(
new StringReader(jsonArrayText));
JsonReader reader = Json.createReader(mbr);
mbr.setThrowIOException(true);
- System.out.println("Calling JsonReader.read()");
+ LOGGER.info("Calling JsonReader.read()");
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException for JsonReader.readArray() if i/o error
try {
- System.out.println("Trip JsonException for JsonReader.readArray() if i/o error.");
- System.out.println("Reading array " + jsonArrayText);
+ LOGGER.info("Trip JsonException for JsonReader.readArray() if i/o error.");
+ LOGGER.info("Reading array " + jsonArrayText);
MyBufferedReader mbr = new MyBufferedReader(
new StringReader(jsonArrayText));
JsonReader reader = Json.createReader(mbr);
mbr.setThrowIOException(true);
- System.out.println("Calling JsonReader.readArray()");
+ LOGGER.info("Calling JsonReader.readArray()");
JsonArray jsonArray = reader.readArray();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException for JsonReader.readObject() if i/o error
try {
- System.out.println("Trip JsonException for JsonReader.read() if i/o error.");
- System.out.println("Reading object " + jsonObjectText);
+ LOGGER.info("Trip JsonException for JsonReader.read() if i/o error.");
+ LOGGER.info("Reading object " + jsonObjectText);
MyBufferedReader mbr = new MyBufferedReader(
new StringReader(jsonObjectText));
JsonReader reader = Json.createReader(mbr);
mbr.setThrowIOException(true);
- System.out.println("Calling JsonReader.readObject()");
+ LOGGER.info("Calling JsonReader.readObject()");
JsonObject jsonObject = reader.readObject();
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonReaderIOErrorTests Failed");
+ assertTrue(pass, "jsonReaderIOErrorTests Failed");
}
/*
@@ -3105,114 +3037,113 @@
*
*/
@Test
- public void invalidLiteralNamesTest() throws Fault {
+ public void invalidLiteralNamesTest() {
boolean pass = true;
JsonReader reader;
// Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE
// instead of true
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE instead of true.");
- System.out.println("Reading " + "[TRUE]");
+ LOGGER.info("Reading " + "[TRUE]");
reader = Json.createReader(new StringReader("[TRUE]"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE
// instead of false
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE instead of false.");
- System.out.println("Reading " + "[FALSE]");
+ LOGGER.info("Reading " + "[FALSE]");
reader = Json.createReader(new StringReader("[FALSE]"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if invalid liternal NULL
// instead of null
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal NULL instead of null.");
- System.out.println("Reading " + "[NULL]");
+ LOGGER.info("Reading " + "[NULL]");
reader = Json.createReader(new StringReader("[NULL]"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE
// instead of true
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE instead of true.");
- System.out.println("Reading " + "{\"true\":TRUE}");
+ LOGGER.info("Reading " + "{\"true\":TRUE}");
reader = Json.createReader(new StringReader("{\"true\":TRUE}"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE
// instead of false
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE instead of false.");
- System.out.println("Reading " + "{\"false\":FALSE}");
+ LOGGER.info("Reading " + "{\"false\":FALSE}");
reader = Json.createReader(new StringReader("{\"false\":FALSE}"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonParsingException for JsonReader.read() if invalid liternal NULL
// instead of null
try {
- System.out.println(
+ LOGGER.info(
"Trip JsonParsingException for JsonReader.read() if invalid liternal NULL instead of null.");
- System.out.println("Reading " + "{\"null\":NULL}");
+ LOGGER.info("Reading " + "{\"null\":NULL}");
reader = Json.createReader(new StringReader("{\"null\":NULL}"));
JsonStructure jsonStructure = reader.read();
- System.err.println("Did not get expected JsonParsingException");
+ LOGGER.warning("Did not get expected JsonParsingException");
pass = false;
} catch (JsonParsingException e) {
- System.out.println("Caught expected JsonParsingException");
+ LOGGER.info("Caught expected JsonParsingException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("invalidLiteralNamesTest Failed");
+ assertTrue(pass, "invalidLiteralNamesTest Failed");
}
/*
@@ -3226,7 +3157,7 @@
* @test_Strategy: Tests JsonReader API methods added in JSON-P 1.1.
*/
@Test
- public void jsonReader11Test() throws Fault {
+ public void jsonReader11Test() {
Reader readerTest = new Reader();
final TestResult result = readerTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/Reader.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/Reader.java
index e400ca2..80818c2 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/Reader.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonreadertests/Reader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonException;
import jakarta.json.JsonReader;
@@ -39,6 +41,8 @@
*/
public class Reader {
+ private static final Logger LOGGER = Logger.getLogger(Reader.class.getName());
+
/** Tests input data. */
private static final Object[] VALUES = new Object[] { OBJ_VALUE, // readValue()
// for
@@ -70,7 +74,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonReader API methods added in JSON-P 1.1.");
- System.out.println("JsonReader API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonReader API methods added in JSON-P 1.1.");
testReadValue(result);
testDoubleReadValue(result);
testIOExceptionOnReadValue(result);
@@ -88,16 +92,16 @@
private void testReadValue(final TestResult result) {
for (Object value : VALUES) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - readValue() for " + typeName + " in source data");
+ LOGGER.info(" - readValue() for " + typeName + " in source data");
final JsonValue jsonValue = SimpleValues.toJsonValue(value);
final String data = JsonValueType.toStringValue(value);
- System.out.println(" - Data: " + data);
+ LOGGER.info(" - Data: " + data);
final StringReader strReader = new StringReader(data);
JsonValue outValue = null;
try (final JsonReader reader = Json.createReader(strReader)) {
outValue = reader.readValue();
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("readValue()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -119,7 +123,7 @@
private void testDoubleReadValue(final TestResult result) {
for (Object value : VALUES) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(
+ LOGGER.info(
" - duplicate readValue() for " + typeName + " in source data");
final String data = JsonValueType.toStringValue(value);
final StringReader strReader = new StringReader(data);
@@ -132,14 +136,14 @@
result.fail("readValue()",
"Duplicate call of readValue() shall throw IllegalStateException");
} catch (IllegalStateException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("readValue()",
"Duplicate call of readValue() shall throw IllegalStateException, not "
+ t.getClass().getSimpleName());
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("readValue()",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -155,13 +159,13 @@
*/
@SuppressWarnings("ConvertToTryWithResources")
private void testIOExceptionOnReadValue(final TestResult result) {
- System.out.println(" - readValue() from already closed file reader");
+ LOGGER.info(" - readValue() from already closed file reader");
File temp = null;
JsonReader reader;
// Close writer before calling write method.
try {
temp = File.createTempFile("testIOExceptionOnReadValue", ".txt");
- System.out.println(" - Temporary file: " + temp.getAbsolutePath());
+ LOGGER.info(" - Temporary file: " + temp.getAbsolutePath());
try (final FileWriter fileWriter = new FileWriter(temp)) {
fileWriter.write(JsonValueType.toStringValue(DEF_VALUE));
}
@@ -169,7 +173,7 @@
reader = Json.createReader(fileReader);
fileReader.close();
} catch (IOException ex) {
- System.out.println("Caught IOException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught IOException: " + ex.getLocalizedMessage());
result.fail("write(JsonValue)",
"Caught IOException: " + ex.getLocalizedMessage());
return;
@@ -183,7 +187,7 @@
result.fail("readValue()",
"Call of readValue() on already closed file reader shall throw JsonException");
} catch (JsonException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("readValue()",
"Call of readValue() on already closed file reader shall throw JsonException, not "
@@ -199,7 +203,7 @@
* Test suite result.
*/
private void testReadInvalidValue(final TestResult result) {
- System.out.println(" - readValue() on invalid JSON data");
+ LOGGER.info(" - readValue() on invalid JSON data");
// Invalid JSON: starting an array, closing an object.
final String data = "[" + SimpleValues.toJsonValue(DEF_VALUE) + "}";
final StringReader strReader = new StringReader(data);
@@ -209,7 +213,7 @@
result.fail("readValue()",
"Call of readValue() on invalid data shall throw JsonParsingException");
} catch (JsonParsingException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("readValue()",
"Call of readValue() on invalid data shall throw JsonParsingException, not "
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstreamingtests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstreamingtests/ClientTests.java
index 188e46d..0741b11 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstreamingtests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstreamingtests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,26 +23,18 @@
import jakarta.json.stream.*;
import java.io.*;
-import java.util.*;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/*
* @testName: streamingTest1
*
@@ -55,15 +47,14 @@
*
*/
@Test
- public void streamingTest1() throws Fault {
- boolean pass = true;
+ public void streamingTest1() {
JsonReader reader = null;
try {
// Set expected result
String expJsonText = "[1,2,3,4,5,6,7,8,9,10]";
- System.out.println("expJsonText=" + expJsonText);
+ LOGGER.info("expJsonText=" + expJsonText);
- System.out.println("Generate stream of Json Text containing a JsonArray");
+ LOGGER.info("Generate stream of Json Text containing a JsonArray");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write(1).write(2).write(3).write(4).write(5)
@@ -72,18 +63,16 @@
// Get actual result
String actJsonText = JSONP_Util.removeWhitespace(sWriter.toString());
- System.out.println("actJsonText=" + actJsonText);
+ LOGGER.info("actJsonText=" + actJsonText);
- System.out.println("Compare expJsonText and actJsonText for equality");
- pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText);
+ LOGGER.info("Compare expJsonText and actJsonText for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText), "streamingTest1 Failed");
} catch (Exception e) {
- throw new Fault("streamingTest1 Failed: ", e);
+ fail("streamingTest1 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("streamingTest1 Failed");
}
/*
@@ -100,52 +89,49 @@
*
*/
@Test
- public void streamingTest2() throws Fault {
- boolean pass = true;
+ public void streamingTest2() {
JsonReader reader = null;
try {
- System.out.println("Generate data containing a JsonArray");
+ LOGGER.info("Generate data containing a JsonArray");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartArray().write(2).write(4).write(6).write(8).write(10)
.writeEnd();
generator.close();
- System.out.println("Read data from Writer stream containing a JsonArray");
+ LOGGER.info("Read data from Writer stream containing a JsonArray");
reader = Json.createReader(new StringReader(sWriter.toString()));
JsonArray expJsonArray = reader.readArray();
- System.out.println("Dump of expJsonArray");
+ LOGGER.info("Dump of expJsonArray");
JSONP_Util.dumpJsonArray(expJsonArray);
- System.out.println("Write JsonArray out to a Writer stream");
+ LOGGER.info("Write JsonArray out to a Writer stream");
sWriter = new StringWriter();
JsonWriter writer = Json.createWriter(sWriter);
writer.writeArray(expJsonArray);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("writerContents=" + writerContents);
+ LOGGER.info("writerContents=" + writerContents);
- System.out.println("Re-read data from Writer stream containing a JsonArray");
+ LOGGER.info("Re-read data from Writer stream containing a JsonArray");
reader = Json.createReader(new StringReader(writerContents));
JsonArray actJsonArray = reader.readArray();
- System.out.println("Dump of actJsonArray");
+ LOGGER.info("Dump of actJsonArray");
JSONP_Util.dumpJsonArray(actJsonArray);
- System.out.println("Compare expJsonArray and actJsonArray for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray);
+ LOGGER.info("Compare expJsonArray and actJsonArray for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray), "streamingTest2 Failed");
} catch (Exception e) {
- throw new Fault("streamingTest2 Failed: ", e);
+ fail("streamingTest2 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("streamingTest2 Failed");
}
/*
@@ -161,37 +147,36 @@
*
*/
@Test
- public void streamingTest3() throws Fault {
- boolean pass = true;
+ public void streamingTest3() {
JsonReader reader = null;
JsonParser parser = null;
try {
- System.out.println("Generate data containing a JsonObject");
+ LOGGER.info("Generate data containing a JsonObject");
StringWriter sWriter = new StringWriter();
JsonGenerator generator = Json.createGenerator(sWriter);
generator.writeStartObject().write("two", 2).write("false", false)
.writeEnd();
generator.close();
- System.out.println("Read data from Writer stream containing a JsonObject");
+ LOGGER.info("Read data from Writer stream containing a JsonObject");
reader = Json.createReader(new StringReader(sWriter.toString()));
JsonObject expJsonObject = reader.readObject();
- System.out.println("Dump of expJsonObject");
+ LOGGER.info("Dump of expJsonObject");
JSONP_Util.dumpJsonObject(expJsonObject);
- System.out.println("Write JsonObject out to a Writer stream");
+ LOGGER.info("Write JsonObject out to a Writer stream");
sWriter = new StringWriter();
JsonWriter writer = Json.createWriter(sWriter);
writer.writeObject(expJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = sWriter.toString();
- System.out.println("writerContents=" + writerContents);
+ LOGGER.info("writerContents=" + writerContents);
- System.out.println("Parse data from Writer stream containing a JsonObject");
+ LOGGER.info("Parse data from Writer stream containing a JsonObject");
parser = Json
.createParser(JSONP_Util.getInputStreamFromString((writerContents)));
@@ -201,19 +186,16 @@
JSONP_Util.testKeyFalseValue(parser, "false");
JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT);
int parseErrs = JSONP_Util.getParseErrs();
- if (parseErrs != 0) {
- System.err.println("There were " + parseErrs + " parser errors that occurred.");
- pass = false;
- }
-
+ assertTrue(
+ parseErrs == 0,
+ "StreamingTest3 Failed. There were " + parseErrs + " parser errors that occurred."
+ );
} catch (Exception e) {
- throw new Fault("streamingTest3 Failed: ", e);
+ fail("streamingTest3 Failed: ", e);
} finally {
if (reader != null)
reader.close();
}
- if (!pass)
- throw new Fault("streamingTest3 Failed");
}
/*
@@ -230,13 +212,13 @@
*
*/
@Test
- public void streamingTest4() throws Fault {
+ public void streamingTest4() {
boolean pass = true;
JsonReader reader = null;
JsonParser parser = null;
String expJsonText = "{\"two\":2,\"false\":false}";
try {
- System.out.println("Generate data containing a JsonObject to an OutputStream");
+ LOGGER.info("Generate data containing a JsonObject to an OutputStream");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator generator = Json.createGenerator(baos);
generator.writeStartObject().write("two", 2).write("false", false)
@@ -244,43 +226,42 @@
baos.close();
generator.close();
- System.out.println("Compare JSON text generated to what is expected.");
+ LOGGER.info("Compare JSON text generated to what is expected.");
if (!JSONP_Util.assertEqualsJsonText(expJsonText,
JSONP_Util.removeWhitespace(baos.toString("UTF-8"))))
pass = false;
- System.out.println("Read data from InputStream containing a JsonObject");
+ LOGGER.info("Read data from InputStream containing a JsonObject");
reader = Json.createReader(
JSONP_Util.getInputStreamFromString(baos.toString("UTF-8")));
JsonObject expJsonObject = reader.readObject();
- System.out.println("Close JsonReader");
+ LOGGER.info("Close JsonReader");
reader.close();
- System.out.println("Dump of expJsonObject");
+ LOGGER.info("Dump of expJsonObject");
JSONP_Util.dumpJsonObject(expJsonObject);
- System.out.println("Write JsonObject back out to an OutputStream");
+ LOGGER.info("Write JsonObject back out to an OutputStream");
baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriter(baos);
writer.writeObject(expJsonObject);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String writerContents = baos.toString("UTF-8");
- System.out.println("writerContents=" + writerContents);
+ LOGGER.info("writerContents=" + writerContents);
- System.out.println("Compare again JSON text generated to what is expected.");
+ LOGGER.info("Compare again JSON text generated to what is expected.");
if (!JSONP_Util.assertEqualsJsonText(expJsonText,
JSONP_Util.removeWhitespace(writerContents)))
pass = false;
} catch (Exception e) {
- throw new Fault("streamingTest4 Failed: ", e);
+ fail("streamingTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("streamingTest4 Failed");
+ assertTrue(pass, "streamingTest4 Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstringtests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstringtests/ClientTests.java
index 06672ca..04282db 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstringtests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonstringtests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,36 +20,19 @@
package jakarta.jsonp.tck.api.jsonstringtests;
import jakarta.json.*;
-import jakarta.json.stream.*;
-
-import java.io.*;
-
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.math.BigDecimal;
-import java.math.BigInteger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -62,48 +45,47 @@
* JsonStrings and compare them for equality and expect false.
*/
@Test
- public void jsonStringEqualsTest() throws Fault {
+ public void jsonStringEqualsTest() {
boolean pass = true;
try {
- System.out.println("Create sample JsonString 1 for testing");
+ LOGGER.info("Create sample JsonString 1 for testing");
JsonString string1 = (JsonString) JSONP_Util
.createJsonString("Hello World");
- System.out.println("string1=" + JSONP_Util.toStringJsonString(string1));
+ LOGGER.info("string1=" + JSONP_Util.toStringJsonString(string1));
- System.out.println("Create sample JsonString 2 for testing");
+ LOGGER.info("Create sample JsonString 2 for testing");
JsonString string2 = JSONP_Util.createJsonString("Hello World");
- System.out.println("string2=" + JSONP_Util.toStringJsonString(string2));
+ LOGGER.info("string2=" + JSONP_Util.toStringJsonString(string2));
- System.out.println(
+ LOGGER.info(
"Call JsonString.equals() to compare 2 equal JsonStrings and expect true");
if (string1.equals(string2)) {
- System.out.println("JsonStrings are equal - expected.");
+ LOGGER.info("JsonStrings are equal - expected.");
} else {
pass = false;
- System.err.println("JsonStrings are not equal - unexpected.");
+ LOGGER.warning("JsonStrings are not equal - unexpected.");
}
- System.out.println("Create sample JsonString 1 for testing");
+ LOGGER.info("Create sample JsonString 1 for testing");
string1 = JSONP_Util.createJsonString("Hello World");
- System.out.println("string1=" + JSONP_Util.toStringJsonString(string1));
+ LOGGER.info("string1=" + JSONP_Util.toStringJsonString(string1));
- System.out.println("Create sample JsonString 2 for testing");
+ LOGGER.info("Create sample JsonString 2 for testing");
string2 = JSONP_Util.createJsonString("Hello USA");
- System.out.println("string2=" + JSONP_Util.toStringJsonString(string2));
+ LOGGER.info("string2=" + JSONP_Util.toStringJsonString(string2));
- System.out.println(
+ LOGGER.info(
"Call JsonString.equals() to compare 2 equal JsonStrings and expect false");
if (!string1.equals(string2)) {
- System.out.println("JsonStrings are not equal - expected.");
+ LOGGER.info("JsonStrings are not equal - expected.");
} else {
pass = false;
- System.err.println("JsonStrings are equal - unexpected.");
+ LOGGER.warning("JsonStrings are equal - unexpected.");
}
} catch (Exception e) {
- throw new Fault("jsonStringEqualsTest Failed: ", e);
+ fail("jsonStringEqualsTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonStringEqualsTest Failed");
+ assertTrue(pass, "jsonStringEqualsTest Failed");
}
/*
@@ -116,51 +98,50 @@
* JsonStrings and compare them for hashcode and expect false.
*/
@Test
- public void jsonStringHashCodeTest() throws Fault {
+ public void jsonStringHashCodeTest() {
boolean pass = true;
try {
- System.out.println("Create sample JsonString 1 for testing");
+ LOGGER.info("Create sample JsonString 1 for testing");
JsonString string1 = JSONP_Util.createJsonString("Hello World");
- System.out.println("string1=" + JSONP_Util.toStringJsonString(string1));
- System.out.println("string1.hashCode()=" + string1.hashCode());
+ LOGGER.info("string1=" + JSONP_Util.toStringJsonString(string1));
+ LOGGER.info("string1.hashCode()=" + string1.hashCode());
- System.out.println("Create sample JsonString 2 for testing");
+ LOGGER.info("Create sample JsonString 2 for testing");
JsonString string2 = JSONP_Util.createJsonString("Hello World");
- System.out.println("string2=" + JSONP_Util.toStringJsonString(string2));
- System.out.println("string2.hashCode()=" + string2.hashCode());
+ LOGGER.info("string2=" + JSONP_Util.toStringJsonString(string2));
+ LOGGER.info("string2.hashCode()=" + string2.hashCode());
- System.out.println(
+ LOGGER.info(
"Call JsonString.hashCode() to compare 2 equal JsonStrings and expect true");
if (string1.hashCode() == string2.hashCode()) {
- System.out.println("JsonStrings hashCode are equal - expected.");
+ LOGGER.info("JsonStrings hashCode are equal - expected.");
} else {
pass = false;
- System.err.println("JsonStrings hashCode are not equal - unexpected.");
+ LOGGER.warning("JsonStrings hashCode are not equal - unexpected.");
}
- System.out.println("Create sample JsonString 1 for testing");
+ LOGGER.info("Create sample JsonString 1 for testing");
string1 = JSONP_Util.createJsonString("Hello World");
- System.out.println("string1=" + JSONP_Util.toStringJsonString(string1));
- System.out.println("string1.hashCode()=" + string1.hashCode());
+ LOGGER.info("string1=" + JSONP_Util.toStringJsonString(string1));
+ LOGGER.info("string1.hashCode()=" + string1.hashCode());
- System.out.println("Create sample JsonString 2 for testing");
+ LOGGER.info("Create sample JsonString 2 for testing");
string2 = JSONP_Util.createJsonString("Hello USA");
- System.out.println("string2=" + JSONP_Util.toStringJsonString(string2));
- System.out.println("string2.hashCode()=" + string2.hashCode());
+ LOGGER.info("string2=" + JSONP_Util.toStringJsonString(string2));
+ LOGGER.info("string2.hashCode()=" + string2.hashCode());
- System.out.println(
+ LOGGER.info(
"Call JsonString.hashCode() to compare 2 equal JsonStrings and expect false");
if (string1.hashCode() != string2.hashCode()) {
- System.out.println("JsonStrings hashCode are not equal - expected.");
+ LOGGER.info("JsonStrings hashCode are not equal - expected.");
} else {
pass = false;
- System.err.println("JsonStrings hashCode are equal - unexpected.");
+ LOGGER.warning("JsonStrings hashCode are equal - unexpected.");
}
} catch (Exception e) {
- throw new Fault("jsonStringHashCodeTest Failed: ", e);
+ fail("jsonStringHashCodeTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonStringHashCodeTest Failed");
+ assertTrue(pass, "jsonStringHashCodeTest Failed");
}
/*
@@ -171,31 +152,30 @@
* @test_Strategy: Tests JsonString getChars method.
*/
@Test
- public void jsonStringGetCharsTest() throws Fault {
+ public void jsonStringGetCharsTest() {
boolean pass = true;
String helloWorld = "Hello World";
try {
- System.out.println("Create sample JsonString for testing");
+ LOGGER.info("Create sample JsonString for testing");
JsonString string = JSONP_Util.createJsonString(helloWorld);
- System.out.println("string=" + JSONP_Util.toStringJsonString(string));
+ LOGGER.info("string=" + JSONP_Util.toStringJsonString(string));
- System.out.println(
+ LOGGER.info(
"Call JsonString.getChars() to return the char sequence for the JSON string");
CharSequence cs = string.getChars();
- System.out.println("charSequence=" + cs.toString());
+ LOGGER.info("charSequence=" + cs.toString());
- System.out.println("Checking char sequence for equality to expected string contents");
+ LOGGER.info("Checking char sequence for equality to expected string contents");
if (!JSONP_Util.assertEquals(helloWorld, cs.toString()))
pass = false;
- System.out.println("Checking char sequence for expected equality to string length");
+ LOGGER.info("Checking char sequence for expected equality to string length");
if (!JSONP_Util.assertEquals(helloWorld.length(), cs.length()))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonStringGetCharsTest Failed: ", e);
+ fail("jsonStringGetCharsTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonStringGetCharsTest Failed");
+ assertTrue(pass, "jsonStringGetCharsTest Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/ClientTests.java
index ee74557..92935da 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/ClientTests.java
@@ -19,29 +19,22 @@
*/
package jakarta.jsonp.tck.api.jsonvaluetests;
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import jakarta.json.Json;
-import jakarta.json.JsonValue;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.jsonp.tck.common.JSONP_Util;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import jakarta.jsonp.tck.common.*;
-@RunWith(Arquillian.class)
+import jakarta.json.*;
+import org.junit.jupiter.api.Test;
+
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -54,80 +47,79 @@
*
*/
@Test
- public void jsonValueTypesTest() throws Fault {
+ public void jsonValueTypesTest() {
boolean pass = true;
try {
JsonValue.ValueType valueType;
// Testing JsonValue.FALSE case
- System.out.println("Testing getValueType for JsonValue.FALSE value");
+ LOGGER.info("Testing getValueType for JsonValue.FALSE value");
valueType = JsonValue.FALSE.getValueType();
if (valueType != JsonValue.ValueType.FALSE) {
- System.err.println("Expected JSON FALSE value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON FALSE value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON FALSE value");
+ LOGGER.info("Got expected value type for JSON FALSE value");
// Testing JsonValue.TRUE case
- System.out.println("Testing getValueType for JsonValue.TRUE value");
+ LOGGER.info("Testing getValueType for JsonValue.TRUE value");
valueType = JsonValue.TRUE.getValueType();
if (valueType != JsonValue.ValueType.TRUE) {
- System.err.println("Expected JSON TRUE value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON TRUE value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON TRUE value");
+ LOGGER.info("Got expected value type for JSON TRUE value");
// Testing JsonValue.NULL case
- System.out.println("Testing getValueType for JsonValue.NULL value");
+ LOGGER.info("Testing getValueType for JsonValue.NULL value");
valueType = JsonValue.NULL.getValueType();
if (valueType != JsonValue.ValueType.NULL) {
- System.err.println("Expected JSON NULL value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON NULL value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON NULL value");
+ LOGGER.info("Got expected value type for JSON NULL value");
// Testing JsonValue.String case
- System.out.println("Testing getValueType for JsonValue.String value");
+ LOGGER.info("Testing getValueType for JsonValue.String value");
valueType = JSONP_Util.createJsonString("string").getValueType();
if (valueType != JsonValue.ValueType.STRING) {
- System.err.println("Expected JSON STRING value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON STRING value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON STRING value");
+ LOGGER.info("Got expected value type for JSON STRING value");
// Testing JsonValue.Number case
- System.out.println("Testing getValueType for JsonValue.Number value");
+ LOGGER.info("Testing getValueType for JsonValue.Number value");
valueType = JSONP_Util.createJsonNumber(Integer.MAX_VALUE).getValueType();
if (valueType != JsonValue.ValueType.NUMBER) {
- System.err.println("Expected JSON NUMBER value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON NUMBER value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON NUMBER value");
+ LOGGER.info("Got expected value type for JSON NUMBER value");
// Testing JsonValue.Array case
- System.out.println("Testing getValueType for JsonValue.Array value");
+ LOGGER.info("Testing getValueType for JsonValue.Array value");
valueType = JSONP_Util.createJsonArrayFromString("[]").getValueType();
if (valueType != JsonValue.ValueType.ARRAY) {
- System.err.println("Expected JSON ARRAY value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON ARRAY value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON ARRAY value");
+ LOGGER.info("Got expected value type for JSON ARRAY value");
// Testing JsonValue.Object case
- System.out.println("Testing getValueType for JsonValue.Object value");
+ LOGGER.info("Testing getValueType for JsonValue.Object value");
valueType = JSONP_Util.createJsonObjectFromString("{}").getValueType();
if (valueType != JsonValue.ValueType.OBJECT) {
- System.err.println("Expected JSON OBJECT value type but got instead " + valueType);
+ LOGGER.warning("Expected JSON OBJECT value type but got instead " + valueType);
pass = false;
} else
- System.out.println("Got expected value type for JSON OBJECT value");
+ LOGGER.info("Got expected value type for JSON OBJECT value");
} catch (Exception e) {
- throw new Fault("jsonValueTypesTest Failed: ", e);
+ fail("jsonValueTypesTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonValueTypesTest Failed");
+ assertTrue(pass, "jsonValueTypesTest Failed");
}
/*
@@ -140,7 +132,7 @@
*
*/
@Test
- public void jsonValueOfTest() throws Fault {
+ public void jsonValueOfTest() {
boolean pass = true;
String valueTypeStrings[] = { "ARRAY", "FALSE", "NULL", "NUMBER", "OBJECT",
@@ -149,44 +141,43 @@
for (String valueTypeString : valueTypeStrings) {
JsonValue.ValueType valueType;
try {
- System.out.println(
+ LOGGER.info(
"Testing enum value for string constant name " + valueTypeString);
valueType = JsonValue.ValueType.valueOf(valueTypeString);
- System.out.println("Got enum type " + valueType + " for enum string constant named "
+ LOGGER.info("Got enum type " + valueType + " for enum string constant named "
+ valueTypeString);
} catch (Exception e) {
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
pass = false;
}
}
- System.out.println("Testing negative test case for NullPointerException");
+ LOGGER.info("Testing negative test case for NullPointerException");
try {
JsonValue.ValueType.valueOf(null);
- System.err.println("did not get expected NullPointerException");
+ LOGGER.warning("did not get expected NullPointerException");
pass = false;
} catch (NullPointerException e) {
- System.out.println("Got expected NullPointerException");
+ LOGGER.info("Got expected NullPointerException");
} catch (Exception e) {
- System.err.println("Got unexpected exception " + e);
+ LOGGER.warning("Got unexpected exception " + e);
pass = false;
}
- System.out.println("Testing negative test case for IllegalArgumentException");
+ LOGGER.info("Testing negative test case for IllegalArgumentException");
try {
JsonValue.ValueType.valueOf("INVALID");
- System.err.println("did not get expected IllegalArgumentException");
+ LOGGER.warning("did not get expected IllegalArgumentException");
pass = false;
} catch (IllegalArgumentException e) {
- System.out.println("Got expected IllegalArgumentException");
+ LOGGER.info("Got expected IllegalArgumentException");
} catch (Exception e) {
- System.err.println("Got unexpected exception " + e);
+ LOGGER.warning("Got unexpected exception " + e);
pass = false;
}
- if (!pass)
- throw new Fault("jsonValueOfTest Failed");
+ assertTrue(pass, "jsonValueOfTest Failed");
}
/*
@@ -199,24 +190,18 @@
*
*/
@Test
- public void jsonValuesTest() throws Fault {
- boolean pass = true;
-
- System.out.println(
+ public void jsonValuesTest() {
+ LOGGER.info(
"Testing API method JsonValue.ValueType.values() to return array of enums.");
JsonValue.ValueType[] values = JsonValue.ValueType.values();
for (JsonValue.ValueType valueType : values) {
String valueString = JSONP_Util.getValueTypeString(valueType);
if (valueString == null) {
- System.err.println("Got no value for enum " + valueType);
- pass = false;
+ fail("jsonValuesTest Failed. Got no value for enum " + valueType);
} else
- System.out.println("Got " + valueString + " for enum " + valueType);
+ LOGGER.info("Got " + valueString + " for enum " + valueType);
}
-
- if (!pass)
- throw new Fault("jsonValuesTest Failed");
}
/*
@@ -229,98 +214,97 @@
*
*/
@Test
- public void jsonValueToStringTest() throws Fault {
+ public void jsonValueToStringTest() {
boolean pass = true;
try {
String stringValue;
JsonValue jsonValue;
// Testing JsonValue.FALSE case
- System.out.println("Testing JsonValue.toString() for JsonValue.FALSE value");
+ LOGGER.info("Testing JsonValue.toString() for JsonValue.FALSE value");
stringValue = JsonValue.FALSE.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("false")) {
- System.err.println("Expected false");
+ LOGGER.warning("Expected false");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonValue.TRUE case
- System.out.println("Testing JsonValue.toString() for JsonValue.TRUE value");
+ LOGGER.info("Testing JsonValue.toString() for JsonValue.TRUE value");
stringValue = JsonValue.TRUE.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("true")) {
- System.err.println("Expected true");
+ LOGGER.warning("Expected true");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonValue.NULL case
- System.out.println("Testing JsonValue.toString() for JsonValue.NULL value");
+ LOGGER.info("Testing JsonValue.toString() for JsonValue.NULL value");
stringValue = JsonValue.NULL.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("null")) {
- System.err.println("Expected null");
+ LOGGER.warning("Expected null");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonString case
- System.out.println("Testing JsonValue.toString() for JsonString value");
+ LOGGER.info("Testing JsonValue.toString() for JsonString value");
jsonValue = JSONP_Util.createJsonString("string");
stringValue = jsonValue.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("\"string\"")) {
- System.err.println("Expected \"string\"");
+ LOGGER.warning("Expected \"string\"");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonNumber case
- System.out.println("Testing JsonValue.toString() for JsonNumber value");
+ LOGGER.info("Testing JsonValue.toString() for JsonNumber value");
jsonValue = JSONP_Util.createJsonNumber(10);
stringValue = jsonValue.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("10")) {
- System.err.println("Expected 10");
+ LOGGER.warning("Expected 10");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonArray case
- System.out.println("Testing JsonValue.toString() for JsonArray value");
+ LOGGER.info("Testing JsonValue.toString() for JsonArray value");
jsonValue = JSONP_Util.createJsonArrayFromString("[]");
stringValue = jsonValue.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("[]")) {
- System.err.println("Expected []");
+ LOGGER.warning("Expected []");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
// Testing JsonObject case
- System.out.println("Testing JsonValue.toString() for JsonObject value");
+ LOGGER.info("Testing JsonValue.toString() for JsonObject value");
jsonValue = JSONP_Util.createJsonObjectFromString("{}");
stringValue = jsonValue.toString();
- System.out.println("stringValue=" + stringValue);
+ LOGGER.info("stringValue=" + stringValue);
if (!stringValue.equals("{}")) {
- System.err.println("Expected {}");
+ LOGGER.warning("Expected {}");
pass = false;
} else {
- System.out.println("Got " + stringValue);
+ LOGGER.info("Got " + stringValue);
}
} catch (Exception e) {
- throw new Fault("jsonValueToStringTest Failed: ", e);
+ fail("jsonValueToStringTest Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonValueToStringTest Failed");
+ assertTrue(pass, "jsonValueToStringTest Failed");
}
/*
@@ -331,7 +315,7 @@
* @test_Strategy: Tests JsonValue API methods added in JSON-P 1.1.
*/
@Test
- public void jsonValue11Test() throws Fault {
+ public void jsonValue11Test() {
Value valueTest = new Value();
final TestResult result = valueTest.test();
result.eval();
@@ -345,7 +329,7 @@
* @test_Strategy: Tests JsonStructure API methods added in JSON-P 1.1.
*/
@Test
- public void jsonStructure11Test() throws Fault {
+ public void jsonStructure11Test() {
Structure structTest = new Structure();
final TestResult result = structTest.test();
result.eval();
@@ -353,7 +337,7 @@
/*
* @testName: jsonNumber21Test
- *
+ *
* @test_Strategy: Tests Json.createValue(Number) API method added in JSON-P 2.1.
*/
@Test
@@ -373,7 +357,7 @@
assertEquals(Json.createValue(1), Json.createValue(new CustomNumber(1)));
assertEquals(Json.createValue(1).toString(), Json.createValue(new CustomNumber(1)).toString());
}
-
+
private static class CustomNumber extends Number {
private static final long serialVersionUID = 1L;
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Structure.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Structure.java
index 629dd3e..923b254 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Structure.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Structure.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonStructure;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.PointerRFCObject.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -36,6 +38,9 @@
* sample is being used to test this method.
*/
public class Structure {
+
+ private static final Logger LOGGER = Logger.getLogger(Structure.class.getName());
+
/**
* Creates an instance of JavaScript Object Notation (JSON) compatibility
* tests for {@link JsonStructure}.
@@ -52,7 +57,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonStructure API methods added in JSON-P 1.1.");
- System.out.println("JsonStructure API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonStructure API methods added in JSON-P 1.1.");
testResolveWholeDocument(result);
testResolveEmptyName(result);
testResolveSimpleArray(result);
@@ -253,7 +258,7 @@
* Tests result record.
*/
private void testResolvePathWithTilde(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)");
+ LOGGER.info(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)");
final JsonStructure value = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL10);
boolean noError = true;
@@ -261,15 +266,15 @@
final JsonValue out = value.getValue(RFC_PTR10);
if (operationFailed(check, out)) {
noError = false;
- System.out.println(" - Pointer \"" + RFC_KEY10
+ LOGGER.info(" - Pointer \"" + RFC_KEY10
+ "\" did not return expected value");
}
} catch (JsonException e) {
noError = false;
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
if (noError) {
- System.out.println(
+ LOGGER.info(
" - Pointer resolving accepts '~' outside escape sequence");
}
}
@@ -318,7 +323,7 @@
* </ul>
*/
private void testResolveValidNumericIndexInArray(final TestResult result) {
- System.out.println(
+ LOGGER.info(
" - getValue(String) resolving of pointer containing existing numeric array index");
final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(),
createSimpleIntArray5(), createSimpleBoolArray5(),
@@ -370,7 +375,7 @@
* character is to be handled, if it is to be useful.
*/
private void testResolveMemberAfterLastInArray(final TestResult result) {
- System.out.println(" - getValue(String) resolving of array \"/-\" pointer");
+ LOGGER.info(" - getValue(String) resolving of array \"/-\" pointer");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray(), createSimpleIntArray5(), createBoolArray2(),
createSimpleObjectArray5() };
@@ -380,7 +385,7 @@
result.fail("getValue(String)", "Call of getValue(String) on \"" + "/-"
+ "\" shall throw JsonException");
} catch (JsonException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
}
}
@@ -396,7 +401,7 @@
* document ({@code ""}) which must return the whole array.
*/
private void testResolveNonNumericIndexInArray(final TestResult result) {
- System.out.println(
+ LOGGER.info(
" - getValue(String) resolving of pointer containing non numeric array index");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray(), createSimpleIntArray5(), createBoolArray2(),
@@ -437,7 +442,7 @@
*/
private void verifyGetValue(final TestResult result, final JsonValue check,
final JsonStructure value, final String path) {
- System.out.println(" - getValue(String) resolving of \"" + path + "\" pointer");
+ LOGGER.info(" - getValue(String) resolving of \"" + path + "\" pointer");
try {
final JsonValue out = value.getValue(path);
if (operationFailed(check, out)) {
@@ -456,14 +461,14 @@
*/
private void verifyGetValueFail(final TestResult result,
final JsonStructure value, final String path) {
- System.out.println(
+ LOGGER.info(
" - getValue(String) resolving of invalid \"" + path + "\" pointer");
try {
value.getValue(path);
result.fail("getValue(String)", "Call of getValue(String) on \"" + path
+ "\" shall throw JsonException");
} catch (JsonException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Value.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Value.java
index 29e5179..32cc27b 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Value.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonvaluetests/Value.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,6 +21,8 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -30,6 +32,8 @@
*/
public class Value {
+ private static final Logger LOGGER = Logger.getLogger(Value.class.getName());
+
/**
* Creates an instance of JavaScript Object Notation (JSON) compatibility
* tests for {@link JsonValue}.
@@ -46,7 +50,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonValue API methods added in JSON-P 1.1.");
- System.out.println("JsonValue API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonValue API methods added in JSON-P 1.1.");
testAsJsonObject(result);
testAsJsonObjectOnNonObject(result);
testAsJsonArray(result);
@@ -62,7 +66,7 @@
* Test suite result.
*/
private void testAsJsonObject(final TestResult result) {
- System.out.println(" - asJsonObject() on JsonObject instances");
+ LOGGER.info(" - asJsonObject() on JsonObject instances");
final JsonObject[] values = { createEmptyObject(), createSimpleObjectStr(),
createSimpleObjectInt(), createSimpleObjectBool(),
createSimpleObjectObject(), createCompoundObject() };
@@ -84,7 +88,7 @@
* Test suite result.
*/
private void testAsJsonObjectOnNonObject(final TestResult result) {
- System.out.println(" - asJsonObject() on non JsonObject instances");
+ LOGGER.info(" - asJsonObject() on non JsonObject instances");
final JsonValue[] values = { createEmptyArrayWithStr(),
createEmptyArrayWithInt(), createEmptyArrayWithBool(),
createEmptyArrayWithObject(), toJsonValue(STR_VALUE),
@@ -97,7 +101,7 @@
result.fail("asJsonObject()",
"Call of asJsonObject() on non JsonObject instance shall throw ClassCastException");
} catch (ClassCastException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("asJsonObject()",
"Call of asJsonObject() on non JsonObject instance shall throw ClassCastException, not "
@@ -114,7 +118,7 @@
* Test suite result.
*/
private void testAsJsonArray(final TestResult result) {
- System.out.println(" - asJsonArray() on JsonArray instances");
+ LOGGER.info(" - asJsonArray() on JsonArray instances");
final JsonArray[] values = { createEmptyArray(), createEmptyArrayWithStr(),
createEmptyArrayWithInt(), createEmptyArrayWithBool(),
createEmptyArrayWithObject(), createSimpleStringArray5(),
@@ -138,7 +142,7 @@
* Test suite result.
*/
private void testAsJsonArrayOnNonArray(final TestResult result) {
- System.out.println(" - asJsonArray() on non JsonArray instances");
+ LOGGER.info(" - asJsonArray() on non JsonArray instances");
final JsonValue[] values = { createSimpleObjectStr(),
createSimpleObjectInt(), createSimpleObjectBool(),
createSimpleObjectObject(), createCompoundObject(),
@@ -151,7 +155,7 @@
result.fail("asJsonArray()",
"Call of asJsonArray() on non JsonArray instance shall throw ClassCastException");
} catch (ClassCastException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("asJsonArray()",
"Call of asJsonArray() on non JsonArray instance shall throw ClassCastException, not "
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwriterfactorytests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwriterfactorytests/ClientTests.java
index 875bbe1..aa22708 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwriterfactorytests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwriterfactorytests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,33 +23,20 @@
import jakarta.json.stream.*;
import java.io.*;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.Map;
-import java.util.ArrayList;
+import java.util.logging.Logger;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -65,7 +52,7 @@
* = writerFactory.createWriter(Writer)
*/
@Test
- public void jsonWriterFactoryTest1() throws Fault {
+ public void jsonWriterFactoryTest1() {
boolean pass = true;
JsonWriter writer1 = null;
JsonWriter writer2 = null;
@@ -74,51 +61,50 @@
JsonObject jsonObject = Json.createReader(new StringReader(expString))
.readObject();
try {
- System.out.println("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
JsonWriterFactory writerFactory = Json
.createWriterFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = writerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("--------------------------------------------------");
- System.out.println("TEST CASE [JsonWriterFactory.createWriter(Writer)]");
- System.out.println("--------------------------------------------------");
- System.out.println("Create 1st JsonWriter using JsonWriterFactory");
+ LOGGER.info("--------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonWriterFactory.createWriter(Writer)]");
+ LOGGER.info("--------------------------------------------------");
+ LOGGER.info("Create 1st JsonWriter using JsonWriterFactory");
Writer sWriter1 = new StringWriter();
writer1 = writerFactory.createWriter(sWriter1);
if (writer1 == null) {
- System.err.println("WriterFactory failed to create writer1");
+ LOGGER.warning("WriterFactory failed to create writer1");
pass = false;
} else {
writer1.writeObject(jsonObject);
writer1.close();
}
- System.out.println("sWriter1=" + sWriter1.toString());
+ LOGGER.info("sWriter1=" + sWriter1.toString());
actString = JSONP_Util.removeWhitespace(sWriter1.toString());
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println("Create 2nd JsonWriter using JsonWriterFactory");
+ LOGGER.info("Create 2nd JsonWriter using JsonWriterFactory");
Writer sWriter2 = new StringWriter();
writer2 = writerFactory.createWriter(sWriter2);
if (writer2 == null) {
- System.err.println("WriterFactory failed to create writer2");
+ LOGGER.warning("WriterFactory failed to create writer2");
pass = false;
} else {
writer2.writeObject(jsonObject);
writer2.close();
}
- System.out.println("sWriter2=" + sWriter2.toString());
+ LOGGER.info("sWriter2=" + sWriter2.toString());
actString = JSONP_Util.removeWhitespace(sWriter2.toString());
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonWriterFactoryTest1 Failed: ", e);
+ fail("jsonWriterFactoryTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterFactoryTest1 Failed");
+ assertTrue(pass, "jsonWriterFactoryTest1 Failed");
}
/*
@@ -136,7 +122,7 @@
* Create writer with both UTF-8 and UTF-16BE.
*/
@Test
- public void jsonWriterFactoryTest2() throws Fault {
+ public void jsonWriterFactoryTest2() {
boolean pass = true;
JsonWriter writer1 = null;
JsonWriter writer2 = null;
@@ -145,57 +131,56 @@
JsonObject jsonObject = Json.createReader(new StringReader(expString))
.readObject();
try {
- System.out.println("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
JsonWriterFactory writerFactory = Json
.createWriterFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = writerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [JsonWriterFactory.createWriter(OutputStream, Charset)]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"Create 1st JsonWriter using JsonWriterFactory with UTF-8 encoding");
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
writer1 = writerFactory.createWriter(baos1, JSONP_Util.UTF_8);
if (writer1 == null) {
- System.err.println("WriterFactory failed to create writer1");
+ LOGGER.warning("WriterFactory failed to create writer1");
pass = false;
} else {
writer1.writeObject(jsonObject);
writer1.close();
}
- System.out.println("baos1=" + baos1.toString("UTF-8"));
+ LOGGER.info("baos1=" + baos1.toString("UTF-8"));
actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println(
+ LOGGER.info(
"Create 2nd JsonWriter using JsonWriterFactory with UTF-8 encoding");
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
writer2 = writerFactory.createWriter(baos2, JSONP_Util.UTF_8);
if (writer2 == null) {
- System.err.println("WriterFactory failed to create writer2");
+ LOGGER.warning("WriterFactory failed to create writer2");
pass = false;
} else {
writer2.writeObject(jsonObject);
writer2.close();
}
- System.out.println("baos2=" + baos2.toString("UTF-8"));
+ LOGGER.info("baos2=" + baos2.toString("UTF-8"));
actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonWriterFactoryTest2 Failed: ", e);
+ fail("jsonWriterFactoryTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterFactoryTest2 Failed");
+ assertTrue(pass, "jsonWriterFactoryTest2 Failed");
}
/*
@@ -211,7 +196,7 @@
* writer2 = writerFactory.createWriter(OutputStream)
*/
@Test
- public void jsonWriterFactoryTest3() throws Fault {
+ public void jsonWriterFactoryTest3() {
boolean pass = true;
JsonWriter writer1 = null;
JsonWriter writer2 = null;
@@ -220,52 +205,51 @@
JsonObject jsonObject = Json.createReader(new StringReader(expString))
.readObject();
try {
- System.out.println("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
JsonWriterFactory writerFactory = Json
.createWriterFactory(JSONP_Util.getEmptyConfig());
- System.out.println("Checking factory configuration properties");
+ LOGGER.info("Checking factory configuration properties");
Map<String, ?> config = writerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("--------------------------------------------------------");
- System.out.println("TEST CASE [JsonWriterFactory.createWriter(OutputStream)]");
- System.out.println("--------------------------------------------------------");
- System.out.println("Create 1st JsonWriter using JsonWriterFactory");
+ LOGGER.info("--------------------------------------------------------");
+ LOGGER.info("TEST CASE [JsonWriterFactory.createWriter(OutputStream)]");
+ LOGGER.info("--------------------------------------------------------");
+ LOGGER.info("Create 1st JsonWriter using JsonWriterFactory");
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
writer1 = writerFactory.createWriter(baos1);
if (writer1 == null) {
- System.err.println("WriterFactory failed to create writer1");
+ LOGGER.warning("WriterFactory failed to create writer1");
pass = false;
} else {
writer1.writeObject(jsonObject);
writer1.close();
}
- System.out.println("baos1=" + baos1.toString("UTF-8"));
+ LOGGER.info("baos1=" + baos1.toString("UTF-8"));
actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
- System.out.println("Create 2nd JsonWriter using JsonWriterFactory");
+ LOGGER.info("Create 2nd JsonWriter using JsonWriterFactory");
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
writer2 = writerFactory.createWriter(baos2);
if (writer2 == null) {
- System.err.println("WriterFactory failed to create writer2");
+ LOGGER.warning("WriterFactory failed to create writer2");
pass = false;
} else {
writer2.writeObject(jsonObject);
writer2.close();
}
- System.out.println("baos2=" + baos2.toString("UTF-8"));
+ LOGGER.info("baos2=" + baos2.toString("UTF-8"));
actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expString, actString))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonWriterFactoryTest3 Failed: ", e);
+ fail("jsonWriterFactoryTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterFactoryTest3 Failed");
+ assertTrue(pass, "jsonWriterFactoryTest3 Failed");
}
/*
@@ -283,42 +267,41 @@
* supported provider property
*/
@Test
- public void jsonWriterFactoryTest4() throws Fault {
+ public void jsonWriterFactoryTest4() {
boolean pass = true;
JsonWriterFactory writerFactory;
Map<String, ?> config;
try {
- System.out.println("----------------------------------------------");
- System.out.println("Test scenario1: no supported provider property");
- System.out.println("----------------------------------------------");
- System.out.println("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Test scenario1: no supported provider property");
+ LOGGER.info("----------------------------------------------");
+ LOGGER.info("Create JsonWriterFactory with Map<String, ?> with EMPTY config");
writerFactory = Json.createWriterFactory(JSONP_Util.getEmptyConfig());
config = writerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-------------------------------------------");
- System.out.println("Test scenario2: supported provider property");
- System.out.println("-------------------------------------------");
- System.out.println("Create JsonWriterFactory with Map<String, ?> with FOO config");
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info("Test scenario2: supported provider property");
+ LOGGER.info("-------------------------------------------");
+ LOGGER.info("Create JsonWriterFactory with Map<String, ?> with FOO config");
writerFactory = Json.createWriterFactory(JSONP_Util.getFooConfig());
config = writerFactory.getConfigInUse();
String[] props = { JsonGenerator.PRETTY_PRINTING, };
if (!JSONP_Util.doConfigCheck(config, 0))
pass = false;
- System.out.println("-------------------------------------------------------------");
- System.out.println("Test scenario3: supported and non supported provider property");
- System.out.println("-------------------------------------------------------------");
- System.out.println("Create JsonGeneratorFactory with Map<String, ?> with all config");
+ LOGGER.info("-------------------------------------------------------------");
+ LOGGER.info("Test scenario3: supported and non supported provider property");
+ LOGGER.info("-------------------------------------------------------------");
+ LOGGER.info("Create JsonGeneratorFactory with Map<String, ?> with all config");
writerFactory = Json.createWriterFactory(JSONP_Util.getAllConfig());
config = writerFactory.getConfigInUse();
if (!JSONP_Util.doConfigCheck(config, 1, props))
pass = false;
} catch (Exception e) {
- throw new Fault("jsonWriterFactoryTest4 Failed: ", e);
+ fail("jsonWriterFactoryTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterFactoryTest4 Failed");
+ assertTrue(pass, "jsonWriterFactoryTest4 Failed");
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/ClientTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/ClientTests.java
index 19bed5b..227d21f 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/ClientTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/ClientTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,29 +18,22 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.jsonp.tck.common.*;
-import jakarta.jsonp.tck.lib.harness.Fault;
import java.io.*;
import java.util.*;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.logging.Logger;
import jakarta.json.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
// $Id$
-@RunWith(Arquillian.class)
public class ClientTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, ClientTests.class.getPackage().getName());
- }
+ private static final Logger LOGGER = Logger.getLogger(ClientTests.class.getName());
+
/* Tests */
/*
@@ -58,38 +51,35 @@
*
*/
@Test
- public void jsonWriterTest1() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest1() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
- System.out.println(
+ LOGGER.info(
"Read the JsonObject back into 'myJsonObject2' using a JsonReader");
JsonReader reader = Json.createReader(new StringReader(contents));
JsonObject myJsonObject2 = (JsonObject) reader.read();
- System.out.println("Compare myJsonObject1 and myJsonObject2 for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2);
+ LOGGER.info("Compare myJsonObject1 and myJsonObject2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2), "jsonWriterTest1 Failed");
} catch (Exception e) {
- throw new Fault("jsonWriterTest1 Failed: ", e);
+ fail("jsonWriterTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest1 Failed");
}
/*
@@ -106,36 +96,35 @@
*
*/
@Test
- public void jsonWriterTest2() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest2() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriter(baos);
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonObjectText = baos.toString("UTF-8");
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonObjectText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonObjectText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonObject text with actual JsonObject text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText),
+ "jsonWriterTest2 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterTest2 Failed: ", e);
+ fail("jsonWriterTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest2 Failed");
}
/*
@@ -153,40 +142,37 @@
*
*/
@Test
- public void jsonWriterTest3() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest3() {
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
- System.out.println("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
+ LOGGER.info("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
JsonArray myJsonArray2;
try (JsonReader reader = Json.createReader(new StringReader(contents))) {
myJsonArray2 = (JsonArray) reader.read();
- System.out.println("Close JsonReader");
+ LOGGER.info("Close JsonReader");
}
- System.out.println("Compare myJsonArray1 and myJsonArray2 for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2);
+ LOGGER.info("Compare myJsonArray1 and myJsonArray2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2), "jsonWriterTest3 Failed");
} catch (Exception e) {
- throw new Fault("jsonWriterTest3 Failed: ", e);
+ fail("jsonWriterTest3 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest3 Failed");
}
/*
@@ -203,36 +189,35 @@
*
*/
@Test
- public void jsonWriterTest4() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest4() {
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriter(baos);
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonArrayText = baos.toString("UTF-8");
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonArrayText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonArrayText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonArray text with actual JsonArray text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText),
+ "jsonWriterTest4 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterTest4 Failed: ", e);
+ fail("jsonWriterTest4 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest4 Failed");
}
/*
@@ -252,38 +237,37 @@
* For encoding use UTF-16BE.
*/
@Test
- public void jsonWriterTest5() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest5() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_16BE);
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonObjectText = JSONP_Util
.removeWhitespace(baos.toString("UTF-16BE"));
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonObjectText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonObjectText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonObject text with actual JsonObject text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText),
+ "jsonWriterTest5 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterTest5 Failed: ", e);
+ fail("jsonWriterTest5 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest5 Failed");
}
/*
@@ -303,41 +287,40 @@
* For encoding use UTF-8.
*/
@Test
- public void jsonWriterTest6() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest6() {
try {
- System.out.println("Create a configuration with PRETT_PRINTING enabled.");
+ LOGGER.info("Create a configuration with PRETT_PRINTING enabled.");
Map<String, ?> config = JSONP_Util.getPrettyPrintingConfig();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(config).createWriter(baos,
JSONP_Util.UTF_8);
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonArrayText = JSONP_Util
.removeWhitespace(baos.toString("UTF-8"));
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonArrayText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonArrayText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonArray text with actual JsonArray text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText),
+ "jsonWriterTest6 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterTest6 Failed: ", e);
+ fail("jsonWriterTest6 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest6 Failed");
}
/*
@@ -355,37 +338,34 @@
*
*/
@Test
- public void jsonWriterTest7() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest7() {
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.write(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
- System.out.println(
+ LOGGER.info(
"Read the JsonObject back into 'myJsonObject2' using a JsonReader");
JsonReader reader = Json.createReader(new StringReader(contents));
JsonObject myJsonObject2 = (JsonObject) reader.read();
- System.out.println("Compare myJsonObject1 and myJsonObject2 for equality");
- pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2);
+ LOGGER.info("Compare myJsonObject1 and myJsonObject2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2), "jsonWriterTest7 Failed");
} catch (Exception e) {
- throw new Fault("jsonWriterTest7 Failed: ", e);
+ fail("jsonWriterTest7 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest7 Failed");
}
/*
@@ -403,37 +383,34 @@
*
*/
@Test
- public void jsonWriterTest8() throws Fault {
- boolean pass = true;
+ public void jsonWriterTest8() {
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
StringWriter sWriter = new StringWriter();
try (JsonWriter writer = Json.createWriter(sWriter)) {
writer.write(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String contents = sWriter.toString();
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + contents);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + contents);
- System.out.println("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
+ LOGGER.info("Read the JsonArray back into 'myJsonArray2' using a JsonReader");
JsonReader reader = Json.createReader(new StringReader(contents));
JsonArray myJsonArray2 = (JsonArray) reader.read();
- System.out.println("Compare myJsonArray1 and myJsonArray2 for equality");
- pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2);
+ LOGGER.info("Compare myJsonArray1 and myJsonArray2 for equality");
+ assertTrue(JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2), "jsonWriterTest8 Failed");
} catch (Exception e) {
- throw new Fault("jsonWriterTest8 Failed: ", e);
+ fail("jsonWriterTest8 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterTest8 Failed");
}
/*
@@ -453,29 +430,29 @@
* null}, "array":["string", 1, true, false, null] }
*/
@Test
- public void jsonWriterUTFEncodedTests() throws Fault {
+ public void jsonWriterUTFEncodedTests() {
boolean pass = true;
- System.out.println(
+ LOGGER.info(
"Create expected JSON text with no whitespace for use in comparsion");
String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}";
try {
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-8]");
- System.out.println(
+ LOGGER.info(
"-----------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-8 encoding");
+ LOGGER.info("Create JsonWriter using UTF-8 encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_8);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-8"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-8"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -483,26 +460,26 @@
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing generation to UTF-8 encoding: " + e);
+ LOGGER.warning("Exception occurred testing generation to UTF-8 encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-16]");
- System.out.println(
+ LOGGER.info(
"------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-16 encoding");
+ LOGGER.info("Create JsonWriter using UTF-16 encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_16);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16 encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -510,26 +487,26 @@
} catch (Exception e) {
pass = false;
- System.err.println("Exception occurred testing generation to UTF-16 encoding: " + e);
+ LOGGER.warning("Exception occurred testing generation to UTF-16 encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-16LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-16LE encoding");
+ LOGGER.info("Create JsonWriter using UTF-16LE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_16LE);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16LE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16LE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16LE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16LE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -537,27 +514,27 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-16LE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-16BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-16BE encoding");
+ LOGGER.info("Create JsonWriter using UTF-16BE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_16BE);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-16BE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-16BE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -565,27 +542,27 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-16BE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-32LE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-32LE encoding");
+ LOGGER.info("Create JsonWriter using UTF-32LE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_32LE);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-32LE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-32LE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-32LE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32LE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -593,27 +570,27 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-32LE encoding: " + e);
}
try {
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println(
+ LOGGER.info(
"TEST CASE [Json.createWriterFactory(Map<String,?>).createWriter(OutputStream, Charset) as UTF-32BE]");
- System.out.println(
+ LOGGER.info(
"--------------------------------------------------------------------------------------------------");
- System.out.println("Create JsonWriter using UTF-32BE encoding");
+ LOGGER.info("Create JsonWriter using UTF-32BE encoding");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig())
.createWriter(baos, JSONP_Util.UTF_32BE);
JSONP_Util.writeJsonObjectFromString(writer, expJson);
// Dump JsonText output
- System.out.println("Generated Output=" + baos.toString("UTF-32BE"));
+ LOGGER.info("Generated Output=" + baos.toString("UTF-32BE"));
// Do comparison
- System.out.println(
+ LOGGER.info(
"Read the JSON text back from OutputStream using UTF-32BE encoding removing whitespace");
String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32BE"));
if (!JSONP_Util.assertEqualsJsonText(expJson, actJson))
@@ -621,11 +598,10 @@
} catch (Exception e) {
pass = false;
- System.err.println(
+ LOGGER.warning(
"Exception occurred testing generation to UTF-32BE encoding: " + e);
}
- if (!pass)
- throw new Fault("jsonWriterUTFEncodedTests Failed");
+ assertTrue(pass, "jsonWriterUTFEncodedTests Failed");
}
/*
@@ -644,40 +620,39 @@
*
*/
@Test
- public void jsonWriterWithConfigTest1() throws Fault {
- boolean pass = true;
+ public void jsonWriterWithConfigTest1() {
try {
- System.out.println("Create a configuration with PRETT_PRINTING enabled.");
+ LOGGER.info("Create a configuration with PRETT_PRINTING enabled.");
Map<String, ?> config = JSONP_Util.getPrettyPrintingConfig();
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject();
- System.out.println("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
+ LOGGER.info("Write the JsonObject 'myJsonObject1' out to a JsonWriter");
StringWriter swriter = new StringWriter();
try (JsonWriter writer = Json.createWriterFactory(config)
.createWriter(swriter)) {
writer.writeObject(myJsonObject1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
}
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonObjectText = JSONP_Util
.removeWhitespace(swriter.toString());
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonObjectText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonObjectText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonObject text with actual JsonObject text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText),
+ "jsonWriterWithConfigTest1 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterWithConfigTest1 Failed: ", e);
+ fail("jsonWriterWithConfigTest1 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterWithConfigTest1 Failed");
}
/*
@@ -695,40 +670,39 @@
*
*/
@Test
- public void jsonWriterWithConfigTest2() throws Fault {
- boolean pass = true;
+ public void jsonWriterWithConfigTest2() {
try {
- System.out.println("Create a configuration with PRETT_PRINTING enabled.");
+ LOGGER.info("Create a configuration with PRETT_PRINTING enabled.");
Map<String, ?> config = JSONP_Util.getPrettyPrintingConfig();
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray();
- System.out.println("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
+ LOGGER.info("Write the JsonArray 'myJsonArray1' out to a JsonWriter");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonWriter writer = Json.createWriterFactory(config).createWriter(baos);
writer.writeArray(myJsonArray1);
- System.out.println("Close JsonWriter");
+ LOGGER.info("Close JsonWriter");
baos.close();
writer.close();
- System.out.println("Save contents of the JsonWriter as a String");
+ LOGGER.info("Save contents of the JsonWriter as a String");
String actJsonArrayText = JSONP_Util
.removeWhitespace(baos.toString("UTF-8"));
- System.out.println("Dump contents of JsonWriter as a String");
- System.out.println("JsonWriterContents=" + actJsonArrayText);
+ LOGGER.info("Dump contents of JsonWriter as a String");
+ LOGGER.info("JsonWriterContents=" + actJsonArrayText);
- System.out.println(
+ LOGGER.info(
"Compare expected JsonArray text with actual JsonArray text for equality");
- pass = JSONP_Util.assertEqualsJsonText(
- JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText);
+ assertTrue(
+ JSONP_Util.assertEqualsJsonText(JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText),
+ "jsonWriterWithConfigTest2 Failed"
+ );
} catch (Exception e) {
- throw new Fault("jsonWriterWithConfigTest2 Failed: ", e);
+ fail("jsonWriterWithConfigTest2 Failed: ", e);
}
- if (!pass)
- throw new Fault("jsonWriterWithConfigTest2 Failed");
}
/*
@@ -742,55 +716,55 @@
*
*/
@Test
- public void jsonWriterExceptionTests() throws Fault {
+ public void jsonWriterExceptionTests() {
boolean pass = true;
JsonWriter writer = null;
// IllegalStateException if writer.close() already called before
// writer.writeArray(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create JsonWriter, write something and close it");
+ LOGGER.info("Create JsonWriter, write something and close it");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeArray(jsonArray);
writer.close();
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.close() already called before writer.writeArray(JsonArray)");
writer.writeArray(jsonArray);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if writer.writeArray() called after
// writer.writeArray(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create JsonWriter and write out array");
+ LOGGER.info("Create JsonWriter and write out array");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeArray(jsonArray);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.writeArray(JsonArray) called after writer.writeArray(JsonArray)");
writer.writeArray(jsonArray);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
@@ -799,27 +773,27 @@
// IllegalStateException if writer.writeObject() called after
// writer.writeArray(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject jsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create JsonWriter and write out array");
+ LOGGER.info("Create JsonWriter and write out array");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeArray(jsonArray);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.writeObject(JsonObject) called after writer.writeArray(JsonArray)");
writer.writeObject(jsonObject);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
@@ -828,48 +802,48 @@
// IllegalStateException if writer.close() already called before
// writer.writeObject(JsonArray)
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject jsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create JsonWriter, write something and close it");
+ LOGGER.info("Create JsonWriter, write something and close it");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeObject(jsonObject);
writer.close();
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.close() already called before writer.writeObject(JsonObject)");
writer.writeObject(jsonObject);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if writer.writeObject() called after
// writer.writeObject(JsonObject)
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject jsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create JsonWriter and write out object");
+ LOGGER.info("Create JsonWriter and write out object");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeObject(jsonObject);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.writeObject(JsonObject) called after writer.writeObject(JsonObject)");
writer.writeObject(jsonObject);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
@@ -878,27 +852,27 @@
// IllegalStateException if writer.writeArray() called after
// writer.writeObject(JsonObject)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject jsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create JsonWriter and write out object");
+ LOGGER.info("Create JsonWriter and write out object");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeObject(jsonObject);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.writeArray(JsonArray) called after writer.writeObject(JsonObject)");
writer.writeArray(jsonArray);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
@@ -907,48 +881,48 @@
// IllegalStateException if writer.close() already called before
// writer.write(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create JsonWriter, write something and close it");
+ LOGGER.info("Create JsonWriter, write something and close it");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.write(jsonArray);
writer.close();
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.close() already called before writer.write(JsonArray)");
writer.write(jsonArray);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// IllegalStateException if writer.write(JsonArray) called after
// writer.writeArray(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray jsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println("Create JsonWriter and write out array");
+ LOGGER.info("Create JsonWriter and write out array");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeArray(jsonArray);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.write(JsonArray) called after writer.writeArray(JsonArray)");
writer.write(jsonArray);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
@@ -957,31 +931,30 @@
// IllegalStateException if writer.write(JsonObject) called after
// writer.writeJsonObject(JsonObject)
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject jsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println("Create JsonWriter and write out object");
+ LOGGER.info("Create JsonWriter and write out object");
StringWriter sWriter = new StringWriter();
writer = Json.createWriter(sWriter);
writer.writeObject(jsonObject);
- System.out.println(
+ LOGGER.info(
"IllegalStateException if writer.write(JsonObject) called after writer.writeObject(JsonObject)");
writer.write(jsonObject);
pass = false;
- System.err.println("Failed to throw IllegalStateException");
+ LOGGER.warning("Failed to throw IllegalStateException");
} catch (IllegalStateException e) {
- System.out.println("Got expected IllegalStateException");
+ LOGGER.info("Got expected IllegalStateException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
} finally {
if (writer != null)
writer.close();
}
- if (!pass)
- throw new Fault("jsonWriterExceptionTests Failed");
+ assertTrue(pass, "jsonWriterExceptionTests Failed");
}
/*
@@ -994,98 +967,97 @@
*
*/
@Test
- public void jsonWriterIOErrorTests() throws Fault {
+ public void jsonWriterIOErrorTests() {
boolean pass = true;
// Trip JsonException if there is an i/o error on JsonWriter.close()
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonWriter.close().");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
try (JsonWriter writer = Json.createWriter(mbw)) {
writer.writeObject(myJsonObject);
mbw.setThrowIOException(true);
- System.out.println("Calling JsonWriter.close()");
+ LOGGER.info("Calling JsonWriter.close()");
}
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on
// JsonWriter.writeObject(JsonObject)
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonWriter.writeObject(JsonObject).");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
try (JsonWriter writer = Json.createWriter(mbw)) {
mbw.setThrowIOException(true);
- System.out.println("Calling JsonWriter.writeObject(JsonObject)");
+ LOGGER.info("Calling JsonWriter.writeObject(JsonObject)");
writer.writeObject(myJsonObject);
}
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on
// JsonWriter.writeArray(JsonArray)
try {
- System.out.println("Create sample JsonArray for testing");
+ LOGGER.info("Create sample JsonArray for testing");
JsonArray myJsonArray = JSONP_Util.createSampleJsonArray();
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonWriter.writeArray(JsonArray).");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
try (JsonWriter writer = Json.createWriter(mbw)) {
mbw.setThrowIOException(true);
- System.out.println("Calling JsonWriter.writeArray(JsonArray)");
+ LOGGER.info("Calling JsonWriter.writeArray(JsonArray)");
writer.writeArray(myJsonArray);
}
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
// Trip JsonException if there is an i/o error on
// JsonWriter.write(JsonStructure)
try {
- System.out.println("Create sample JsonObject for testing");
+ LOGGER.info("Create sample JsonObject for testing");
JsonObject myJsonObject = JSONP_Util.createSampleJsonObject();
- System.out.println(
+ LOGGER.info(
"Trip JsonException if there is an i/o error on JsonWriter.write(JsonStructure).");
MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter());
try (JsonWriter writer = Json.createWriter(mbw)) {
mbw.setThrowIOException(true);
- System.out.println("Calling JsonWriter.write(JsonStructure)");
+ LOGGER.info("Calling JsonWriter.write(JsonStructure)");
writer.write(myJsonObject);
}
- System.err.println("Did not get expected JsonException");
+ LOGGER.warning("Did not get expected JsonException");
pass = false;
} catch (JsonException e) {
- System.out.println("Caught expected JsonException");
+ LOGGER.info("Caught expected JsonException");
} catch (Exception e) {
pass = false;
- System.err.println("Caught unexpected exception: " + e);
+ LOGGER.warning("Caught unexpected exception: " + e);
}
- if (!pass)
- throw new Fault("jsonWriterIOErrorTests Failed");
+ assertTrue(pass, "jsonWriterIOErrorTests Failed");
}
/*
@@ -1099,7 +1071,7 @@
* @test_Strategy: Tests JsonWriter API methods added in JSON-P 1.1.
*/
@Test
- public void jsonWriter11Test() throws Fault {
+ public void jsonWriter11Test() {
Writer writerTest = new Writer();
final TestResult result = writerTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/Writer.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/Writer.java
index 8de8832..6f35b1d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/Writer.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/jsonwritertests/Writer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.logging.Logger;
+
import jakarta.json.Json;
import jakarta.json.JsonException;
import jakarta.json.JsonValue;
@@ -39,6 +41,8 @@
*/
public class Writer {
+ private static final Logger LOGGER = Logger.getLogger(Writer.class.getName());
+
/** Tests input data. */
private static final Object[] VALUES = new Object[] { OBJ_VALUE, // write(JsonValue)
// for
@@ -70,7 +74,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonWriter API methods added in JSON-P 1.1.");
- System.out.println("JsonWriter API methods added in JSON-P 1.1.");
+ LOGGER.info("JsonWriter API methods added in JSON-P 1.1.");
testWriteValue(result);
testDoubleWriteValue(result);
testIOExceptionOnWriteValue(result);
@@ -87,18 +91,18 @@
private void testWriteValue(final TestResult result) {
for (Object value : VALUES) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(" - write(JsonValue) for " + typeName + " as an argument");
+ LOGGER.info(" - write(JsonValue) for " + typeName + " as an argument");
final JsonValue jsonValue = SimpleValues.toJsonValue(value);
final StringWriter strWriter = new StringWriter();
try (final JsonWriter writer = Json.createWriter(strWriter)) {
writer.write(jsonValue);
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("write(JsonValue)",
"Caught JsonException: " + ex.getLocalizedMessage());
}
final String data = strWriter.toString();
- System.out.println(" - Data: " + data);
+ LOGGER.info(" - Data: " + data);
final JsonParser parser = Json.createParser(new StringReader(data));
parser.next();
final JsonValue outValue = parser.getValue();
@@ -121,7 +125,7 @@
private void testDoubleWriteValue(final TestResult result) {
for (Object value : VALUES) {
final String typeName = JsonValueType.getType(value).name();
- System.out.println(
+ LOGGER.info(
" - duplicate write(JsonValue) for " + typeName + " as an argument");
final JsonValue jsonValue = SimpleValues.toJsonValue(value);
final StringWriter strWriter = new StringWriter();
@@ -134,14 +138,14 @@
result.fail("write(JsonValue)",
"Duplicate call of write(JsonValue) shall throw IllegalStateException");
} catch (IllegalStateException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("write(JsonValue)",
"Duplicate call of write(JsonValue) shall throw IllegalStateException, not "
+ t.getClass().getSimpleName());
}
} catch (JsonException ex) {
- System.out.println("Caught JsonException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught JsonException: " + ex.getLocalizedMessage());
result.fail("write(JsonValue)",
"Caught JsonException: " + ex.getLocalizedMessage());
}
@@ -157,19 +161,19 @@
*/
@SuppressWarnings("ConvertToTryWithResources")
private void testIOExceptionOnWriteValue(final TestResult result) {
- System.out.println(" - write(JsonValue) into already closed file writer");
+ LOGGER.info(" - write(JsonValue) into already closed file writer");
final JsonValue jsonValue = SimpleValues.toJsonValue(DEF_VALUE);
File temp = null;
JsonWriter writer;
// Close writer before calling write method.
try {
temp = File.createTempFile("testIOExceptionOnWriteValue", ".txt");
- System.out.println(" - Temporary file: " + temp.getAbsolutePath());
+ LOGGER.info(" - Temporary file: " + temp.getAbsolutePath());
final FileWriter fileWriter = new FileWriter(temp);
writer = Json.createWriter(fileWriter);
fileWriter.close();
} catch (IOException ex) {
- System.out.println("Caught IOException: " + ex.getLocalizedMessage());
+ LOGGER.info("Caught IOException: " + ex.getLocalizedMessage());
result.fail("write(JsonValue)",
"Caught IOException: " + ex.getLocalizedMessage());
return;
@@ -183,7 +187,7 @@
result.fail("write(JsonValue)",
"Call of write(JsonValue) on already closed file writer shall throw JsonException");
} catch (JsonException ex) {
- System.out.println(" - Expected exception: " + ex.getMessage());
+ LOGGER.info(" - Expected exception: " + ex.getMessage());
} catch (Throwable t) {
result.fail("write(JsonValue)",
"Call of write(JsonValue) on already closed file writer shall throw JsonException, not "
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeAddValue.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeAddValue.java
index 13d5b78..0c1a21d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeAddValue.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeAddValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.json.JsonObject;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -32,6 +34,8 @@
*/
public class MergeAddValue extends MergeCommon {
+ private static final Logger LOGGER = Logger.getLogger(MergeAddValue.class.getName());
+
/**
* Creates an instance of RFC 7396 value adding test.
*/
@@ -47,7 +51,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 7396: Add non existing values");
- System.out.println("Testing RFC 7396: Add non existing values");
+ LOGGER.info("Testing RFC 7396: Add non existing values");
testStringOnEmptyObject(result);
testStringOnsimpleObject(result);
testIntOnEmptyObject(result);
@@ -66,7 +70,7 @@
* Tests result record.
*/
private void testStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String on empty JSON object");
+ LOGGER.info(" - for String on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject patch = createSimpleObjectStr();
final JsonObject check = createSimpleObjectStr();
@@ -81,7 +85,7 @@
* Tests result record.
*/
private void testStringOnsimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectStr();
final JsonObject check = createSimpleObjectWithStr();
@@ -96,7 +100,7 @@
* Tests result record.
*/
private void testIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int on empty JSON object");
+ LOGGER.info(" - for int on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject patch = createSimpleObjectInt();
final JsonObject check = createSimpleObjectInt();
@@ -111,7 +115,7 @@
* Tests result record.
*/
private void testIntOnsimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectInt();
final JsonObject check = createSimpleObjectWithInt();
@@ -126,7 +130,7 @@
* Tests result record.
*/
private void testBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean on empty JSON object");
+ LOGGER.info(" - for boolean on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject patch = createSimpleObjectBool();
final JsonObject check = createSimpleObjectBool();
@@ -141,7 +145,7 @@
* Tests result record.
*/
private void testBoolOnsimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectBool();
final JsonObject check = createSimpleObjectWithBool();
@@ -156,7 +160,7 @@
* Tests result record.
*/
private void testObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject on empty JSON object");
+ LOGGER.info(" - for JsonObject on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject patch = createSimpleObjectObject();
final JsonObject check = createSimpleObjectObject();
@@ -172,7 +176,7 @@
* Tests result record.
*/
private void testObjectOnsimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on compound JSON object");
+ LOGGER.info(" - for JsonObject on compound JSON object");
final JsonObject in = createCompoundObject();
final JsonObject patch = createSimpleObjectObject();
final JsonObject check = createCompoundObjectWithObject();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeNonObject.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeNonObject.java
index dbcba22..147658d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeNonObject.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeNonObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,8 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -35,6 +37,8 @@
*/
public class MergeNonObject extends MergeCommon {
+ private static final Logger LOGGER = Logger.getLogger(MergeNonObject.class.getName());
+
/**
* Creates an instance of RFC 7396 non object patch test.
*/
@@ -49,7 +53,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 7396: Non object patch");
- System.out.println("Testing RFC 7396: Non object patch");
+ LOGGER.info("Testing RFC 7396: Non object patch");
testStringOnEmptyObject(result);
testStringOnSimpleObject(result);
testStringOnSimpleArray(result);
@@ -72,7 +76,7 @@
* Tests result record.
*/
private void testStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String on empty JSON object");
+ LOGGER.info(" - for String on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonValue patch = Json.createValue(STR_VALUE);
final JsonValue check = Json.createValue(STR_VALUE);
@@ -87,7 +91,7 @@
* Tests result record.
*/
private void testStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectWithStr();
final JsonValue patch = Json.createValue(STR_VALUE);
final JsonValue check = Json.createValue(STR_VALUE);
@@ -102,7 +106,7 @@
* Tests result record.
*/
private void testStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array");
+ LOGGER.info(" - for String on simple JSON array");
final JsonArray in = createStringArray2();
final JsonValue patch = Json.createValue(STR_VALUE);
final JsonValue check = Json.createValue(STR_VALUE);
@@ -117,7 +121,7 @@
* Tests result record.
*/
private void testIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int on empty JSON object");
+ LOGGER.info(" - for int on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonValue patch = Json.createValue(INT_VALUE);
final JsonValue check = Json.createValue(INT_VALUE);
@@ -132,7 +136,7 @@
* Tests result record.
*/
private void testIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectWithInt();
final JsonValue patch = Json.createValue(INT_VALUE);
final JsonValue check = Json.createValue(INT_VALUE);
@@ -147,7 +151,7 @@
* Tests result record.
*/
private void testIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array");
+ LOGGER.info(" - for int on simple JSON array");
final JsonArray in = createIntArray2();
final JsonValue patch = Json.createValue(INT_VALUE);
final JsonValue check = Json.createValue(INT_VALUE);
@@ -162,7 +166,7 @@
* Tests result record.
*/
private void testBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean on empty JSON object");
+ LOGGER.info(" - for boolean on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonValue patch = toJsonValue(BOOL_VALUE);
final JsonValue check = toJsonValue(BOOL_VALUE);
@@ -177,7 +181,7 @@
* Tests result record.
*/
private void testBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectWithBool();
final JsonValue patch = toJsonValue(BOOL_VALUE);
final JsonValue check = toJsonValue(BOOL_VALUE);
@@ -192,7 +196,7 @@
* Tests result record.
*/
private void testBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array");
+ LOGGER.info(" - for boolean on simple JSON array");
final JsonArray in = createBoolArray2();
final JsonValue patch = toJsonValue(BOOL_VALUE);
final JsonValue check = toJsonValue(BOOL_VALUE);
@@ -207,7 +211,7 @@
* Tests result record.
*/
private void testArrayOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonArray on empty JSON object");
+ LOGGER.info(" - for JsonArray on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonArray patch = createStringArray1();
final JsonArray check = createStringArray1();
@@ -222,7 +226,7 @@
* Tests result record.
*/
private void testArrayOnCompoundObject(final TestResult result) {
- System.out.println(" - for JsonArray on compound JSON object");
+ LOGGER.info(" - for JsonArray on compound JSON object");
final JsonObject in = createCompoundObject();
final JsonValue patch = createStringArray2();
final JsonValue check = createStringArray2();
@@ -237,7 +241,7 @@
* Tests result record.
*/
private void testArrayOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonArray on simple JSON array");
+ LOGGER.info(" - for JsonArray on simple JSON array");
final JsonArray in = createBoolArray2();
final JsonValue patch = createIntArray2();
final JsonValue check = createIntArray2();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRFCSample.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRFCSample.java
index 37dd77f..e8eddd2 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRFCSample.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRFCSample.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.json.JsonObject;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.MergeRFCObject.*;
// $Id$
@@ -31,6 +33,8 @@
*/
public class MergeRFCSample extends MergeCommon {
+ private static final Logger LOGGER = Logger.getLogger(MergeRFCSample.class.getName());
+
/**
* Creates an instance of RFC 7396 value replacing test.
*/
@@ -45,7 +49,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 7396: Example JSON object");
- System.out.println("Testing RFC 7396: Example JSON object");
+ LOGGER.info("Testing RFC 7396: Example JSON object");
testMerge(result);
testDiff(result);
return result;
@@ -58,7 +62,7 @@
* Tests result record.
*/
private void testMerge(final TestResult result) {
- System.out.println(" - merge");
+ LOGGER.info(" - merge");
final JsonObject in = createRFCSourceObject();
final JsonObject patch = createRFCPatchObject();
final JsonObject check = createRFCTargetObject();
@@ -73,7 +77,7 @@
* Tests result record.
*/
private void testDiff(final TestResult result) {
- System.out.println(" - diff");
+ LOGGER.info(" - diff");
final JsonObject in = createRFCSourceObject();
final JsonObject diff = createRFCPatchObject();
final JsonObject out = createRFCTargetObject();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRemoveValue.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRemoveValue.java
index 039fb70..af21f31 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRemoveValue.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeRemoveValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.json.JsonObject;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -32,6 +34,8 @@
*/
public class MergeRemoveValue extends MergeCommon {
+ private static final Logger LOGGER = Logger.getLogger(MergeRemoveValue.class.getName());
+
/**
* Creates an instance of RFC 7396 value removal test.
*/
@@ -47,7 +51,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 7396: Remove existing values");
- System.out.println("Testing RFC 7396: Remove existing values");
+ LOGGER.info("Testing RFC 7396: Remove existing values");
testStringOnEmptyObject(result);
testStringOnsimpleObject(result);
testIntOnEmptyObject(result);
@@ -66,7 +70,7 @@
* Tests result record.
*/
private void testStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String to produce empty JSON object");
+ LOGGER.info(" - for String to produce empty JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject patch = createPatchRemoveStr();
final JsonObject check = createEmptyObject();
@@ -81,7 +85,7 @@
* Tests result record.
*/
private void testStringOnsimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectWithStr();
final JsonObject patch = createPatchRemoveStr();
final JsonObject check = createSimpleObject();
@@ -96,7 +100,7 @@
* Tests result record.
*/
private void testIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int to produce empty JSON object");
+ LOGGER.info(" - for int to produce empty JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject patch = createPatchRemoveInt();
final JsonObject check = createEmptyObject();
@@ -111,7 +115,7 @@
* Tests result record.
*/
private void testIntOnsimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectWithInt();
final JsonObject patch = createPatchRemoveInt();
final JsonObject check = createSimpleObject();
@@ -126,7 +130,7 @@
* Tests result record.
*/
private void testBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean to produce empty JSON object");
+ LOGGER.info(" - for boolean to produce empty JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject patch = createPatchRemoveBool();
final JsonObject check = createEmptyObject();
@@ -141,7 +145,7 @@
* Tests result record.
*/
private void testBoolOnsimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectWithBool();
final JsonObject patch = createPatchRemoveBool();
final JsonObject check = createSimpleObject();
@@ -156,7 +160,7 @@
* Tests result record.
*/
private void testObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject to produce empty JSON object");
+ LOGGER.info(" - for JsonObject to produce empty JSON object");
final JsonObject in = createSimpleObjectObject();
final JsonObject patch = createPatchRemoveObject();
final JsonObject check = createEmptyObject();
@@ -171,7 +175,7 @@
* Tests result record.
*/
private void testObjectOnsimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on compoubnd JSON object");
+ LOGGER.info(" - for JsonObject on compoubnd JSON object");
final JsonObject in = createCompoundObjectWithObject();
final JsonObject patch = createPatchRemoveObject();
final JsonObject check = createCompoundObject();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeReplaceValue.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeReplaceValue.java
index 5d66b44..ad24a17 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeReplaceValue.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeReplaceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.json.JsonObject;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -32,6 +34,8 @@
*/
public class MergeReplaceValue extends MergeCommon {
+ private static final Logger LOGGER = Logger.getLogger(MergeReplaceValue.class.getName());
+
/**
* Creates an instance of RFC 7396 value replacing test.
*/
@@ -47,7 +51,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 7396: Replace existing values");
- System.out.println("Testing RFC 7396: Replace existing values");
+ LOGGER.info("Testing RFC 7396: Replace existing values");
testStringOnsimpleObject(result);
testIntOnsimpleObject(result);
testBoolOnsimpleObject(result);
@@ -62,7 +66,7 @@
* Tests result record.
*/
private void testStringOnsimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectMoveStr();
final JsonObject check = createSimpleObjectMoveStr();
@@ -77,7 +81,7 @@
* Tests result record.
*/
private void testIntOnsimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectMoveInt();
final JsonObject check = createSimpleObjectMoveInt();
@@ -92,7 +96,7 @@
* Tests result record.
*/
private void testBoolOnsimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectMoveBool();
final JsonObject check = createSimpleObjectMoveBool();
@@ -108,7 +112,7 @@
* Tests result record.
*/
private void testObjectOnsimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject patch = createSimpleObjectMoveObject();
final JsonObject check = createSimpleObjectMoveObject();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeTests.java
index b9cd494..510456d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/mergetests/MergeTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,9 +17,8 @@
package jakarta.jsonp.tck.api.mergetests;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.jsonp.tck.lib.harness.Fault;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
// $Id$
/**
@@ -35,7 +34,7 @@
* Introduction</a>}: If the provided merge patch contains members that do not
* appear within the target, those members are added.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonMergeAddValueTest
@@ -45,7 +44,7 @@
* @test_Strategy: Test API response on various JSON values.
*/
@Test
- public void jsonMergeAddValueTest() throws Fault {
+ public void jsonMergeAddValueTest() {
MergeAddValue addTest = new MergeAddValue();
final TestResult result = addTest.test();
result.eval();
@@ -57,7 +56,7 @@
* Introduction</a>}: If the target does contain the member, the value is
* replaced.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonMergeReplaceValueTest
@@ -66,7 +65,7 @@
* @test_Strategy: Test API response on various JSON values.
*/
@Test
- public void jsonMergeReplaceValueTest() throws Fault {
+ public void jsonMergeReplaceValueTest() {
MergeReplaceValue replaceTest = new MergeReplaceValue();
final TestResult result = replaceTest.test();
result.eval();
@@ -78,7 +77,7 @@
* Introduction</a>}: {@code null} values in the merge patch are given special
* meaning to indicate the removal of existing values in the target.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonMergeRemoveValueTest
@@ -87,7 +86,7 @@
* @test_Strategy: Test API response on various JSON values.
*/
@Test
- public void jsonMergeRemoveValueTest() throws Fault {
+ public void jsonMergeRemoveValueTest() {
MergeRemoveValue removeTest = new MergeRemoveValue();
final TestResult result = removeTest.test();
result.eval();
@@ -99,7 +98,7 @@
* Introduction</a>}: If the patch is anything other than an object, the
* result will always be to replace the entire target with the entire patch.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonMergeNonObjectTest
@@ -109,7 +108,7 @@
* @test_Strategy: Test API response on various JSON values.
*/
@Test
- public void jsonMergeNonObjectTest() throws Fault {
+ public void jsonMergeNonObjectTest() {
MergeNonObject nonObjTest = new MergeNonObject();
final TestResult result = nonObjTest.test();
result.eval();
@@ -120,7 +119,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc7396#section-3">RFC 7396: 3.
* Example</a>} objects.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonMergeRFCSampleTest
@@ -129,7 +128,7 @@
* @test_Strategy: Test API response on RFC example objects.
*/
@Test
- public void jsonMergeRFCSampleTest() throws Fault {
+ public void jsonMergeRFCSampleTest() {
MergeRFCSample rfcSampleTest = new MergeRFCSample();
final TestResult result = rfcSampleTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/CommonOperation.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/CommonOperation.java
index 0ac6675..ed233ef 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/CommonOperation.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/CommonOperation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPatchBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -33,6 +35,8 @@
*/
public abstract class CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(CommonOperation.class.getName());
+
/** Message content template for test failure log message: operation name. */
private static final String TEST_FAIL_OP = " operation";
@@ -129,14 +133,14 @@
out = patchApply(patch, in);
} catch (JsonException e) {
out = null;
- System.out.println(
+ LOGGER.info(
" Exception for path \"" + path + "\" on " + valueToString(in));
- System.out.println(" " + e.getMessage());
+ LOGGER.info(" " + e.getMessage());
}
if (operationFailed(check, out)) {
final String targetClassName = in.getValueType().name().toLowerCase();
final String operation = valueToString(patch.toJsonArray());
- System.out.println(" " + operation);
+ LOGGER.info(" " + operation);
result.fail(testName(path, targetClassName),
testMessage(operation, path, valueToString(in)));
}
@@ -197,7 +201,7 @@
if (operationFailed(check, out)) {
final String operations = valueToString(patch.toJsonArray());
final String targetClassName = in.getValueType().name().toLowerCase();
- System.out.println(" " + operations);
+ LOGGER.info(" " + operations);
result.fail(testName(paths, targetClassName),
testMessage(operations, paths, valueToString(in)));
}
@@ -257,14 +261,14 @@
patchApply(patch, in);
final String targetClassName = in.getValueType().name().toLowerCase();
final String operation = valueToString(patch.toJsonArray());
- System.out.println(
+ LOGGER.info(
" Failed for path \"" + path + "\" on " + valueToString(in));
- System.out.println(" " + operation);
+ LOGGER.info(" " + operation);
result.fail(testName(path, targetClassName),
testMessage(operation, path, valueToString(in)));
} catch (JsonException e) {
// There are too many combinations to log them.
- // System.out.println(" - Expected exception: "+e.getMessage());
+ // LOGGER.info(" - Expected exception: "+e.getMessage());
}
}
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchCreate.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchCreate.java
index e5fc243..3d64b8e 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchCreate.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchCreate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,13 +16,10 @@
package jakarta.jsonp.tck.api.patchtests;
+import jakarta.json.*;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.json.Json;
-import jakarta.json.JsonArray;
-import jakarta.json.JsonObject;
-import jakarta.json.JsonPatch;
-import jakarta.json.JsonPatchBuilder;
-import jakarta.json.JsonValue;
+
+import java.util.logging.Logger;
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -34,6 +31,8 @@
*/
public class PatchCreate {
+ private static final Logger LOGGER = Logger.getLogger(PatchCreate.class.getName());
+
/**
* Creates an instance of {@link JsonPatch} API factory methods added in
* JSON-P 1.1 test.
@@ -50,7 +49,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonPatch API factory methods added in JSON-P 1.1.");
- System.out.println("JsonPatch API factory methods added in JSON-P 1.1.");
+ LOGGER.info("JsonPatch API factory methods added in JSON-P 1.1.");
testCreateDiff(result);
testCreatePatch(result);
testCreatePatchBuilder(result);
@@ -64,7 +63,7 @@
* Test suite result.
*/
private void testCreateDiff(final TestResult result) {
- System.out.println(" - Json#createDiff(JsonStructure,JsonStructure)");
+ LOGGER.info(" - Json#createDiff(JsonStructure,JsonStructure)");
final JsonObject src = createSimpleObject();
final JsonObject trg = createSimpleObjectWithStr();
final JsonPatch patch = Json.createDiff(src, trg);
@@ -82,7 +81,7 @@
* Test suite result.
*/
private void testCreatePatch(final TestResult result) {
- System.out.println(" - Json#createPatch(JsonArray)");
+ LOGGER.info(" - Json#createPatch(JsonArray)");
final JsonObject src = createSimpleObject();
final JsonObject trg = createSimpleObjectWithStr();
final JsonArray patchArray = Json.createDiff(src, trg).toJsonArray();
@@ -101,7 +100,7 @@
* Test suite result.
*/
private void testCreatePatchBuilder(final TestResult result) {
- System.out.println(" - Json#createPatchBuilder(JsonArray)");
+ LOGGER.info(" - Json#createPatchBuilder(JsonArray)");
final JsonObject src = createSimpleObject();
final JsonObject trg = createSimpleObjectWithStr();
final JsonArray patchArray = Json.createDiff(src, trg).toJsonArray();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationAdd.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationAdd.java
index 7318284..9f0c94d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationAdd.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationAdd.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,6 +27,8 @@
import jakarta.json.Json;
import jakarta.json.JsonPointer;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -41,6 +43,8 @@
*/
class PatchOperationAdd extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationAdd.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "ADD";
@@ -58,7 +62,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 add operation");
- System.out.println("Testing RFC 6902 add operation:");
+ LOGGER.info("Testing RFC 6902 add operation:");
testAddStringOnEmptyObject(result);
testAddStringOnSimpleObject(result);
testAddStringOnEmptyArray(result);
@@ -93,7 +97,7 @@
* Tests result record.
*/
private void testAddStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String on empty JSON object");
+ LOGGER.info(" - for String on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectStr();
simpleOperation(result, in, check, STR_PATH, STR_VALUE);
@@ -107,7 +111,7 @@
* Tests result record.
*/
private void testAddStringOnEmptyArray(final TestResult result) {
- System.out.println(" - for String on empty JSON array");
+ LOGGER.info(" - for String on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithStr();
simpleOperation(result, in, check, "/0", STR_VALUE);
@@ -120,7 +124,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithStr();
simpleOperation(result, in, check, STR_PATH, STR_VALUE);
@@ -135,7 +139,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 1");
+ LOGGER.info(" - for String on simple JSON array of size 1");
final JsonArray in = createStringArray1();
final JsonArray checkBefore = createSimpleStringArrayWithStrBefore();
final JsonArray checkAfter = createSimpleStringArrayWithStrAfter();
@@ -159,7 +163,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray in = createStringArray2();
final JsonArray check = createSimpleStringArray5();
complexOperation(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -175,7 +179,7 @@
* Tests result record.
*/
private void testAddIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int on empty JSON object");
+ LOGGER.info(" - for int on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectInt();
simpleOperation(result, in, check, INT_PATH, INT_VALUE);
@@ -189,7 +193,7 @@
* Tests result record.
*/
private void testAddIntOnEmptyArray(final TestResult result) {
- System.out.println(" - for int on empty JSON array");
+ LOGGER.info(" - for int on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithInt();
simpleOperation(result, in, check, "/0", INT_VALUE);
@@ -202,7 +206,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithInt();
simpleOperation(result, in, check, INT_PATH, INT_VALUE);
@@ -217,7 +221,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 1");
+ LOGGER.info(" - for int on simple JSON array of size 1");
final JsonArray in = createIntArray1();
final JsonArray checkBefore = createSimpleIntArrayWithIntBefore();
final JsonArray checkAfter = createSimpleIntArrayWithIntAfter();
@@ -241,7 +245,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray in = createIntArray2();
final JsonArray check = createSimpleIntArray5();
complexOperation(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -257,7 +261,7 @@
* Tests result record.
*/
private void testAddBooleanOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean on empty JSON object");
+ LOGGER.info(" - for boolean on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectBool();
simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE);
@@ -271,7 +275,7 @@
* Tests result record.
*/
private void testAddBooleanOnEmptyArray(final TestResult result) {
- System.out.println(" - for boolean on empty JSON array");
+ LOGGER.info(" - for boolean on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithBool();
simpleOperation(result, in, check, "/0", BOOL_VALUE);
@@ -284,7 +288,7 @@
* Tests result record.
*/
private void testAddBooleanOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithBool();
simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE);
@@ -299,7 +303,7 @@
* Tests result record.
*/
private void testAddBooleanOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 1");
+ LOGGER.info(" - for boolean on simple JSON array of size 1");
final JsonArray in = createBoolArray1();
final JsonArray checkBefore = createSimpleBoolArrayWithBoolBefore();
final JsonArray checkAfter = createSimpleBoolArrayWithBoolAfter();
@@ -323,7 +327,7 @@
* Tests result record.
*/
private void testAddBooleanOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray in = createBoolArray2();
final JsonArray check = createSimpleBoolArray5();
complexOperation(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -339,7 +343,7 @@
* Tests result record.
*/
private void testAddObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject on empty JSON object");
+ LOGGER.info(" - for JsonObject on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectObject();
simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE);
@@ -353,7 +357,7 @@
* Tests result record.
*/
private void testAddObjectOnEmptyArray(final TestResult result) {
- System.out.println(" - for JsonObject on empty JSON array");
+ LOGGER.info(" - for JsonObject on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithObject();
simpleOperation(result, in, check, "/0", OBJ_VALUE);
@@ -366,7 +370,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectWithObject();
simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE);
@@ -382,7 +386,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 1");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 1");
final JsonArray in = createObjectArray1();
final JsonArray checkBefore = createSimpleObjectArrayWithObjectBefore();
final JsonArray checkAfter = createSimpleObjectArrayWithObjectAfter();
@@ -406,7 +410,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray in = createObjectArray2();
final JsonArray check = createSimpleObjectArray5();
complexOperation(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -431,7 +435,7 @@
* </ul>
*/
private void testAddArrayToReplaceObject(final TestResult result) {
- System.out.println(" - for JsonArray to replace JsonObject");
+ LOGGER.info(" - for JsonArray to replace JsonObject");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectWithObjectReplaced();
final JsonArray value = createSimpleStringArray5();
@@ -451,7 +455,7 @@
* </ul>
*/
private void testAddArrayToReplaceDocument(final TestResult result) {
- System.out.println(" - for JsonArray to replace whole document");
+ LOGGER.info(" - for JsonArray to replace whole document");
final JsonObject in = createCompoundObject();
final JsonArray check = createSimpleStringArray5();
final JsonArray value = createSimpleStringArray5();
@@ -486,7 +490,7 @@
* </ul>
*/
private void testAddStringArrayToStringArray(final TestResult result) {
- System.out.println(" - for String array to be added to existing String array");
+ LOGGER.info(" - for String array to be added to existing String array");
final JsonArray in = createStringArray2();
final JsonArray check = createStringArray2WithStringArrayInTheMiddle();
final JsonArray value = createStringInnerArray2();
@@ -503,7 +507,7 @@
*
*/
private void testAddStringToNonExistingObject(final TestResult result) {
- System.out.println(" - for String to be added to non existing JsonObject");
+ LOGGER.info(" - for String to be added to non existing JsonObject");
final JsonObject in = createSimpleObject();
final JsonValue value = Json.createValue(STR_VALUE);
final String path = DEF_OBJ_PATH + STR_PATH;
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationCopy.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationCopy.java
index f0765c6..43a7360 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationCopy.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationCopy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,8 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonPatchBuilder;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -35,6 +37,8 @@
*/
public class PatchOperationCopy extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationCopy.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "COPY";
@@ -52,7 +56,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 copy operation");
- System.out.println("Testing RFC 6902 copy operation:");
+ LOGGER.info("Testing RFC 6902 copy operation:");
testCopyStringOnSimpleObject(result);
testCopyStringOnSimpleArray(result);
testCopyIntOnSimpleObject(result);
@@ -75,7 +79,7 @@
* Tests result record.
*/
private void testCopyStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createSimpleObjectCopyStr();
simpleOperation(result, in, check, STR_PATH, DEF_PATH);
@@ -88,7 +92,7 @@
* Tests result record.
*/
private void testCopyStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray in = createStringArray2();
simpleOperation(result, in, createStringArray2Copy1to0(), "/1", "/0");
simpleOperation(result, in, createStringArray2Copy0to2(), "/0", "/2");
@@ -102,7 +106,7 @@
* Tests result record.
*/
private void testCopyIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createSimpleObjectCopyInt();
simpleOperation(result, in, check, INT_PATH, DEF_PATH);
@@ -115,7 +119,7 @@
* Tests result record.
*/
private void testCopyIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray in = createIntArray2();
simpleOperation(result, in, createIntArray2Copy1to0(), "/1", "/0");
simpleOperation(result, in, createIntArray2Copy0to2(), "/0", "/2");
@@ -129,7 +133,7 @@
* Tests result record.
*/
private void testCopyBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createSimpleObjectCopyBool();
simpleOperation(result, in, check, BOOL_PATH, DEF_PATH);
@@ -142,7 +146,7 @@
* Tests result record.
*/
private void testCopyBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray in = createBoolArray2();
simpleOperation(result, in, createBoolArray2Copy1to0(), "/1", "/0");
simpleOperation(result, in, createBoolArray2Copy0to2(), "/0", "/2");
@@ -156,7 +160,7 @@
* Tests result record.
*/
private void testCopyObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createSimpleObjectObject();
final JsonObject check = createSimpleObjectCopyObject();
simpleOperation(result, in, check, OBJ_PATH, DEF_PATH);
@@ -169,7 +173,7 @@
* Tests result record.
*/
private void testCopyObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray in = createObjectArray2();
simpleOperation(result, in, createObjectArray2Copy1to0(), "/1", "/0");
simpleOperation(result, in, createObjectArray2Copy0to2(), "/0", "/2");
@@ -184,7 +188,7 @@
* Tests result record.
*/
private void testCopyStringOnCompoundObject(final TestResult result) {
- System.out.println(" - for String on compound JSON object");
+ LOGGER.info(" - for String on compound JSON object");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectCopyValue();
simpleOperation(result, in, check, DEF_PATH, DEF_OBJ_PATH + DEF_PATH);
@@ -199,7 +203,7 @@
* The "from" location MUST exist for the operation to be successful.
*/
private void testCopyOfNonExistingLocationInObject(final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -222,7 +226,7 @@
* The "from" location MUST exist for the operation to be successful.
*/
private void testCopyOfNonExistingLocationInArray(final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2() };
@@ -263,7 +267,7 @@
protected JsonPatchBuilder createOperationBuilder(final String path,
final Object value) {
if (value instanceof String) {
- // System.out.println(" COPY "+path+" -> "+(String)value);
+ // LOGGER.info(" COPY "+path+" -> "+(String)value);
return Json.createPatchBuilder().copy((String) value, path);
} else {
throw new IllegalArgumentException(
@@ -287,7 +291,7 @@
protected JsonPatchBuilder updateOperationBuilder(
final JsonPatchBuilder builder, final String path, final Object value) {
if (value instanceof String) {
- // System.out.println(" COPY "+path+" -> "+(String)value);
+ // LOGGER.info(" COPY "+path+" -> "+(String)value);
return builder.copy((String) value, path);
} else {
throw new IllegalArgumentException(
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationEnum.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationEnum.java
index 82f0c6b..3ae293d 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationEnum.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationEnum.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,8 @@
import jakarta.jsonp.tck.api.common.TestResult;
import jakarta.json.JsonPatch;
+import java.util.logging.Logger;
+
// $Id$
/**
* RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.<br>
@@ -28,6 +30,8 @@
*/
public class PatchOperationEnum {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationEnum.class.getName());
+
/**
* Creates an instance of {@link JsonPatch.Operation} enumeration test.
*/
@@ -43,7 +47,7 @@
TestResult test() {
final TestResult result = new TestResult(
"JsonPatch.Operation enumeration test");
- System.out.println("JsonPatch.Operation enumeration test");
+ LOGGER.info("JsonPatch.Operation enumeration test");
testOperationName(result);
testOperationValueOf(result);
return result;
@@ -57,7 +61,7 @@
* Tests result record.
*/
private void testOperationName(final TestResult result) {
- System.out.println(" - fromOperationName(String) and operationName(String)");
+ LOGGER.info(" - fromOperationName(String) and operationName(String)");
for (final JsonPatch.Operation op : JsonPatch.Operation.values()) {
final String opName = op.operationName();
final JsonPatch.Operation opOut = JsonPatch.Operation
@@ -85,7 +89,7 @@
* Tests result record.
*/
private void testOperationValueOf(final TestResult result) {
- System.out.println(" - valueOf(String)");
+ LOGGER.info(" - valueOf(String)");
for (final JsonPatch.Operation op : JsonPatch.Operation.values()) {
final String opName = op.name();
final JsonPatch.Operation opOut = JsonPatch.Operation.valueOf(opName);
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationMove.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationMove.java
index 0286f52..7136d4e 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationMove.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationMove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -26,6 +26,8 @@
import jakarta.json.JsonPointer;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -40,6 +42,8 @@
*/
public class PatchOperationMove extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationMove.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "MOVE";
@@ -57,7 +61,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 move operation");
- System.out.println("Testing RFC 6902 move operation:");
+ LOGGER.info("Testing RFC 6902 move operation:");
testMoveStringOnSimpleObject(result);
testMoveStringOnSimpleArray(result);
testMoveStringOnSimpleArray2(result);
@@ -84,7 +88,7 @@
* Tests result record.
*/
private void testMoveStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createSimpleObjectMoveStr();
simpleOperation(result, in, check, STR_PATH, DEF_PATH);
@@ -97,7 +101,7 @@
* Tests result record.
*/
private void testMoveStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray in = createStringArray2();
final JsonArray check = createStringArray2R();
simpleOperation(result, in, in, "/0", "/0");
@@ -113,7 +117,7 @@
* Tests result record.
*/
private void testMoveStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 5");
+ LOGGER.info(" - for String on simple JSON array of size 5");
final JsonArray in = createSimpleStringArray5();
final JsonArray check = createSimpleStringArray5R();
complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" },
@@ -129,7 +133,7 @@
* Tests result record.
*/
private void testMoveIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createSimpleObjectMoveInt();
simpleOperation(result, in, check, INT_PATH, DEF_PATH);
@@ -142,7 +146,7 @@
* Tests result record.
*/
private void testMoveIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray in = createIntArray2();
final JsonArray check = createIntArray2R();
simpleOperation(result, in, in, "/0", "/0");
@@ -158,7 +162,7 @@
* Tests result record.
*/
private void testMoveIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 5");
+ LOGGER.info(" - for int on simple JSON array of size 5");
final JsonArray in = createSimpleIntArray5();
final JsonArray check = createSimpleIntArray5R();
complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" },
@@ -174,7 +178,7 @@
* Tests result record.
*/
private void testMoveBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createSimpleObjectMoveBool();
simpleOperation(result, in, check, BOOL_PATH, DEF_PATH);
@@ -187,7 +191,7 @@
* Tests result record.
*/
private void testMoveBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray in = createBoolArray2();
final JsonArray check = createBoolArray2R();
simpleOperation(result, in, in, "/0", "/0");
@@ -203,7 +207,7 @@
* Tests result record.
*/
private void testMoveBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 5");
+ LOGGER.info(" - for boolean on simple JSON array of size 5");
final JsonArray in = createSimpleBoolArray5();
final JsonArray check = createSimpleBoolArray5R();
complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" },
@@ -219,7 +223,7 @@
* Tests result record.
*/
private void testMoveObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createSimpleObjectObject();
final JsonObject check = createSimpleObjectMoveObject();
simpleOperation(result, in, check, OBJ_PATH, DEF_PATH);
@@ -232,7 +236,7 @@
* Tests result record.
*/
private void testMoveObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray in = createObjectArray2();
final JsonArray check = createObjectArray2R();
simpleOperation(result, in, in, "/0", "/0");
@@ -248,7 +252,7 @@
* Tests result record.
*/
private void testMoveObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 5");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 5");
final JsonArray in = createSimpleObjectArray5();
final JsonArray check = createSimpleObjectArray5R();
complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" },
@@ -265,7 +269,7 @@
* Tests result record.
*/
private void testMoveStringOnCompoundObject(final TestResult result) {
- System.out.println(" - for String on compound JSON object");
+ LOGGER.info(" - for String on compound JSON object");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectMoveValue();
simpleOperation(result, in, check, DEF_PATH, DEF_OBJ_PATH + DEF_PATH);
@@ -280,7 +284,7 @@
* The "from" location MUST exist for the operation to be successful.
*/
private void testMoveOfNonExistingLocationInObject(final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -303,7 +307,7 @@
* The "from" location MUST exist for the operation to be successful.
*/
private void testMoveOfNonExistingLocationInArray(final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2() };
@@ -341,7 +345,7 @@
* REMOVE and ADD operations MUST produce the same result.
*/
private void testMoveVsRemoveAddOnSelfContainedPath(final TestResult result) {
- System.out.println(" - for moving JsonObject under itself");
+ LOGGER.info(" - for moving JsonObject under itself");
final JsonObject in = createCompoundObject();
final String targetPath = DEF_OBJ_PATH + DEF_PATH;
final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH);
@@ -357,19 +361,19 @@
try {
remAddOut = remAddPatch.apply(in);
- System.out.println(" REMOVE and ADD passed");
+ LOGGER.info(" REMOVE and ADD passed");
} catch (JsonException e) {
remAddOut = null;
- System.out.println(" REMOVE and ADD failed: " + e.getMessage());
+ LOGGER.info(" REMOVE and ADD failed: " + e.getMessage());
}
// Check MOVE second
JsonObject moveOut;
try {
moveOut = movePatch.apply(in);
- System.out.println(" MOVE passed");
+ LOGGER.info(" MOVE passed");
} catch (JsonException e) {
moveOut = null;
- System.out.println(" MOVE failed: " + e.getMessage());
+ LOGGER.info(" MOVE failed: " + e.getMessage());
}
// Results evaluation
if (remAddOut != null) {
@@ -420,7 +424,7 @@
protected JsonPatchBuilder createOperationBuilder(final String path,
final Object value) {
if (value instanceof String) {
- // System.out.println(" MOVE "+path+" -> "+(String)value);
+ // LOGGER.info(" MOVE "+path+" -> "+(String)value);
return Json.createPatchBuilder().move((String) value, path);
} else {
throw new IllegalArgumentException(
@@ -444,7 +448,7 @@
protected JsonPatchBuilder updateOperationBuilder(
final JsonPatchBuilder builder, final String path, final Object value) {
if (value instanceof String) {
- // System.out.println(" MOVE "+path+" -> "+(String)value);
+ // LOGGER.info(" MOVE "+path+" -> "+(String)value);
return builder.move((String) value, path);
} else {
throw new IllegalArgumentException(
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationRemove.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationRemove.java
index a19b362..90bc5b3 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationRemove.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,8 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonPatchBuilder;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -34,6 +36,8 @@
*/
public class PatchOperationRemove extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationRemove.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "REMOVE";
@@ -51,7 +55,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 remove operation");
- System.out.println("Testing RFC 6902 remove operation:");
+ LOGGER.info("Testing RFC 6902 remove operation:");
testRemoveStringOnEmptyObject(result);
testRemoveStringOnEmptyArray(result);
testRemoveStringOnSimpleObject(result);
@@ -85,7 +89,7 @@
* Tests result record.
*/
private void testRemoveStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String to produce empty JSON object");
+ LOGGER.info(" - for String to produce empty JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createEmptyObject();
simpleOperation(result, in, check, STR_PATH, null);
@@ -99,7 +103,7 @@
* Tests result record.
*/
private void testRemoveStringOnEmptyArray(final TestResult result) {
- System.out.println(" - for String to produce empty JSON array");
+ LOGGER.info(" - for String to produce empty JSON array");
final JsonArray in = createEmptyArrayWithStr();
final JsonArray check = createEmptyArray();
simpleOperation(result, in, check, "/0", null);
@@ -112,7 +116,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectWithStr();
final JsonObject check = createSimpleObject();
simpleOperation(result, in, check, STR_PATH, null);
@@ -128,7 +132,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray inBefore = createSimpleStringArrayWithStrBefore();
final JsonArray inAfter = createSimpleStringArrayWithStrAfter();
final JsonArray check = createStringArray1();
@@ -150,7 +154,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 5");
+ LOGGER.info(" - for String on simple JSON array of size 5");
final JsonArray in = createSimpleStringArray5();
final JsonArray check = createStringArray2();
complexOperation(result, in, check, new String[] { "/4", "/2", "/0" });
@@ -164,7 +168,7 @@
* Tests result record.
*/
private void testRemoveIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int to produce empty JSON object");
+ LOGGER.info(" - for int to produce empty JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createEmptyObject();
simpleOperation(result, in, check, INT_PATH, null);
@@ -178,7 +182,7 @@
* Tests result record.
*/
private void testRemoveIntOnEmptyArray(final TestResult result) {
- System.out.println(" - for int to produce empty JSON array");
+ LOGGER.info(" - for int to produce empty JSON array");
final JsonArray in = createEmptyArrayWithInt();
final JsonArray check = createEmptyArray();
simpleOperation(result, in, check, "/0", null);
@@ -191,7 +195,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectWithInt();
final JsonObject check = createSimpleObject();
simpleOperation(result, in, check, INT_PATH, null);
@@ -207,7 +211,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray inBefore = createSimpleIntArrayWithIntBefore();
final JsonArray inAfter = createSimpleIntArrayWithIntAfter();
final JsonArray check = createIntArray1();
@@ -229,7 +233,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 5");
+ LOGGER.info(" - for int on simple JSON array of size 5");
final JsonArray in = createSimpleIntArray5();
final JsonArray check = createIntArray2();
complexOperation(result, in, check, new String[] { "/4", "/2", "/0" });
@@ -244,7 +248,7 @@
* Tests result record.
*/
private void testRemoveBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean to produce empty JSON object");
+ LOGGER.info(" - for boolean to produce empty JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createEmptyObject();
simpleOperation(result, in, check, BOOL_PATH, null);
@@ -258,7 +262,7 @@
* Tests result record.
*/
private void testRemoveBoolOnEmptyArray(final TestResult result) {
- System.out.println(" - for boolean to produce empty JSON array");
+ LOGGER.info(" - for boolean to produce empty JSON array");
final JsonArray in = createEmptyArrayWithBool();
final JsonArray check = createEmptyArray();
simpleOperation(result, in, check, "/0", null);
@@ -271,7 +275,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectWithBool();
final JsonObject check = createSimpleObject();
simpleOperation(result, in, check, BOOL_PATH, null);
@@ -287,7 +291,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray inBefore = createSimpleBoolArrayWithBoolBefore();
final JsonArray inAfter = createSimpleBoolArrayWithBoolAfter();
final JsonArray check = createBoolArray1();
@@ -309,7 +313,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 5");
+ LOGGER.info(" - for boolean on simple JSON array of size 5");
final JsonArray in = createSimpleBoolArray5();
final JsonArray check = createBoolArray2();
complexOperation(result, in, check, new String[] { "/4", "/2", "/0" });
@@ -324,7 +328,7 @@
* Tests result record.
*/
private void testRemoveObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject to produce empty JSON object");
+ LOGGER.info(" - for JsonObject to produce empty JSON object");
final JsonObject in = createSimpleObjectObject();
final JsonObject check = createEmptyObject();
simpleOperation(result, in, check, OBJ_PATH, null);
@@ -338,7 +342,7 @@
* Tests result record.
*/
private void testRemoveObjectOnEmptyArray(final TestResult result) {
- System.out.println(" - for JsonObject to produce empty JSON array");
+ LOGGER.info(" - for JsonObject to produce empty JSON array");
final JsonArray in = createEmptyArrayWithObject();
final JsonArray check = createEmptyArray();
simpleOperation(result, in, check, "/0", null);
@@ -351,7 +355,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObjectWithObject();
final JsonObject check = createCompoundObject();
simpleOperation(result, in, check, OBJ_PATH, null);
@@ -367,7 +371,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray inBefore = createSimpleObjectArrayWithObjectBefore();
final JsonArray inAfter = createSimpleObjectArrayWithObjectAfter();
final JsonArray check = createObjectArray1();
@@ -389,7 +393,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 5");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 5");
final JsonArray in = createSimpleObjectArray5();
final JsonArray check = createObjectArray2();
complexOperation(result, in, check, new String[] { "/4", "/2", "/0" });
@@ -406,7 +410,7 @@
*/
private void testRemoveFromNonExistingLocationInObject(
final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -428,7 +432,7 @@
*/
private void testRemoveFromNonExistingLocationInArray(
final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2()
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationReplace.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationReplace.java
index 66190c5..afec8dd 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationReplace.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationReplace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPatchBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -37,6 +39,8 @@
*/
public class PatchOperationReplace extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationReplace.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "REPLACE";
@@ -54,7 +58,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 replace operation");
- System.out.println("Testing RFC 6902 replace operation:");
+ LOGGER.info("Testing RFC 6902 replace operation:");
testReplaceStringOnSimpleObject(result);
testReplaceStringOnSimpleArray(result);
testReplaceStringOnSimpleArray2(result);
@@ -79,7 +83,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createSimpleObjectReplaceStr();
simpleOperation(result, in, check, STR_PATH, STR_VALUE2);
@@ -92,7 +96,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 1");
+ LOGGER.info(" - for String on simple JSON array of size 1");
final JsonArray in = createStringArray1();
final JsonArray check = createSimpleStringArrayReplaceStr();
simpleOperation(result, in, check, "/0", STR_VALUE);
@@ -111,7 +115,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 5");
+ LOGGER.info(" - for String on simple JSON array of size 5");
final JsonArray in = createSimpleStringArray5();
final JsonArray check = createSimpleStringArray5R();
complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" },
@@ -127,7 +131,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createSimpleObjectReplaceInt();
simpleOperation(result, in, check, INT_PATH, INT_VALUE2);
@@ -140,7 +144,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 1");
+ LOGGER.info(" - for int on simple JSON array of size 1");
final JsonArray in = createIntArray1();
final JsonArray check = createSimpleIntArrayReplaceInt();
simpleOperation(result, in, check, "/0", INT_VALUE);
@@ -159,7 +163,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 5");
+ LOGGER.info(" - for int on simple JSON array of size 5");
final JsonArray in = createSimpleIntArray5();
final JsonArray check = createSimpleIntArray5R();
complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" },
@@ -175,7 +179,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createSimpleObjectReplaceBool();
simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE2);
@@ -188,7 +192,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 1");
+ LOGGER.info(" - for boolean on simple JSON array of size 1");
final JsonArray in = createBoolArray1();
final JsonArray check = createSimpleBoolArrayReplaceBool();
simpleOperation(result, in, check, "/0", BOOL_FALSE);
@@ -207,7 +211,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 5");
+ LOGGER.info(" - for boolean on simple JSON array of size 5");
final JsonArray in = createSimpleBoolArray5();
final JsonArray check = createSimpleBoolArray5R();
complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" },
@@ -224,7 +228,7 @@
* Tests result record.
*/
private void testReplaceObjectOnCompoundObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObjectWithObject();
final JsonObject check = createCompoundObjectReplaceObject();
simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE2);
@@ -237,7 +241,7 @@
* Tests result record.
*/
private void testReplaceObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 1");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 1");
final JsonArray in = createObjectArray1();
final JsonArray check = createSimpleObjectArrayReplaceObject();
simpleOperation(result, in, check, "/0", OBJ_VALUE);
@@ -257,7 +261,7 @@
* Tests result record.
*/
private void testReplaceObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 5");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 5");
final JsonArray in = createSimpleObjectArray5();
final JsonArray check = createSimpleObjectArray5R();
complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" },
@@ -278,7 +282,7 @@
*/
private void testReplaceOfNonExistingLocationInObject(
final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -302,7 +306,7 @@
*/
private void testReplaceOfNonExistingLocationInArray(
final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2() };
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationTest.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationTest.java
index 14ac33b..3bbd346 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationTest.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchOperationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPatchBuilder;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
// $Id$
@@ -37,6 +39,8 @@
*/
public class PatchOperationTest extends CommonOperation {
+ private static final Logger LOGGER = Logger.getLogger(PatchOperationTest.class.getName());
+
/** Tested operation name. */
private final String OPERATION = "TEST";
@@ -54,7 +58,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6902 test operation");
- System.out.println("Testing RFC 6902 test operation:");
+ LOGGER.info("Testing RFC 6902 test operation:");
testOnEmptyObject(result);
testOnEmptyArray(result);
testOnSimpleObject(result);
@@ -72,7 +76,7 @@
* Tests result record.
*/
private void testOnEmptyObject(final TestResult result) {
- System.out.println(" - on empty JSON object");
+ LOGGER.info(" - on empty JSON object");
final JsonObject in = createEmptyObject();
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
OBJ_PATH };
@@ -97,7 +101,7 @@
* Tests result record.
*/
private void testOnEmptyArray(final TestResult result) {
- System.out.println(" - on empty JSON array");
+ LOGGER.info(" - on empty JSON array");
final JsonArray in = createEmptyArray();
final String[] paths = new String[] { "/-1", "/0", "/1", "/2", "/3", "/4",
"/5", "/-" };
@@ -122,7 +126,7 @@
* Tests result record.
*/
private void testOnSimpleObject(final TestResult result) {
- System.out.println(" - on simple JSON object");
+ LOGGER.info(" - on simple JSON object");
final JsonObject[] in = new JsonObject[] { createSimpleObjectStr(),
createSimpleObjectInt(), createSimpleObjectBool(),
createSimpleObjectObject() };
@@ -157,7 +161,7 @@
* Tests result record.
*/
private void testOnSimpleStringArray(final TestResult result) {
- System.out.println(" - on simple JSON String array of size 5");
+ LOGGER.info(" - on simple JSON String array of size 5");
final JsonArray in = createSimpleStringArray5();
final String[] indexes = new String[] { "/-1", "/-", STR_PATH };
final String[] values = new String[] { STR_VALUE_1, STR_VALUE_2,
@@ -195,7 +199,7 @@
* Tests result record.
*/
private void testOnSimpleIntArray(final TestResult result) {
- System.out.println(" - on simple JSON int array of size 5");
+ LOGGER.info(" - on simple JSON int array of size 5");
final JsonArray in = createSimpleIntArray5();
final String[] indexes = new String[] { "/-1", "/-", INT_PATH };
final int[] values = new int[] { INT_VALUE_1, INT_VALUE_2, INT_VALUE_3,
@@ -233,7 +237,7 @@
* Tests result record.
*/
private void testOnSimpleBoolArray(final TestResult result) {
- System.out.println(" - on simple JSON boolean array of size 2");
+ LOGGER.info(" - on simple JSON boolean array of size 2");
final JsonArray in = createBoolArray2();
final String[] indexes = new String[] { "/-1", "/-", BOOL_PATH };
final boolean[] values = new boolean[] { BOOL_TRUE, BOOL_FALSE };
@@ -270,7 +274,7 @@
* Tests result record.
*/
private void testOnSimpleObjectArray(final TestResult result) {
- System.out.println(" - on simple JSON JsonObject array of size 5");
+ LOGGER.info(" - on simple JSON JsonObject array of size 5");
final JsonArray in = createSimpleObjectArray5();
final String[] indexes = new String[] { "/-1", "/-", OBJ_PATH };
final JsonObject[] values = new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2,
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchTests.java
index 1c66c45..bf2e551 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/patchtests/PatchTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,33 +16,23 @@
package jakarta.jsonp.tck.api.patchtests;
+import jakarta.json.JsonPatch;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.jsonp.tck.lib.harness.Fault;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
// $Id$
/*
* RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.<br>
* {@see <a href="https://tools.ietf.org/html/rfc6902">RFC 6902</a>}.
*/
-@RunWith(Arquillian.class)
public class PatchTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, PatchTests.class.getPackage().getName());
- }
/**
* Test {@link JsonPatch} factory methods added in JSON-P 1.1.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonCreatePatch11Test
@@ -54,7 +44,7 @@
* @test_Strategy: Tests JsonPatch API factory methods added in JSON-P 1.1.
*/
@Test
- public void jsonCreatePatch11Test() throws Fault {
+ public void jsonCreatePatch11Test() {
PatchCreate createTest = new PatchCreate();
final TestResult result = createTest.test();
result.eval();
@@ -63,7 +53,7 @@
/**
* Test {@code JsonPatch.Operation} enumeration added in JSON-P 1.1.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonJsonPatchOperation11Test
@@ -74,7 +64,7 @@
* @test_Strategy: Tests JsonPatch.Operation enumeration added in JSON-P 1.1.
*/
@Test
- public void jsonJsonPatchOperation11Test() throws Fault {
+ public void jsonJsonPatchOperation11Test() {
PatchOperationEnum enumTest = new PatchOperationEnum();
final TestResult result = enumTest.test();
result.eval();
@@ -85,7 +75,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.1">RFC 6902:
* 4.1. add</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchAddTest
@@ -95,7 +85,7 @@
* @test_Strategy: Test API response on various usages of add operation.
*/
@Test
- public void jsonPatchAddTest() throws Fault {
+ public void jsonPatchAddTest() {
PatchOperationAdd addTest = new PatchOperationAdd();
final TestResult result = addTest.test();
result.eval();
@@ -106,7 +96,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.2">RFC 6902:
* 4.2. remove</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchRemoveTest
@@ -115,7 +105,7 @@
* @test_Strategy: Test API response on various usages of remove operation.
*/
@Test
- public void jsonPatchRemoveTest() throws Fault {
+ public void jsonPatchRemoveTest() {
PatchOperationRemove removeTest = new PatchOperationRemove();
final TestResult result = removeTest.test();
result.eval();
@@ -126,7 +116,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.3">RFC 6902:
* 4.3. replace</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchReplaceTest
@@ -136,7 +126,7 @@
* @test_Strategy: Test API response on various usages of replace operation.
*/
@Test
- public void jsonPatchReplaceTest() throws Fault {
+ public void jsonPatchReplaceTest() {
PatchOperationReplace replaceTest = new PatchOperationReplace();
final TestResult result = replaceTest.test();
result.eval();
@@ -147,7 +137,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.4">RFC 6902:
* 4.4. move</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchMoveTest
@@ -156,7 +146,7 @@
* @test_Strategy: Test API response on various usages of move operation.
*/
@Test
- public void jsonPatchMoveTest() throws Fault {
+ public void jsonPatchMoveTest() {
PatchOperationMove moveTest = new PatchOperationMove();
final TestResult result = moveTest.test();
result.eval();
@@ -167,7 +157,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.5">RFC 6902:
* 4.5. copy</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchCopyTest
@@ -176,7 +166,7 @@
* @test_Strategy: Test API response on various usages of copy operation.
*/
@Test
- public void jsonPatchCopyTest() throws Fault {
+ public void jsonPatchCopyTest() {
PatchOperationCopy copyTest = new PatchOperationCopy();
final TestResult result = copyTest.test();
result.eval();
@@ -187,7 +177,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6902#section-4.6">RFC 6902:
* 4.6. test</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPatchTestTest
@@ -197,7 +187,7 @@
* @test_Strategy: Test API response on various usages of test operation.
*/
@Test
- public void jsonPatchTestTest() throws Fault {
+ public void jsonPatchTestTest() {
PatchOperationTest testTest = new PatchOperationTest();
final TestResult result = testTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerAdd.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerAdd.java
index 7b0d9d4..ed4f8df 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerAdd.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerAdd.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPointer;
import jakarta.json.JsonStructure;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -35,6 +37,8 @@
*/
public class PointerAdd {
+ private static final Logger LOGGER = Logger.getLogger(PointerAdd.class.getName());
+
/**
* Creates an instance of RFC 6901 pointer instance usage for RFC 6902 add
* operation tests.
@@ -52,7 +56,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 6901 pointer usage for RFC 6902 add operation");
- System.out.println("Testing RFC 6901 pointer usage for RFC 6902 add operation");
+ LOGGER.info("Testing RFC 6901 pointer usage for RFC 6902 add operation");
testAddStringOnEmptyObject(result);
testAddStringOnEmptyArray(result);
testAddStringOnSimpleObject(result);
@@ -87,7 +91,7 @@
* Tests result record.
*/
private void testAddStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String on empty JSON object");
+ LOGGER.info(" - for String on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectStr();
final JsonPointer ptr = Json.createPointer(STR_PATH);
@@ -106,7 +110,7 @@
* Tests result record.
*/
private void testAddStringOnEmptyArray(final TestResult result) {
- System.out.println(" - for String on empty JSON array");
+ LOGGER.info(" - for String on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithStr();
final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"),
@@ -127,7 +131,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithStr();
final JsonPointer ptr = Json.createPointer(STR_PATH);
@@ -148,7 +152,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 1");
+ LOGGER.info(" - for String on simple JSON array of size 1");
final JsonArray in = createStringArray1();
final JsonArray checkBefore = createSimpleStringArrayWithStrBefore();
final JsonArray checkAfter = createSimpleStringArrayWithStrAfter();
@@ -183,7 +187,7 @@
* Tests result record.
*/
private void testAddStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray in = createStringArray2();
final JsonArray check = createSimpleStringArray5();
verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -203,7 +207,7 @@
* Tests result record.
*/
private void testAddIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int on empty JSON object");
+ LOGGER.info(" - for int on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectInt();
final JsonPointer ptr = Json.createPointer(INT_PATH);
@@ -222,7 +226,7 @@
* Tests result record.
*/
private void testAddIntOnEmptyArray(final TestResult result) {
- System.out.println(" - for int on empty JSON array");
+ LOGGER.info(" - for int on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithInt();
final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"),
@@ -243,7 +247,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithInt();
final JsonPointer ptr = Json.createPointer(INT_PATH);
@@ -264,7 +268,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 1");
+ LOGGER.info(" - for int on simple JSON array of size 1");
final JsonArray in = createIntArray1();
final JsonArray checkBefore = createSimpleIntArrayWithIntBefore();
final JsonArray checkAfter = createSimpleIntArrayWithIntAfter();
@@ -299,7 +303,7 @@
* Tests result record.
*/
private void testAddIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray in = createIntArray2();
final JsonArray check = createSimpleIntArray5();
verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -319,7 +323,7 @@
* Tests result record.
*/
private void testAddBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean on empty JSON object");
+ LOGGER.info(" - for boolean on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectBool();
final JsonPointer ptr = Json.createPointer(BOOL_PATH);
@@ -338,7 +342,7 @@
* Tests result record.
*/
private void testAddBoolOnEmptyArray(final TestResult result) {
- System.out.println(" - for boolean on empty JSON array");
+ LOGGER.info(" - for boolean on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithBool();
final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"),
@@ -359,7 +363,7 @@
* Tests result record.
*/
private void testAddBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObject();
final JsonObject check = createSimpleObjectWithBool();
final JsonPointer ptr = Json.createPointer(BOOL_PATH);
@@ -380,7 +384,7 @@
* Tests result record.
*/
private void testAddBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 1");
+ LOGGER.info(" - for boolean on simple JSON array of size 1");
final JsonArray in = createBoolArray1();
final JsonArray checkBefore = createSimpleBoolArrayWithBoolBefore();
final JsonArray checkAfter = createSimpleBoolArrayWithBoolAfter();
@@ -415,7 +419,7 @@
* Tests result record.
*/
private void testAddBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray in = createBoolArray2();
final JsonArray check = createSimpleBoolArray5();
verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -435,7 +439,7 @@
* Tests result record.
*/
private void testAddObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject on empty JSON object");
+ LOGGER.info(" - for JsonObject on empty JSON object");
final JsonObject in = createEmptyObject();
final JsonObject check = createSimpleObjectObject();
final JsonPointer ptr = Json.createPointer(OBJ_PATH);
@@ -454,7 +458,7 @@
* Tests result record.
*/
private void testAddObjectOnEmptyArray(final TestResult result) {
- System.out.println(" - for JsonObject on empty JSON array");
+ LOGGER.info(" - for JsonObject on empty JSON array");
final JsonArray in = createEmptyArray();
final JsonArray check = createEmptyArrayWithObject();
final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"),
@@ -475,7 +479,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectWithObject();
final JsonPointer ptr = Json.createPointer(OBJ_PATH);
@@ -496,7 +500,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 1");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 1");
final JsonArray in = createObjectArray1();
final JsonArray checkBefore = createSimpleObjectArrayWithObjectBefore();
final JsonArray checkAfter = createSimpleObjectArrayWithObjectAfter();
@@ -531,7 +535,7 @@
* Tests result record.
*/
private void testAddObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray in = createObjectArray2();
final JsonArray check = createSimpleObjectArray5();
verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" },
@@ -560,7 +564,7 @@
* </ul>
*/
private void testAddArrayToReplaceObject(final TestResult result) {
- System.out.println(" - for JsonArray to replace JsonObject");
+ LOGGER.info(" - for JsonArray to replace JsonObject");
final JsonObject in = createCompoundObject();
final JsonObject check = createCompoundObjectWithObjectReplaced();
final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH);
@@ -585,7 +589,7 @@
* </ul>
*/
private void testAddArrayToReplaceDocument(final TestResult result) {
- System.out.println(" - for JsonArray to replace whole document");
+ LOGGER.info(" - for JsonArray to replace whole document");
final JsonObject in = createCompoundObject();
final JsonArray check = createSimpleStringArray5();
final JsonPointer ptr = Json.createPointer("");
@@ -615,7 +619,7 @@
* </ul>
*/
private void testAddStringArrayToStringArray(final TestResult result) {
- System.out.println(" - for String array to be added to existing String array");
+ LOGGER.info(" - for String array to be added to existing String array");
final JsonArray in = createStringArray2();
final JsonArray check = createStringArray2WithStringArrayInTheMiddle();
final JsonArray arrayToAdd = createStringInnerArray2();
@@ -637,7 +641,7 @@
*
*/
private void testAddStringToNonExistingObject(final TestResult result) {
- System.out.println(" - for String to be added to non existing JsonObject");
+ LOGGER.info(" - for String to be added to non existing JsonObject");
final JsonObject in = createSimpleObject();
final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH + STR_PATH);
boolean exception = false;
@@ -645,7 +649,7 @@
ptr.add(in, Json.createValue(STR_VALUE));
} catch (JsonException e) {
exception = true;
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
if (!exception) {
result.fail("Pointer ADD operation",
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerRemove.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerRemove.java
index 3622a4e..68fc528 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerRemove.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,6 +23,8 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonPointer;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -34,6 +36,8 @@
*/
public class PointerRemove {
+ private static final Logger LOGGER = Logger.getLogger(PointerRemove.class.getName());
+
/**
* Creates an instance of RFC 6901 pointer instance usage for RFC 6902 remove
* operation tests.
@@ -51,7 +55,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 6901 pointer usage for RFC 6902 remove operation");
- System.out.println("Testing RFC 6901 pointer usage for RFC 6902 remove operation");
+ LOGGER.info("Testing RFC 6901 pointer usage for RFC 6902 remove operation");
testRemoveStringOnEmptyObject(result);
testRemoveStringOnEmptyArray(result);
testRemoveStringOnSimpleObject(result);
@@ -85,7 +89,7 @@
* Tests result record.
*/
private void testRemoveStringOnEmptyObject(final TestResult result) {
- System.out.println(" - for String to produce empty JSON object");
+ LOGGER.info(" - for String to produce empty JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createEmptyObject();
final JsonPointer ptr = Json.createPointer(STR_PATH);
@@ -104,7 +108,7 @@
* Tests result record.
*/
private void testRemoveStringOnEmptyArray(final TestResult result) {
- System.out.println(" - for String to produce empty JSON array");
+ LOGGER.info(" - for String to produce empty JSON array");
final JsonArray in = createEmptyArrayWithStr();
final JsonArray check = createEmptyArray();
final JsonPointer ptr = Json.createPointer("/0");
@@ -122,7 +126,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectWithStr();
final JsonObject check = createSimpleObject();
final JsonPointer ptr = Json.createPointer(STR_PATH);
@@ -143,7 +147,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 2");
+ LOGGER.info(" - for String on simple JSON array of size 2");
final JsonArray inBefore = createSimpleStringArrayWithStrBefore();
final JsonArray inAfter = createSimpleStringArrayWithStrAfter();
final JsonArray check = createStringArray1();
@@ -175,7 +179,7 @@
* Tests result record.
*/
private void testRemoveStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 5");
+ LOGGER.info(" - for String on simple JSON array of size 5");
final JsonArray in = createSimpleStringArray5();
final JsonArray check = createStringArray2();
verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" },
@@ -193,7 +197,7 @@
* Tests result record.
*/
private void testRemoveIntOnEmptyObject(final TestResult result) {
- System.out.println(" - for int to produce empty JSON object");
+ LOGGER.info(" - for int to produce empty JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createEmptyObject();
final JsonPointer ptr = Json.createPointer(INT_PATH);
@@ -212,7 +216,7 @@
* Tests result record.
*/
private void testRemoveIntOnEmptyArray(final TestResult result) {
- System.out.println(" - for int to produce empty JSON array");
+ LOGGER.info(" - for int to produce empty JSON array");
final JsonArray in = createEmptyArrayWithInt();
final JsonArray check = createEmptyArray();
final JsonPointer ptr = Json.createPointer("/0");
@@ -230,7 +234,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectWithInt();
final JsonObject check = createSimpleObject();
final JsonPointer ptr = Json.createPointer(INT_PATH);
@@ -251,7 +255,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 2");
+ LOGGER.info(" - for int on simple JSON array of size 2");
final JsonArray inBefore = createSimpleIntArrayWithIntBefore();
final JsonArray inAfter = createSimpleIntArrayWithIntAfter();
final JsonArray check = createIntArray1();
@@ -283,7 +287,7 @@
* Tests result record.
*/
private void testRemoveIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 5");
+ LOGGER.info(" - for int on simple JSON array of size 5");
final JsonArray in = createSimpleIntArray5();
final JsonArray check = createIntArray2();
verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" },
@@ -302,7 +306,7 @@
* Tests result record.
*/
private void testRemoveBoolOnEmptyObject(final TestResult result) {
- System.out.println(" - for boolean to produce empty JSON object");
+ LOGGER.info(" - for boolean to produce empty JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createEmptyObject();
final JsonPointer ptr = Json.createPointer(BOOL_PATH);
@@ -321,7 +325,7 @@
* Tests result record.
*/
private void testRemoveBoolOnEmptyArray(final TestResult result) {
- System.out.println(" - for boolean to produce empty JSON array");
+ LOGGER.info(" - for boolean to produce empty JSON array");
final JsonArray in = createEmptyArrayWithBool();
final JsonArray check = createEmptyArray();
final JsonPointer ptr = Json.createPointer("/0");
@@ -339,7 +343,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectWithBool();
final JsonObject check = createSimpleObject();
final JsonPointer ptr = Json.createPointer(BOOL_PATH);
@@ -360,7 +364,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 2");
+ LOGGER.info(" - for boolean on simple JSON array of size 2");
final JsonArray inBefore = createSimpleBoolArrayWithBoolBefore();
final JsonArray inAfter = createSimpleBoolArrayWithBoolAfter();
final JsonArray check = createBoolArray1();
@@ -392,7 +396,7 @@
* Tests result record.
*/
private void testRemoveBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 5");
+ LOGGER.info(" - for boolean on simple JSON array of size 5");
final JsonArray in = createSimpleBoolArray5();
final JsonArray check = createBoolArray2();
verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" },
@@ -411,7 +415,7 @@
* Tests result record.
*/
private void testRemoveObjectOnEmptyObject(final TestResult result) {
- System.out.println(" - for JsonObject to produce empty JSON object");
+ LOGGER.info(" - for JsonObject to produce empty JSON object");
final JsonObject in = createSimpleObjectObject();
final JsonObject check = createEmptyObject();
final JsonPointer ptr = Json.createPointer(OBJ_PATH);
@@ -430,7 +434,7 @@
* Tests result record.
*/
private void testRemoveObjectOnEmptyArray(final TestResult result) {
- System.out.println(" - for JsonObject to produce empty JSON array");
+ LOGGER.info(" - for JsonObject to produce empty JSON array");
final JsonArray in = createEmptyArrayWithObject();
final JsonArray check = createEmptyArray();
final JsonPointer ptr = Json.createPointer("/0");
@@ -448,7 +452,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObjectWithObject();
final JsonObject check = createCompoundObject();
final JsonPointer ptr = Json.createPointer(OBJ_PATH);
@@ -469,7 +473,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 2");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 2");
final JsonArray inBefore = createSimpleObjectArrayWithObjectBefore();
final JsonArray inAfter = createSimpleObjectArrayWithObjectAfter();
final JsonArray check = createObjectArray1();
@@ -501,7 +505,7 @@
* Tests result record.
*/
private void testRemoveObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 5");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 5");
final JsonArray in = createSimpleObjectArray5();
final JsonArray check = createObjectArray2();
verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" },
@@ -522,7 +526,7 @@
*/
private void testRemoveFromNonExistingLocationInObject(
final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -551,7 +555,7 @@
*/
private void testRemoveFromNonExistingLocationInArray(
final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2()
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerReplace.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerReplace.java
index 0d9708d..cd4391f 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerReplace.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerReplace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPointer;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -35,6 +37,8 @@
*/
public class PointerReplace {
+ private static final Logger LOGGER = Logger.getLogger(PointerReplace.class.getName());
+
/**
* Creates an instance of RFC 6901 pointer instance usage for RFC 6902 replace
* operation tests.
@@ -52,7 +56,7 @@
TestResult test() {
final TestResult result = new TestResult(
"RFC 6901 pointer usage for RFC 6902 replace operation");
- System.out.println(
+ LOGGER.info(
"Testing RFC 6901 pointer usage for RFC 6902 replace operation");
testReplaceStringOnSimpleObject(result);
testReplaceStringOnSimpleArray(result);
@@ -78,7 +82,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleObject(final TestResult result) {
- System.out.println(" - for String on simple JSON object");
+ LOGGER.info(" - for String on simple JSON object");
final JsonObject in = createSimpleObjectStr();
final JsonObject check = createSimpleObjectReplaceStr();
final JsonPointer ptr = Json.createPointer(STR_PATH);
@@ -96,7 +100,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleArray(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 1");
+ LOGGER.info(" - for String on simple JSON array of size 1");
final JsonArray in = createStringArray1();
final JsonArray check = createSimpleStringArrayReplaceStr();
final JsonPointer ptr = Json.createPointer("/0");
@@ -120,7 +124,7 @@
* Tests result record.
*/
private void testReplaceStringOnSimpleArray2(final TestResult result) {
- System.out.println(" - for String on simple JSON array of size 5");
+ LOGGER.info(" - for String on simple JSON array of size 5");
final JsonArray in = createSimpleStringArray5();
final JsonArray check = createSimpleStringArray5R();
verifyReplaceValues(result, in, check,
@@ -142,7 +146,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleObject(final TestResult result) {
- System.out.println(" - for int on simple JSON object");
+ LOGGER.info(" - for int on simple JSON object");
final JsonObject in = createSimpleObjectInt();
final JsonObject check = createSimpleObjectReplaceInt();
final JsonPointer ptr = Json.createPointer(INT_PATH);
@@ -160,7 +164,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleArray(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 1");
+ LOGGER.info(" - for int on simple JSON array of size 1");
final JsonArray in = createIntArray1();
final JsonArray check = createSimpleIntArrayReplaceInt();
final JsonPointer ptr = Json.createPointer("/0");
@@ -184,7 +188,7 @@
* Tests result record.
*/
private void testReplaceIntOnSimpleArray2(final TestResult result) {
- System.out.println(" - for int on simple JSON array of size 5");
+ LOGGER.info(" - for int on simple JSON array of size 5");
final JsonArray in = createSimpleIntArray5();
final JsonArray check = createSimpleIntArray5R();
verifyReplaceValues(result, in, check,
@@ -206,7 +210,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleObject(final TestResult result) {
- System.out.println(" - for boolean on simple JSON object");
+ LOGGER.info(" - for boolean on simple JSON object");
final JsonObject in = createSimpleObjectBool();
final JsonObject check = createSimpleObjectReplaceBool();
final JsonPointer ptr = Json.createPointer(BOOL_PATH);
@@ -224,7 +228,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleArray(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 1");
+ LOGGER.info(" - for boolean on simple JSON array of size 1");
final JsonArray in = createBoolArray1();
final JsonArray check = createSimpleBoolArrayReplaceBool();
final JsonPointer ptr = Json.createPointer("/0");
@@ -248,7 +252,7 @@
* Tests result record.
*/
private void testReplaceBoolOnSimpleArray2(final TestResult result) {
- System.out.println(" - for boolean on simple JSON array of size 5");
+ LOGGER.info(" - for boolean on simple JSON array of size 5");
final JsonArray in = createSimpleBoolArray5();
final JsonArray check = createSimpleBoolArray5R();
verifyReplaceValues(result, in, check,
@@ -271,7 +275,7 @@
* Tests result record.
*/
private void testReplaceObjectOnCompoundObject(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON object");
+ LOGGER.info(" - for JsonObject on simple JSON object");
final JsonObject in = createCompoundObjectWithObject();
final JsonObject check = createCompoundObjectReplaceObject();
final JsonPointer ptr = Json.createPointer(OBJ_PATH);
@@ -289,7 +293,7 @@
* Tests result record.
*/
private void testReplaceObjectOnSimpleArray(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 1");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 1");
final JsonArray in = createObjectArray1();
final JsonArray check = createSimpleObjectArrayReplaceObject();
final JsonPointer ptr = Json.createPointer("/0");
@@ -314,7 +318,7 @@
* Tests result record.
*/
private void testReplaceObjectOnSimpleArray2(final TestResult result) {
- System.out.println(" - for JsonObject on simple JSON array of size 5");
+ LOGGER.info(" - for JsonObject on simple JSON array of size 5");
final JsonArray in = createSimpleObjectArray5();
final JsonArray check = createSimpleObjectArray5R();
verifyReplaceValues(result, in, check,
@@ -339,7 +343,7 @@
*/
private void testReplaceOfNonExistingLocationInObject(
final TestResult result) {
- System.out.println(" - for non existing location in JsonObject");
+ LOGGER.info(" - for non existing location in JsonObject");
final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(),
createSimpleObject(), createCompoundObject() };
final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH,
@@ -370,7 +374,7 @@
*/
private void testReplaceOfNonExistingLocationInArray(
final TestResult result) {
- System.out.println(" - for non existing location in JsonArray");
+ LOGGER.info(" - for non existing location in JsonArray");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray1(), createIntArray2(), createSimpleBoolArray5(),
createObjectArray2()
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerResolve.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerResolve.java
index 130df0f..c82d4fa 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerResolve.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerResolve.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,6 +24,8 @@
import jakarta.json.JsonPointer;
import jakarta.json.JsonValue;
+import java.util.logging.Logger;
+
import static jakarta.jsonp.tck.api.common.JsonAssert.*;
import static jakarta.jsonp.tck.api.common.PointerRFCObject.*;
import static jakarta.jsonp.tck.api.common.SimpleValues.*;
@@ -35,6 +37,8 @@
*/
public class PointerResolve {
+ private static final Logger LOGGER = Logger.getLogger(PointerResolve.class.getName());
+
/**
* Creates an instance of RFC 6901 JSON Pointer resolver tests.
*/
@@ -49,7 +53,7 @@
*/
TestResult test() {
final TestResult result = new TestResult("RFC 6901 pointer resolving");
- System.out.println("Testing RFC 6901 pointer resolving");
+ LOGGER.info("Testing RFC 6901 pointer resolving");
testResolveWholeDocument(result);
testResolveEmptyName(result);
testResolveSimpleArray(result);
@@ -79,7 +83,7 @@
* Tests result record.
*/
private void testResolveWholeDocument(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_KEY_WHOLE + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_KEY_WHOLE + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = in;
final JsonPointer ptr = Json.createPointer(RFC_KEY_WHOLE);
@@ -102,7 +106,7 @@
* Tests result record.
*/
private void testResolveEmptyName(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR2 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR2 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL2);
final JsonPointer ptr = Json.createPointer(RFC_PTR2);
@@ -125,7 +129,7 @@
* Tests result record.
*/
private void testResolveSimpleArray(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR1 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR1 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = RFC_VAL1;
final JsonPointer ptr = Json.createPointer(RFC_PTR1);
@@ -153,7 +157,7 @@
final String[] itemVals = new String[] { RFC_VAL1_ITEM1, RFC_VAL1_ITEM2 };
final JsonObject in = createRFC6901Object();
for (int i = 0; i < itemPtrs.length; i++) {
- System.out.println(" - resolving of \"" + itemPtrs[i] + "\" pointer");
+ LOGGER.info(" - resolving of \"" + itemPtrs[i] + "\" pointer");
final JsonValue check = Json.createValue(itemVals[i]);
final JsonPointer ptr = Json.createPointer(itemPtrs[i]);
try {
@@ -177,7 +181,7 @@
* Tests result record.
*/
private void testResolvePathWithEncodedSlash(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR3_ENC + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR3_ENC + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL3);
final JsonPointer ptr = Json.createPointer(RFC_PTR3_ENC);
@@ -188,7 +192,7 @@
"GET operation failed for \"" + RFC_PTR3_ENC + "\" path");
}
} catch (JsonException e) {
- System.out.println(" ! Exception: " + e.getMessage());
+ LOGGER.info(" ! Exception: " + e.getMessage());
result.fail("GET \"" + RFC_PTR3_ENC + "\"",
"GET operation exception: " + e.getMessage());
}
@@ -203,7 +207,7 @@
* Tests result record.
*/
private void testResolvePathWithSlash(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR3 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR3 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonPointer ptr = Json.createPointer(RFC_PTR3);
try {
@@ -211,7 +215,7 @@
result.fail("GET \"" + RFC_PTR3 + "\"",
"GET operation succeeded for \"" + RFC_PTR3 + "\" path");
} catch (JsonException e) {
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
}
@@ -222,7 +226,7 @@
* Tests result record.
*/
private void testResolvePathWithPercent(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR4 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR4 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL4);
final JsonPointer ptr = Json.createPointer(RFC_PTR4);
@@ -245,7 +249,7 @@
* Tests result record.
*/
private void testResolvePathWithCaret(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR5 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR5 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL5);
final JsonPointer ptr = Json.createPointer(RFC_PTR5);
@@ -268,7 +272,7 @@
* Tests result record.
*/
private void testResolvePathWithVerticalBar(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR6 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR6 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL6);
final JsonPointer ptr = Json.createPointer(RFC_PTR6);
@@ -291,7 +295,7 @@
* Tests result record.
*/
private void testResolvePathWithBackSlash(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR7 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR7 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL7);
final JsonPointer ptr = Json.createPointer(RFC_PTR7);
@@ -314,7 +318,7 @@
* Tests result record.
*/
private void testResolvePathWithDoubleQuotes(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR8 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR8 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL8);
final JsonPointer ptr = Json.createPointer(RFC_PTR8);
@@ -337,7 +341,7 @@
* Tests result record.
*/
private void testResolvePathWithSpace(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR9 + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR9 + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL9);
final JsonPointer ptr = Json.createPointer(RFC_PTR9);
@@ -369,7 +373,7 @@
* Tests result record.
*/
private void testResolvePathWithTilde(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)");
+ LOGGER.info(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL10);
final JsonPointer ptr = Json.createPointer(RFC_PTR10);
@@ -378,15 +382,15 @@
final JsonValue out = ptr.getValue(in);
if (!assertEquals(out, check)) {
noError = false;
- System.out.println(" - Pointer \"" + RFC_KEY10
+ LOGGER.info(" - Pointer \"" + RFC_KEY10
+ "\" did not return expected value");
}
} catch (JsonException e) {
noError = false;
- System.out.println(" - Expected exception: " + e.getMessage());
+ LOGGER.info(" - Expected exception: " + e.getMessage());
}
if (noError) {
- System.out.println(
+ LOGGER.info(
" - Pointer resolving accepts '~' outside escape sequence");
}
}
@@ -399,7 +403,7 @@
* Tests result record.
*/
private void testResolvePathWithEncodedTilde(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_KEY10_ENC + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_KEY10_ENC + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL10);
final JsonPointer ptr = Json.createPointer(RFC_KEY10_ENC);
@@ -427,7 +431,7 @@
* Tests result record.
*/
private void testResolvePathWithEncodedTildeOne(final TestResult result) {
- System.out.println(" - resolving of \"" + RFC_PTR11_ENC + "\" pointer");
+ LOGGER.info(" - resolving of \"" + RFC_PTR11_ENC + "\" pointer");
final JsonObject in = createRFC6901Object();
final JsonValue check = Json.createValue(RFC_VAL11);
final JsonPointer ptr = Json.createPointer(RFC_PTR11_ENC);
@@ -457,7 +461,7 @@
* </ul>
*/
private void testResolveValidNumericIndexInArray(final TestResult result) {
- System.out.println(
+ LOGGER.info(
" - resolving of pointer containing existing numeric array index");
final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(),
createSimpleIntArray5(), createSimpleBoolArray5(),
@@ -511,7 +515,7 @@
* character is to be handled, if it is to be useful.
*/
private void testResolveMemberAfterLastInArray(final TestResult result) {
- System.out.println(" - resolving of array \"/-\" pointer");
+ LOGGER.info(" - resolving of array \"/-\" pointer");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray(), createSimpleIntArray5(), createBoolArray2(),
createSimpleObjectArray5() };
@@ -524,7 +528,7 @@
final JsonValue out = ptr.getValue(arraysIn[i]);
result.fail("GET \"/-\"", "GET operation succeeded for \"/-\" key");
} catch (JsonException e) {
- System.out.println(" - Expected exception for \"/-\" path in "
+ LOGGER.info(" - Expected exception for \"/-\" path in "
+ typeNames[i] + " array: " + e.getMessage());
}
}
@@ -544,7 +548,7 @@
*/
private void testResolveNumericIndexWithLeadingZeroInArray(
final TestResult result) {
- System.out.println(
+ LOGGER.info(
" - resolving of pointer containing numeric array index with leading '0' (optional)");
final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(),
createSimpleIntArray5(), createSimpleBoolArray5(),
@@ -559,7 +563,7 @@
final JsonPointer ptr = Json.createPointer(path);
try {
final JsonValue out = ptr.getValue(arraysIn[i]);
- System.out.println(" ! GET operation succeeded for \"" + path
+ LOGGER.info(" ! GET operation succeeded for \"" + path
+ "\" path on " + typeNames[i] + " array");
// result.fail("GET \""+path+"\"",
// "GET operation succeeded for \""+path+"\" key on "+typeNames[i]+"
@@ -582,7 +586,7 @@
* document ({@code ""}) which must return the whole array.
*/
private void testResolvenonNumericIndexInArray(final TestResult result) {
- System.out.println(" - resolving of pointer containing non numeric array index");
+ LOGGER.info(" - resolving of pointer containing non numeric array index");
final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(),
createStringArray(), createSimpleIntArray5(), createBoolArray2(),
createSimpleObjectArray5() };
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerTests.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerTests.java
index 571fe47..7013aa0 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerTests.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/pointertests/PointerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,14 +17,8 @@
package jakarta.jsonp.tck.api.pointertests;
import jakarta.jsonp.tck.api.common.TestResult;
-import jakarta.jsonp.tck.lib.harness.Fault;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
// $Id$
/**
@@ -33,14 +27,8 @@
* JSON-P API defines {@link jakarta.json.JsonPointer} interface to work with RFC
* 6901 JSON Pointer.
*/
-@RunWith(Arquillian.class)
public class PointerTests {
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addPackages(true, PointerTests.class.getPackage().getName());
- }
/**
* Test JSON-P API response on pointer resolving.<br>
* Checks set of JSON pointers from sample object of RFC 6901.
@@ -49,7 +37,7 @@
* {@see <a href="https://tools.ietf.org/html/rfc6901#section-5">RFC 6901: 5.
* JSON String Representation</a>}.
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPointerResolveTest
@@ -59,7 +47,7 @@
* @test_Strategy: Test API response on various JSON pointer values.
*/
@Test
- public void jsonPointerResolveTest() throws Fault {
+ public void jsonPointerResolveTest() {
PointerResolve resolveTest = new PointerResolve();
final TestResult result = resolveTest.test();
result.eval();
@@ -71,7 +59,7 @@
* 4.1. add</a>} operation using RFC 6901 pointer instance.<br>
* Checks set of simple JSON values.<br>
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPointerAddOperationTest
@@ -81,7 +69,7 @@
* @test_Strategy: Test API response on various JSON pointer values.
*/
@Test
- public void jsonPointerAddOperationTest() throws Fault {
+ public void jsonPointerAddOperationTest() {
PointerAdd addTest = new PointerAdd();
final TestResult result = addTest.test();
result.eval();
@@ -93,7 +81,7 @@
* 4.2. remove</a>} operation using RFC 6901 pointer instance.<br>
* Checks set of simple JSON values.<br>
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPointerRemoveOperationTest
@@ -101,7 +89,7 @@
* @test_Strategy: Test API response on various JSON pointer values.
*/
@Test
- public void jsonPointerRemoveOperationTest() throws Fault {
+ public void jsonPointerRemoveOperationTest() {
PointerRemove removeTest = new PointerRemove();
final TestResult result = removeTest.test();
result.eval();
@@ -113,7 +101,7 @@
* 4.3. replace</a>} operation using RFC 6901 pointer instance.<br>
* Checks set of simple JSON values.<br>
*
- * @throws Fault
+ * @throws AssertionFailedError
* when this test failed.
*
* @testName: jsonPointerReplaceOperationTest
@@ -123,7 +111,7 @@
* @test_Strategy: Test API response on various JSON pointer values.
*/
@Test
- public void jsonPointerReplaceOperationTest() throws Fault {
+ public void jsonPointerReplaceOperationTest() {
PointerReplace replaceTest = new PointerReplace();
final TestResult result = replaceTest.test();
result.eval();
diff --git a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/provider/JsonProviderTest.java b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/provider/JsonProviderTest.java
index fb584c6..09cc300 100644
--- a/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/provider/JsonProviderTest.java
+++ b/tck/tck-tests/src/main/java/jakarta/jsonp/tck/api/provider/JsonProviderTest.java
@@ -16,16 +16,12 @@
package jakarta.jsonp.tck.api.provider;
-import static org.junit.Assert.assertEquals;
-
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.util.Map;
-import org.junit.Test;
-
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonObjectBuilder;
@@ -38,6 +34,9 @@
import jakarta.json.stream.JsonGeneratorFactory;
import jakarta.json.stream.JsonParser;
import jakarta.json.stream.JsonParserFactory;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests related to JsonProvider.