1 import java.io.IOException;
4 import org.apache.log4j.Level;
5 import org.json.JSONException;
6 import org.json.JSONObject;
7 import org.opendaylight.mwtn.base.internalTypes.Resources;
8 import org.opendaylight.mwtn.config.impl.HtLogger;
10 public class ResTest {
12 private static void testDuplicateKeyJSON()
16 String str=Resources.getFileContent("/elasticsearch/index/mwtn/modelDescription/CoreModel-ForMicrowave.json");
18 JSONObject o=new JSONObject(str) {
21 public JSONObject putOnce(String key, Object value) throws JSONException {
25 if (key != null && value != null) {
26 if ((storedValue = this.opt(key)) != null ) {
27 if(!storedValue.equals(value)) { //Only through Exception for different values with same key
29 System.out.println("duplicate found");
42 System.out.println(o.toString());
44 catch(IOException err)
46 err.printStackTrace();
49 public static void main(String[] args)
51 HtLogger.initConsole(Level.DEBUG);
52 JSONObject o=Resources.getJSONFile("/elasticsearch/index/sdnevents/sdneventsMapping.json");
53 System.out.println(o==null?"null":o.toString());
55 List<JSONObject> list=Resources.getJSONFiles("/elasticsearch/index", true);
56 System.out.println("found "+list.size()+" valid json files");
58 testDuplicateKeyJSON();