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

@Test
public void transientData() {
    try {/*ww  w. jav  a  2s  . c om*/
        assertSerializable(new TransientData(1));
    } catch (AssertionError ex) {
        assertEquals("expected object is 'I am 1' actual is 'I am 0'", ex.getMessage());
        assertNull(ex.getCause());
        return;
    }
    fail();
}

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

@RequestMapping(value = "/assertSameGraph", method = RequestMethod.POST)
@ResponseBody/*from w  w w  .j  ava 2  s  .  co  m*/
public String assertSameGraph(@RequestBody RestTestRequest request, HttpServletResponse response)
        throws IOException {
    if (request.getCypher() == null) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Cypher statement must be provided");
    }

    try {
        GraphUnit.assertSameGraph(database, request.getCypher(), 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.graphaware.module.resttest.RestTestApi.java

@RequestMapping(value = "/assertSubgraph", method = RequestMethod.POST)
@ResponseBody/* w  w w .  j  av a  2  s.c o m*/
public String assertSubgraph(@RequestBody RestTestRequest request, HttpServletResponse response)
        throws IOException {
    if (request.getCypher() == null) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Cypher statement must be provided");
    }

    try {
        GraphUnit.assertSubgraph(database, request.getCypher(), 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.meltmedia.cadmium.blackbox.test.AbstractBodyApiResponseValidator.java

@Override
public void validate(HttpResponse response) {
    try {/*w w w  .java 2  s. co  m*/
        super.validate(response);
    } catch (AssertionError e) {
        String responseBody = null;
        try {
            responseBody = EntityUtils.toString(response.getEntity());
        } catch (Exception e1) {
            fail(e.getMessage() + ": Failed to dump response body.");
        }
        fail(e.getMessage() + ": " + responseBody);
    }
    try {
        validateBody(response, EntityUtils.toString(response.getEntity()));
    } catch (Exception e) {
        fail("Failed to validate body: " + e.getMessage());
    }
}

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

@Test
public void message() {
    try {/*from w w w . ja v  a2 s .  c  o  m*/
        assertSerializable("Right now,", new TransientData(1));
    } catch (AssertionError ex) {
        assertEquals("Right now, expected object is 'I am 1' actual is 'I am 0'", ex.getMessage());
        assertNull(ex.getCause());
        return;
    }
    fail();
}

From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.PersonDAOTest.java

@Test
@Rollback(false)/*from  www .j  a v a 2 s.c o m*/
public final void testCreatePerson() {
    final IPersonDAO personDAO = daoFactory.getPersonDAO();
    final PersonPE testPerson = createPerson();
    try {
        // Try with <code>null</code>
        personDAO.createPerson(null);
        fail("AssertionError expected");
    } catch (final AssertionError e) {
        assertEquals("Given person can not be null.", e.getMessage());
    }
    personDAO.createPerson(testPerson);
    final List<PersonPE> persons = personDAO.listPersons();
    assertEquals(4, persons.size());
    final PersonPE testPersonFromDB = personDAO.getPerson(testPerson.getId());
    assertEquals(testPerson, testPersonFromDB);
}

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

@Test
public void differentClass() {
    try {//from   w w w.  ja  v a 2  s . co  m
        assertArrayPermutation(new Number[0], new Integer[0]);
    } catch (AssertionError ex) {
        assertEquals("expected array class is " + Number[].class.getName() + " but actual array class is "
                + Integer[].class.getName(), ex.getMessage());
        return;
    }
    fail();
}

From source file:com.shazam.shazamcrest.matcher.DiagnosingCustomisableMatcher.java

private boolean assertEquals(final String expectedJson, String actualJson, Description mismatchDescription) {
    try {//w  w w  .j av a 2s  . c  o  m
        JSONAssert.assertEquals(expectedJson, actualJson, true);
    } catch (AssertionError e) {
        return appendMismatchDescription(mismatchDescription, expectedJson, actualJson, e.getMessage());
    } catch (JSONException e) {
        return appendMismatchDescription(mismatchDescription, expectedJson, actualJson, e.getMessage());
    }

    return true;
}

From source file:com.alliander.osgp.acceptancetests.devicemanagement.RemoveOrganisationSteps.java

@DomainStep("the remove organisation request should return result (.*)")
public boolean thenTheResponseShouldReturn(final String result) {
    LOGGER.info("THEN: the set remove organisation request should return {}.", result);

    if (result.toUpperCase().equals("OK")) {
        try {/*from w ww.  j ava  2 s. c  o m*/
            Assert.assertNotNull("Response should not be null", this.response);
            Assert.assertNull("Throwable should be null", this.throwable);
        } catch (final AssertionError e) {
            LOGGER.error("Exception [{}]: {}", e.getClass().getSimpleName(), e.getMessage());
            return false;
        }
    } else {
        try {
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertEquals(result.toUpperCase(),
                    this.throwable.getCause().getClass().getSimpleName().toUpperCase());
        } catch (final AssertionError e) {
            LOGGER.error("Exception [{}]: {}", e.getClass().getSimpleName(), e.getMessage());
            return false;
        }
    }

    return true;
}

From source file:net.javacrumbs.jsonunit.spring.ExampleControllerTest.java

@Test
public void isNotEqualToShouldFailIfEquals() throws Exception {
    try {/*w ww . j  a  va 2 s. c  om*/
        exec().andExpect(json().isNotEqualTo(CORRECT_JSON));
        failIfNoException();
    } catch (AssertionError e) {
        assertEquals("JSON is equal.", e.getMessage());
    }
}