accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject svn commit: r1422156 - /accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java
Date Fri, 14 Dec 2012 23:52:07 GMT
Author: ctubbsii
Date: Fri Dec 14 23:52:06 2012
New Revision: 1422156

URL: http://svn.apache.org/viewvc?rev=1422156&view=rev
Log:
ACCUMULO-870 Made sure these tests load the proper accumulo-site.xml file from their respective
test resource directory without merging in the same configuration between tests

Modified:
    accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java

Modified: accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java?rev=1422156&r1=1422155&r2=1422156&view=diff
==============================================================================
--- accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java
(original)
+++ accumulo/trunk/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java
Fri Dec 14 23:52:06 2012
@@ -36,14 +36,11 @@ import org.powermock.reflect.Whitebox;
 
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AccumuloVFSClassLoader.class)
-@SuppressStaticInitializationFor({"org.apache.accumulo.start.classloader.AccumuloVFSClassLoader",

-  "org.apache.log4j.LogManager"})
-@PowerMockIgnore({"org.apache.log4j.*", 
-  "org.apache.hadoop.log.metrics", "org.apache.commons.logging.*",
-  "org.xml.*", "javax.xml.*", "org.w3c.dom.*", "org.apache.hadoop.*"})
+@SuppressStaticInitializationFor({"org.apache.accumulo.start.classloader.AccumuloVFSClassLoader",
"org.apache.log4j.LogManager"})
+@PowerMockIgnore({"org.apache.log4j.*", "org.apache.hadoop.log.metrics", "org.apache.commons.logging.*",
"org.xml.*", "javax.xml.*", "org.w3c.dom.*",
+    "org.apache.hadoop.*"})
 public class AccumuloVFSClassLoaderTest extends AccumuloDFSBase {
-
-
+  
   /*
    * Test that if not enabled, the AccumuloClassLoader is used
    */
@@ -71,9 +68,9 @@ public class AccumuloVFSClassLoaderTest 
     ClassLoader acl = AccumuloVFSClassLoader.getClassLoader();
     Assert.assertTrue((acl instanceof URLClassLoader));
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "loader", (AccumuloContextClassLoader)
null);
-//    URLClassLoader ucl = (URLClassLoader) acl;
-//    URL[] classpath = ucl.getURLs();
-//    System.out.println(Arrays.toString(classpath));
+    // URLClassLoader ucl = (URLClassLoader) acl;
+    // URL[] classpath = ucl.getURLs();
+    // System.out.println(Arrays.toString(classpath));
   }
   
   /*
@@ -82,19 +79,19 @@ public class AccumuloVFSClassLoaderTest 
   @Test
   public void testDefaultContextConfigured() throws Exception {
     
-    //Create default context directory
-    @SuppressWarnings("resource")
+    // Create default context directory
     FileSystem hdfs = cluster.getFileSystem();
     Path DEFAULT = new Path("/accumulo/classpath");
     hdfs.mkdirs(DEFAULT);
     
-    //Copy jar file to TEST_DIR
+    // Copy jar file to TEST_DIR
     URL jarPath = this.getClass().getResource("/HelloWorld.jar");
     Path src = new Path(jarPath.toURI().toString());
     Path dst = new Path(DEFAULT, src.getName());
     hdfs.copyFromLocalFile(src, dst);
     
     URL defaultDir = this.getClass().getResource("/default");
+    Configuration conf = new Configuration(hdfs.getConf());
     conf.addResource(new File(defaultDir.getPath() + "/conf/accumulo-site.xml").toURI().toURL());
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "ACC_CONF", conf);
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "lock", new Object());
@@ -111,22 +108,20 @@ public class AccumuloVFSClassLoaderTest 
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "loader", (AccumuloContextClassLoader)
null);
     
     hdfs.delete(DEFAULT, true);
-
+    
   }
-
+  
   @Test
   public void testAdditionalContextConfigured() throws Exception {
-
-    //Create default and application1 context directory
-    @SuppressWarnings("resource")
+    
+    // Create default and application1 context directory
     FileSystem hdfs = cluster.getFileSystem();
     Path DEFAULT = new Path("/accumulo/classpath");
     hdfs.mkdirs(DEFAULT);
     Path APPLICATION = new Path("/application1/classpath");
     hdfs.mkdirs(APPLICATION);
-
     
-    //Copy jar file to DEFAULT and APPLICATION directories
+    // Copy jar file to DEFAULT and APPLICATION directories
     URL jarPath = this.getClass().getResource("/HelloWorld.jar");
     Path src = new Path(jarPath.toURI().toString());
     Path dst = new Path(DEFAULT, src.getName());
@@ -135,23 +130,24 @@ public class AccumuloVFSClassLoaderTest 
     hdfs.copyFromLocalFile(src, dst);
     
     URL defaultDir = this.getClass().getResource("/application1");
+    Configuration conf = new Configuration(hdfs.getConf());
     conf.addResource(new File(defaultDir.getPath() + "/conf/accumulo-site.xml").toURI().toURL());
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "ACC_CONF", conf);
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "lock", new Object());
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "log", Logger.getLogger(AccumuloVFSClassLoader.class));
-
+    
     ClassLoader acl = AccumuloVFSClassLoader.getClassLoader();
     Assert.assertTrue((acl instanceof AccumuloContextClassLoader));
     AccumuloContextClassLoader accl = (AccumuloContextClassLoader) acl;
-    //DEFAULT CONTEXT
+    // DEFAULT CONTEXT
     AccumuloReloadingVFSClassLoader arvcl = accl.getClassLoader(AccumuloContextClassLoader.DEFAULT_CONTEXT);
     Assert.assertEquals(1, arvcl.getFiles().length);
     Assert.assertTrue(arvcl.getFiles()[0].getURL().toString().equals(AccumuloDFSBase.HDFS_URI
+ "/accumulo/classpath/HelloWorld.jar"));
     Class<?> clazz1 = arvcl.loadClass("test.HelloWorld");
     Object o1 = clazz1.newInstance();
     Assert.assertEquals("Hello World!", o1.toString());
-
-    //APPLICATION CONTEXT
+    
+    // APPLICATION CONTEXT
     AccumuloReloadingVFSClassLoader arvcl2 = accl.getClassLoader("application1");
     Assert.assertEquals(1, arvcl2.getFiles().length);
     Assert.assertTrue(arvcl2.getFiles()[0].getURL().toString().equals(AccumuloDFSBase.HDFS_URI
+ "/application1/classpath/HelloWorld.jar"));
@@ -166,19 +162,17 @@ public class AccumuloVFSClassLoaderTest 
     hdfs.delete(APPLICATION, true);
     
   }
-
+  
   @Test
   public void testLoadClass() throws Exception {
-    //Create default and application1 context directory
-    @SuppressWarnings("resource")
+    // Create default and application1 context directory
     FileSystem hdfs = cluster.getFileSystem();
     Path DEFAULT = new Path("/accumulo/classpath");
     hdfs.mkdirs(DEFAULT);
     Path APPLICATION = new Path("/application1/classpath");
     hdfs.mkdirs(APPLICATION);
-
     
-    //Copy jar file to DEFAULT and APPLICATION directories
+    // Copy jar file to DEFAULT and APPLICATION directories
     URL jarPath = this.getClass().getResource("/HelloWorld.jar");
     Path src = new Path(jarPath.toURI().toString());
     Path dst = new Path(DEFAULT, src.getName());
@@ -187,11 +181,12 @@ public class AccumuloVFSClassLoaderTest 
     hdfs.copyFromLocalFile(src, dst);
     
     URL defaultDir = this.getClass().getResource("/application1");
+    Configuration conf = new Configuration(hdfs.getConf());
     conf.addResource(new File(defaultDir.getPath() + "/conf/accumulo-site.xml").toURI().toURL());
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "ACC_CONF", conf);
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "lock", new Object());
     Whitebox.setInternalState(AccumuloVFSClassLoader.class, "log", Logger.getLogger(AccumuloVFSClassLoader.class));
-
+    
     Class<?> clazz1 = AccumuloVFSClassLoader.loadClass("test.HelloWorld");
     Object o1 = clazz1.newInstance();
     Assert.assertEquals("Hello World!", o1.toString());
@@ -202,5 +197,5 @@ public class AccumuloVFSClassLoaderTest 
     hdfs.delete(APPLICATION, true);
     
   }
-
+  
 }



Mime
View raw message