Example usage for junit.framework AssertionFailedError getCause

List of usage examples for junit.framework AssertionFailedError getCause

Introduction

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

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

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./*  ww w  .  j  av a 2s .co 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 w  w .  j a v a 2  s  .com*/
 * 
 * @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 . j a va2s.c o  m
 * 
 * @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;
    }
}