Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONArray


     */
    public void test_getLong_typeMisMatch() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[\"1\"]");
            assertTrue(jArray.getLong(0) == (long)1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here


     */
    public void test_getDouble_typeMisMatch() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[\"1\"]");
            assertTrue(jArray.getDouble(0) == 1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     */
    public void test_getInt_typeMisMatch() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[\"1\"]");
            assertTrue(jArray.getLong(0) == (int)1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     */
    public void test_getString_typeMisMatch() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getString(0) == "null");
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     */
    public void test_getBoolean_typeMisMatch() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[1]");
            assertTrue(jArray.getBoolean(0) == true);
        } catch (Exception ex1) {
            ex = ex1;
        }
        System.out.println("Error: " + ex);
        assertTrue(ex instanceof JSONException);
View Full Code Here

     */
    public void test_getLong_typeMisMatchNull() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getLong(0) == (long)1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     */
    public void test_getInt_typeMisMatchNull() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getLong(0) == (int)1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

            -1,
            -1);
     
      System.out.println(sessions);
     
      JSONArray arr = null;
      if(sessions != null)
        arr = new JSONArray(sessions);
      else
        arr = new JSONArray();
     
      arr.write(resp.getWriter());
    }
    catch(Exception e) {
      e.printStackTrace();
      //throw new ServletException(e.getMessage());
    }
View Full Code Here

            -1,
            -1);
     
      System.out.println(sessions);
     
      JSONArray arr = null;
      if(sessions != null)
        arr = new JSONArray(sessions);
      else
        arr = new JSONArray();
     
      arr.write(resp.getWriter());
    }
    catch(Exception e) {
      e.printStackTrace();
      //throw new ServletException(e.getMessage());
    }
View Full Code Here

    this.userClientStore = Collections.synchronizedMap(uMap);
    loadConfig();
  }
 
  public JSONArray getUserClients(String userId) throws JSONException, UnsupportedEncodingException {
    JSONArray array = new JSONArray();
    if(this.userClientStore.containsKey(userId)) {
      Map<String, OAuth2Client> userMap = this.userClientStore.get(userId);
      for (Entry<String, OAuth2Client> entry : userMap.entrySet()) {
        OAuth2Client client = entry.getValue();
        JSONObject service = new JSONObject();
        service.put("name", client.getServiceName());
        service.put("clientId", client.getClientId());
        service.put("clientSecret", new String(client.getClientSecret(), "UTF-8"));
        service.put("authUrl", client.getAuthorizationUrl());
        service.put("tokenUrl", client.getTokenUrl());
        service.put("type", client.getType().toString());
        service.put("grantType", client.getGrantType());
        service.put("authentication", client.getClientAuthenticationType());
        service.put("override", client.isAllowModuleOverride());
        service.put("authHeader", client.isAuthorizationHeader());
        service.put("urlParam", client.isUrlParameter());
        service.put("redirectUrl", client.getRedirectUri());
        array.add(service);
      }
    }
    return array;
  }
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.JSONArray

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.