accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject [1/3] git commit: ACCUMULO-2765 Convert FrameworkTest to junit4
Date Wed, 30 Apr 2014 19:39:54 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT b3c893671 -> 1c38957c4
  refs/heads/master 7a826251d -> 1dae0298f


ACCUMULO-2765 Convert FrameworkTest to junit4

Use JUnit 4
To enable new features
Don't catch exceptions


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1c38957c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1c38957c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1c38957c

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 1c38957c453df84462a2cd837b155d590d012d05
Parents: b3c8936
Author: Mike Drob <mdrob@cloudera.com>
Authored: Wed Apr 30 15:29:18 2014 -0400
Committer: Mike Drob <mdrob@cloudera.com>
Committed: Wed Apr 30 15:29:18 2014 -0400

----------------------------------------------------------------------
 .../accumulo/test/randomwalk/FrameworkTest.java | 48 ++++++++++----------
 1 file changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c38957c/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java b/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
index d43347e..ca003ab 100644
--- a/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
@@ -16,52 +16,52 @@
  */
 package org.apache.accumulo.test.randomwalk;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
 import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
-import junit.framework.TestCase;
-
 import org.apache.accumulo.test.randomwalk.unit.CreateTable;
-import org.junit.Assert;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
-public class FrameworkTest extends TestCase {
+public class FrameworkTest {
 
-  public void testXML() {
+  // Need to use fully qualified name here because of conflict with org.apache.accumulo.test.randomwalk.Test
+  @org.junit.Test
+  public void testXML() throws SAXException, URISyntaxException, ParserConfigurationException,
IOException {
+    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+    Schema moduleSchema = sf.newSchema(getFile("/randomwalk/module.xsd"));
 
     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-    DocumentBuilder docbuilder;
+    dbf.setSchema(moduleSchema);
 
-    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-    Schema moduleSchema = null;
-    try {
-      moduleSchema = sf.newSchema(new File(this.getClass().getResource("/randomwalk/module.xsd").toURI()));
-    } catch (Exception e) {
-      Assert.fail("Caught exception: " + e);
-    }
+    DocumentBuilder docbuilder = dbf.newDocumentBuilder();
+    Document document = docbuilder.parse(getFile("/randomwalk/Basic.xml"));
 
-    dbf.setSchema(moduleSchema);
+    assertNotEquals("Parsing randomwalk xml should result in nodes.", 0, document.getChildNodes().getLength());
+  }
 
-    try {
-      File f = new File(this.getClass().getResource("/randomwalk/Basic.xml").toURI());
-      docbuilder = dbf.newDocumentBuilder();
-      docbuilder.parse(f);
-    } catch (Exception e) {
-      Assert.fail("Caught exception: " + e);
-    }
+  private File getFile(String resource) throws URISyntaxException {
+    return new File(this.getClass().getResource(resource).toURI());
   }
 
+  @org.junit.Test
   public void testRWTest() {
-
     Test t1 = new CreateTable();
-    assertTrue(t1.toString().equals("org.apache.accumulo.test.randomwalk.unit.CreateTable"));
+    assertEquals("org.apache.accumulo.test.randomwalk.unit.CreateTable", t1.toString());
 
     Test t2 = new CreateTable();
-    assertTrue(t1.equals(t2));
+    assertEquals("CreateTable test nodes were not equal.", t1, t2);
   }
 
 }


Mime
View raw message