Package org.exoplatform.ws.frameworks.json

Examples of org.exoplatform.ws.frameworks.json.JavaMapBean


      assertEquals(l.get(2).getTitle(), iterator.next().getElement("title").getStringValue());
   }

   public void testBeanMap() throws Exception
   {
      JavaMapBean mb = new JavaMapBean();

      Map<String, Book> m = new HashMap<String, Book>();
      m.put("test", junitBook);
      mb.setHashMap((HashMap<String, Book>)m);

      List<Book> l = new ArrayList<Book>();
      l.add(junitBook);
      l.add(csharpBook);
      l.add(javaScriptBook);

      Map<String, List<Book>> hu = new HashMap<String, List<Book>>();
      hu.put("1", l);
      hu.put("2", l);
      hu.put("3", l);
      mb.setMapList(hu);

      Map<String, String> str = new HashMap<String, String>();
      str.put("key1", "value1");
      str.put("key2", "value2");
      str.put("key3", "value3");
      mb.setStrings(str);

      JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(mb);

      assertEquals(str.get("key2"), jsonValue.getElement("strings").getElement("key2").getStringValue());
      assertNotNull(jsonValue.getElement("hashMap"));
View Full Code Here


      JsonParser jsonParser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "MapTest.txt")), handler);
      JsonValue jv = handler.getJsonObject();
      JavaMapBean o = ObjectBuilder.createObject(JavaMapBean.class, jv);

      assertTrue(o.getMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getMap().get("JavaScript").equals(sourceCollection.get(2)));

      assertTrue(o.getHashMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getHashMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getHashMap().get("JavaScript").equals(sourceCollection.get(2)));

      assertTrue(o.getHashtable().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getHashtable().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getHashtable().get("JavaScript").equals(sourceCollection.get(2)));

      assertTrue(o.getLinkedHashMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getLinkedHashMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getLinkedHashMap().get("JavaScript").equals(sourceCollection.get(2)));

   }
View Full Code Here

      JsonParser jsonParser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "MapTest.txt")), handler);
      JsonValue jv = handler.getJsonObject();
      JavaMapBean o = ObjectBuilder.createObject(JavaMapBean.class, jv);

      assertTrue(o.getMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getMap().get("JavaScript").equals(sourceCollection.get(2)));
   }
View Full Code Here

      JsonParser jsonParser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "MapTest.txt")), handler);
      JsonValue jv = handler.getJsonObject();
      JavaMapBean o = ObjectBuilder.createObject(JavaMapBean.class, jv);

      assertTrue(o.getHashMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getHashMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getHashMap().get("JavaScript").equals(sourceCollection.get(2)));
   }
View Full Code Here

      JsonParser jsonParser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "MapTest.txt")), handler);
      JsonValue jv = handler.getJsonObject();
      JavaMapBean o = ObjectBuilder.createObject(JavaMapBean.class, jv);

      assertTrue(o.getHashtable().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getHashtable().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getHashtable().get("JavaScript").equals(sourceCollection.get(2)));
   }
View Full Code Here

      JsonParser jsonParser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "MapTest.txt")), handler);
      JsonValue jv = handler.getJsonObject();
      JavaMapBean o = ObjectBuilder.createObject(JavaMapBean.class, jv);

      assertTrue(o.getLinkedHashMap().get("JUnit").equals(sourceCollection.get(0)));
      assertTrue(o.getLinkedHashMap().get("C#").equals(sourceCollection.get(1)));
      assertTrue(o.getLinkedHashMap().get("JavaScript").equals(sourceCollection.get(2)));
   }
View Full Code Here

      assertEquals(l.get(2).getTitle(), iterator.next().getElement("title").getStringValue());
   }

   public void testBeanMap() throws Exception
   {
      JavaMapBean mb = new JavaMapBean();

      Map<String, Book> m = new HashMap<String, Book>();
      m.put("test", junitBook);
      mb.setHashMap((HashMap<String, Book>)m);

      List<Book> l = new ArrayList<Book>();
      l.add(junitBook);
      l.add(csharpBook);
      l.add(javaScriptBook);

      Map<String, List<Book>> hu = new HashMap<String, List<Book>>();
      hu.put("1", l);
      hu.put("2", l);
      hu.put("3", l);
      mb.setMapList(hu);

      Map<String, String> str = new HashMap<String, String>();
      str.put("key1", "value1");
      str.put("key2", "value2");
      str.put("key3", "value3");
      mb.setStrings(str);

      JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(mb);

      assertEquals(str.get("key2"), jsonValue.getElement("strings").getElement("key2").getStringValue());
      assertNotNull(jsonValue.getElement("hashMap"));
View Full Code Here

TOP

Related Classes of org.exoplatform.ws.frameworks.json.JavaMapBean

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.