Java Examples for junit.framework.AssertionFailedError
The following java examples will help you to understand the usage of junit.framework.AssertionFailedError. These source code samples are taken from different open source projects.
Example 1
Project: crezoo-master File: PerfService_ServiceTestCase.java View source code |
public void test1PerfPortHandleStringArray() throws Exception {
samples.perf.PerfPortSoapBindingStub binding;
try {
binding = (samples.perf.PerfPortSoapBindingStub) new samples.perf.PerfService_ServiceLocator().getPerfPort();
} catch (javax.xml.rpc.ServiceException jre) {
if (jre.getLinkedCause() != null)
jre.getLinkedCause().printStackTrace();
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
assertNotNull("binding is null", binding);
// Time out after a minute
binding.setTimeout(60000);
binding._setProperty(org.apache.axis.client.Call.STREAMING_PROPERTY, Boolean.TRUE);
// Time out after a minute
binding.setTimeout(60000);
log.info(">>>> Warming up...");
pump(binding, 1);
log.info(">>>> Running volume tests...");
pump(binding, 100);
pump(binding, 1000);
pump(binding, 10000);
pump(binding, 100000);
}
Example 2
Project: ps-scripts-master File: PerfService_ServiceTestCase.java View source code |
public void test1PerfPortHandleStringArray() throws Exception {
samples.perf.PerfPortSoapBindingStub binding;
try {
binding = (samples.perf.PerfPortSoapBindingStub) new samples.perf.PerfService_ServiceLocator().getPerfPort();
} catch (javax.xml.rpc.ServiceException jre) {
if (jre.getLinkedCause() != null)
jre.getLinkedCause().printStackTrace();
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
assertNotNull("binding is null", binding);
// Time out after a minute
binding.setTimeout(60000);
binding._setProperty(org.apache.axis.client.Call.STREAMING_PROPERTY, Boolean.TRUE);
// Time out after a minute
binding.setTimeout(60000);
log.info(">>>> Warming up...");
pump(binding, 1);
log.info(">>>> Running volume tests...");
pump(binding, 100);
pump(binding, 1000);
pump(binding, 10000);
pump(binding, 100000);
}
Example 3
Project: mut4j-master File: TestOdbcService.java View source code |
public void testSanity() { try { ResultSet rs = netConn.createStatement().executeQuery("SELECT count(*) FROM nullmix"); if (!rs.next()) { throw new RuntimeException("The most basic query failed. " + "No row count from 'nullmix'."); } assertEquals("Sanity check failed. Rowcount of 'nullmix'", 6, rs.getInt(1)); rs.close(); } catch (SQLException se) { junit.framework.AssertionFailedError ase = new junit.framework.AssertionFailedError("The most basic query failed"); ase.initCause(se); throw ase; } }
Example 4
Project: ipf-labs-master File: PdfExportRpcServiceTestCase.java View source code |
@Test public void test1pdfexportExportSpace() throws Exception { org.openehealth.ipf.labs.maven.confluence.export.pdf.PdfexportSoapBindingStub binding; try { binding = (org.openehealth.ipf.labs.maven.confluence.export.pdf.PdfexportSoapBindingStub) new org.openehealth.ipf.labs.maven.confluence.export.pdf.PdfExportRpcServiceLocator().getpdfexport(); } catch (javax.xml.rpc.ServiceException jre) { if (jre.getLinkedCause() != null) jre.getLinkedCause().printStackTrace(); throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertNotNull("binding is null", binding); // Time out after a minute binding.setTimeout(60000); // Test operation try { java.lang.String value = null; value = binding.exportSpace(new java.lang.String(), new java.lang.String()); } catch (org.openehealth.ipf.labs.maven.confluence.export.pdf.RemoteException e1) { throw new junit.framework.AssertionFailedError("RemoteException Exception caught: " + e1); } // TBD - validate results }
Example 5
Project: android-15-master File: AnimatorSetEventsTest.java View source code |
@Override
public void run() {
try {
Handler handler = new Handler();
animSet.addListener(mFutureListener);
mRunning = true;
animSet.start();
handler.postDelayed(new Canceler(animSet, mFuture), ANIM_DURATION + 250);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
Example 6
Project: android-sync-master File: ExpectFetchSinceDelegate.java View source code |
@Override public void onFetchCompleted(final long fetchEnd) { AssertionFailedError err = null; try { int countSpecials = 0; for (Record record : records) { // Check if record should be ignored. if (!ignore.contains(record.guid)) { assertFalse(-1 == Arrays.binarySearch(this.expected, record.guid)); } else { countSpecials++; } // Check that record is later than timestamp-earliest. assertTrue(record.lastModified >= this.earliest); } assertEquals(this.expected.length, records.size() - countSpecials); } catch (AssertionFailedError e) { err = e; } performNotify(err); }
Example 7
Project: bnd-master File: BndTestCase.java View source code |
protected static void assertOk(Reporter reporter, int errors, int warnings) throws AssertionFailedError { try { assertEquals(errors, reporter.getErrors().size()); assertEquals(warnings, reporter.getWarnings().size()); } catch (AssertionFailedError t) { print("Errors", reporter.getErrors()); print("Warnings", reporter.getWarnings()); throw t; } }
Example 8
Project: floodlight-master File: FutureTestUtils.java View source code |
@SuppressWarnings("unchecked")
public static <T extends Exception> T assertFutureFailedWithException(Future<?> future, Class<T> clazz) throws InterruptedException {
assertThat("Future should be complete ", future.isDone(), equalTo(true));
try {
future.get();
throw new AssertionFailedError("Expected ExecutionExcepion");
} catch (ExecutionException e) {
assertThat(e.getCause(), instanceOf(clazz));
return (T) e.getCause();
}
}
Example 9
Project: frameworks_base_disabled-master File: ViewPropertyAnimatorTest.java View source code |
/**
* Verify that calling cancel on a started animator does the right thing.
*/
@UiThreadTest
@SmallTest
public void testStartCancel() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
mRunning = true;
mAnimator.start();
mAnimator.cancel();
mFuture.release();
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Example 10
Project: jtwig-master File: MatcherUtils.java View source code |
public static <T> Matcher<? extends T> theSame(final T input) {
return new BaseMatcher<T>() {
@Override
public boolean matches(Object item) {
try {
ReflectionAssert.assertReflectionEquals(item, input);
return true;
} catch (AssertionFailedError e) {
return false;
}
}
@Override
public void describeTo(Description description) {
description.appendValue(ToStringBuilder.reflectionToString(input));
}
@Override
public void describeMismatch(Object item, Description description) {
description.appendValue(ToStringBuilder.reflectionToString(item));
}
};
}
Example 11
Project: junit-master File: AssertTest.java View source code |
public void testAssertNotSame() {
assertNotSame(new Integer(1), null);
assertNotSame(null, new Integer(1));
assertNotSame(new Integer(1), new Integer(1));
try {
Integer obj = new Integer(1);
assertNotSame(obj, obj);
} catch (AssertionFailedError e) {
return;
}
fail();
}
Example 12
Project: junit4-master File: AssertTest.java View source code |
public void testAssertNotSame() {
assertNotSame(new Integer(1), null);
assertNotSame(null, new Integer(1));
assertNotSame(new Integer(1), new Integer(1));
try {
Integer obj = new Integer(1);
assertNotSame(obj, obj);
} catch (AssertionFailedError e) {
return;
}
fail();
}
Example 13
Project: property-db-master File: ViewPropertyAnimatorTest.java View source code |
/**
* Verify that calling cancel on a started animator does the right thing.
*/
@UiThreadTest
@SmallTest
public void testStartCancel() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
mRunning = true;
mAnimator.start();
mAnimator.cancel();
mFuture.release();
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Example 14
Project: RoboBuggy-master File: AssertTest.java View source code |
public void testAssertNotSame() {
assertNotSame(new Integer(1), null);
assertNotSame(null, new Integer(1));
assertNotSame(new Integer(1), new Integer(1));
try {
Integer obj = new Integer(1);
assertNotSame(obj, obj);
} catch (AssertionFailedError e) {
return;
}
fail();
}
Example 15
Project: sosies-generator-master File: AssertTest.java View source code |
public void testAssertNotSame() {
assertNotSame(new Integer(1), null);
assertNotSame(null, new Integer(1));
assertNotSame(new Integer(1), new Integer(1));
try {
Integer obj = new Integer(1);
assertNotSame(obj, obj);
} catch (AssertionFailedError e) {
return;
}
fail();
}
Example 16
Project: android-sdk-sources-for-api-level-23-master File: UiAutomatorInstrumentationTestRunner.java View source code |
@Override
protected AndroidTestRunner getAndroidTestRunner() {
AndroidTestRunner testRunner = super.getAndroidTestRunner();
testRunner.addTestListener(new TestListener() {
@Override
public void startTest(Test test) {
if (test instanceof UiAutomatorTestCase) {
((UiAutomatorTestCase) test).initialize(getArguments());
}
}
@Override
public void endTest(Test test) {
}
@Override
public void addFailure(Test test, AssertionFailedError e) {
}
@Override
public void addError(Test test, Throwable t) {
}
});
return testRunner;
}
Example 17
Project: android_frameworks_base-master File: AnimatorSetEventsTest.java View source code |
@Override
public void run() {
try {
Handler handler = new Handler();
animSet.addListener(mFutureListener);
mRunning = true;
animSet.start();
handler.postDelayed(new Canceler(animSet, mFuture), ANIM_DURATION + 250);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
Example 18
Project: platform_frameworks_base-master File: ViewPropertyAnimatorTest.java View source code |
/**
* Verify that calling cancel on a started animator does the right thing.
*/
@UiThreadTest
@SmallTest
public void testStartCancel() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
mRunning = true;
mAnimator.start();
mAnimator.cancel();
mFuture.release();
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Example 19
Project: damp.ekeko.snippets-master File: StackFilterTest.java View source code |
protected void setUp() { StringWriter swin = new StringWriter(); PrintWriter pwin = new PrintWriter(swin); pwin.println("junit.framework.AssertionFailedError"); pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); pwin.println(" at MyTest.f(MyTest.java:13)"); pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); fUnfiltered = swin.toString(); StringWriter swout = new StringWriter(); PrintWriter pwout = new PrintWriter(swout); pwout.println("junit.framework.AssertionFailedError"); pwout.println(" at MyTest.f(MyTest.java:13)"); pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); fFiltered = swout.toString(); }
Example 20
Project: rngzip-master File: StackFilterTest.java View source code |
@Override protected void setUp() { StringWriter swin = new StringWriter(); PrintWriter pwin = new PrintWriter(swin); pwin.println("junit.framework.AssertionFailedError"); pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); pwin.println(" at MyTest.f(MyTest.java:13)"); pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); fUnfiltered = swin.toString(); StringWriter swout = new StringWriter(); PrintWriter pwout = new PrintWriter(swout); pwout.println("junit.framework.AssertionFailedError"); pwout.println(" at MyTest.f(MyTest.java:13)"); pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); fFiltered = swout.toString(); }
Example 21
Project: zinara-master File: StackFilterTest.java View source code |
protected void setUp() { StringWriter swin = new StringWriter(); PrintWriter pwin = new PrintWriter(swin); pwin.println("junit.framework.AssertionFailedError"); pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); pwin.println(" at MyTest.f(MyTest.java:13)"); pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); fUnfiltered = swin.toString(); StringWriter swout = new StringWriter(); PrintWriter pwout = new PrintWriter(swout); pwout.println("junit.framework.AssertionFailedError"); pwout.println(" at MyTest.f(MyTest.java:13)"); pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); fFiltered = swout.toString(); }
Example 22
Project: kfs-master File: MockService.java View source code |
/** * Returns the result associated with the given method and list of arguments. If there is no mock method, invokes the given * method on the noMethodFallback Object. If the noMethodFallback Object is null, throws a * {@link junit.framework.AssertionFailedError}. * * @see java.lang.reflect.InvocationHandler#invoke */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (nameToMockMethodMap.containsKey(name)) { MockMethod m = nameToMockMethodMap.get(name); return m.invoke(proxy, method, args); } if (noMethodFallback == null) { throw new AssertionFailedError("no mock method " + name); } return method.invoke(noMethodFallback, args); }
Example 23
Project: XPagesExtensionLibrary-master File: SkipFileParser.java View source code |
private void updateContent(SkipFileContent content, boolean inChunk, int startChunk, boolean inTrace, int startTrace, int index, String[] lines) { if (inChunk && inTrace) { // Look for a line like: // junit.framework.AssertionFailedError: 4 fail(s). : int beginFailsIndex = -1; for (int i = startChunk; i < startTrace; i++) { String line = lines[i]; if (line.startsWith("junit.framework.AssertionFailedError: ") && line.endsWith(" fail(s). :")) { beginFailsIndex = i + 1; break; } } if (-1 == beginFailsIndex) { // no line with " fails(s). :" return; } String[] fails = new String[startTrace - beginFailsIndex]; System.arraycopy(lines, beginFailsIndex, fails, 0, fails.length); // Lines in the range [startChunk, beginFailsIndex] will be like: // //~ IncubatorTestSuite //xsp.extlibinc.test.IncubatorTestSuite //com.ibm.xsp.test.framework.registry.BaseComponentTypeTest //testComponentType(com.ibm.xsp.test.framework.registry.BaseComponentTypeTest) //junit.framework.AssertionFailedError: 1 fail(s). : // counting from the end of that range backwards: //String failsLine = lines[beginFailsIndex-1]; String methodLine = lines[beginFailsIndex - 2]; String testClassLine = lines[beginFailsIndex - 3]; //testComponentType(com.ibm.xsp.test.framework.registry.BaseComponentTypeTest) String methodName = methodLine.substring(0, methodLine.indexOf('(')); content.addSkips(testClassLine, methodName, fails); } }
Example 24
Project: blazegraph-master File: AbstractParserTestCase.java View source code |
/** * Used to verify that the header corresponds to our expectations. Logs * errors when the expectations are not met. * * @param header * The header line. * @param fields * The fields parsed from that header. * @param field * The field number in [0:#fields-1]. * @param expected * The expected value of the header for that field. */ protected static void assertField(final String header, final String[] fields, final int field, final String expected) { if (header == null) throw new IllegalArgumentException(); if (fields == null) throw new IllegalArgumentException(); if (expected == null) throw new IllegalArgumentException(); if (field < 0) throw new IllegalArgumentException(); if (field >= fields.length) throw new AssertionFailedError("There are only " + fields.length + " fields, but field=" + field + "\n" + header); if (!expected.equals(fields[field])) { throw new AssertionFailedError("Expected field=" + field + " to be [" + expected + "], actual=" + fields[field] + "\n" + header); } }
Example 25
Project: database-master File: AbstractParserTestCase.java View source code |
/** * Used to verify that the header corresponds to our expectations. Logs * errors when the expectations are not met. * * @param header * The header line. * @param fields * The fields parsed from that header. * @param field * The field number in [0:#fields-1]. * @param expected * The expected value of the header for that field. */ protected static void assertField(final String header, final String[] fields, final int field, final String expected) { if (header == null) throw new IllegalArgumentException(); if (fields == null) throw new IllegalArgumentException(); if (expected == null) throw new IllegalArgumentException(); if (field < 0) throw new IllegalArgumentException(); if (field >= fields.length) throw new AssertionFailedError("There are only " + fields.length + " fields, but field=" + field + "\n" + header); if (!expected.equals(fields[field])) { throw new AssertionFailedError("Expected field=" + field + " to be [" + expected + "], actual=" + fields[field] + "\n" + header); } }
Example 26
Project: freehep-io-master File: XMLSequenceTest.java View source code |
/**
* Test XMLSequence reading using XML Parsers.
*
* @throws Exception
* if something goes wrong
*/
public void testXMLSequence() throws Exception {
File testFile = new File(testDir, "XMLSequence.txt");
XMLSequence sequence = new XMLSequence(new BufferedInputStream(new FileInputStream(testFile)));
if (!sequence.markSupported()) {
throw new AssertionFailedError("Mark is not supported for XMLSequence");
}
sequence.mark((int) testFile.length() + 1);
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
XMLReader xmlReader = factory.newSAXParser().getXMLReader();
int i = 0;
while (sequence.hasNext()) {
InputStream input = sequence.next();
InputSource source = new InputSource(input);
xmlReader.parse(source);
input.close();
i++;
}
sequence.reset();
i = 0;
while (sequence.hasNext()) {
InputStream input = sequence.next();
InputSource source = new InputSource(input);
xmlReader.parse(source);
input.close();
i++;
}
sequence.close();
}
Example 27
Project: freehep-ncolor-pdf-master File: XMLSequenceTest.java View source code |
/**
* Test XMLSequence reading using XML Parsers.
*
* @throws Exception if something goes wrong
*/
public void testXMLSequence() throws Exception {
File testFile = new File(testDir, "XMLSequence.txt");
XMLSequence sequence = new XMLSequence(new BufferedInputStream(new FileInputStream(testFile)));
if (!sequence.markSupported())
throw new AssertionFailedError("Mark is not supported for XMLSequence");
sequence.mark((int) testFile.length() + 1);
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
XMLReader xmlReader = factory.newSAXParser().getXMLReader();
int i = 0;
while (sequence.hasNext()) {
InputStream input = sequence.next();
InputSource source = new InputSource(input);
xmlReader.parse(source);
input.close();
i++;
}
sequence.reset();
i = 0;
while (sequence.hasNext()) {
InputStream input = sequence.next();
InputSource source = new InputSource(input);
xmlReader.parse(source);
input.close();
i++;
}
sequence.close();
}
Example 28
Project: is.idega.idegaweb.egov.bpm-master File: SendMessageMockupImpl.java View source code |
public void send(MessageValueContext mvCtx, final Object context, final ProcessInstance pi, final LocalizedMessages msgs, final Token tkn) { if (!"english message".equals(msgs.getLocalizedMessage(new Locale("en")))) throw new AssertionFailedError(); if (!"icelandic message".equals(msgs.getLocalizedMessage(new Locale("is", "IS")))) throw new AssertionFailedError(); if (!"english subject".equals(msgs.getLocalizedSubject(new Locale("en")))) throw new AssertionFailedError(); if (!"icelandic subject".equals(msgs.getLocalizedSubject(new Locale("is", "IS")))) throw new AssertionFailedError(); }
Example 29
Project: jndikit-master File: AbstractRMIContextTestCase.java View source code |
public void testGetNameInNamespace() throws AssertionFailedError { try { Context sub1 = m_root.createSubcontext("sub1"); Context sub2 = sub1.createSubcontext("sub2"); Context sub3 = sub2.createSubcontext("sub3"); Context sub4 = sub3.createSubcontext("sub4"); assertEquals("sub1/sub2/sub3/sub4", sub4.getNameInNamespace()); } catch (final NamingException ne) { throw new AssertionFailedError(ne.getMessage()); } }
Example 30
Project: keycloak-dropwizard-integration-master File: LoginPage.java View source code |
public T login(String login, String password) throws IOException, ReflectiveOperationException {
HtmlForm form = page.getForms().stream().filter( f -> f.getId().equals("kc-form-login")).findFirst().orElseThrow(() -> new AssertionFailedError("unable to find keycloak form"));
form.getInputByName("username").setValueAttribute(login);
form.getInputByName("password").setValueAttribute(password);
HtmlPage afterLogin = form.getInputByName("login").click();
return (T) clazz.getConstructor(HtmlPage.class).newInstance(afterLogin);
}
Example 31
Project: linkbench-master File: TestStats.java View source code |
@Test
public void testBucketing() {
// 0 microseconds until 100 seconds
for (long us = 0; us < 100 * 1000 * 1000; us += 100) {
int bucket = LatencyStats.latencyToBucket(us);
try {
assertTrue(bucket >= 0);
assertTrue(bucket < LatencyStats.NUM_BUCKETS);
long range[] = LatencyStats.bucketBound(bucket);
assertTrue(us >= range[0]);
assertTrue(us < range[1]);
} catch (AssertionFailedError e) {
System.err.println("Failed for " + us + "us, bucket=" + bucket);
throw e;
}
}
}
Example 32
Project: mayfly-master File: A.java View source code |
public static void assertEquals(Object expected, Object actual) {
try {
Assert.assertEquals(expected, actual);
} catch (AssertionFailedError err) {
if (!String.valueOf(expected).equals(String.valueOf(actual))) {
Assert.assertEquals(String.valueOf(expected), String.valueOf(actual));
} else {
throw err;
}
}
}
Example 33
Project: mvn-dev-proxy-master File: SocketRule.java View source code |
@Override
public Statement apply(final Statement statement, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
statement.evaluate();
if (!checkProvidedPorts()) {
throw new AssertionFailedError("All ports have not been released");
}
}
};
}
Example 34
Project: org.eclipse.ecr-master File: RuntimeInitializationTest.java View source code |
// Deactivated for now since duplicate contributions are still allowed.
public void XXXtestContributionsWithDuplicateComponent() throws Exception {
deployContrib("org.eclipse.ecr.runtime.test", "MyComp1.xml");
deployContrib("org.eclipse.ecr.runtime.test", "MyComp2.xml");
boolean success = false;
try {
deployContrib("org.eclipse.ecr.runtime.test", "CopyOfMyComp2.xml");
success = true;
} catch (AssertionFailedError e) {
}
assertFalse("An exception should have been raised.", success);
}
Example 35
Project: rendersnake-master File: PersonUITest.java View source code |
public void testPageRenderWithError() throws IOException {
HtmlCanvas html = new HtmlCanvas();
html.tag("bogus");
html.render(new PersonalPage());
Tidy tidy = new Tidy();
tidy.setMessageListener(new TidyMessageCheck());
tidy.setXHTML(true);
tidy.setDocType("loose");
try {
tidy.parse(new ByteArrayInputStream(html.toHtml().getBytes()), System.out);
} catch (AssertionFailedError err) {
System.out.println(err);
}
}
Example 36
Project: seasar2-master File: ExceptionAssert.java View source code |
/**
* @param th
*/
public static void assertMessageExist(Throwable th) {
String message = th.getMessage();
try {
Assert.assertNotNull("Throwable should have message", message);
Assert.assertTrue("Throwable should have message", message.trim().length() > 0);
} catch (AssertionFailedError afe) {
th.printStackTrace();
throw afe;
}
}
Example 37
Project: jain-sip-master File: JunkAtEndOfMessageTest.java View source code |
public void testMessageSyntax() {
MessageFactoryImpl messageFactory = new MessageFactoryImpl();
try {
Request request = messageFactory.createRequest("BYE sip:127.0.0.1:5080;transport=tcp SIP/2.0\r\n" + "Via: SIP/2.0/TCP 127.0.0.1:5060;rport=5060;branch=z9hG4bKd2c87858eb0a7a09becc7a115c608d27\r\n" + "CSeq: 2 BYE\r\n" + "Call-ID: 84a5c57fd263bcce6fec05edf20c5aba@127.0.0.1\r\n" + "From: \"The Master Blaster\" <sip:BigGuy@here.com>;tag=12345\r\n" + "To: \"The Little Blister\" <sip:LittleGuy@there.com>;tag=2955\r\n" + "Max-Forwards: 70\r\n" + "Route: \"proxy\" <sip:proxy@127.0.0.1:5070;transport=tcp;lr>\r\n" + "Content-Length: 0\r\n" + // the space here is invalid
" \r\n");
fail("Should throw an exception");
} catch (junit.framework.AssertionFailedError afe) {
fail("Should throw exception ");
} catch (ParseException ex) {
System.out.println("Got expected error");
} catch (Throwable t) {
t.printStackTrace();
fail("Should throw a ParseException");
} finally {
System.out.println("testMessageSyntax()");
}
}
Example 38
Project: jsip-master File: JunkAtEndOfMessageTest.java View source code |
public void testMessageSyntax() {
MessageFactoryImpl messageFactory = new MessageFactoryImpl();
try {
Request request = messageFactory.createRequest("BYE sip:127.0.0.1:5080;transport=tcp SIP/2.0\r\n" + "Via: SIP/2.0/TCP 127.0.0.1:5060;rport=5060;branch=z9hG4bKd2c87858eb0a7a09becc7a115c608d27\r\n" + "CSeq: 2 BYE\r\n" + "Call-ID: 84a5c57fd263bcce6fec05edf20c5aba@127.0.0.1\r\n" + "From: \"The Master Blaster\" <sip:BigGuy@here.com>;tag=12345\r\n" + "To: \"The Little Blister\" <sip:LittleGuy@there.com>;tag=2955\r\n" + "Max-Forwards: 70\r\n" + "Route: \"proxy\" <sip:proxy@127.0.0.1:5070;transport=tcp;lr>\r\n" + "Content-Length: 0\r\n" + // the space here is invalid
" \r\n");
fail("Should throw an exception");
} catch (junit.framework.AssertionFailedError afe) {
fail("Should throw exception ");
} catch (ParseException ex) {
System.out.println("Got expected error");
} catch (Throwable t) {
t.printStackTrace();
fail("Should throw a ParseException");
} finally {
System.out.println("testMessageSyntax()");
}
}
Example 39
Project: assertj-swing-master File: XmlJUnitResultFormatter_addFailure_Test.java View source code |
@Test
public void should_Write_Test_Execution_When_Test_Fails() {
startSuite();
junit.framework.Test test = mockTest();
AssertionFailedError error = errorOrFailure();
formatter.addFailure(test, error);
XmlNode root = root();
assertThatTestCaseNodeWasAddedTo(root, test);
XmlNode failureNode = firstTestCaseNodeIn(root).child(0);
assertThat(failureNode.name()).isEqualTo("failure");
assertThatErrorOrFailureWasWrittenTo(failureNode);
assertThat(formatter.onFailureOrErrorMethod).wasCalledPassing(test, error, failureNode);
}
Example 40
Project: fest-swing-1.x-master File: XmlJUnitResultFormatter_addFailure_Test.java View source code |
@Test
public void should_write_test_execution_when_test_fails() {
startSuite();
junit.framework.Test test = mockTest();
AssertionFailedError error = errorOrFailure();
formatter.addFailure(test, error);
XmlNode root = root();
assertThatTestCaseNodeWasAddedTo(root);
XmlNode failureNode = firstTestCaseNodeIn(root).child(0);
assertThat(failureNode.name()).isEqualTo("failure");
assertThatErrorOrFailureWasWrittenTo(failureNode);
assertThat(formatter.onFailureOrErrorMethod).wasCalledPassing(test, error, failureNode);
}
Example 41
Project: gocd-master File: AntJUnitReportRDFizerTest.java View source code |
@Test public void testLoadingFailingJUnit() throws Exception { String failingTestXML = "<?xml version='1.0' encoding='UTF-8' ?>" + "<testsuite errors='1' failures='1' hostname='fake-host-name' name='com.example.TheTest' tests='1' time='1.058' timestamp='2009-12-25T00:34:36'>" + "<testcase classname='com.example.TheTest' name='testSomething' time='0.011'>" + "<failure message='foo' type='junit.framework.AssertionFailedError'>junit.framework.AssertionFailedError: foo" + "\tat com.example.TheTest.testSomething(TheTest.java:96)" + "</failure>" + "</testcase>" + "</testsuite>"; AntJUnitReportRDFizer junitRDFizer = new AntJUnitReportRDFizer(new InMemoryTempGraphFactory(), XSLTTransformerRegistry); Graph graph = junitRDFizer.importFile("http://job", document(failingTestXML)); String ask = "prefix cruise: <" + GoOntology.URI + "> " + "PREFIX xunit: <" + XUnitOntology.URI + "> " + "prefix xsd: <http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE { " + "<http://job> xunit:hasTestCase _:testCase . " + "_:testCase a xunit:TestCase . " + "_:testCase xunit:testSuiteName 'com.example.TheTest'^^xsd:string . " + "_:testCase xunit:testCaseName 'testSomething'^^xsd:string . " + "_:testCase xunit:hasFailure _:failure . " + "_:failure xunit:isError 'false'^^xsd:boolean " + "}"; assertAskIsTrue(graph, ask); }
Example 42
Project: gwt-master File: JUnitResult.java View source code |
/** * Returns best effort type info by checking against some common exceptions for unit tests. */ private static void improveDesignatedType(SerializableThrowable t, Throwable designatedType) { if (designatedType instanceof AssertionFailedError) { String className = "junit.framework.AssertionFailedError"; t.setDesignatedType(className, AssertionFailedError.class == designatedType.getClass()); } else if (designatedType instanceof TimeoutException) { String className = "com.google.gwt.junit.client.TimeoutException"; t.setDesignatedType(className, TimeoutException.class == designatedType.getClass()); } }
Example 43
Project: gwt-sandbox-master File: JUnitResult.java View source code |
/** * Returns best effort type info by checking against some common exceptions for unit tests. */ private static void improveDesignatedType(SerializableThrowable t, Throwable designatedType) { if (designatedType instanceof AssertionFailedError) { String className = "junit.framework.AssertionFailedError"; t.setDesignatedType(className, AssertionFailedError.class == designatedType.getClass()); } else if (designatedType instanceof TimeoutException) { String className = "com.google.gwt.junit.client.TimeoutException"; t.setDesignatedType(className, TimeoutException.class == designatedType.getClass()); } }
Example 44
Project: gwt.svn-master File: JUnitResult.java View source code |
/** * Returns best effort type info by checking against some common exceptions for unit tests. */ private static void improveDesignatedType(SerializableThrowable t, Throwable designatedType) { if (designatedType instanceof AssertionFailedError) { String className = "junit.framework.AssertionFailedError"; t.setDesignatedType(className, AssertionFailedError.class == designatedType.getClass()); } else if (designatedType instanceof TimeoutException) { String className = "com.google.gwt.junit.client.TimeoutException"; t.setDesignatedType(className, TimeoutException.class == designatedType.getClass()); } }
Example 45
Project: activemq-master File: JDBCPersistenceAdapterTest.java View source code |
public void testAuditOff() throws Exception {
pa.stop();
pa = createPersistenceAdapter(true);
((JDBCPersistenceAdapter) pa).setEnableAudit(false);
pa.start();
boolean failed = true;
try {
testStoreCanHandleDupMessages();
failed = false;
} catch (AssertionFailedError e) {
}
if (!failed) {
fail("Should have failed with audit turned off");
}
}
Example 46
Project: activiti-engine-5.12-master File: PvmTestCase.java View source code |
@Override
protected void runTest() throws Throwable {
if (log.isDebugEnabled()) {
if (isEmptyLinesEnabled) {
log.debug(EMPTY_LINE);
}
log.debug("#### START {}.{} ###########################################################", this.getClass().getSimpleName(), getName());
}
try {
super.runTest();
} catch (AssertionFailedError e) {
log.error(EMPTY_LINE);
log.error("ASSERTION FAILED: {}", e, e);
throw e;
} catch (Throwable e) {
log.error(EMPTY_LINE);
log.error("EXCEPTION: {}", e, e);
throw e;
} finally {
log.debug("#### END {}.{} #############################################################", this.getClass().getSimpleName(), getName());
}
}
Example 47
Project: Activiti-master File: PvmTestCase.java View source code |
@Override
protected void runTest() throws Throwable {
if (log.isDebugEnabled()) {
if (isEmptyLinesEnabled) {
log.debug(EMPTY_LINE);
}
log.debug("#### START {}.{} ###########################################################", this.getClass().getSimpleName(), getName());
}
try {
super.runTest();
} catch (AssertionFailedError e) {
log.error(EMPTY_LINE);
log.error("ASSERTION FAILED: {}", e, e);
throw e;
} catch (Throwable e) {
log.error(EMPTY_LINE);
log.error("EXCEPTION: {}", e, e);
throw e;
} finally {
log.debug("#### END {}.{} #############################################################", this.getClass().getSimpleName(), getName());
}
}
Example 48
Project: Asper-master File: StmtUpdateSendCallable.java View source code |
public Object call() throws Exception {
try {
log.info(".call Thread " + Thread.currentThread().getId() + " sending " + numRepeats + " events");
for (int loop = 0; loop < numRepeats; loop++) {
String id = Long.toString(threadNum * 100000000 + loop);
SupportBean bean = new SupportBean(id, 0);
engine.getEPRuntime().sendEvent(bean);
}
log.info(".call Thread " + Thread.currentThread().getId() + " completed.");
} catch (AssertionFailedError ex) {
log.fatal("Assertion error in thread " + Thread.currentThread().getId(), ex);
return false;
} catch (Throwable t) {
log.fatal("Error in thread " + Thread.currentThread().getId(), t);
return false;
}
return true;
}
Example 49
Project: atsd-api-java-master File: RerunRule.java View source code |
private Statement statement(final Statement base) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
for (int i = 0; i < RERUN_COUNT; i++) {
try {
base.evaluate();
return;
} catch (AtsdClientException ex) {
onError(i, ex);
} catch (AssertionFailedError ex) {
onError(i, ex);
}
}
}
};
}
Example 50
Project: Canoo-WebTest-master File: ThrowAssert.java View source code |
public static void assertPasses(String message, TestBlock block) { try { block.call(); } catch (Throwable t) { String fullMessage = appendPrefix(message) + "should not have raised exception " + t.getClass().getName(); AssertionFailedError junitError = new AssertionFailedError(fullMessage); junitError.setStackTrace(t.getStackTrace()); throw junitError; } }
Example 51
Project: cdo-master File: TestListener.java View source code |
@SuppressWarnings("unchecked")
@Override
protected boolean successful() {
synchronized (events) {
for (int i = nextAssertion; i < events.size(); i++) {
IEvent event = events.get(i);
System.out.println(event);
++nextAssertion;
if (eventType.isAssignableFrom(event.getClass())) {
try {
assertion.execute((T) event);
return true;
} catch (AssertionFailedError ignore) {
}
}
}
}
return false;
}
Example 52
Project: cdt-master File: FailingTest.java View source code |
/* (non-Javadoc) * @see junit.framework.Test#run(junit.framework.TestResult) */ @Override public void run(TestResult result) { result.startTest(this); TestResult r = new TestResult(); test.run(r); if (r.failureCount() == 1) { TestFailure failure = r.failures().nextElement(); String msg = failure.exceptionMessage(); if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) { result.addFailure(this, new AssertionFailedError(msg)); } } else if (r.errorCount() == 0 && r.failureCount() == 0) { //$NON-NLS-1$ String err = "Unexpected success"; if (bugNum != -1) //$NON-NLS-1$ err += ", bug #" + bugNum; result.addFailure(this, new AssertionFailedError(err)); } result.endTest(this); }
Example 53
Project: cdt-tests-runner-master File: FailingTest.java View source code |
/* (non-Javadoc) * @see junit.framework.Test#run(junit.framework.TestResult) */ public void run(TestResult result) { result.startTest(this); TestResult r = new TestResult(); test.run(r); if (r.failureCount() == 1) { TestFailure failure = r.failures().nextElement(); String msg = failure.exceptionMessage(); if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) { result.addFailure(this, new AssertionFailedError(msg)); } } else if (r.errorCount() == 0 && r.failureCount() == 0) { //$NON-NLS-1$ String err = "Unexpected success"; if (bugNum != -1) //$NON-NLS-1$ err += ", bug #" + bugNum; result.addFailure(this, new AssertionFailedError(err)); } result.endTest(this); }
Example 54
Project: clearskies-ruboto-master File: ActivityTest.java View source code |
public void runTest() throws Exception { try { Log.i(getClass().getName(), "runTest: " + getName()); final Activity activity = getActivity(); Log.i(getClass().getName(), "Activity OK"); Runnable testRunnable = new Runnable() { public void run() { if (setup != null) { Log.i(getClass().getName(), "calling setup"); JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(setup, "call", activity); Log.i(getClass().getName(), "setup ok"); } JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(block, "call", activity); if (teardown != null) { Log.i(getClass().getName(), "calling teardown"); JRubyAdapter.runRubyMethod(teardown, "call", activity); Log.i(getClass().getName(), "teardown ok"); } } }; if (onUiThread) { runTestOnUiThread(testRunnable); } else { testRunnable.run(); } Log.i(getClass().getName(), "runTest ok"); } catch (Throwable t) { AssertionFailedError afe = new AssertionFailedError("Exception running test."); afe.initCause(t); throw afe; } }
Example 55
Project: ComplexEventProcessingPlatform-master File: WeatherImporterTest.java View source code |
@Test
public void testDeletesOldFiles() throws IOException, XMLParsingException {
File testFile = new File(System.getProperty("user.dir") + "/bin/weatherXML/testFile.xml");
testFile.createNewFile();
System.out.println(testFile.getAbsolutePath());
File downloadFolder = new File(System.getProperty("user.dir") + "/bin/weatherXML/");
boolean fileExist = false;
for (File fileInDLFolder : downloadFolder.listFiles()) {
if (fileInDLFolder.getName().equals("testFile.xml"))
fileExist = true;
}
assertTrue("testfile was not correctly created", fileExist);
weatherImporter.getNewWeatherEvents();
for (File fileInDLFolder : downloadFolder.listFiles()) {
if (fileInDLFolder.getName().equals("testFile.xml"))
throw new AssertionFailedError("file was not deleted");
}
}
Example 56
Project: dltk.javascript-master File: AbstractContentAssistTest.java View source code |
public static int lastPositionInFile(String string, IModuleSource source, boolean after) {
int position = source.getSourceContents().lastIndexOf(string);
if (position >= 0) {
if (after) {
position += string.length();
}
return position;
} else {
throw new AssertionFailedError(NLS.bind("Pattern \"{0}\" not found in {1}", string, source.getFileName()));
}
}
Example 57
Project: elements-of-programming-interviews-master File: AssertUtils.java View source code |
public static void assertSameListPosting(PostingListNode<Integer> expected, PostingListNode<Integer> result) {
PostingListNode<Integer> given = expected;
PostingListNode<Integer> transformed = result;
try {
while (expected != null) {
Assert.assertEquals(expected.data, result.data);
expected = expected.next;
result = result.next;
}
assertNull(result);
} catch (AssertionFailedError e) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("\nExpected: " + given.toString() + "\n");
if (transformed != null && transformed.data != null)
errorMessage.append("Actual: " + transformed.toString() + "\n");
else
errorMessage.append("Actual: null\n");
Assert.fail(errorMessage.toString());
}
}
Example 58
Project: erjang-master File: AbstractTestCaseWithoutErlangNodeAccess.java View source code |
/* (non-Javadoc)
* @see junit.framework.Test#run(junit.framework.TestResult)
*/
@Override
public void run(TestResult result) {
result.startTest(this);
try {
TestUtil.erl_compile(RUN_WRAPPER_HOME + File.separator + "run_wrapper.erl");
TestUtil.erl_compile(file.getAbsolutePath());
EObject expected = do_run(file, TestUtil.ERL_PRG);
EObject actual = do_run(file, TestUtil.get_ej());
Assert.assertEquals(expected, actual);
} catch (AssertionFailedError e) {
result.addFailure(this, e);
} catch (Throwable e) {
result.addError(this, e);
}
result.endTest(this);
}
Example 59
Project: errai-master File: SecurityContextInitializationTest.java View source code |
private void replaceUncaughtExceptionHandler() { final UncaughtExceptionHandler originalHandler = GWT.getUncaughtExceptionHandler(); GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void onUncaughtException(final Throwable e) { if (e instanceof AssertionFailedError) { originalHandler.onUncaughtException(e); } else { originalHandler.onUncaughtException(new AssertionFailedError("An error occurred during initialization: " + e)); } } }); }
Example 60
Project: esper-master File: StmtUpdateSendCallable.java View source code |
public Object call() throws Exception {
try {
log.info(".call Thread " + Thread.currentThread().getId() + " sending " + numRepeats + " events");
for (int loop = 0; loop < numRepeats; loop++) {
String id = Long.toString(threadNum * 100000000 + loop);
SupportBean bean = new SupportBean(id, 0);
engine.getEPRuntime().sendEvent(bean);
}
log.info(".call Thread " + Thread.currentThread().getId() + " completed.");
} catch (AssertionFailedError ex) {
log.error("Assertion error in thread " + Thread.currentThread().getId(), ex);
return false;
} catch (Throwable t) {
log.error("Error in thread " + Thread.currentThread().getId(), t);
return false;
}
return true;
}
Example 61
Project: funf-core-android-master File: TemperatureSensorProbeTest.java View source code |
public void testData() throws InterruptedException {
Bundle params = new Bundle();
params.putLong(Parameter.Builtin.DURATION.name, 10L);
params.putLong(Parameter.Builtin.PERIOD.name, 10L);
startProbe(params);
try {
Bundle data = getData(10);
fail("Should only fail if temperature probe is present on device.");
} catch (AssertionFailedError e) {
}
}
Example 62
Project: funf-v3-master File: TemperatureSensorProbeTest.java View source code |
public void testData() throws InterruptedException {
Bundle params = new Bundle();
params.putLong(Parameter.Builtin.DURATION.name, 10L);
params.putLong(Parameter.Builtin.PERIOD.name, 10L);
startProbe(params);
try {
Bundle data = getData(10);
fail("Should only fail if temperature probe is present on device.");
} catch (AssertionFailedError e) {
}
}
Example 63
Project: gluegen-master File: Jogamp01Suite.java View source code |
public static Test suite() throws Exception {
if (test == null) {
// Load Test object from the jar.
JarClassLoader loader = new JarClassLoader("");
Boot.setClassLoader(loader);
// loader.setVerbose(true);
loader.load(null);
test = loader.loadClass(MAIN_CLASS).newInstance();
}
TestSuite top = new TestSuite();
TestSuite suite = new TestSuite(MAIN_CLASS);
top.addTest(suite);
Method methods[] = test.getClass().getMethods();
for (final Method method : methods) {
if (method.getName().startsWith("test")) {
System.out.println("" + method);
suite.addTest(new TestCase() {
{
setName(method.getName());
}
@Override
public void run(TestResult result) {
// TODO Auto-generated method stub
result.startTest(this);
try {
Invoker.invoke(test, method.getName());
} catch (Exception x) {
x.printStackTrace();
result.addFailure(this, new AssertionFailedError(x.toString()));
}
result.endTest(this);
}
});
}
}
return suite;
}
Example 64
Project: guice-master File: SerializationTest.java View source code |
private CreationException createCreationException() {
try {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(List.class);
}
});
throw new AssertionFailedError();
} catch (CreationException e) {
return e;
}
}
Example 65
Project: hadaps-master File: TestFsShell.java View source code |
@Test
public void testConfWithInvalidFile() throws Throwable {
String[] args = new String[1];
args[0] = "--conf=invalidFile";
Throwable th = null;
try {
FsShell.main(args);
} catch (Exception e) {
th = e;
}
if (!(th instanceof RuntimeException)) {
throw new AssertionFailedError("Expected Runtime exception, got: " + th).initCause(th);
}
}
Example 66
Project: hadoop-on-lustre2-master File: TestFsShell.java View source code |
@Test
public void testConfWithInvalidFile() throws Throwable {
String[] args = new String[1];
args[0] = "--conf=invalidFile";
Throwable th = null;
try {
FsShell.main(args);
} catch (Exception e) {
th = e;
}
if (!(th instanceof RuntimeException)) {
throw new AssertionFailedError("Expected Runtime exception, got: " + th).initCause(th);
}
}
Example 67
Project: hermit-maven-master File: AbstractHermiTTest.java View source code |
@SuppressWarnings("all")
protected static <T> void assertContainsAll(Collection<T> actual, T... control) {
try {
assertEquals(control.length, actual.size());
for (int i = 0; i < control.length; i++) assertTrue(actual.contains(control[i]));
} catch (AssertionFailedError e) {
System.out.println("Control set (" + control.length + " elements):");
System.out.println("------------------------------------------");
for (T object : control) System.out.println(object.toString());
System.out.println("------------------------------------------");
System.out.println("Actual set (" + actual.size() + " elements):");
System.out.println("------------------------------------------");
for (Object object : actual) System.out.println(object.toString());
System.out.println("------------------------------------------");
System.out.flush();
throw e;
}
}
Example 68
Project: hermit-reasoner-master File: AbstractHermiTTest.java View source code |
@SuppressWarnings("all")
protected static <T> void assertContainsAll(Collection<T> actual, T... control) {
try {
assertEquals(control.length, actual.size());
for (int i = 0; i < control.length; i++) assertTrue(actual.contains(control[i]));
} catch (AssertionFailedError e) {
System.out.println("Control set (" + control.length + " elements):");
System.out.println("------------------------------------------");
for (T object : control) System.out.println(object.toString());
System.out.println("------------------------------------------");
System.out.println("Actual set (" + actual.size() + " elements):");
System.out.println("------------------------------------------");
for (Object object : actual) System.out.println(object.toString());
System.out.println("------------------------------------------");
System.out.flush();
throw e;
}
}
Example 69
Project: hops-master File: TestFsShell.java View source code |
@Test
public void testConfWithInvalidFile() throws Throwable {
String[] args = new String[1];
args[0] = "--conf=invalidFile";
Throwable th = null;
try {
FsShell.main(args);
} catch (Exception e) {
th = e;
}
if (!(th instanceof RuntimeException)) {
throw new AssertionFailedError("Expected Runtime exception, got: " + th).initCause(th);
}
}
Example 70
Project: ISBN-Reporter-master File: ActivityTest.java View source code |
public void runTest() throws Exception { try { Log.i(getClass().getName(), "runTest: " + getName()); final Activity activity = getActivity(); Log.i(getClass().getName(), "Activity OK"); Runnable testRunnable = new Runnable() { public void run() { if (setup != null) { Log.i(getClass().getName(), "calling setup"); JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(setup, "call", activity); Log.i(getClass().getName(), "setup ok"); } JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(block, "call", activity); if (teardown != null) { Log.i(getClass().getName(), "calling teardown"); JRubyAdapter.runRubyMethod(teardown, "call", activity); Log.i(getClass().getName(), "teardown ok"); } } }; if (onUiThread) { runTestOnUiThread(testRunnable); } else { testRunnable.run(); } Log.i(getClass().getName(), "runTest ok"); } catch (Throwable t) { AssertionFailedError afe = new AssertionFailedError("Exception running test."); afe.initCause(t); throw afe; } }
Example 71
Project: jagger-master File: BaseHttpResponseValidator.java View source code |
@Override
public boolean validate(JHttpQuery<String> query, JHttpEndpoint endpoint, JHttpResponse<T> result, long duration) {
boolean isValid;
try {
assertTrue("The response is not valid.", isValid(query, endpoint, result));
isValid = true;
} catch (AssertionFailedError e) {
isValid = false;
LOGGER.warn("{}'s query response content is not valid, due to [{}].", query.toString(), e.getMessage());
LOGGER.warn(String.format("------> Failed response:\n%s \n%s", endpoint.toString(), result.toString()));
}
return isValid;
}
Example 72
Project: jsfunit-master File: ManagedPropertyTestCase_JSFUNIT_34_TestCase.java View source code |
public void testDuplicateKeys() throws Exception {
String property = "<managed-property>" + " <property-name>map</property-name>" + " <map-entries>" + " <map-entry>" + " <key>duplicate</key>" + " <value>3</value>" + " </map-entry>" + " <map-entry>" + " <key>duplicate</key>" + " <value>4</value>" + " </map-entry>" + " </map-entries>" + "</managed-property>";
Node managedPropertyNode = createManagedPropertyNode(property, "map");
ManagedPropertyTestCase testCase = new ManagedPropertyTestCase("ManagedPropertyTestCase_JSFUNIT_34_TestCase", (String) Utilities.STUBBED_RESOURCEPATH.toArray()[0], "bean", "bean", "map", managedPropertyNode);
try {
testCase.testMapDuplicateKeys();
throw new RuntimeException("should have failed");
} catch (AssertionFailedError e) {
String msg = "Managed Bean 'bean' has a managed Map property with a duplicate key 'duplicate'";
assertEquals(msg, e.getMessage());
}
}
Example 73
Project: jsptest-fork-master File: TestHtmlTestCaseFormAssertions.java View source code |
public void testUnnamedFormShouldHaveButton() throws Exception {
testcase.form().shouldHaveSubmitButton();
testcase.form().shouldHaveSubmitButton("submit_value");
testcase.form().shouldHaveSubmitButton("submit_name");
try {
testcase.form().shouldHaveSubmitButton("nosuchbutton");
throw new RuntimeException("Test should've failed");
} catch (AssertionFailedError expected) {
}
}
Example 74
Project: jsptest-master File: TestHtmlTestCaseFormAssertions.java View source code |
public void testUnnamedFormShouldHaveButton() throws Exception {
testcase.form().shouldHaveSubmitButton();
testcase.form().shouldHaveSubmitButton("submit_value");
testcase.form().shouldHaveSubmitButton("submit_name");
try {
testcase.form().shouldHaveSubmitButton("nosuchbutton");
throw new RuntimeException("Test should've failed");
} catch (AssertionFailedError expected) {
}
}
Example 75
Project: LeanEngine-Android-master File: BroadcastingTestListener.java View source code |
@Override
public void addFailure(Test test, AssertionFailedError assertionFailedError) {
TestCase testCase = (TestCase) test;
Intent intent = new Intent(action);
intent.putExtra("event", "failure");
intent.putExtra("test", test.getClass().getSimpleName() + " " + testCase.getName());
intent.putExtra("assertion", assertionFailedError.getMessage());
context.sendBroadcast(intent);
}
Example 76
Project: maven-surefire-master File: TestSuiteXmlParserTest.java View source code |
@Test public void testParse() throws Exception { TestSuiteXmlParser testSuiteXmlParser = new TestSuiteXmlParser(consoleLogger); String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<testsuite failures=\"4\" time=\"0.005\" errors=\"0\" skipped=\"0\" tests=\"4\" name=\"wellFormedXmlFailures.TestSurefire3\">\n" + " <properties>\n" + " <property name=\"java.runtime.name\" value=\"Java(TM) SE Runtime Environment\"/>\n" + " <property name=\"sun.cpu.isalist\" value=\"amd64\"/>\n" + " </properties>\n" + " <testcase time=\"0.005\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testLower\">\n" + " <failure message=\"<\" type=\"junit.framework.AssertionFailedError\"><![CDATA[junit.framework.AssertionFailedError: <\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testLower(TestSurefire3.java:30)\n" + "]]></failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testU0000\">\n" + " <failure message=\"&0#;\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: \n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testU0000(TestSurefire3.java:40)\n" + "</failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testGreater\">\n" + " <failure message=\">\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: >\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testGreater(TestSurefire3.java:35)\n" + "</failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testQuote\">\n" + " <failure message=\""\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: \"\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testQuote(TestSurefire3.java:25)\n" + "</failure>\n" + " </testcase>\n" + "</testsuite>"; InputStream byteArrayIs = new ByteArrayInputStream(xml.getBytes()); List<ReportTestSuite> parse = testSuiteXmlParser.parse(new InputStreamReader(byteArrayIs, "UTF-8")); assertThat(parse.size(), is(1)); ReportTestSuite report = parse.get(0); assertThat(report.getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(report.getName(), is("TestSurefire3")); assertThat(report.getPackageName(), is("wellFormedXmlFailures")); assertThat(report.getNumberOfTests(), is(4)); assertThat(report.getNumberOfSkipped(), is(0)); assertThat(report.getNumberOfErrors(), is(0)); assertThat(report.getNumberOfFailures(), is(4)); assertThat(report.getNumberOfFlakes(), is(0)); assertThat(report.getTimeElapsed(), is(0.005f)); assertThat(report.getTestCases().size(), is(4)); List<ReportTestCase> tests = report.getTestCases(); assertThat(tests.get(0).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(0).getName(), is("testLower")); assertThat(tests.get(0).getFailureDetail(), is("junit.framework.AssertionFailedError: <\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testLower(TestSurefire3.java:30)\n")); assertThat(tests.get(0).getClassName(), is("TestSurefire3")); assertThat(tests.get(0).getTime(), is(0.005f)); assertThat(tests.get(0).getFailureErrorLine(), is("30")); assertThat(tests.get(0).getFailureMessage(), is("<")); assertThat(tests.get(0).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testLower")); assertThat(tests.get(0).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(1).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(1).getName(), is("testU0000")); assertThat(tests.get(1).getFailureDetail(), is("junit.framework.AssertionFailedError: \n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testU0000(TestSurefire3.java:40)\n")); assertThat(tests.get(1).getClassName(), is("TestSurefire3")); assertThat(tests.get(1).getTime(), is(0f)); assertThat(tests.get(1).getFailureErrorLine(), is("40")); assertThat(tests.get(1).getFailureMessage(), is("&0#;")); assertThat(tests.get(1).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testU0000")); assertThat(tests.get(1).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(2).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(2).getName(), is("testGreater")); assertThat(tests.get(2).getFailureDetail(), is("junit.framework.AssertionFailedError: >\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testGreater(TestSurefire3.java:35)\n")); assertThat(tests.get(2).getClassName(), is("TestSurefire3")); assertThat(tests.get(2).getTime(), is(0f)); assertThat(tests.get(2).getFailureErrorLine(), is("35")); assertThat(tests.get(2).getFailureMessage(), is(">")); assertThat(tests.get(2).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testGreater")); assertThat(tests.get(2).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(3).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(3).getName(), is("testQuote")); assertThat(tests.get(3).getFailureDetail(), is("junit.framework.AssertionFailedError: \"\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testQuote(TestSurefire3.java:25)\n")); assertThat(tests.get(3).getClassName(), is("TestSurefire3")); assertThat(tests.get(3).getTime(), is(0f)); assertThat(tests.get(3).getFailureErrorLine(), is("25")); assertThat(tests.get(3).getFailureMessage(), is("\"")); assertThat(tests.get(3).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testQuote")); assertThat(tests.get(3).getFailureType(), is("junit.framework.AssertionFailedError")); }
Example 77
Project: nanobot-master File: ManageTroopsScreenSteps.java View source code |
@Then("^troops count is (.*)$")
public void thenTroopsCountIs(final String troopsCount) {
final TroopsInfo expected = TroopsInfo.parse(troopsCount);
final TroopsInfo actual = ScenarioContext.get("troopsInfo", TroopsInfo.class);
try {
Assert.assertEquals(expected, actual);
} catch (final AssertionError e) {
throw new AssertionFailedError(String.format("expected <%s> but was <%s>", expected.toString(), actual.toString()));
}
}
Example 78
Project: newFunf-master File: TemperatureSensorProbeTest.java View source code |
public void testData() throws InterruptedException {
Bundle params = new Bundle();
params.putLong(Parameter.Builtin.DURATION.name, 10L);
params.putLong(Parameter.Builtin.PERIOD.name, 10L);
startProbe(params);
try {
Bundle data = getData(10);
fail("Should only fail if temperature probe is present on device.");
} catch (AssertionFailedError e) {
}
}
Example 79
Project: njexl-master File: AsserterTest.java View source code |
public void testThis() throws Exception {
Asserter asserter = new Asserter(JEXL);
asserter.setVariable("this", new Foo());
asserter.assertExpression("this.get('abc')", "Repeat : abc");
try {
asserter.assertExpression("this.count", "Wrong Value");
fail("This method should have thrown an assertion exception");
} catch (AssertionFailedError e) {
}
}
Example 80
Project: opennms_dashboard-master File: ThrowableAnticipator.java View source code |
/** * Perform after-test verification that all anticipated java.lang.Throwable's * have been seen and that no unanticipated java.lang.Throwable's have been * seen. * * @throws junit.framework.AssertionFailedError if one or more anticipated Throwables were * not received or one or more unanticipated Throwables were received. */ public void verifyAnticipated() throws AssertionFailedError { StringBuffer error = new StringBuffer(); if (m_anticipated.size() != 0) { error.append("Anticipated list is non-zero (has " + m_anticipated.size() + " entries):\n"); error.append(listAnticipated()); } if (m_unanticipated.size() != 0) { error.append("Unanticipated list is non-zero (has " + m_unanticipated.size() + " entries):\n"); error.append(listUnanticipated()); } if (error.length() > 0) { fail(error.toString()); } }
Example 81
Project: platform_frameworks_support-master File: TestUtilsAssertions.java View source code |
@Override public void check(final View foundView, NoMatchingViewException noViewException) { if (noViewException != null) { throw noViewException; } else { if (!(foundView instanceof ViewGroup)) { throw new AssertionFailedError("View " + foundView.getClass().getSimpleName() + " is not a ViewGroup"); } final ViewGroup foundGroup = (ViewGroup) foundView; final int childrenCount = foundGroup.getChildCount(); int childrenDisplayedCount = 0; for (int i = 0; i < childrenCount; i++) { if (isDisplayed().matches(foundGroup.getChildAt(i))) { childrenDisplayedCount++; } } if (childrenDisplayedCount != expectedCount) { throw new AssertionFailedError("Expected " + expectedCount + " displayed children, but found " + childrenDisplayedCount); } } }
Example 82
Project: poi-master File: TestAttrPtg.java View source code |
/**
* Fix for bug visible around svn r706772.
*/
public void testReserializeAttrChoose() {
byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data);
Ptg[] ptgs = Ptg.readTokens(data.length, in);
byte[] data2 = new byte[data.length];
try {
Ptg.serializePtgs(ptgs, data2, 0);
} catch (ArrayIndexOutOfBoundsException e) {
throw new AssertionFailedError("incorrect re-serialization of tAttrChoose");
}
assertArrayEquals(data, data2);
}
Example 83
Project: rabbitmq-java-client-master File: ConfirmBase.java View source code |
protected void waitForConfirms(final String testTitle) throws Exception { try { FutureTask<?> waiter = new FutureTask<Object>(new Runnable() { public void run() { try { channel.waitForConfirmsOrDie(); } catch (IOException e) { throw (ShutdownSignalException) e.getCause(); } catch (InterruptedException _e) { fail(testTitle + ": interrupted"); } } }, null); (Executors.newSingleThreadExecutor()).execute(waiter); waiter.get(10, TimeUnit.SECONDS); } catch (ExecutionException ee) { Throwable t = ee.getCause(); if (t instanceof ShutdownSignalException) throw (ShutdownSignalException) t; if (t instanceof AssertionFailedError) throw (AssertionFailedError) t; throw (Exception) t; } catch (TimeoutException _e) { fail(testTitle + ": timeout"); } }
Example 84
Project: ruboto-core-master File: ActivityTest.java View source code |
public void runTest() throws Exception { try { Log.i(getClass().getName(), "runTest: " + getName()); final Activity activity = getActivity(); Log.i(getClass().getName(), "Activity OK"); Runnable testRunnable = new Runnable() { public void run() { if (setup != null) { Log.i(getClass().getName(), "calling setup"); JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(setup, "call", activity); Log.i(getClass().getName(), "setup ok"); } JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(block, "call", activity); if (teardown != null) { Log.i(getClass().getName(), "calling teardown"); JRubyAdapter.runRubyMethod(teardown, "call", activity); Log.i(getClass().getName(), "teardown ok"); } } }; if (onUiThread) { runTestOnUiThread(testRunnable); } else { testRunnable.run(); } Log.i(getClass().getName(), "runTest ok"); } catch (Throwable t) { AssertionFailedError afe = new AssertionFailedError("Exception running test."); afe.initCause(t); throw afe; } }
Example 85
Project: ruboto-irb-master File: ActivityTest.java View source code |
public void runTest() throws Exception { try { Log.i(getClass().getName(), "runTest: " + getName()); final Activity activity = getActivity(); Log.i(getClass().getName(), "Activity OK"); Runnable testRunnable = new Runnable() { public void run() { if (setup != null) { Log.i(getClass().getName(), "calling setup"); JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(setup, "call", activity); Log.i(getClass().getName(), "setup ok"); } JRubyAdapter.setScriptFilename(filename); JRubyAdapter.runRubyMethod(block, "call", activity); if (teardown != null) { Log.i(getClass().getName(), "calling teardown"); JRubyAdapter.runRubyMethod(teardown, "call", activity); Log.i(getClass().getName(), "teardown ok"); } } }; if (onUiThread) { runTestOnUiThread(testRunnable); } else { testRunnable.run(); } Log.i(getClass().getName(), "runTest ok"); } catch (Throwable t) { AssertionFailedError afe = new AssertionFailedError("Exception running test."); afe.initCause(t); throw afe; } }
Example 86
Project: Signal-Android-master File: SmsListenerTest.java View source code |
@Test
public void testChallenges() throws Exception {
for (Entry<String, String> challenge : CHALLENGES.entrySet()) {
if (!listener.isChallenge(context, challenge.getKey())) {
throw new AssertionFailedError("SmsListener didn't recognize body as a challenge.");
}
assertEquals(listener.parseChallenge(challenge.getKey()), challenge.getValue());
}
}
Example 87
Project: sisu-guice-master File: SerializationTest.java View source code |
private CreationException createCreationException() {
try {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(List.class);
}
});
throw new AssertionFailedError();
} catch (CreationException e) {
return e;
}
}
Example 88
Project: surefire-master File: TestSuiteXmlParserTest.java View source code |
@Test public void testParse() throws Exception { TestSuiteXmlParser testSuiteXmlParser = new TestSuiteXmlParser(consoleLogger); String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<testsuite failures=\"4\" time=\"0.005\" errors=\"0\" skipped=\"0\" tests=\"4\" name=\"wellFormedXmlFailures.TestSurefire3\">\n" + " <properties>\n" + " <property name=\"java.runtime.name\" value=\"Java(TM) SE Runtime Environment\"/>\n" + " <property name=\"sun.cpu.isalist\" value=\"amd64\"/>\n" + " </properties>\n" + " <testcase time=\"0.005\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testLower\">\n" + " <failure message=\"<\" type=\"junit.framework.AssertionFailedError\"><![CDATA[junit.framework.AssertionFailedError: <\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testLower(TestSurefire3.java:30)\n" + "]]></failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testU0000\">\n" + " <failure message=\"&0#;\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: \n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testU0000(TestSurefire3.java:40)\n" + "</failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testGreater\">\n" + " <failure message=\">\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: >\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testGreater(TestSurefire3.java:35)\n" + "</failure>\n" + " </testcase>\n" + " <testcase time=\"0\" classname=\"wellFormedXmlFailures.TestSurefire3\" name=\"testQuote\">\n" + " <failure message=\""\" type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError: \"\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testQuote(TestSurefire3.java:25)\n" + "</failure>\n" + " </testcase>\n" + "</testsuite>"; InputStream byteArrayIs = new ByteArrayInputStream(xml.getBytes()); List<ReportTestSuite> parse = testSuiteXmlParser.parse(new InputStreamReader(byteArrayIs, "UTF-8")); assertThat(parse.size(), is(1)); ReportTestSuite report = parse.get(0); assertThat(report.getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(report.getName(), is("TestSurefire3")); assertThat(report.getPackageName(), is("wellFormedXmlFailures")); assertThat(report.getNumberOfTests(), is(4)); assertThat(report.getNumberOfSkipped(), is(0)); assertThat(report.getNumberOfErrors(), is(0)); assertThat(report.getNumberOfFailures(), is(4)); assertThat(report.getNumberOfFlakes(), is(0)); assertThat(report.getTimeElapsed(), is(0.005f)); assertThat(report.getTestCases().size(), is(4)); List<ReportTestCase> tests = report.getTestCases(); assertThat(tests.get(0).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(0).getName(), is("testLower")); assertThat(tests.get(0).getFailureDetail(), is("junit.framework.AssertionFailedError: <\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testLower(TestSurefire3.java:30)\n")); assertThat(tests.get(0).getClassName(), is("TestSurefire3")); assertThat(tests.get(0).getTime(), is(0.005f)); assertThat(tests.get(0).getFailureErrorLine(), is("30")); assertThat(tests.get(0).getFailureMessage(), is("<")); assertThat(tests.get(0).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testLower")); assertThat(tests.get(0).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(1).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(1).getName(), is("testU0000")); assertThat(tests.get(1).getFailureDetail(), is("junit.framework.AssertionFailedError: \n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testU0000(TestSurefire3.java:40)\n")); assertThat(tests.get(1).getClassName(), is("TestSurefire3")); assertThat(tests.get(1).getTime(), is(0f)); assertThat(tests.get(1).getFailureErrorLine(), is("40")); assertThat(tests.get(1).getFailureMessage(), is("&0#;")); assertThat(tests.get(1).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testU0000")); assertThat(tests.get(1).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(2).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(2).getName(), is("testGreater")); assertThat(tests.get(2).getFailureDetail(), is("junit.framework.AssertionFailedError: >\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testGreater(TestSurefire3.java:35)\n")); assertThat(tests.get(2).getClassName(), is("TestSurefire3")); assertThat(tests.get(2).getTime(), is(0f)); assertThat(tests.get(2).getFailureErrorLine(), is("35")); assertThat(tests.get(2).getFailureMessage(), is(">")); assertThat(tests.get(2).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testGreater")); assertThat(tests.get(2).getFailureType(), is("junit.framework.AssertionFailedError")); assertThat(tests.get(3).getFullClassName(), is("wellFormedXmlFailures.TestSurefire3")); assertThat(tests.get(3).getName(), is("testQuote")); assertThat(tests.get(3).getFailureDetail(), is("junit.framework.AssertionFailedError: \"\n" + "\tat junit.framework.Assert.fail(Assert.java:47)\n" + "\tat wellFormedXmlFailures.TestSurefire3.testQuote(TestSurefire3.java:25)\n")); assertThat(tests.get(3).getClassName(), is("TestSurefire3")); assertThat(tests.get(3).getTime(), is(0f)); assertThat(tests.get(3).getFailureErrorLine(), is("25")); assertThat(tests.get(3).getFailureMessage(), is("\"")); assertThat(tests.get(3).getFullName(), is("wellFormedXmlFailures.TestSurefire3.testQuote")); assertThat(tests.get(3).getFailureType(), is("junit.framework.AssertionFailedError")); }
Example 89
Project: unitils-master File: SimpleDifferenceView.java View source code |
/**
* Creates a string representation of the given difference tree.
*
* @param difference The root difference, not null
* @return The string representation, not null
*/
public String createView(Difference difference) {
String expectedStr = objectFormatter.format(difference.getLeftValue());
String actualStr = objectFormatter.format(difference.getRightValue());
String formattedOnOneLine = formatOnOneLine(expectedStr, actualStr);
if (AssertionFailedError.class.getName().length() + 2 + formattedOnOneLine.length() < MAX_LINE_SIZE) {
return formattedOnOneLine;
} else {
return formatOnTwoLines(expectedStr, actualStr);
}
}
Example 90
Project: webtest-master File: ThrowAssert.java View source code |
public static void assertPasses(String message, TestBlock block) { try { block.call(); } catch (Throwable t) { String fullMessage = appendPrefix(message) + "should not have raised exception " + t.getClass().getName(); AssertionFailedError junitError = new AssertionFailedError(fullMessage); junitError.setStackTrace(t.getStackTrace()); throw junitError; } }
Example 91
Project: wicket-master File: TesterTest.java View source code |
/**
*
*/
@Test
public void assertTest() {
tester.startPage(new MyPage());
tester.debugComponentTrees();
try {
tester.assertVisible("label");
fail("Should fail, because label is invisible");
} catch (AssertionFailedError e) {
} catch (NullPointerException e) {
fail("NullPointerException shouldn't be thrown, instead it must fail.");
}
}
Example 92
Project: xbpm5-master File: PvmTestCase.java View source code |
@Override
protected void runTest() throws Throwable {
if (log.isDebugEnabled()) {
if (isEmptyLinesEnabled) {
log.debug(EMPTY_LINE);
}
log.debug("#### START {}.{} ###########################################################", this.getClass().getSimpleName(), getName());
}
try {
super.runTest();
} catch (AssertionFailedError e) {
log.error(EMPTY_LINE);
log.error("ASSERTION FAILED: {}", e, e);
throw e;
} catch (Throwable e) {
log.error(EMPTY_LINE);
log.error("EXCEPTION: {}", e, e);
throw e;
} finally {
log.debug("#### END {}.{} #############################################################", this.getClass().getSimpleName(), getName());
}
}
Example 93
Project: espresso-cucumber-master File: CucumberHelperTestSteps.java View source code |
/**
* Try to press a button with some text or load button if it's in adapter
* This doesn't guarantee the button is visible to the user, for example:
* user needs to scroll down to press button
*
* @param buttonText
* Text of the button to press
*/
public static void pressButtonWithTextOnce(final String buttonText) {
try {
onView(withText(buttonText)).perform(click());
} catch (final junit.framework.AssertionFailedError e) {
onData(hasToString(equalToIgnoringCase(buttonText))).perform(click());
} catch (final NoMatchingViewException e) {
onData(hasToString(equalToIgnoringCase(buttonText))).perform(click());
} catch (final RuntimeException e) {
onData(hasToString(equalToIgnoringCase(buttonText))).perform(click());
}
}
Example 94
Project: mulgara-master File: DescriptorUtilServiceTest.java View source code |
/* DISABLED BECAUSE IT FAILS - TODO FIX public void test1DescriptorServiceInvokeDescriptor() throws Exception { org.mulgara.descriptor.DescriptorServiceSoapBindingStub binding; try { binding = (org.mulgara.descriptor.DescriptorServiceSoapBindingStub) new org.mulgara.descriptor.DescriptorUtilServiceLocator().getDescriptorService(); } catch (javax.xml.rpc.ServiceException jre) { if(jre.getLinkedCause()!=null) jre.getLinkedCause().printStackTrace(); throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertNotNull("binding is null", binding); // Time out after a minute binding.setTimeout(60000); // Test operation org.w3c.dom.Element retValue = null; org.w3c.dom.Element descParam = createElement(); retValue = binding.invokeDescriptor(descParam); // TBD - validate results System.out.println("SOAP CLIENT RECEIVED:" + DOM2Writer.nodeToString((Node)retValue, true)); } */ public void test1DescriptorServiceInvokeToString() throws Exception { /* org.mulgara.descriptor.DescriptorServiceSoapBindingStub binding = null; try { binding = (org.mulgara.descriptor.DescriptorServiceSoapBindingStub) new org.mulgara.descriptor.DescriptorUtilServiceLocator().getDescriptorService(); } catch (javax.xml.rpc.ServiceException jre) { if(jre.getLinkedCause()!=null) jre.getLinkedCause().printStackTrace(); throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertNotNull("binding is null", binding); // Time out after a minute binding.setTimeout(60000); // Test operation java.util.HashMap map = createHashMap(); java.lang.String value = null; value = binding.invokeToString(map); System.out.println(this.getClass().getName() + " invoke to string returned:'" + value + "'"); //String testValue ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<desc:message xmlns:desc=\"http://mulgara.org/descriptor#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">helloworld</desc:message>"; String testValue ="<desc:message xmlns:desc=\"http://mulgara.org/descriptor#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">helloworld</desc:message>"; // finally, test for helloworld assertEquals(testValue, value); */ }
Example 95
Project: acs-master File: AccTests.java View source code |
/*
* Forwards to its companion of the same name, with a
* pre-defined timeout. See there for more info.
*
static public void assertCompletion (AssertableTask t) throws Throwable {
assertCompletion (30, t);
}
*/
/**
* Asserts that <code>t</code> terminates without errors within the given time limit.
* <p>
* This runs <code>t</code>. If <code>t</code> takes longer than <code>secs</code>,
* an <code>Exception</code> will be thrown. If <code>t</code> terminates with an
* error, it will be rethrown.
* </p>
*/
public static void assertCompletion(int secs, AssertableTask t) throws Throwable {
long start = System.currentTimeMillis();
t.start();
do {
try {
t.join(secs * 1000);
} catch (InterruptedException e) {
}
} while (t.isAlive() && (System.currentTimeMillis() - start) / 1000 < secs);
if (t.isAlive()) {
Error e = new AssertionFailedError("'" + t.desc + "' has not finished within " + secs + " seconds");
System.err.println(" (failure... " + e.getMessage() + ")");
throw e;
}
if (t.err != null) {
System.err.println(" (exception... " + t.err.getMessage() + ")");
throw t.err;
}
}
Example 96
Project: activiti-engine-ppi-master File: PvmTestCase.java View source code |
@Override
protected void runTest() throws Throwable {
LogUtil.resetThreadIndents();
ThreadLogMode oldThreadRenderingMode = LogUtil.setThreadLogMode(threadRenderingMode);
if (log.isLoggable(Level.FINE)) {
if (isEmptyLinesEnabled) {
log.fine(EMPTY_LINE);
}
log.fine("#### START " + ClassNameUtil.getClassNameWithoutPackage(this) + "." + getName() + " ###########################################################");
}
try {
super.runTest();
} catch (AssertionFailedError e) {
log.severe(EMPTY_LINE);
log.log(Level.SEVERE, "ASSERTION FAILED: " + e, e);
throw e;
} catch (Throwable e) {
log.severe(EMPTY_LINE);
log.log(Level.SEVERE, "EXCEPTION: " + e, e);
throw e;
} finally {
log.fine("#### END " + ClassNameUtil.getClassNameWithoutPackage(this) + "." + getName() + " #############################################################");
LogUtil.setThreadLogMode(oldThreadRenderingMode);
}
}
Example 97
Project: alien-ofelia-conet-ccnx-master File: AssertionCCNHandleTest.java View source code |
@Test
public void testFilterListenerAssertError() throws Exception {
AssertionCCNHandle getHandle = AssertionCCNHandle.open();
ContentName filter = testHelper.getTestNamespace("testFilterListenerAssertError");
FilterListenerTester flt = new FilterListenerTester();
getHandle.registerFilter(filter, flt);
putHandle.expressInterest(new Interest(filter), new InterestListenerTester());
getHandle.checkError(WAIT_TIME);
ContentName pastFilter = new ContentName(filter, "pastFilter");
putHandle.expressInterest(new Interest(pastFilter), new InterestListenerTester());
try {
getHandle.checkError(WAIT_TIME);
} catch (AssertionFailedError afe) {
return;
}
Assert.fail("Missed an assertion error we should have seen");
}
Example 98
Project: android-libcore64-master File: AccessControllerTest.java View source code |
public void testDoPrivilegedWithCombiner() {
final Permission permission = new RuntimePermission("do stuff");
final DomainCombiner union = new DomainCombiner() {
public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
throw new AssertionFailedError("Expected combiner to be unused");
}
};
ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
final AtomicInteger actionCount = new AtomicInteger();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
// Calling doPrivileged again would have exercised the combiner
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
actionCount.incrementAndGet();
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
return null;
}
});
return null;
}
}, accessControlContext);
assertEquals(1, actionCount.get());
}
Example 99
Project: android-test-kit-master File: DefaultFailureHandlerTest.java View source code |
public void testCustomAssertionError() {
try {
onView(isRoot()).check(new ViewAssertion() {
@Override
public void check(Optional<View> view, Optional<NoMatchingViewException> noViewFoundException) {
assertFalse(true);
}
});
fail("Previous call expected to fail");
} catch (AssertionFailedError e) {
assertFailureStackContainsThisClass(e);
}
}
Example 100
Project: android_platform_libcore-master File: AccessControllerTest.java View source code |
public void testDoPrivilegedWithCombiner() {
final Permission permission = new RuntimePermission("do stuff");
final DomainCombiner union = new DomainCombiner() {
public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
throw new AssertionFailedError("Expected combiner to be unused");
}
};
ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
final AtomicInteger actionCount = new AtomicInteger();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
// Calling doPrivileged again would have exercised the combiner
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
actionCount.incrementAndGet();
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
return null;
}
});
return null;
}
}, accessControlContext);
assertEquals(1, actionCount.get());
}
Example 101
Project: ARTPart-master File: AccessControllerTest.java View source code |
public void testDoPrivilegedWithCombiner() {
final Permission permission = new RuntimePermission("do stuff");
final DomainCombiner union = new DomainCombiner() {
public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
throw new AssertionFailedError("Expected combiner to be unused");
}
};
ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
final AtomicInteger actionCount = new AtomicInteger();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
// Calling doPrivileged again would have exercised the combiner
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
actionCount.incrementAndGet();
assertEquals(null, AccessController.getContext().getDomainCombiner());
AccessController.getContext().checkPermission(permission);
return null;
}
});
return null;
}
}, accessControlContext);
assertEquals(1, actionCount.get());
}