Example usage for junit.framework AssertionFailedError getMessage

List of usage examples for junit.framework AssertionFailedError getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.pig.test.TestLogicalPlanBuilder.java

@Test
public void testQueryFail94() throws FrontendException, ParseException {
    buildPlan("a = load 'one' as (name, age, gpa);");
    buildPlan("b = load 'two' as (name, age, somethingelse);");
    buildPlan("c = cogroup a by name, b by name;");
    buildPlan("d = foreach c generate flatten(a), flatten(b);");
    // test that we can refer to "a::name" field and not name
    try {// www.  j ava2  s .  c o  m
        buildPlan("e = foreach d generate name;");
    } catch (AssertionFailedError e) {
        assertTrue(e.getMessage().contains("Found more than one match:"));
    }
}

From source file:org.apache.pig.test.TestLogicalPlanBuilder.java

@Test
public void testQuery110Fail() throws FrontendException, ParseException {
    LogicalPlan lp;//from ww w .  jav  a2 s  . c o  m
    LOLoad load;
    LOCogroup cogroup;

    buildPlan("a = load 'one' as (name, age, gpa);");
    lp = buildPlan("b = load 'two';");

    load = (LOLoad) lp.getLeaves().get(0);
    boolean exceptionThrown = false;
    try {
        lp = buildPlan("c = cogroup a by $0, b by *;");
    } catch (AssertionFailedError e) {
        assertTrue(
                e.getMessage().contains("Cogroup/Group by * is only allowed if " + "the input has a schema"));
        exceptionThrown = true;
    }
    assertTrue(exceptionThrown);

}

From source file:org.apache.pig.test.TestLogicalPlanBuilder.java

@Test
public void testCogroupByStarFailure1() {
    boolean exceptionThrown = false;
    try {//from  ww  w. j  ava2  s .  co  m
        buildPlan(" a = load '1.txt' as (a0:int, a1:int);");
        buildPlan(" b = load '2.txt'; ");
        buildPlan("c = cogroup a by *, b by *;");
    } catch (AssertionFailedError e) {
        assertTrue(
                e.getMessage().contains("Cogroup/Group by * is only allowed if " + "the input has a schema"));
        exceptionThrown = true;
    }
    assertEquals("An exception was expected but did " + "not occur", true, exceptionThrown);
}

From source file:org.apache.pig.test.TestLogicalPlanBuilder.java

@Test
public void testCogroupByStarFailure2() {
    boolean exceptionThrown = false;
    try {/*from   ww  w.  ja v  a2 s.c  o  m*/
        buildPlan(" a = load '1.txt' ;");
        buildPlan(" b = load '2.txt' as (b0:int, b1:int); ");
        buildPlan("c = cogroup a by *, b by *;");
    } catch (AssertionFailedError e) {
        assertTrue(
                e.getMessage().contains("Cogroup/Group by * is only allowed if " + "the input has a schema"));
        exceptionThrown = true;
    }
    assertEquals("An exception was expected but did " + "not occur", true, exceptionThrown);
}

From source file:org.apache.pig.test.TestLogicalPlanBuilder.java

@Test
public void testCogroupByIncompatibleSchemaFailure() {
    boolean exceptionThrown = false;
    try {/*from w  w w  .ja  va 2  s .  c om*/
        buildPlan(" a = load '1.txt' as (a0:int, a1:int);");
        buildPlan(" b = load '2.txt' as (a0:int, a1:chararray); ");
        buildPlan("c = cogroup a by (a0,a1), b by (a0,a1);");
    } catch (AssertionFailedError e) {
        assertTrue(e.getMessage().contains("Cogroup column"));
        assertTrue(e.getMessage().contains("has incompatible types"));
        exceptionThrown = true;
    }
    assertEquals("An exception was expected but did " + "not occur", true, exceptionThrown);
}

From source file:org.intermine.modelviewer.jaxb.ConfigParserTest.java

/**
 * Test whether the model read from <code>src/test/(no)schema/core.xml</code>
 * is correct.//from w ww .  j a v  a 2 s.  c o  m
 * 
 * @param model The core Model.
 * 
 * @param sourceFile The source file.
 */
