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:com.owncloud.android.lib.test_project.test.GetCapabilitiesTest.java

public GetCapabilitiesTest() {
    super();//from  www.j a v  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:org.usapi.BaseSeleniumTestTest.java

@Test
public void testAssertTrue() {
    try {/*w  w w. ja v  a 2s. c  o m*/
        myTest.assertTrue("msg", true);
    } catch (USAPIException e) {
        throw new AssertionFailedError("assertTrue threw exception when encountering true condition");
    }
    boolean assertionThrown = false;
    try {
        myTest.assertTrue("msg", false);
    } catch (USAPIException e) {
        assertEquals(e.getMessage(), "Assertion failed: msg");
        assertionThrown = true;
    }
    assertTrue("", assertionThrown);
}

From source file:com.hoccer.tools.TestHelper.java

public static void blockUntilEquals(String pFailMessage, long pTimeout, Object pExpected,
        final TestHelper.Measurement pMesurement) throws Exception {
    Object mesuredValue = null;// w w  w .j  a va2  s  . c o m
    long start = System.currentTimeMillis();
    while (System.currentTimeMillis() - start < pTimeout) {
        mesuredValue = pMesurement.getActualValue();
        if (pExpected.equals(mesuredValue)) {
            return;
        }
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            throw new AssertionError(e);
        }
    }

    throw new AssertionFailedError(
            pFailMessage + ": should be <" + pExpected + ">, but was <" + mesuredValue + ">");
}

From source file:fi.solita.phantomrunner.jasmine.JasmineSpec.java

@Override
public void run(RunNotifier notifier, PhantomProcessNotifier processNotifier) {
    notifier.fireTestStarted(description.get());
    try {/*from  www .ja v a 2  s . com*/
        JsonNode result = processNotifier.runTest(this);
        if (!result.has("passed")) {
            // oops something went terribly terribly wrong, raise an error
            throw new RuntimeException("Error occured in Javascript evaluation, see console");
        }

        if (!result.get("passed").asBoolean()) {
            throw new AssertionFailedError(result.get("failMessage").asText());
        }
        notifier.fireTestFinished(description.get());
    } catch (Throwable t) {
        notifier.fireTestFailure(new Failure(description.get(), t));
    }
}

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

public KeloudClientTest() {
    super();//  w ww. jav a  2s.com

    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.mastercard.test.spring.security.WatchWithUserTestExecutionListener.java

/**
 * Build a list of mock/test users for the provided TestContext if not present.  If
 * present, validate that the user set in the SecurityContext matches the expected User based
 * on the current iteration of the TestContext.  If the actual user does not match expected,
 * then a test failure is raised.//from   w w  w.  j ava2 s .  c  o  m
 * @param testContext The TestContext being executed
 * @throws Exception if an Exception occurs
 */
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
    testClass = testContext.getTestClass();
    String methodMapKey = testClass.getName() + ":" + testContext.getTestMethod().getName();
    TestMethodContext context = methodContextMap.get(methodMapKey);
    if (context == null) {
        context = new TestMethodContext(testContext.getTestMethod().getName(), findUserAnnotations(testContext),
                testContext.getApplicationContext());
        methodContextMap.put(methodMapKey, context);
    }

    boolean pop = false;

    User expectedUser = null;
    User user = null;
    if (SecurityContextHolder.getContext().getAuthentication() != null) {
        user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
    if (context.getExecutionStack().size() > 0) {
        expectedUser = context.getExecutionStack().pop();
    }

    if (user != null || expectedUser != null) {
        if (user != null && !user.equals(expectedUser)) {
            throw new AssertionFailedError(
                    "Invalid SecurityUser, actual=" + user + ", expected=" + expectedUser);
        }
    }
}

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

public OwnCloudClientTest() {
    super();/*w w  w  . j  a  va2 s  . c om*/

    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.UpdateShareTest.java

public UpdateShareTest() {
    super();// ww  w .  j  a  va2  s  . c o  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.GetShareesTest.java

public GetShareesTest() {
    super();/*  w ww.j  a v a 2  s. c  o  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.UpdatePrivateShareTest.java

public UpdatePrivateShareTest() {
    super();/*from   w  ww .j av a2 s.  c  o 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");
        }
    }
}