List of usage examples for junit.framework AssertionFailedError setStackTrace
public void setStackTrace(StackTraceElement[] stackTrace)
From source file:com.owncloud.android.lib.test_project.test.GetShareesTest.java
/** * Test get federated sharees//ww w.j av a 2 s. c om * * Requires OC server 8.2 or later */ public void testGetFederatedShareesOperation() { Log.v(LOG_TAG, "testGetFederatedSharees in"); /// successful cases // search for sharees including "@" GetRemoteShareesOperation getShareesOperation = new GetRemoteShareesOperation("@", 1, 50); RemoteOperationResult result = getShareesOperation.execute(mClient); JSONObject resultItem; JSONObject value; int type; int fedCount = 0; assertTrue(result.isSuccess() && result.getData().size() > 0); try { for (int i = 0; i < result.getData().size(); i++) { resultItem = (JSONObject) result.getData().get(i); value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); if (type == ShareType.FEDERATED.getValue()) { fedCount++; } } assertTrue(fedCount > 0); } catch (JSONException e) { AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); afe.setStackTrace(e.getStackTrace()); throw afe; } // search for 'admin' sharee from external server - expecting at least 1 result String remoteSharee = "admin@" + mServerUri2.split("//")[1]; getShareesOperation = new GetRemoteShareesOperation(remoteSharee, 1, 50); result = getShareesOperation.execute(mClient); assertTrue(result.isSuccess() && result.getData().size() > 0); /// failed cases // search for sharees including wrong page values getShareesOperation = new GetRemoteShareesOperation("@", 0, 50); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); getShareesOperation = new GetRemoteShareesOperation("@", 1, 0); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); }
From source file:com.owncloud.android.lib.test_project.test.GetShareesTest.java
/** * Test get sharees// w w w .j ava2s.com * * Requires OC server 8.2 or later */ public void testGetRemoteShareesOperation() { Log.v(LOG_TAG, "testGetRemoteSharees in"); /// successful cases // search for sharees including "a" GetRemoteShareesOperation getShareesOperation = new GetRemoteShareesOperation("a", 1, 50); RemoteOperationResult result = getShareesOperation.execute(mClient); JSONObject resultItem; JSONObject value; int type; int userCount = 0, groupCount = 0; assertTrue(result.isSuccess() && result.getData().size() > 0); try { for (int i = 0; i < result.getData().size(); i++) { resultItem = (JSONObject) result.getData().get(i); value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); if (type == ShareType.GROUP.getValue()) { groupCount++; } else { userCount++; } } assertTrue(userCount > 0); assertTrue(groupCount > 0); } catch (JSONException e) { AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); afe.setStackTrace(e.getStackTrace()); throw afe; } // search for sharees including "ad" - expecting user "admin" & group "admin" getShareesOperation = new GetRemoteShareesOperation("ad", 1, 50); result = getShareesOperation.execute(mClient); assertTrue(result.isSuccess() && result.getData().size() == 2); userCount = 0; groupCount = 0; try { for (int i = 0; i < 2; i++) { resultItem = (JSONObject) result.getData().get(i); value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); if (type == ShareType.GROUP.getValue()) { groupCount++; } else { userCount++; } } assertEquals(userCount, 1); assertEquals(groupCount, 1); } catch (JSONException e) { AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); afe.setStackTrace(e.getStackTrace()); throw afe; } // search for sharees including "bd" - expecting 0 results getShareesOperation = new GetRemoteShareesOperation("bd", 1, 50); result = getShareesOperation.execute(mClient); assertTrue(result.isSuccess() && result.getData().size() == 0); /// failed cases // search for sharees including wrong page values getShareesOperation = new GetRemoteShareesOperation("a", 0, 50); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); getShareesOperation = new GetRemoteShareesOperation("a", 1, 0); result = getShareesOperation.execute(mClient); assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); }
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 www . ja 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.//from ww w .ja va 2 s. co 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.//ww w . jav a 2s . co 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; } }