Example usage for java.lang AssertionError getMessage

List of usage examples for java.lang AssertionError getMessage

Introduction

In this page you can find the example usage for java.lang AssertionError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.marketcetera.util.test.CollectionAssertTest.java

@Test
public void actualNull() {
    try {/*www.  j  a va  2 s . c o m*/
        assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, null);
    } catch (AssertionError ex) {
        assertEquals("actual array is null but expected is not", ex.getMessage());
        return;
    }
    fail();
}

From source file:org.marketcetera.util.test.CollectionAssertTest.java

@Test
public void expectedShorter() {
    try {//from   ww  w  .  j a v  a2 s.  c o m
        assertArrayPermutation(new Integer[] { 1 }, new Integer[] { 1, 1 });
    } catch (AssertionError ex) {
        assertEquals("actual contains extra elements such as 1", ex.getMessage());
        return;
    }
    fail();
}

From source file:com.meltmedia.cadmium.blackbox.test.endpoints.UpdateEndpointTest.java

@Override
public void preTest() throws Exception {
    try {/*  w  ww. j  a  va  2s  .co  m*/
        assertContentDeployed("Initial content isn't as expected.", new File(TEST_CONTENT_LOCATION), DEPLOY_URL,
                "tester", "tester");
        String revision = git.setupContentUpdate(TEST_UPDATED_CONTENT_LOCATION);
        updateRequest.setComment("Updating for test.");
        updateRequest.setBranch("cd-master");
        updateRequest.setRepo(git.getRepo());
        updateRequest.setSha(revision);
        System.out.println("Passed pretest...");
    } catch (AssertionError e) {
        fail("Pretest failed: " + e.getMessage());
    }
}

From source file:com.cedarsoft.serialization.test.utils.AbstractXmlSerializerMultiTest.java

@Override
protected void verifySerialized(@Nonnull List<? extends byte[]> serialized) throws Exception {
    List<? extends String> expected = getExpectedSerialized();

    int index = 0;
    for (byte[] current : serialized) {
        String expectedWithNamespace = AbstractXmlSerializerTest2.addNameSpace(
                (AbstractXmlSerializer<?, ?, ?, ?>) getSerializer(), expected.get(index).getBytes());
        try {/*from  w w  w  . j a  va  2  s.c om*/
            AssertUtils.assertXMLEquals(new String(current, getCharset()), expectedWithNamespace);
        } catch (AssertionError e) {
            AssertionError newError = new AssertionError("Failed for index <" + index + ">: " + e.getMessage());
            newError.setStackTrace(e.getStackTrace());
            throw newError;
        }
        index++;
    }
}

From source file:org.marketcetera.util.test.SerializableAssertTest.java

@Test
public void nonSerializable() {
    try {/*  ww w.j a v  a  2  s.  com*/
        assertSerializable(new NonSerializableClass(new NonSerializableMember(1)));
    } catch (AssertionError ex) {
        assertEquals("de/serialization failed", ex.getMessage());
        assertEquals(SerializationException.class, ex.getCause().getClass());
        return;
    }
    fail();
}

From source file:org.auraframework.util.javascript.directive.impl.IncludeDirectiveTest.java

/**
 * Test config parameters passed for Include directive
 *///www.j a  v  a2 s . c  om
@Test
public void testIncludeConfig() throws Exception {
    String[] config = { "{\"modes\": [\"TESTING\"]}", "reallyconkyinclude" };
    IncludeDirective id = null;
    boolean failed = false;
    try {
        id = new IncludeDirective(4, config[0]);
        fail("Should not have continued processing the include directive without a value for path");
    } catch (AssertionError expected) {
        assertTrue(expected.getMessage().equals("Path is required in include directive config"));
        // just to avoid the "local variable never read" error
        assertTrue(id == null);
    }
    try {
        File file = getResourceFile("/testdata/javascript/head.js");
        DirectiveBasedJavascriptGroup jg = new DirectiveBasedJavascriptGroup("testDummy", file.getParentFile(),
                file.getName(), ImmutableList.<DirectiveType<?>>of(DirectiveTypes.includeType),
                EnumSet.of(JavascriptGeneratorMode.TESTING));
        id = new IncludeDirective(4, config[1]);
        id.processDirective(jg);
        failed = true;
    } catch (Throwable e) {
        // Expected the Javascript group to throw an error while adding an
        // invalid file
        assertTrue("Add File function failed because of an unexpected error message",
                e.getMessage().indexOf("reallyconkyinclude") != -1);
    }
    if (failed) {
        fail("should have failed because 'reallyconkyinclude' is an invalid javascript file to include");
    }
}

From source file:net.javacrumbs.smock.http.client.connection.AbstractMockWebServiceServerTest.java

@Test
public void testUnexpectedFirst() throws IOException {
    try {//from w w  w.  ja v  a2s  .  co m
        sendMessage(ADDRESS, "request1.xml");
        fail("Unexpected exeption");
    } catch (AssertionError e) {
        assertEquals("No further connections expected", e.getMessage());
    }
}

From source file:net.javacrumbs.smock.http.client.connection.AbstractMockWebServiceServerTest.java

@Test
public void testUnexpected() throws IOException {
    MockWebServiceServer server = createServer();
    server.expect(connectionTo(ADDRESS)).andExpect(message("request.xml"))
            .andRespond(withMessage("response.xml"));

    WebServiceMessage response1 = sendMessage(ADDRESS, "request.xml");
    message("response.xml").match(null, response1);

    try {//  w  w w.ja  v a  2  s.  c o m
        sendMessage(ADDRESS, "request2.xml");
        fail("Unexpected exeption");
    } catch (AssertionError e) {
        assertEquals("No further connections expected", e.getMessage());
    }
}

From source file:com.graphaware.module.resttest.RestTestApi.java

@RequestMapping(value = "/assertEmpty", method = RequestMethod.POST)
@ResponseBody//from ww w  .  j av  a 2  s. c  o  m
public String assertEmpty(@RequestBody(required = false) RestTestRequest request, HttpServletResponse response)
        throws IOException {
    try {
        GraphUnit.assertEmpty(database, resolveInclusionPolicies(request));
        response.setStatus(HttpServletResponse.SC_OK);
        return null;
    } catch (AssertionError error) {
        response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
        return error.getMessage();
    }
}

From source file:com.xtructure.xutil.valid.strategy.UTestTestValidationStrategy.java

public void processFailureBehavesAsExpected() {
    Condition predicate = isNotNull();
    Object object = null;//from   w w  w  .  ja  v a 2s  . com
    String msg = RandomStringUtils.randomAlphanumeric(10);
    TestValidationStrategy<Object> vs = new TestValidationStrategy<Object>(predicate);
    try {
        vs.validate(object);
    } catch (AssertionError e) {
        if (!String.format("%s (%s): %s", TestValidationStrategy.DEFAULT_MSG, object, predicate)
                .equals(e.getMessage())) {
            throw new AssertionError();
        }
    }
    try {
        vs.validate(object, msg);
    } catch (AssertionError e) {
        if (!String.format("%s (%s): %s", msg, object, predicate).equals(e.getMessage())) {
            throw new AssertionError();
        }
    }
}