private void coreCorrect(Model model, File sourceFile) {

    try {
        assertEquals("Model name wrong", "genomic", model.getName());
        assertEquals("Package wrong", "org.intermine.model.bio", model.getPackage());

        assertEquals("Wrong number of classes", 34, model.getClazz().size());

        Map<String, Class> classMap = new HashMap<String, Class>();
        for (Class c : model.getClazz()) {
            classMap.put(c.getName(), c);
        }

        Class relation = classMap.get("Relation");
        assertNotNull("Class 'Relation' not found", relation);

        assertEquals("Relation extends wrong", "SymmetricalRelation", relation.getExtends());
        assertTrue("Relation interface wrong", relation.isIsInterface());
        assertEquals("Relation should have no attributes", 0, relation.getAttribute().size());

        assertNotNull("Relation should have 2 references (list unset)", relation.getReference());
        assertEquals("Relation should have 2 references", 2, relation.getReference().size());
        ClassReference ref = relation.getReference().get(0);
        assertEquals("Reference name wrong", "subject", ref.getName());
        assertEquals("Reference type wrong", "BioEntity", ref.getReferencedType());
        assertEquals("Reference reverse wrong", "objects", ref.getReverseReference());

        assertNotNull("Relation should have 2 collections (list unset)", relation.getCollection());
        assertEquals("Relation should have 2 collections", 2, relation.getCollection().size());
        ClassReference col = relation.getCollection().get(0);
        assertEquals("Collection name wrong", "evidence", col.getName());
        assertEquals("Collection type wrong", "Evidence", col.getReferencedType());
        assertEquals("Collection reverse wrong", "relations", col.getReverseReference());

        Class comment = classMap.get("Comment");
        assertNotNull("Class 'Comment' not found", comment);

        assertNull("Comment extends wrong", comment.getExtends());
        assertTrue("Comment interface wrong", comment.isIsInterface());

        assertEquals("Comment should have 2 attributes", 2, comment.getAttribute().size());
        Attribute att = comment.getAttribute().get(0);
        assertEquals("Attribute name wrong", "text", att.getName());
        assertEquals("Attribute type wrong", String.class.getName(), att.getType());

        assertNotNull("Comment should have 1 reference (list unset)", comment.getReference());
        assertEquals("Comment should have 1 reference", 1, comment.getReference().size());
        ref = comment.getReference().get(0);
        assertEquals("Reference name wrong", "source", ref.getName());
        assertEquals("Reference type wrong", "InfoSource", ref.getReferencedType());
        assertNull("Reference reverse wrong", ref.getReverseReference());

        assertEquals("Comment should have 0 collections", 0, comment.getCollection().size());

    } catch (AssertionFailedError e) {
        AssertionFailedError addition = new AssertionFailedError(
                "Failure with file " + sourceFile.getAbsolutePath() + " :\n" + e.getMessage());
        addition.initCause(e.getCause());
        addition.setStackTrace(e.getStackTrace());
        throw addition;
    }
}

From source file:org.intermine.modelviewer.jaxb.ConfigParserTest.java

/**
 * Test whether the model read from <code>src/test/(no)schema/genomic_additions.xml</code>
 * is correct.// w ww .  jav a2 s. c  o m
 * 
 * @param classes The top level Classes object.
 * 
 * @param sourceFile The source file.
 */
