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:
parent
974a5f7d5d
commit
0e3f23d7a1
16 changed files with 44 additions and 30 deletions
|
@ -10,6 +10,9 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
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 org.junit.Test;
|
||||||
|
|
||||||
import com.jayway.jsonpath.Configuration;
|
import com.jayway.jsonpath.Configuration;
|
||||||
|
@ -195,7 +198,7 @@ public class EnumTest {
|
||||||
* However, an enum within another class will not be rendered
|
* However, an enum within another class will not be rendered
|
||||||
* unless that class overrides default toString()
|
* unless that class overrides default toString()
|
||||||
*/
|
*/
|
||||||
String expectedStr3 = "\"org.json.junit.MyEnumClass@";
|
String expectedStr3 = "\"org.json.junit.data.MyEnumClass@";
|
||||||
myEnumClass.setMyEnum(MyEnum.VAL1);
|
myEnumClass.setMyEnum(MyEnum.VAL1);
|
||||||
myEnumClass.setMyEnumField(MyEnumField.VAL1);
|
myEnumClass.setMyEnumField(MyEnumField.VAL1);
|
||||||
String str3 = JSONObject.valueToString(myEnumClass);
|
String str3 = JSONObject.valueToString(myEnumClass);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.json.*;
|
import org.json.*;
|
||||||
|
import org.json.junit.data.MyLocaleBean;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,16 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONPointerException;
|
import org.json.JSONPointerException;
|
||||||
import org.json.XML;
|
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 org.junit.Test;
|
||||||
|
|
||||||
import com.jayway.jsonpath.Configuration;
|
import com.jayway.jsonpath.Configuration;
|
||||||
|
@ -484,7 +494,7 @@ public class JSONObjectTest {
|
||||||
@Test
|
@Test
|
||||||
public void jsonObjectByResourceBundle() {
|
public void jsonObjectByResourceBundle() {
|
||||||
JSONObject jsonObject = new
|
JSONObject jsonObject = new
|
||||||
JSONObject("org.json.junit.StringsResourceBundle",
|
JSONObject("org.json.junit.data.StringsResourceBundle",
|
||||||
Locale.getDefault());
|
Locale.getDefault());
|
||||||
|
|
||||||
// validate JSON
|
// validate JSON
|
||||||
|
@ -2572,18 +2582,5 @@ public class JSONObjectTest {
|
||||||
// assert that the new map is mutable
|
// assert that the new map is mutable
|
||||||
assertTrue("Removing a key should succeed", map.remove("key3") != null);
|
assertTrue("Removing a key should succeed", map.remove("key3") != null);
|
||||||
assertTrue("Map should have 2 elements", map.size() == 2);
|
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!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/test/java/org/json/junit/data/BrokenToString.java
Normal file
13
src/test/java/org/json/junit/data/BrokenToString.java
Normal 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!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
|
@ -1,11 +1,11 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in testing when Bean behavior is needed
|
* Used in testing when Bean behavior is needed
|
||||||
*/
|
*/
|
||||||
interface MyBean {
|
public interface MyBean {
|
||||||
public Integer getIntKey();
|
public Integer getIntKey();
|
||||||
public Double getDoubleKey();
|
public Double getDoubleKey();
|
||||||
public String getStringKey();
|
public String getStringKey();
|
|
@ -1,11 +1,11 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in testing when a Bean containing big numbers is needed
|
* Used in testing when a Bean containing big numbers is needed
|
||||||
*/
|
*/
|
||||||
interface MyBigNumberBean {
|
public interface MyBigNumberBean {
|
||||||
public BigInteger getBigInteger();
|
public BigInteger getBigInteger();
|
||||||
public BigDecimal getBigDecimal();
|
public BigDecimal getBigDecimal();
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum with no methods or data
|
* An enum with no methods or data
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is simply a class that contains some enum instances
|
* this is simply a class that contains some enum instances
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum that contains getters and some internal fields
|
* An enum that contains getters and some internal fields
|
|
@ -1,11 +1,11 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import org.json.*;
|
import org.json.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in testing when a JSONString is needed
|
* Used in testing when a JSONString is needed
|
||||||
*/
|
*/
|
||||||
class MyJsonString implements JSONString {
|
public class MyJsonString implements JSONString {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJSONString() {
|
public String toJSONString() {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
public class MyLocaleBean {
|
public class MyLocaleBean {
|
||||||
private final String id = "beanId";
|
private final String id = "beanId";
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that holds our MyNumber override as a property.
|
* Class that holds our MyNumber override as a property.
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need a class with some public data members for testing
|
* Need a class with some public data members for testing
|
|
@ -1,4 +1,4 @@
|
||||||
package org.json.junit;
|
package org.json.junit.data;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue