Search in sources :

Example 51 with AssertionFailedError

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");
            }
        }
    };
}
Also used : ViewAssertion(android.support.test.espresso.ViewAssertion) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) TextView(android.widget.TextView) AssertionFailedError(junit.framework.AssertionFailedError) TextView(android.widget.TextView) View(android.view.View)

Example 52 with AssertionFailedError

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();
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 53 with AssertionFailedError

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);
        }
    }
}
Also used : Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) AssertionFailedError(junit.framework.AssertionFailedError) MailTransportTest(org.opennms.netmgt.config.mailtransporttest.MailTransportTest) Test(org.junit.Test)

Example 54 with AssertionFailedError

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");
            }
        }
    };
}
Also used : ViewAssertion(android.support.test.espresso.ViewAssertion) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) TextView(android.widget.TextView) AssertionFailedError(junit.framework.AssertionFailedError) TextView(android.widget.TextView) View(android.view.View)

Example 55 with AssertionFailedError

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");
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError) TimeoutException(java.util.concurrent.TimeoutException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15