From dlanglais@users.nuiton.org Sat Mar  6 13:47:30 2010
From: dlanglais@users.nuiton.org
To: mapstoragemanager-commits@list.nuiton.org
Subject: [Mapstoragemanager-commits] r192 - in trunk/msm: .
	src/main/java/org/nuiton/mapstoragemanager/core
	src/main/java/org/nuiton/mapstoragemanager/ui/gui
	src/test/java/org/nuiton/mapstoragemanager/core
Date: Sat, 06 Mar 2010 13:47:29 +0100
Message-ID: <20100306124730.056D759DA6@nuiton.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1572816195513161584=="

--===============1572816195513161584==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Author: dlanglais
Date: 2010-03-06 13:47:28 +0100 (Sat, 06 Mar 2010)
New Revision: 192

Log:
Suppression de la classe de test TestServiceLoader.
Cr?\195?\169ation d'une classe de test pour PluginLoader (quasi vide pour le =
moment).

Added:
   trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/PluginLoaderTest=
.java
Removed:
   trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/TestServiceLoade=
r.java
Modified:
   trunk/msm/pom.xml
   trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.java
   trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEng=
ine.java

Modified: trunk/msm/pom.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/msm/pom.xml	2010-03-06 05:34:16 UTC (rev 191)
+++ trunk/msm/pom.xml	2010-03-06 12:47:28 UTC (rev 192)
@@ -126,7 +126,7 @@
     <!-- *** Build Settings ****************************************** -->
     <!-- ************************************************************* -->
     <properties>
-        <maven.test.skip>true</maven.test.skip>
+        <maven.test.skip>false</maven.test.skip>
=20
         <!--MSM Main Class in JAR -->
         <maven.jar.main.class>org.nuiton.mapstoragemanager.Main</maven.jar.m=
ain.class>

Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoa=
der.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.ja=
va	2010-03-06 05:34:16 UTC (rev 191)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.ja=
va	2010-03-06 12:47:28 UTC (rev 192)
@@ -151,8 +151,6 @@
                     pluginsWanted.add(plugin);
                 }
             }
-        } else {
-            pluginsWanted =3D plugins.values();
         }
        =20
         return pluginsWanted;

Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/Applica=
tionEngine.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEn=
gine.java	2010-03-06 05:34:16 UTC (rev 191)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEn=
gine.java	2010-03-06 12:47:28 UTC (rev 192)
@@ -44,11 +44,11 @@
     /**
      * Importer.
      */
-    private Importer importer;
+//    private Importer importer;
     /**
      * Exporter.
      */
-    private Exporter exporter;
+//    private Exporter exporter;
     /**
      * classe instance (singleton pattern).
      */
@@ -408,7 +408,7 @@
         Item selectedItem =3D ui.getImporter().getSelectedJaxxItem();
         String importerName =3D selectedItem.getValue().toString();
=20
-        importer =3D (Importer) pluginLoader.getPlugin(importerName);
+        Importer importer =3D (Importer) pluginLoader.getPlugin(importerName=
);
=20
         /** Create FileChooser and set FileFilter.   */
         JFileChooser jfc =3D new JFileChooser(lastPath);
@@ -441,7 +441,7 @@
         Item selectedItem =3D ui.getExporter().getSelectedJaxxItem();
         String exporterName =3D selectedItem.getValue().toString();
        =20
-        exporter =3D (Exporter) pluginLoader.getPlugin(exporterName);
+        Exporter exporter =3D (Exporter) pluginLoader.getPlugin(exporterName=
);
=20
         /** Create FileChooser and set FileFilter.   */
         JFileChooser jfc =3D new JFileChooser(lastPath);

