Tabnine Logo
JsonConversionUtilTest
Code IndexAdd Tabnine to your IDE (free)

How to use
JsonConversionUtilTest
in
org.apache.shindig.common.util

Best Java code snippets using org.apache.shindig.common.util.JsonConversionUtilTest (Showing top 20 results out of 315)

origin: apache/shindig

public static void assertJsonEquals(Object expected, Object actual)
  throws JSONException {
 if (expected == null) {
  assertNull(actual);
  return;
 assertNotNull(actual);
 if (expected instanceof JSONObject) {
  JSONObject expectedObject = (JSONObject) expected;
  JSONObject actualObject = (JSONObject) actual;
  if (expectedObject.length() == 0) {
   assertEquals(expectedObject.length(), actualObject.length());
   return;
  assertEquals(expectedObject.names().length(), actualObject.names().length());
   assertTrue("missing key " + key, actualObject.has(key));
   assertJsonEquals(expectedObject.get(key), actualObject.get(key));
  assertEquals(expectedArray.length(), actualArray.length());
  for (int i = 0; i < expectedArray.length(); i++) {
   if (expectedArray.isNull(i)) {
    assertTrue(actualArray.isNull(i));
   } else {
    assertJsonEquals(expectedArray.get(i), actualArray.get(i));
  assertEquals(expected, actual);
origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void testSimplePathToJsonParsing()
  throws Exception {
 JSONObject root = new JSONObject();
 JsonConversionUtil.buildHolder(root, "a.a.a".split("\\."), 0);
 assertJsonEquals(root, new JSONObject("{a:{a:{}}}"));
}
origin: org.apache.shindig/shindig-common

@Test
public void testJsonFromRequest() throws Exception {
 HttpServletRequest fakeRequest;
 for (String badParms : ImmutableList.of("x=1", "x=1&callback=")) {
  fakeRequest = new FakeHttpServletRequest("http://foo.com/gadgets/rpc?" + badParms);
  assertNull(JsonConversionUtil.fromRequest(fakeRequest));
 }
 }
origin: com.lmco.shindig/shindig-common

@Test
public void testJSONToParameterMapParsing()
  throws Exception {
 Map<String, String> resultMap = JsonConversionUtil
   .fromJson(new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}"));
 assertEquals(2, resultMap.size());
 assertEquals("hello", resultMap.get(".a.b(0).c"));
 assertEquals("hello", resultMap.get(".a.b(1).c"));
}
origin: org.apache.shindig/shindig-common

@Test
public void testSimplePathToJsonParsing()
  throws Exception {
 JSONObject root = new JSONObject();
 JsonConversionUtil.buildHolder(root, "a.a.a".split("\\."), 0);
 assertJsonEquals(root, new JSONObject("{a:{a:{}}}"));
}
origin: com.lmco.shindig/shindig-common

@Test
public void testJsonFromRequest() throws Exception {
 HttpServletRequest fakeRequest;
 for (String badParms : ImmutableList.of("x=1", "x=1&callback=")) {
  fakeRequest = new FakeHttpServletRequest("http://foo.com/gadgets/rpc?" + badParms);
  assertNull(JsonConversionUtil.fromRequest(fakeRequest));
 }
 }
origin: org.gatein.shindig/shindig-common

@Test
public void testJSONToParameterMapParsing()
  throws Exception {
 Map<String, String> resultMap = JsonConversionUtil
   .fromJson(new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}"));
 assertEquals(2, resultMap.size());
 assertEquals("hello", resultMap.get(".a.b(0).c"));
 assertEquals("hello", resultMap.get(".a.b(1).c"));
}
origin: org.gatein.shindig/shindig-common

public static void assertJsonEquals(Object expected, Object actual)
  throws JSONException {
 if (expected == null) {
  assertNull(actual);
  return;
 assertNotNull(actual);
 if (expected instanceof JSONObject) {
  JSONObject expectedObject = (JSONObject) expected;
  JSONObject actualObject = (JSONObject) actual;
  if (expectedObject.length() == 0) {
   assertEquals(expectedObject.length(), actualObject.length());
   return;
  assertEquals(expectedObject.names().length(), actualObject.names().length());
   assertTrue("missing key " + key, actualObject.has(key));
   assertJsonEquals(expectedObject.get(key), actualObject.get(key));
  assertEquals(expectedArray.length(), actualArray.length());
  for (int i = 0; i < expectedArray.length(); i++) {
   if (expectedArray.isNull(i)) {
    assertTrue(actualArray.isNull(i));
   } else {
    assertJsonEquals(expectedArray.get(i), actualArray.get(i));
  assertEquals(expected, actual);
origin: org.gatein.shindig/shindig-common

@Test
public void testSimplePathToJsonParsing()
  throws Exception {
 JSONObject root = new JSONObject();
 JsonConversionUtil.buildHolder(root, "a.a.a".split("\\."), 0);
 assertJsonEquals(root, new JSONObject("{a:{a:{}}}"));
}
origin: org.gatein.shindig/shindig-common

@Test
public void testJsonFromRequest() throws Exception {
 HttpServletRequest fakeRequest;
 for (String badParms : ImmutableList.of("x=1", "x=1&callback=")) {
  fakeRequest = new FakeHttpServletRequest("http://foo.com/gadgets/rpc?" + badParms);
  assertNull(JsonConversionUtil.fromRequest(fakeRequest));
 }
 }
origin: apache/shindig

@Test
public void testJSONToParameterMapParsing()
  throws Exception {
 Map<String, String> resultMap = JsonConversionUtil
   .fromJson(new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}"));
 assertEquals(2, resultMap.size());
 assertEquals("hello", resultMap.get(".a.b(0).c"));
 assertEquals("hello", resultMap.get(".a.b(1).c"));
}
origin: org.apache.shindig/shindig-common

public static void assertJsonEquals(Object expected, Object actual)
  throws JSONException {
 if (expected == null) {
  assertNull(actual);
  return;
 assertNotNull(actual);
 if (expected instanceof JSONObject) {
  JSONObject expectedObject = (JSONObject) expected;
  JSONObject actualObject = (JSONObject) actual;
  if (expectedObject.length() == 0) {
   assertEquals(expectedObject.length(), actualObject.length());
   return;
  assertEquals(expectedObject.names().length(), actualObject.names().length());
   assertTrue("missing key " + key, actualObject.has(key));
   assertJsonEquals(expectedObject.get(key), actualObject.get(key));
  assertEquals(expectedArray.length(), actualArray.length());
  for (int i = 0; i < expectedArray.length(); i++) {
   if (expectedArray.isNull(i)) {
    assertTrue(actualArray.isNull(i));
   } else {
    assertJsonEquals(expectedArray.get(i), actualArray.get(i));
  assertEquals(expected, actual);
origin: com.lmco.shindig/shindig-common

@Test
public void testSimplePathToJsonParsing()
  throws Exception {
 JSONObject root = new JSONObject();
 JsonConversionUtil.buildHolder(root, "a.a.a".split("\\."), 0);
 assertJsonEquals(root, new JSONObject("{a:{a:{}}}"));
}
origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void testJsonFromRequest() throws Exception {
 HttpServletRequest fakeRequest;
 for (String badParms : ImmutableList.of("x=1", "x=1&callback=")) {
  fakeRequest = new FakeHttpServletRequest("http://foo.com/gadgets/rpc?" + badParms);
  assertNull(JsonConversionUtil.fromRequest(fakeRequest));
 }
 }
origin: org.apache.shindig/shindig-common

@Test
public void testJSONToParameterMapParsing()
  throws Exception {
 Map<String, String> resultMap = JsonConversionUtil
   .fromJson(new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}"));
 assertEquals(2, resultMap.size());
 assertEquals("hello", resultMap.get(".a.b(0).c"));
 assertEquals("hello", resultMap.get(".a.b(1).c"));
}
origin: org.wso2.org.apache.shindig/shindig-common

public static void assertJsonEquals(Object expected, Object actual)
  throws JSONException {
 if (expected == null) {
  assertNull(actual);
  return;
 assertNotNull(actual);
 if (expected instanceof JSONObject) {
  JSONObject expectedObject = (JSONObject) expected;
  JSONObject actualObject = (JSONObject) actual;
  if (expectedObject.length() == 0) {
   assertEquals(expectedObject.length(), actualObject.length());
   return;
  assertEquals(expectedObject.names().length(), actualObject.names().length());
   assertTrue("missing key " + key, actualObject.has(key));
   assertJsonEquals(expectedObject.get(key), actualObject.get(key));
  assertEquals(expectedArray.length(), actualArray.length());
  for (int i = 0; i < expectedArray.length(); i++) {
   if (expectedArray.isNull(i)) {
    assertTrue(actualArray.isNull(i));
   } else {
    assertJsonEquals(expectedArray.get(i), actualArray.get(i));
  assertEquals(expected, actual);
origin: apache/shindig

@Test
public void testSimplePathToJsonParsing()
  throws Exception {
 JSONObject root = new JSONObject();
 JsonConversionUtil.buildHolder(root, "a.a.a".split("\\."), 0);
 assertJsonEquals(root, new JSONObject("{a:{a:{}}}"));
}
origin: apache/shindig

@Test
public void testJsonFromRequest() throws Exception {
 HttpServletRequest fakeRequest;
 for (String badParms : ImmutableList.of("x=1", "x=1&callback=")) {
  fakeRequest = new FakeHttpServletRequest("http://foo.com/gadgets/rpc?" + badParms);
  assertNull(JsonConversionUtil.fromRequest(fakeRequest));
 }
 }
origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void testJSONToParameterMapParsing()
  throws Exception {
 Map<String, String> resultMap = JsonConversionUtil
   .fromJson(new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}"));
 assertEquals(2, resultMap.size());
 assertEquals("hello", resultMap.get(".a.b(0).c"));
 assertEquals("hello", resultMap.get(".a.b(1).c"));
}
origin: com.lmco.shindig/shindig-common

public static void assertJsonEquals(Object expected, Object actual)
  throws JSONException {
 if (expected == null) {
  assertNull(actual);
  return;
 assertNotNull(actual);
 if (expected instanceof JSONObject) {
  JSONObject expectedObject = (JSONObject) expected;
  JSONObject actualObject = (JSONObject) actual;
  if (expectedObject.length() == 0) {
   assertEquals(expectedObject.length(), actualObject.length());
   return;
  assertEquals(expectedObject.names().length(), actualObject.names().length());
   assertTrue("missing key " + key, actualObject.has(key));
   assertJsonEquals(expectedObject.get(key), actualObject.get(key));
  assertEquals(expectedArray.length(), actualArray.length());
  for (int i = 0; i < expectedArray.length(); i++) {
   if (expectedArray.isNull(i)) {
    assertTrue(actualArray.isNull(i));
   } else {
    assertJsonEquals(expectedArray.get(i), actualArray.get(i));
  assertEquals(expected, actual);
org.apache.shindig.common.utilJsonConversionUtilTest

Javadoc

Test for conversion of a structured key-value set to a JSON object

Most used methods

  • assertEquals
  • assertJsonEquals
  • assertNotNull
  • assertNull
  • assertTrue

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • Kernel (java.awt.image)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now