private void genomicAdditionsCorrect(Classes classes, File sourceFile) {
    try {

        assertEquals("Wrong number of classes", 23, classes.getClazz().size());

        Map<String, Class> classMap = new HashMap<String, Class>();
        for (Class c : classes.getClazz()) {
            classMap.put(c.getName(), c);
        }

        Class transcript = classMap.get("Transcript");
        assertNotNull("Class 'Transcript' not found", transcript);

        assertNull("Transcript extends wrong", transcript.getExtends());
        assertTrue("Transcript interface wrong", transcript.isIsInterface());

        assertEquals("Transcript should have 1 attribute", 1, transcript.getAttribute().size());
        Attribute att = transcript.getAttribute().get(0);
        assertEquals("Attribute name wrong", "exonCount", att.getName());
        assertEquals("Attribute type wrong", Integer.class.getName(), att.getType());

        assertEquals("Transcript should have 1 reference", 1, transcript.getReference().size());
        ClassReference ref = transcript.getReference().get(0);
        assertEquals("Reference name wrong", "protein", ref.getName());
        assertEquals("Reference type wrong", "Protein", ref.getReferencedType());
        assertEquals("Reference reverse wrong", "transcripts", ref.getReverseReference());

        assertNotNull("Transcript should have 2 collections (list unset)", transcript.getCollection());
        assertEquals("Transcript should have 2 collections", 2, transcript.getCollection().size());
        ClassReference col = transcript.getCollection().get(0);
        assertEquals("Collection name wrong", "introns", col.getName());
        assertEquals("Collection type wrong", "Intron", col.getReferencedType());
        assertEquals("Collection reverse wrong", "transcripts", col.getReverseReference());

    } catch (AssertionFailedError e) {
        AssertionFailedError addition = new AssertionFailedError(
                "Failure with file " + sourceFile.getAbsolutePath() + " :\n" + e.getMessage());
        addition.initCause(e.getCause());
        addition.setStackTrace(e.getStackTrace());
        throw addition;
    }
}

From source file:org.intermine.modelviewer.jaxb.ConfigParserTest.java

/**
 * Test whether the project read from <code>src/test/(no)schema/project.xml</code>
 * is correct.//from w  w  w  . ja va 2 s  .c  om
 * 
 * @param project The Project.
 * 
 * @param sourceFile The source file.
 */
private void projectCorrect(Project project, File sourceFile) {

    try {
        assertEquals("Project type wrong", "bio", project.getType());

        assertEquals("Wrong number of project properties", 6, project.getProperty().size());

        // Ignore duplicate source.location
        Map<String, Property> propMap = new HashMap<String, Property>();
        for (Property p : project.getProperty()) {
            propMap.put(p.getName(), p);
        }

        Property propsFile = propMap.get("default.intermine.properties.file");
        assertNotNull("Property 'default.intermine.properties.file' missing", propsFile);
        assertEquals("'default.intermine.properties.file' location wrong",
                "../default.intermine.integrate.properties", propsFile.getLocation());
        assertNull("'default.intermine.properties.file' value set", propsFile.getValue());

        Property targetModel = propMap.get("target.model");
        assertNotNull("Property 'target.model' missing", targetModel);
        assertEquals("'target.model' value wrong", "genomic", targetModel.getValue());
        assertNull("'target.model' location set", targetModel.getLocation());

        assertEquals("Wrong number of project sources", 8, project.getSources().getSource().size());

        Map<String, Source> sourceMap = new HashMap<String, Source>();
        for (Source s : project.getSources().getSource()) {
            sourceMap.put(s.getName(), s);
        }

        Source chromoFasta = sourceMap.get("malaria-chromosome-fasta");
        assertNotNull("Source 'malaria-chromosome-fasta' missing", chromoFasta);
        assertEquals("'malaria-chromosome-fasta' type wrong", "fasta", chromoFasta.getType());
        assertEquals("'malaria-chromosome-fasta' dump wrong", Boolean.TRUE, chromoFasta.isDump());

        assertEquals("'malaria-chromosome-fasta' source has wrong number of properties", 6,
                chromoFasta.getProperty().size());

        propMap.clear();
        for (Property p : chromoFasta.getProperty()) {
            propMap.put(p.getName(), p);
        }

        Property srcDataDir = propMap.get("src.data.dir");
        assertNotNull("Property 'src.data.dir' missing from source 'malaria-chromosome-fasta'", srcDataDir);
        assertEquals("'src.data.dir' location wrong", "/home/richard/malaria/genome/fasta",
                srcDataDir.getLocation());
        assertNull("'src.data.dir' value set", srcDataDir.getValue());

        Property fastaTitle = propMap.get("fasta.dataSourceName");
        assertNotNull("Property 'fasta.dataSourceName' missing from source " + "'malaria-chromosome-fasta'",
                fastaTitle);
        assertEquals("'fasta.dataSourceName' value wrong", "PlasmoDB", fastaTitle.getValue());
        assertNull("'fasta.dataSourceName' location set", fastaTitle.getLocation());

        Source gff = sourceMap.get("malaria-gff");
        assertNotNull("Source 'malaria-gff' missing", gff);
        assertEquals("'malaria-gff' type wrong", "malaria-gff", gff.getType());
        assertEquals("'malaria-gff' dump wrong", Boolean.FALSE, gff.isDump());

        assertEquals("Wrong number of post processors", 5, project.getPostProcessing().getPostProcess().size());

        Map<String, PostProcess> postProcessMap = new HashMap<String, PostProcess>();
        for (PostProcess pp : project.getPostProcessing().getPostProcess()) {
            postProcessMap.put(pp.getName(), pp);
        }

        PostProcess transfer = postProcessMap.get("transfer-sequences");
        assertNotNull("Post processor 'transfer-sequences' missing", transfer);
        assertEquals("'transfer-sequences' dump flag wrong", Boolean.TRUE, transfer.isDump());

        PostProcess doSources = postProcessMap.get("do-sources");
        assertNotNull("Post processor 'do-sources' missing", doSources);
        assertEquals("'do-sources' dump flag wrong", Boolean.FALSE, doSources.isDump());

    } catch (AssertionFailedError e) {
        AssertionFailedError addition = new AssertionFailedError(
                "Failure with file " + sourceFile.getAbsolutePath() + " :\n" + e.getMessage());
        addition.initCause(e.getCause());
        addition.setStackTrace(e.getStackTrace());
        throw addition;
    }
}

