List of usage examples for java.lang AssertionError AssertionError
public AssertionError(double detailMessage)
double
, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification. From source file:org.glowroot.benchmark.ResultFormatter.java
public static void main(String[] args) throws IOException { File resultFile = new File(args[0]); Scores scores = new Scores(); double baselineStartupTime = -1; double glowrootStartupTime = -1; ObjectMapper mapper = new ObjectMapper(); String content = Files.toString(resultFile, Charsets.UTF_8); content = content.replaceAll("\n", " "); ArrayNode results = (ArrayNode) mapper.readTree(content); for (JsonNode result : results) { String benchmark = result.get("benchmark").asText(); benchmark = benchmark.substring(0, benchmark.lastIndexOf('.')); ObjectNode primaryMetric = (ObjectNode) result.get("primaryMetric"); double score = primaryMetric.get("score").asDouble(); if (benchmark.equals(StartupBenchmark.class.getName())) { baselineStartupTime = score; continue; } else if (benchmark.equals(StartupWithGlowrootBenchmark.class.getName())) { glowrootStartupTime = score; continue; }//from ww w .j a v a 2 s.com ObjectNode scorePercentiles = (ObjectNode) primaryMetric.get("scorePercentiles"); double score50 = scorePercentiles.get("50.0").asDouble(); double score95 = scorePercentiles.get("95.0").asDouble(); double score99 = scorePercentiles.get("99.0").asDouble(); double score999 = scorePercentiles.get("99.9").asDouble(); double score9999 = scorePercentiles.get("99.99").asDouble(); double allocatedBytes = getAllocatedBytes(result); if (benchmark.equals(ServletBenchmark.class.getName())) { scores.baselineResponseTimeAvg = score; scores.baselineResponseTime50 = score50; scores.baselineResponseTime95 = score95; scores.baselineResponseTime99 = score99; scores.baselineResponseTime999 = score999; scores.baselineResponseTime9999 = score9999; scores.baselineAllocatedBytes = allocatedBytes; } else if (benchmark.equals(ServletWithGlowrootBenchmark.class.getName())) { scores.glowrootResponseTimeAvg = score; scores.glowrootResponseTime50 = score50; scores.glowrootResponseTime95 = score95; scores.glowrootResponseTime99 = score99; scores.glowrootResponseTime999 = score999; scores.glowrootResponseTime9999 = score9999; scores.glowrootAllocatedBytes = allocatedBytes; } else { throw new AssertionError(benchmark); } } System.out.println(); printScores(scores); if (baselineStartupTime != -1) { System.out.println("STARTUP"); System.out.format("%25s%14s%14s%n", "", "baseline", "glowroot"); printLine("Startup time (avg)", "ms", baselineStartupTime, glowrootStartupTime); } System.out.println(); }
From source file:disko.utils.GoogleLanguageDetector.java
/** * A simple test / example// ww w . j a va 2 s.com * * @param args */ public static void main(String[] args) { if (args.length == 0) { System.out.println(isEnglish("Dnde est el bao?")); System.out.println(isEnglish("The book is on the table.")); if ("jap".equals(detectLanguage( "??????????????????????"))) throw new AssertionError("Error detecting japanese language"); } else { System.out.println(detectLanguage(args[0])); } }
From source file:Main.java
public static void assertIsTrue(boolean condition) { if (!condition) { throw new AssertionError("Expected condition to be true"); }/*from w w w. ja va 2 s .c o m*/ }
From source file:Main.java
public static void asserts(boolean expression, String failedMessage) { if (!expression) { throw new AssertionError(failedMessage); }// w ww. j a v a2s. c o m }
From source file:Main.java
public static void asserts(boolean expression, String failedMessage) { if (!(expression)) { throw new AssertionError(failedMessage); }/*from w w w .j av a2s . c o m*/ }
From source file:Main.java
public static void assertHasHeader(HttpMessage message, String expectedHeader) { if (!containsHeader(message, expectedHeader)) { throw new AssertionError( "Expected header '" + expectedHeader + "' not found in '" + toString(message) + "'"); }/*from w ww .j a va 2 s. co m*/ }
From source file:Main.java
public static void assertNotHasHeader(HttpMessage message, String unexpectedHeader) { if (containsHeader(message, unexpectedHeader)) { throw new AssertionError("Unexpected header '" + unexpectedHeader + "' in '" + toString(message) + "'"); }//from w w w . j a va 2 s . c o m }
From source file:Main.java
public static <T> void assertNotNull(@Nullable T object, @NonNull String parameterName) throws AssertionError { if (object == null) throw new AssertionError(parameterName + " can't be null."); }
From source file:Main.java
public static void readBytes(InputStream in, long count) throws IOException { for (long i = 0; i < count; i++) { try {/* ww w . j a v a 2s .c om*/ if (in.read() == -1) { throw new AssertionError("Unexpected end of stream after " + i + " bytes"); } } catch (SocketTimeoutException e) { throw new AssertionError("Timeout while reading " + count + " bytes (read " + i + " bytes)"); } } }
From source file:Main.java
public static JSONObject newJson(@NonNull String json) { try {//from w w w.j a v a2 s. com return new JSONObject(json); } catch (JSONException e) { throw new AssertionError(e); } }