use of junit.framework.AssertionFailedError in project android_frameworks_base by AOSPA.
the class TextViewAssertions method hasInsertionPointerAtIndex.
/**
* Returns a {@link ViewAssertion} that asserts that the text view insertion pointer is at
* a specified index.<br>
* <br>
* View constraints:
* <ul>
* <li>must be a text view displayed on screen
* <ul>
*
* @param index A matcher representing the expected index.
*/
public static ViewAssertion hasInsertionPointerAtIndex(final Matcher<Integer> index) {
return new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException exception) {
if (view instanceof TextView) {
TextView textView = (TextView) view;
int selectionStart = textView.getSelectionStart();
int selectionEnd = textView.getSelectionEnd();
try {
assertThat(selectionStart, index);
assertThat(selectionEnd, index);
} catch (IndexOutOfBoundsException e) {
throw new AssertionFailedError(e.getMessage());
}
} else {
throw new AssertionFailedError("TextView not found");
}
}
};
}
use of junit.framework.AssertionFailedError in project opennms by OpenNMS.
the class FileAnticipatorTest method testExpectingDeleteExpectedBogus.
public void testExpectingDeleteExpectedBogus() {
String file = "FileAnticipatorTest_bogus_" + System.currentTimeMillis();
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new AssertionFailedError("Errors occurred inside FileAnticipator:\nExpected file that needs to be deleted does not exist: " + m_anticipator.getTempDir() + File.separator + file));
m_anticipator.expecting(file);
try {
m_anticipator.deleteExpected();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of junit.framework.AssertionFailedError in project opennms by OpenNMS.
the class WillItUnmarshalIT method testUnmarshalling.
@Test
public void testUnmarshalling() {
// Be conservative about what we ship, so don't be lenient
final Resource resource = this.createResource();
// Assert that resource is valied
assertNotNull("Resource must not be null", resource);
// Unmarshall the config file
Object result = null;
try {
switch(impl) {
case JAXB:
result = JaxbUtils.unmarshal(this.clazz, resource);
break;
default:
fail("Implementation unknown: " + this.impl);
}
// Assert that unmarshalling returned a valid result
assertNotNull("Unmarshalled instance must not be null", result);
} catch (AssertionFailedError ex) {
throw ex;
} catch (Exception ex) {
// match - if not the test failed
if (this.exception != null) {
assertEquals(this.exception, exception.toString());
} else {
throw new RuntimeException(ex);
}
}
}
use of junit.framework.AssertionFailedError in project android_frameworks_base by ResurrectionRemix.
the class TextViewAssertions method hasInsertionPointerAtIndex.
/**
* Returns a {@link ViewAssertion} that asserts that the text view insertion pointer is at
* a specified index.<br>
* <br>
* View constraints:
* <ul>
* <li>must be a text view displayed on screen
* <ul>
*
* @param index A matcher representing the expected index.
*/
public static ViewAssertion hasInsertionPointerAtIndex(final Matcher<Integer> index) {
return new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException exception) {
if (view instanceof TextView) {
TextView textView = (TextView) view;
int selectionStart = textView.getSelectionStart();
int selectionEnd = textView.getSelectionEnd();
try {
assertThat(selectionStart, index);
assertThat(selectionEnd, index);
} catch (IndexOutOfBoundsException e) {
throw new AssertionFailedError(e.getMessage());
}
} else {
throw new AssertionFailedError("TextView not found");
}
}
};
}
use of junit.framework.AssertionFailedError in project voltdb by VoltDB.
the class JSR166TestCase method tearDown.
/**
* Extra checks that get done for all test cases.
*
* Triggers test case failure if any thread assertions have failed,
* by rethrowing, in the test harness thread, any exception recorded
* earlier by threadRecordFailure.
*
* Triggers test case failure if interrupt status is set in the main thread.
*/
@Override
public void tearDown() throws Exception {
Throwable t = threadFailure.getAndSet(null);
if (t != null) {
if (t instanceof Error)
throw (Error) t;
else if (t instanceof RuntimeException)
throw (RuntimeException) t;
else if (t instanceof Exception)
throw (Exception) t;
else {
AssertionFailedError afe = new AssertionFailedError(t.toString());
afe.initCause(t);
throw afe;
}
}
if (Thread.interrupted())
throw new AssertionFailedError("interrupt status set in main thread");
}
Aggregations