1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

reorganize classes so test data is separate from test cases

This commit is contained in:
John J. Aylward 2017-07-09 16:33:39 -04:00
parent 974a5f7d5d
commit 0e3f23d7a1
16 changed files with 44 additions and 30 deletions

View file

@ -10,6 +10,9 @@ import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.junit.data.MyEnum;
import org.json.junit.data.MyEnumClass;
import org.json.junit.data.MyEnumField;
import org.junit.Test;
import com.jayway.jsonpath.Configuration;
@ -195,7 +198,7 @@ public class EnumTest {
* However, an enum within another class will not be rendered
* unless that class overrides default toString()
*/
String expectedStr3 = "\"org.json.junit.MyEnumClass@";
String expectedStr3 = "\"org.json.junit.data.MyEnumClass@";
myEnumClass.setMyEnum(MyEnum.VAL1);
myEnumClass.setMyEnumField(MyEnumField.VAL1);
String str3 = JSONObject.valueToString(myEnumClass);

View file

@ -5,6 +5,7 @@ import static org.junit.Assert.*;
import java.util.*;
import org.json.*;
import org.json.junit.data.MyLocaleBean;
import org.junit.*;
/**

View file

@ -30,6 +30,16 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONPointerException;
import org.json.XML;
import org.json.junit.data.BrokenToString;
import org.json.junit.data.Fraction;
import org.json.junit.data.MyBean;
import org.json.junit.data.MyBigNumberBean;
import org.json.junit.data.MyEnum;
import org.json.junit.data.MyEnumField;
import org.json.junit.data.MyJsonString;
import org.json.junit.data.MyNumber;
import org.json.junit.data.MyNumberContainer;
import org.json.junit.data.MyPublicClass;
import org.junit.Test;
import com.jayway.jsonpath.Configuration;
@ -484,7 +494,7 @@ public class JSONObjectTest {
@Test
public void jsonObjectByResourceBundle() {
JSONObject jsonObject = new
JSONObject("org.json.junit.StringsResourceBundle",
JSONObject("org.json.junit.data.StringsResourceBundle",
Locale.getDefault());
// validate JSON
@ -2572,18 +2582,5 @@ public class JSONObjectTest {
// assert that the new map is mutable
assertTrue("Removing a key should succeed", map.remove("key3") != null);
assertTrue("Map should have 2 elements", map.size() == 2);
}
/**
* test class for verifying write errors.
* @author John Aylward
*
*/
private static class BrokenToString {
@Override
public String toString() {
throw new IllegalStateException("Something went horribly wrong!");
}
}
}

View file

@ -0,0 +1,13 @@
package org.json.junit.data;
/**
* test class for verifying write errors.
* @author John Aylward
*
*/
public class BrokenToString {
@Override
public String toString() {
throw new IllegalStateException("Something went horribly wrong!");
}
}

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
import java.math.BigDecimal;
import java.math.BigInteger;

View file

@ -1,11 +1,11 @@
package org.json.junit;
package org.json.junit.data;
import java.io.*;
/**
* Used in testing when Bean behavior is needed
*/
interface MyBean {
public interface MyBean {
public Integer getIntKey();
public Double getDoubleKey();
public String getStringKey();

View file

@ -1,11 +1,11 @@
package org.json.junit;
package org.json.junit.data;
import java.math.*;
/**
* Used in testing when a Bean containing big numbers is needed
*/
interface MyBigNumberBean {
public interface MyBigNumberBean {
public BigInteger getBigInteger();
public BigDecimal getBigDecimal();
}

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
/**
* An enum with no methods or data

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
/**
* this is simply a class that contains some enum instances

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
/**
* An enum that contains getters and some internal fields

View file

@ -1,11 +1,11 @@
package org.json.junit;
package org.json.junit.data;
import org.json.*;
/**
* Used in testing when a JSONString is needed
*/
class MyJsonString implements JSONString {
public class MyJsonString implements JSONString {
@Override
public String toJSONString() {

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
public class MyLocaleBean {
private final String id = "beanId";

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
import java.math.BigDecimal;

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
/**
* Class that holds our MyNumber override as a property.

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
/**
* Need a class with some public data members for testing

View file

@ -1,4 +1,4 @@
package org.json.junit;
package org.json.junit.data;
import java.util.*;