/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public Object checkSucceeds(Callable<Object> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public <T> T checkSucceeds(Callable<T> callable) { try { return callable.call(); } catch (AssumptionViolatedException e) { AssertionError error = new AssertionError("Callable threw AssumptionViolatedException"); error.initCause(e); addError(error); return null; } catch (Throwable e) { addError(e); return null; } }
/** * Adds a failure to the table if {@code runnable} does not throw an * exception of type {@code expectedThrowable} when executed. * Execution continues, but the test will fail at the end if the runnable * does not throw an exception, or if it throws a different exception. * * @param expectedThrowable the expected type of the exception * @param runnable a function that is expected to throw an exception when executed * @since 4.13 */ public void checkThrows(Class<? extends Throwable> expectedThrowable, ThrowingRunnable runnable) { try { assertThrows(expectedThrowable, runnable); } catch (AssertionError e) { addError(e); } }
@Test public void default_instance() { Set<Class<? extends Templates>> templates = querydsl.getSubTypesOf(Templates.class); Set<Class<? extends Templates>> moduleSpecific = getAll(templates, MODULE_SPECIFIC); for (Class<? extends Templates> template : moduleSpecific) { try { Templates defaultInstance = (Templates) template.getField("DEFAULT").get(null); errorCollector.checkThat(defaultInstance, instanceOf(template)); } catch (Exception ex) { errorCollector.addError(ex); } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public Object checkSucceeds(Callable<Object> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public Object checkSucceeds(Callable<Object> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public <T> T checkSucceeds(Callable<T> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public Object checkSucceeds(Callable<Object> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
/** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public <T> T checkSucceeds(Callable<T> callable) { try { return callable.call(); } catch (Throwable e) { addError(e); return null; } } }
@Override public void addError(Throwable error) { errors.add(error); super.addError(error); } }
@Test public void raceConditionInUsersAndGroupsLoading() throws InterruptedException, FileNotFoundException, IOException { // Brute force approach to increase the likelihood of the race condition occurring for (int i = 0; i < 25000; i++) { final CountDownLatch start = new CountDownLatch(1); final CountDownLatch finished = new CountDownLatch(processorCount()); prepareLoginThreads(start, finished); // Releases every login thread simultaneously to increase our chances of // encountering the race condition start.countDown(); finished.await(); if (isRaceConditionDetected()) { e.addError(new AssertionError("At least one race condition in PropertiesLoginModule " + "has been encountered. Please examine the " + "following stack traces for more details:")); for (Exception exception : errors) { e.addError(exception); } return; } } }
/** * Checks {@link JiraDeleteWriter#write(Object)} deletes project from Jira server * * @throws IOException */ public void testDeleteProject() throws IOException { IndexedRecord deleteProjectRecord = new GenericData.Record(DELETE_SCHEMA); deleteProjectRecord.put(0, "ITP"); JiraWriter deleteProjectWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.PROJECT, Action.DELETE); deleteProjectWriter.open("delProj"); try { deleteProjectWriter.write(deleteProjectRecord); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
/** * Checks {@link JiraInsertWriter#write(Object)} creates project on Jira server * * @throws IOException */ public void testInsertProject() throws IOException { IndexedRecord insertProjectRecord = new GenericData.Record(INSERT_SCHEMA); String insertProject = "{\"key\":\"ITP\",\"name\":\"Integration Test Project\",\"projectTemplateKey\":" + "\"com.atlassian.jira-core-project-templates:jira-core-project-management\",\"lead\":\"UserID\"}"; insertProject = insertProject.replace("UserID", USER); insertProjectRecord.put(0, insertProject); JiraWriter insertProjectWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.PROJECT, Action.INSERT); insertProjectWriter.open("insProj"); try { insertProjectWriter.write(insertProjectRecord); insertProjectWriter.close(); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
/** * Checks {@link JiraDeleteWriter#write(Object)} deletes issues from Jira server * * @throws IOException */ public void testDeleteIssues() throws IOException { IndexedRecord deleteIssueRecord1 = new GenericData.Record(DELETE_SCHEMA); deleteIssueRecord1.put(0, "ITP-1"); IndexedRecord deleteIssueRecord2 = new GenericData.Record(DELETE_SCHEMA); deleteIssueRecord2.put(0, "ITP-2"); JiraWriter deleteIssueWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.ISSUE, Action.DELETE); deleteIssueWriter.open("delIss"); try { deleteIssueWriter.write(deleteIssueRecord1); deleteIssueWriter.write(deleteIssueRecord2); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
/** * Checks {@link JiraUpdateWriter#write(Object)} updates project on Jira server * * @throws IOException */ public void testUpdateProject() throws IOException { IndexedRecord updateProjectRecord = new GenericData.Record(UPDATE_SCHEMA); String updateProject = "{\"name\":\"Updated Integration Test Project\",\"assigneeType\":\"PROJECT_LEAD\"}"; updateProjectRecord.put(0, "ITP"); updateProjectRecord.put(1, updateProject); JiraWriter updateProjectWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.PROJECT, Action.UPDATE); updateProjectWriter.open("updProj"); try { updateProjectWriter.write(updateProjectRecord); updateProjectWriter.close(); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
/** * Checks {@link JiraInsertWriter#write(Object)} inserts issues on Jira server * * @throws IOException */ public void testInsertIssues() throws IOException { IndexedRecord insertIssueRecord1 = new GenericData.Record(INSERT_SCHEMA); String insertIssue1 = "{\"fields\":{\"project\":{\"key\":\"ITP\"},\"summary\":\"Integration test issue 1\",\"issuetype\":{\"id\":\"10000\"}}}"; insertIssueRecord1.put(0, insertIssue1); IndexedRecord insertIssueRecord2 = new GenericData.Record(INSERT_SCHEMA); String insertIssue2 = "{\"fields\":{\"project\":{\"key\":\"ITP\"},\"summary\":\"Integration test issue 2\",\"issuetype\":{\"id\":\"10000\"}}}"; insertIssueRecord2.put(0, insertIssue2); JiraWriter insertIssueWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.ISSUE, Action.INSERT); insertIssueWriter.open("insIss"); try { insertIssueWriter.write(insertIssueRecord1); insertIssueWriter.write(insertIssueRecord2); insertIssueWriter.close(); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
/** * Checks {@link JiraUpdateWriter#write(Object)} updates issues on Jira server * * @throws IOException */ public void testUpdateIssues() throws IOException { IndexedRecord updateIssueRecord1 = new GenericData.Record(UPDATE_SCHEMA); String updateIssue1 = "{\"fields\":{\"summary\":\"Updated test issue 1\"}}"; updateIssueRecord1.put(0, "ITP-1"); updateIssueRecord1.put(1, updateIssue1); IndexedRecord updateIssueRecord2 = new GenericData.Record(UPDATE_SCHEMA); String updateIssue2 = "{\"fields\":{\"summary\":\"Updated test issue 2\"}}"; updateIssueRecord2.put(0, "ITP-2"); updateIssueRecord2.put(1, updateIssue2); JiraWriter updateIssueWriter = JiraTestsHelper.createWriter(HOST_PORT, USER, PASS, Resource.ISSUE, Action.UPDATE); updateIssueWriter.open("updIss"); try { updateIssueWriter.write(updateIssueRecord1); updateIssueWriter.write(updateIssueRecord2); updateIssueWriter.close(); } catch (DataRejectException e) { String rejectError = e.getRejectInfo().get("error").toString(); LOG.error(rejectError); collector.addError(new Throwable(rejectError)); } }
private boolean checkMessageProperties(MqttMessage message, Map<String, Object> expectedProperties) { System.out.println("Checking properties in interceptor"); try { assertNotNull(message); assertNotNull(server.getNodeID()); MqttFixedHeader header = message.fixedHeader(); assertNotNull(header.messageType()); assertEquals(header.qosLevel().value(), AT_MOST_ONCE); assertEquals(header.isRetain(), expectedProperties.get(RETAINED)); } catch (Throwable t) { collector.addError(t); } return true; }
collector.addError(new Throwable("Exceptional edge deleted, but no instruction as cause. - No last instruction."));