From source file:org.jactr.core.runtime.ModelExecutionTest.java

protected void testModel(IModel model, String goalName, String slotToCheck, IChunk slotValue) throws Exception {
    LOGGER.debug("======================================================================");
    LOGGER.debug("Testing model for goal " + goalName);

    ACTRRuntime runtime = ACTRRuntime.getRuntime();
    IController controller = runtime.getController();

    IChunk goal = model.getDeclarativeModule().getChunk(goalName).get();
    Object value = goal.getSymbolicChunk().getSlot("object").getValue();
    LOGGER.debug("goal slot value " + value + ", " + value.getClass().getName());

    assertNotNull(goal);//from w  w  w . ja  va2 s  . co m
    model.getActivationBuffer("goal").addSourceChunk(goal);

    model.setParameter(BasicModel.AGE_PARAM, "0");

    IChunk currentGoal = model.getActivationBuffer("goal").getSourceChunk();
    LOGGER.debug("current goal is " + currentGoal);

    assertNotNull(currentGoal);

    /*
     * this can not pass in 6.0 since chunks are actually copies
     */
    // assertTrue("Source chunk is not assigned", goal.equals(model
    // .getActivationBuffer("goal").getSourceChunk()));
    long startTime = System.currentTimeMillis();
    controller.start().get();
    //assertTrue(controller.isRunning());
    controller.complete().get();
    long runTime = System.currentTimeMillis() - startTime;

    LOGGER.info("Run took " + runTime + " ms");

    assertFalse(controller.isRunning());

    // goal should now have... g2.judgement = yes
    ISlot slot = currentGoal.getSymbolicChunk().getSlot(slotToCheck);
    LOGGER.debug("Comparing " + slot.getValue() + " to " + slotValue);

    try {
        assertTrue("Comparing " + slot.getValue() + " to " + slotValue, slot.equalValues(slotValue));
    } catch (AssertionFailedError afe) {
        LOGGER.error("Failed, dumping terminal model source (" + afe.getMessage() + ")");
        CommonTree md = ASTResolver.toAST(model, true);
        for (StringBuilder line : CommonIO.generateSource(md, "jactr"))
            System.err.println(line.toString());

        throw afe;
    }
}

From source file:org.jbpm.AbstractJbpmTestCase.java

protected void runTest() throws Throwable {
    try {/*from   w  w w  . j  ava  2  s.  c o  m*/
        super.runTest();
    } catch (AssertionFailedError e) {
        log.error("");
        log.error("ASSERTION FAILURE: " + e.getMessage());
        log.error("");
        throw e;
    } catch (Throwable t) {
        log.error("");
        log.error("EXCEPTION: " + t.getMessage());
        log.error("");
        t.printStackTrace();
        throw t;
    }
}