Package org.apache.wink.json4j.compat

Examples of org.apache.wink.json4j.compat.JSONFactory


     */
    public void test_putJSONObject() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray();
            jArray.put(factory.createJSONObject());
            JSONObject obj = (JSONObject)jArray.get(0);
            assertTrue(obj != null);
            assertTrue(obj instanceof JSONObject);
            assertTrue(((JSONObject)jArray.get(0)).toString().equals("{}"));
        } catch (Exception ex1) {
View Full Code Here


     */
    public void test_putJSONArray() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray();
            jArray.put(factory.createJSONArray());
            JSONArray obj = (JSONArray)jArray.get(0);
            assertTrue(obj != null);
            assertTrue(obj instanceof JSONArray);
            assertTrue(((JSONArray)jArray.get(0)).toString().equals("[]"));
        } catch (Exception ex1) {
View Full Code Here

     */
    public void test_getLong() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[1]");
            assertTrue(jArray.getLong(0) == (long)1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     */
    public void test_getLongNgative() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[-1]");
            assertTrue(jArray.getLong(0) == (long)-1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     */
    public void test_getInt() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[1]");
            assertTrue(jArray.getInt(0) == 1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     */
    public void test_getIntNegative() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[-1]");
            assertTrue(jArray.getInt(0) == -1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     */
    public void test_getDouble() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[1]");
            assertTrue(jArray.getDouble(0) == (double)1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

    /**
     * Test the noargs contructor.
     */
    public void test_new() {
        System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
        JSONFactory factory = JSONFactory.newInstance();
        JSONObject jObject = factory.createJSONObject();
        assertTrue(jObject != null);
        assertTrue(jObject.length() == 0);
    }
View Full Code Here

        JSONObject jObject = null;
        Exception ex = null;
        // Load from empty object string.
        try{
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            jObject = factory.createJSONObject("{}");
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

        JSONObject jObject = null;
        Exception ex = null;
        // Load a basic JSON string
        try{
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            jObject = factory.createJSONObject("{\"foo\":\"bar\", \"bool\": true}");
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.compat.JSONFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.