Package com.eclipsesource.json

Examples of com.eclipsesource.json.JsonObject


  }

  @Test
  public void checkMultipleFiles() {
    // see https://github.com/jshint/jshint/issues/931
    jsHint.configure( new JsonObject().add( "undef", true ) );

    jsHint.check( "var x = 1;\t#", handler );
    jsHint.check( "var x = 1;\t#", handler );
    jsHint.check( "var x = 1;\t#", handler );
    jsHint.check( "var x = 1;\t#", handler );
View Full Code Here


      new Packr().pack(config);
    } else {
      if(args.length == 0) {
        printHelp();
      } else {
        JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(new File(args[0])));
        Config config = new Config();
        config.platform = Platform.valueOf(json.get("platform").asString());
        config.jdk = json.get("jdk").asString();
        config.executable = json.get("executable").asString();
        config.jar = json.get("appjar").asString();
        config.mainClass = json.get("mainclass").asString();
        if(json.get("vmargs") != null) {
          for(JsonValue val: json.get("vmargs").asArray()) {
            config.vmArgs.add(val.asString());
          }
        }
        config.outDir = json.get("outdir").asString();
        if(json.get("minimizejre") != null) {
          if(new File(json.get("minimizejre").asString()).exists()) {
            config.minimizeJre = FileUtils.readFileToString(new File(json.get("minimizejre").asString())).split("\r?\n");
          } else {
            InputStream in = Packr.class.getResourceAsStream("/minimize/" + json.get("minimizejre"));
            if(in != null) {
              config.minimizeJre = IOUtils.toString(in).split("\r?\n");
              in.close();
            } else {
              config.minimizeJre = new String[0];
            }
          }
        }
        if(json.get("resources") != null) {
          config.resources = toStringArray(json.get("resources").asArray());
        }
        new Packr().pack(config);
      }
    }
  }
View Full Code Here

    assertNotNull( jsonValue );
  }

  @Test
  public void mockObject() {
    JsonObject jsonObject = Mockito.mock( JsonObject.class );

    assertNotNull( jsonObject );
  }
View Full Code Here

  CaliperResultsPreprocessor( JsonObject results ) {
    this.results = transformResults( results );
  }

  JsonObject getResults() {
    return new JsonObject( results );
  }
View Full Code Here

  JsonObject getResults() {
    return new JsonObject( results );
  }

  private static JsonObject transformResults( JsonObject caliperResults ) {
    return new JsonObject()
      .add( "name", extractSimpleName( caliperResults ) )
      .add( "details", extractEnvironment( caliperResults ) )
      .add( "measurements", extractMeasurements( caliperResults ) );
  }
View Full Code Here

  private static JsonValue extractTimestamp( JsonObject caliperResults ) {
    return caliperResults.get( "run" ).asObject().get( "executedTimestamp" );
  }

  private static JsonValue extractEnvironment( JsonObject caliperResults ) {
    JsonObject details = caliperResults.get( "environment" ).asObject()
      .get( "propertyMap" ).asObject();
    details.add( "benchmark.classname", extractBenchmarkName( caliperResults ) );
    details.add( "benchmark.executionTime", extractTimestamp( caliperResults ) );
    return details;
  }
View Full Code Here

    }
    return result;
  }

  private static JsonObject extractMeasurement( JsonObject measurement ) {
    JsonObject times = measurement.get( "v" ).asObject()
      .get( "measurementSetMap" ).asObject()
      .get( "TIME" ).asObject();
    return new JsonObject()
      .add( "variables", measurement.get( "k" ).asObject().get( "variables" ) )
      .add( "units", times.get( "unitNames" ) )
      .add( "values", extractTimes( times.get( "measurements" ).asArray() ) );
  }
View Full Code Here

  @Test
  public void results_structure() {
    CaliperResultsPreprocessor preprocessor = new CaliperResultsPreprocessor( caliperJson );

    JsonObject results = preprocessor.getResults();

    assertEquals( asList( "name", "details", "measurements" ), results.names() );
    assertTrue( results.get( "name" ).isString() );
    assertTrue( results.get( "details" ).isObject() );
    assertTrue( results.get( "measurements" ).isArray() );
  }
View Full Code Here

  @Test
  public void name_isSimpleName() {
    CaliperResultsPreprocessor preprocessor = new CaliperResultsPreprocessor( caliperJson );

    JsonObject results = preprocessor.getResults();

    String name = results.get( "name" ).asString();
    assertTrue( name.contains( "Benchmark" ) );
    assertFalse( name.contains( "." ) );
  }
View Full Code Here

  @Test
  public void details_containsEnvironmentVariables() {
    CaliperResultsPreprocessor preprocessor = new CaliperResultsPreprocessor( caliperJson );

    JsonObject results = preprocessor.getResults();

    assertTrue( results.get( "details" ).asObject().names().contains( "os.version" ) );
  }
View Full Code Here

TOP

Related Classes of com.eclipsesource.json.JsonObject

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.