Example usage for junit.framework AssertionFailedError AssertionFailedError

List of usage examples for junit.framework AssertionFailedError AssertionFailedError

Introduction

In this page you can find the example usage for junit.framework AssertionFailedError AssertionFailedError.

Prototype

public AssertionFailedError(String message) 

Source Link

Usage

From source file:ir.keloud.android.lib.test_project.test.SimpleFactoryManagerTest.java

public void testGetClientFor() {
    try {//from w  w w .j  a v a 2  s .co  m
        KeloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());

        assertNotSame("Got same client instances for same account", client,
                mSFMgr.getClientFor(mValidAccount, getContext()));

        assertNotSame("Got same client instances for different accounts", client,
                mSFMgr.getClientFor(mAnonymousAccount, getContext()));

    } catch (Exception e) {
        throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
    }
    // TODO harder tests
}

From source file:com.meltmedia.cadmium.blackbox.test.CadmiumAssertions.java

/**
 * <p>Asserts that the local and remote files pass to this method exist and are identical.</p>
 * @param message The message that will be in the error if the local file isn't the same as the remote file.
 * @param toCheck The file to check//from   w  w w  .  ja  v a 2 s .  c  o m
 * @param username The Basic HTTP auth username.
 * @param password The Basic HTTP auth password.
 * @param remoteLocation A string containing the URL location of the remote resource to check.
 */
public static void assertResourcesEqual(String message, File toCheck, String remoteLocation, String username,
        String password) {
    FileReader reader = null;
    assertExistsLocally(message, toCheck);
    try {
        reader = new FileReader(toCheck);
        byte fileContents[] = IOUtils.toByteArray(reader);
        byte remoteContents[] = EntityUtils
                .toByteArray(assertExistsRemotely(message, remoteLocation, username, password));
        if (!Arrays.equals(fileContents, remoteContents)) {
            throw new AssertionFailedError(message);
        }
    } catch (IOException e) {
        throw new AssertionFailedError(e.getMessage() + ": " + message);
    } finally {
        IOUtils.closeQuietly(reader);
    }
}

From source file:ir.keloud.android.lib.test_project.test.SingleSessionManagerTest.java

public void testGetClientFor() {
    try {//from  w w  w .jav a2 s .c om
        KeloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
        KeloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext());

        assertNotSame("Got same client instances for different accounts", client1, client2);
        assertSame("Got different client instances for same account", client1,
                mSSMgr.getClientFor(mValidAccount, getContext()));

    } catch (Exception e) {
        throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
    }

    // TODO harder tests
}

From source file:com.owncloud.android.lib.test_project.test.SimpleFactoryManagerTest.java

public void testGetClientFor() {
    try {/*  w w  w  .j a v a  2s  .  c o  m*/
        OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());

        assertNotSame("Got same client instances for same account", client,
                mSFMgr.getClientFor(mValidAccount, getContext()));

        assertNotSame("Got same client instances for different accounts", client,
                mSFMgr.getClientFor(mAnonymousAccount, getContext()));

    } catch (Exception e) {
        throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
    }
    // TODO harder tests
}

From source file:com.owncloud.android.lib.test_project.test.UpdatePublicShareTest.java

public UpdatePublicShareTest() {
    super();/*from w w w  .jav a  2 s.co  m*/

    Protocol pr = Protocol.getProtocol("https");
    if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
        try {
            ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
            Protocol.registerProtocol("https", new Protocol("https", psf, 443));

        } catch (GeneralSecurityException e) {
            throw new AssertionFailedError("Self-signed confident SSL context could not be loaded");
        }
    }
}

From source file:com.owncloud.android.lib.test_project.test.SingleSessionManagerTest.java

public void testGetClientFor() {
    try {//from  ww w  . ja  va2s.  com
        OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
        OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext());

        assertNotSame("Got same client instances for different accounts", client1, client2);
        assertSame("Got different client instances for same account", client1,
                mSSMgr.getClientFor(mValidAccount, getContext()));

    } catch (Exception e) {
        throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
    }

    // TODO harder tests
}

From source file:ir.keloud.android.lib.test_project.test.KeloudClientTest.java

public void testConstructor() {
    try {//from  w  w  w.jav a  2 s.c o  m
        new KeloudClient(null, NetworkUtils.getMultiThreadedConnManager());
        throw new AssertionFailedError("Accepted NULL parameter");

    } catch (Exception e) {
        assertTrue("Unexpected exception passing NULL baseUri", (e instanceof IllegalArgumentException));
    }

    try {
        new KeloudClient(mServerUri, null);
        throw new AssertionFailedError("Accepted NULL parameter");

    } catch (Exception e) {
        assertTrue("Unexpected exception passing NULL connectionMgr", (e instanceof IllegalArgumentException));
    }

    KeloudClient client = new KeloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
    assertNotNull("KeloudClient instance not built", client);
}

From source file:com.owncloud.android.lib.test_project.test.OwnCloudClientTest.java

public void testConstructor() {
    try {//from  w w  w  .java2  s.c o m
        new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager());
        throw new AssertionFailedError("Accepted NULL parameter");

    } catch (Exception e) {
        assertTrue("Unexpected exception passing NULL baseUri", (e instanceof IllegalArgumentException));
    }

    try {
        new OwnCloudClient(mServerUri, null);
        throw new AssertionFailedError("Accepted NULL parameter");

    } catch (Exception e) {
        assertTrue("Unexpected exception passing NULL connectionMgr", (e instanceof IllegalArgumentException));
    }

    OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
    assertNotNull("OwnCloudClient instance not built", client);
}

From source file:baggage.BaseTestCase.java

protected void assertContains(String substring, String string) {
    if (!string.contains(substring)) {
        throw new AssertionFailedError("Should have contained '" + string + "', was '" + substring);
    }//from   ww  w . jav a 2 s  .  co m
}

From source file:com.mastercard.test.spring.security.WatchWithUserTestExecutionListener.java

/**
 * Validate that a test has been executed for every mock/test user expected.  If any remain,
 * raise a failure.//ww  w  .ja  v  a 2  s .  com
 * @param testContext The TestContext being executed
 * @throws Exception if an Exception occurs
 */
@Override
public void afterTestClass(TestContext testContext) throws Exception {
    int errorCount = 0;
    for (String key : methodContextMap.keySet()) {
        TestMethodContext context = methodContextMap.get(key);
        if (context.getExecutionStack().size() > 0) {
            System.out.println(context.getExecutionStack().size() + " Unused SecurityUsers on " + key);
            errorCount++;
        }
    }

    if (errorCount > 0) {
        throw new AssertionFailedError("Unused SecurityUsers remaining on " + errorCount + " methods");
    }
}