List of usage examples for java.lang AssertionError AssertionError
public AssertionError(String message, Throwable cause)
From source file:com.hp.autonomy.frontend.configuration.AbstractConfig.java
@Override @JsonIgnore// w ww.j a v a 2 s .c o m public Map<String, ConfigurationComponent> getValidationMap() { // Use getDeclaredFields as the fields will probably be private final Field[] fields = this.getClass().getDeclaredFields(); final Map<String, ConfigurationComponent> result = new HashMap<>(); for (final Field field : fields) { final boolean oldValue = field.isAccessible(); try { field.setAccessible(true); final Object o = field.get(this); // if o is null this is false if (o instanceof ConfigurationComponent) { result.put(field.getName(), (ConfigurationComponent) o); } } catch (IllegalAccessException e) { throw new AssertionError("Your JVM does not allow you to run this code.", e); } finally { field.setAccessible(oldValue); } } return result; }
From source file:moe.encode.airblock.commands.arguments.split.SimpleSplitTest.java
@Test public void testSplit() throws Exception { for (int i = 0; i < SimpleSplitTest.INPUT.length; i++) { String[] values = this.qs.split(SimpleSplitTest.INPUT[i], true); try {//from w w w . j av a2 s .c om assertArrayEquals(SimpleSplitTest.OUTPUT[i], values); } catch (AssertionError e) { throw new AssertionError("[" + i + "] " + ArrayUtils.toString(SimpleSplitTest.OUTPUT[i]) + " != " + ArrayUtils.toString(values), e); } } }
From source file:org.nuxeo.connect.tools.report.viewer.ThreadDumpPrinter.java
public Iterable<ThreadInfo> iterableOf() { return new Iterable<ThreadInfo>() { @Override//ww w. j av a 2 s. c om public Iterator<ThreadInfo> iterator() { try { return iteratorOf(); } catch (IOException cause) { throw new AssertionError("Cannot parse thread dump", cause); } } }; }
From source file:com.magnet.tools.tests.FileSystemStepDefs.java
@Then("^the directory structure for \"([^\"]*)\" should not be:$") public static void the_directory_should_not_be(String directory, List<String> entries) throws Throwable { the_directory_should_exist(directory); try {/*w w w .j a v a 2 s.com*/ for (String entry : entries) { the_file_does_not_exist(directory + "/" + entry); } } catch (AssertionError e) { StringBuilder tree = new StringBuilder( "Entry found: " + e.getMessage() + "\nThe directory structure for " + directory + " was:\n"); for (File f : FileUtils.listFilesAndDirs(new File(directory), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { tree.append(f).append("\n"); } throw new AssertionError(tree.toString(), e); } }
From source file:moe.encode.airblock.commands.arguments.split.QuotedSplitTest.java
@Test public void testSplit() throws Exception { for (int i = 0; i < QuotedSplitTest.INPUT.length; i++) { String[] values = this.qs.split(QuotedSplitTest.INPUT[i], true); try {/*from w w w . jav a 2 s. co m*/ assertArrayEquals(QuotedSplitTest.OUTPUT[i], values); } catch (AssertionError e) { throw new AssertionError("[" + i + "] " + ArrayUtils.toString(QuotedSplitTest.OUTPUT[i]) + " != " + ArrayUtils.toString(values), e); } } }
From source file:org.nuxeo.connect.tools.report.viewer.ThreadDumpPrinter.java
public Iterator<ThreadInfo> iteratorOf() throws IOException { return new Iterator<ThreadInfo>() { Iterator<JsonNode> nodes = dump.iterator(); @Override/*from w ww . j a v a2 s. c o m*/ public boolean hasNext() { return nodes.hasNext(); } @Override public ThreadInfo next() { try { return ThreadInfo.from((CompositeData) converter.convertToObject( MappedMXBeanType.toOpenType(ThreadInfo.class), nodes.next().toString())); } catch (OpenDataException cause) { throw new AssertionError("Cannot parse thread info attributes", cause); } } }; }
From source file:com.linkedin.pinot.controller.ControllerConf.java
public static String constructDownloadUrl(String tableName, String segmentName, String vip) { try {/* w w w. j a v a 2s.com*/ return StringUtil.join("/", vip, "segments", tableName, URLEncoder.encode(segmentName, "UTF-8")); } catch (UnsupportedEncodingException e) { // Shouldn't happen throw new AssertionError("UTF-8 encoding should always be supported", e); } }
From source file:com.github.approval.converters.JacksonJsonConverter.java
@Nonnull @Override/*w w w . j a v a2 s . com*/ protected String getStringForm(T entity) { try { return mapper.writeValueAsString(entity); } catch (JsonProcessingException e) { throw new AssertionError("Could not convert " + entity.getClass() + "object", e); } }
From source file:org.elasticsearch.xpack.core.rollup.RollupRestTestStateCleaner.java
private void waitForPendingTasks() throws Exception { ESTestCase.assertBusy(() -> {// w w w . j a v a 2s .co m try { Response response = adminClient.performRequest("GET", "/_cat/tasks", Collections.singletonMap("detailed", "true")); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { try (BufferedReader responseReader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8))) { int activeTasks = 0; String line; StringBuilder tasksListString = new StringBuilder(); while ((line = responseReader.readLine()) != null) { // We only care about Rollup jobs, otherwise this fails too easily due to unrelated tasks if (line.startsWith(RollupJob.NAME) == true) { activeTasks++; tasksListString.append(line); tasksListString.append('\n'); } } assertEquals(activeTasks + " active tasks found:\n" + tasksListString, 0, activeTasks); } } } catch (IOException e) { throw new AssertionError("Error getting active tasks list", e); } }); }
From source file:com.brokenevent.nanotests.http.TestRequestImpl.java
/** * Executes the http request.// ww w .ja va 2 s. c o m */ public void execute() { try { response = client.execute(host, request); } catch (IOException e) { throw new AssertionError("Failed to do GET to " + hostUrl, e); } }