[jboss-cvs] JBossAS SVN: r103988 - in projects/scanning/trunk: plugins/src/main/java/org/jboss/scanning/hierarchy/plugins and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 15 07:29:56 EDT 2010


Author: alesj
Date: 2010-04-15 07:29:55 -0400 (Thu, 15 Apr 2010)
New Revision: 103988

Added:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/IndexerTestSuite.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/test/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/test/IndexerSmokeTestCase.java
Modified:
   projects/scanning/trunk/indexer/src/main/java/org/jboss/scanning/indexer/core/ScanUtils.java
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java
Log:
Initial indexer tests.

Modified: projects/scanning/trunk/indexer/src/main/java/org/jboss/scanning/indexer/core/ScanUtils.java
===================================================================
--- projects/scanning/trunk/indexer/src/main/java/org/jboss/scanning/indexer/core/ScanUtils.java	2010-04-15 08:59:05 UTC (rev 103987)
+++ projects/scanning/trunk/indexer/src/main/java/org/jboss/scanning/indexer/core/ScanUtils.java	2010-04-15 11:29:55 UTC (rev 103988)
@@ -55,9 +55,10 @@
     * @param input the input jar
     * @param pluginProviders the providers for plugins used while scanning
     * @param cp the classpath
+    * @return output file
     * @throws Exception for any error
     */
-   public static void scan(File input, Set<String> pluginProviders, URL[] cp) throws Exception
+   public static File scan(File input, Set<String> pluginProviders, URL... cp) throws Exception
    {
       if (input == null)
          throw new IllegalArgumentException("Null input");
@@ -86,11 +87,18 @@
       Map<ScanningPlugin, ScanningHandle> handles = scaner.getHandles();
       File tmp = new File(System.getProperty("java.io.tmpdir"));
       File jar = FileUtil.extract(input, tmp);
-      File destination = new File(jar, Scanner.PREFIX);
-      store(destination, handles);
-      File output = new File(input.getName() + Scanner.SUFFIX);
-      FileUtil.compress(jar, output);
-      FileUtil.recursiveDelete(jar);
+      try
+      {
+         File destination = new File(jar, Scanner.PREFIX);
+         store(destination, handles);
+         File output = new File(input.getName() + Scanner.SUFFIX);
+         FileUtil.compress(jar, output);
+         return output;
+      }
+      finally
+      {
+         FileUtil.recursiveDelete(jar);
+      }
    }
 
    /**
@@ -154,7 +162,8 @@
          ObjectOutputStream oos = new ObjectOutputStream(gos);
          try
          {
-            oos.writeObject(entry.getValue());
+            ScanningHandle handle = entry.getValue();
+            oos.writeObject(handle);
             oos.flush();
          }
          finally

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java	2010-04-15 08:59:05 UTC (rev 103987)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java	2010-04-15 11:29:55 UTC (rev 103988)
@@ -22,6 +22,7 @@
 
 package org.jboss.scanning.hierarchy.plugins;
 
+import java.io.Serializable;
 import java.util.*;
 
 import org.jboss.reflect.spi.TypeInfo;
@@ -33,8 +34,10 @@
 /**
  * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
  */
-public class HierarchyIndexImpl implements HierarchyIndex, ScanningHandle<HierarchyIndexImpl>
+public class HierarchyIndexImpl implements HierarchyIndex, ScanningHandle<HierarchyIndexImpl>, Serializable
 {
+   private static final long serialVersionUID = 1l;
+   
    /** The inherited types */
    private Map<String, Map<TypeInfo, Set<TypeInfo>>> cache = new HashMap<String, Map<TypeInfo, Set<TypeInfo>>>();
    /** The type info factory */

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/IndexerTestSuite.java (from rev 103839, projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/ScanningTestSuite.java)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/IndexerTestSuite.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/IndexerTestSuite.java	2010-04-15 11:29:55 UTC (rev 103988)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.scanning.indexer;
+
+import org.jboss.test.scanning.indexer.test.IndexerSmokeTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IndexerTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Indexer Tests");
+
+      suite.addTest(IndexerSmokeTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/test/IndexerSmokeTestCase.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/test/IndexerSmokeTestCase.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/indexer/test/IndexerSmokeTestCase.java	2010-04-15 11:29:55 UTC (rev 103988)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.scanning.indexer.test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Set;
+
+import org.jboss.scanning.indexer.Constants;
+import org.jboss.scanning.indexer.core.ScanUtils;
+import org.jboss.test.BaseTestCase;
+
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IndexerSmokeTestCase extends BaseTestCase
+{
+   public IndexerSmokeTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(IndexerSmokeTestCase.class);
+   }
+
+   public void testSmoke() throws Exception
+   {
+      URL url = getResource("/hibernate/defaultpar.jar");
+      File input = new File(url.toURI());
+      Set<String> providers = Constants.applyAliases("@", "h");
+      File output = ScanUtils.scan(input, providers);
+      assertTrue(output.delete());
+   }
+}




More information about the jboss-cvs-commits mailing list