Added: trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/PluginLoader=
Test.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/PluginLoaderTes=
t.java	                        (rev 0)
+++ trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/PluginLoaderTes=
t.java	2010-03-06 12:47:28 UTC (rev 192)
@@ -0,0 +1,141 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.nuiton.mapstoragemanager.core;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.filechooser.FileFilter;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
+import org.nuiton.mapstoragemanager.plugins.Exporter;
+import org.nuiton.mapstoragemanager.plugins.Importer;
+import org.nuiton.mapstoragemanager.plugins.Plugin;
+
+/**
+ *
+ * @author Dorian Langlais
+ */
+public class PluginLoaderTest extends TestCase {
+
+    /**
+     * Logger.
+     */
+    private static final Log LOG =3D LogFactory.getLog(PluginLoaderTest.clas=
s);
+
+    /**
+     * pluginsMapActual.
+     */
+    Map<String, Plugin> pluginsMapActual;
+    /**
+     * pluginLoader.
+     */
+    PluginLoader pl;
+
+    /**
+     * initialisation to prepare test.
+     */
+    @Override
+    public void setUp() {
+        /**
+         * Initialisation.
+         */
+        try {
+            pl =3D new PluginLoader(new File("").getAbsolutePath(),
+                this.getClass().getClassLoader());
+            Field fPlugins =3D pl.getClass().getDeclaredField("plugins");
+            fPlugins.setAccessible(true);
+            pluginsMapActual =3D (Map<String, Plugin>) fPlugins.get(pl);
+
+            /** Remise =C3=A0 z=C3=A9ro de la Map */
+            pluginsMapActual.clear();
+        } catch (IllegalArgumentException ex) {
+            LOG.fatal(ex, ex);
+            Assert.fail();
+        } catch (IllegalAccessException ex) {
+            LOG.fatal(ex, ex);
+            Assert.fail();
+        } catch (NoSuchFieldException ex) {
+            LOG.fatal(ex, ex);
+            Assert.fail();
+        } catch (SecurityException ex) {
+            LOG.fatal(ex, ex);
+            Assert.fail();
+        } catch (MalformedURLException ex) {
+            LOG.fatal(ex, ex);
+            Assert.fail();
+        }
+    }
+
+    public void testGetAllPluginNames() {
+        this.setUp();
+
+        Set<String> pluginsNamesExpected =3D new HashSet<String>();
+        Set<String> pluginsNamesActual =3D pl.getAllPluginNames();
+
+        assertEquals(pluginsNamesExpected, pluginsNamesActual);
+
+        pluginsNamesExpected.add("Test");
+        pluginsMapActual.put("Test", null);
+        pluginsNamesActual =3D pl.getAllPluginNames();
+
+        assertEquals(pluginsNamesExpected, pluginsNamesActual);
+
+    }
+
+    public void testGetAllPlugin() {
+        this.setUp();
+
+        Collection<Plugin> pluginsExpected =3D new HashSet<Plugin>();
+        Collection<Plugin> pluginsActual =3D pl.getAllPlugin(null);
+
+        assertEquals(pluginsExpected, pluginsActual);
+
+        Plugin test =3D new Importer() {
+
+            @Override
+            public void importFrom(BigTable bigTable, File file) {
+                throw new UnsupportedOperationException("Not supported yet."=
);
+            }
+
+            @Override
+            public FileFilter getFileFilter() {
+                throw new UnsupportedOperationException("Not supported yet."=
);
+            }
+
+            @Override
+            public String getPluginName() {
+                throw new UnsupportedOperationException("Not supported yet."=
);
+            }
+
+        };
+
+        pluginsExpected.add(test);
+        pluginsMapActual.put("Test", test);
+        pluginsActual =3D pl.getAllPlugin(Importer.class);
+        assertEquals(pluginsExpected, pluginsActual);
+
+        pluginsExpected.clear();
+        pluginsActual =3D pl.getAllPlugin(Exporter.class);
+        assertEquals(pluginsExpected, pluginsActual);
+
+        pluginsExpected.clear();
+        pluginsActual =3D pl.getAllPlugin(BigTable.class);
+        assertEquals(pluginsExpected, pluginsActual);
+
+        pluginsExpected.clear();
+        pluginsActual =3D pl.getAllPlugin(null);
+        assertEquals(pluginsExpected, pluginsActual);
+
+    }
+}

Deleted: trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/TestServic=
eLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/TestServiceLoad=
er.java	2010-03-06 05:34:16 UTC (rev 191)
+++ trunk/msm/src/test/java/org/nuiton/mapstoragemanager/core/TestServiceLoad=
er.java	2010-03-06 12:47:28 UTC (rev 192)
@@ -1,35 +0,0 @@
-package org.nuiton.mapstoragemanager.core;
-
-import java.net.MalformedURLException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author fdesbois
- * @deprecated Use org.nuiton.mapstoragemanager.core.BigTableLoaderText inst=
ead
- */
-@Deprecated
-public final class TestServiceLoader {
-
-    /**
-     * Logger.
-     */
-    private static final Log LOG =3D LogFactory.getLog(TestServiceLoader.cla=
ss);
-
-    private TestServiceLoader() {
-        try {
-            PluginLoader p =3D
-                new PluginLoader("plugins", this.getClass().getClassLoader()=
);
-            LOG.info(p.getPluginsToString());
-        } catch (MalformedURLException e) {
-            // TODO Auto-generated catch block
-            //e.printStackTrace();
-            LOG.error(e.toString(),e);
-        }
-    }
-
-    public static void main(final String[] args) {
-
-        new TestServiceLoader();
-    }
-}
\ No newline at end of file


--===============1572816195513161584==--


