Revision: 6129
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6129&view=rev
Author: manningr
Date: 2011-01-02 22:36:38 +0000 (Sun, 02 Jan 2011)
Log Message:
-----------
Allow PluginResources implementation to be injected. Modifed test to support new plugin tests.
Modified Paths:
--------------
trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPlugin.java
trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ConnectAction.java
trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/DisconnectAction.java
trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ValidateSQLAction.java
trunk/sql12/plugins/sqlval/src/test/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPluginTest.java
Modified: trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPlugin.java
===================================================================
--- trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPlugin.java 2011-01-02 22:36:12 UTC (rev 6128)
+++ trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPlugin.java 2011-01-02 22:36:38 UTC (rev 6129)
@@ -28,8 +28,9 @@
import net.sourceforge.squirrel_sql.client.Version;
import net.sourceforge.squirrel_sql.client.action.ActionCollection;
import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
+import net.sourceforge.squirrel_sql.client.plugin.IPluginResourcesFactory;
import net.sourceforge.squirrel_sql.client.plugin.PluginException;
-import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
+import net.sourceforge.squirrel_sql.client.plugin.PluginResourcesFactory;
import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallbackAdaptor;
import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
@@ -39,6 +40,7 @@
import net.sourceforge.squirrel_sql.client.session.event.SQLPanelAdapter;
import net.sourceforge.squirrel_sql.client.session.event.SQLPanelEvent;
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
@@ -81,8 +83,18 @@
private File _userSettingsFolder;
/** Resources for this plugin. */
- private PluginResources _resources;
+ private IResources _resources;
+ private IPluginResourcesFactory _resourcesFactory = new PluginResourcesFactory();
+ /**
+ * @param resourcesFactory the resourcesFactory to set
+ */
+ public void setResourcesFactory(IPluginResourcesFactory resourcesFactory)
+ {
+ _resourcesFactory = resourcesFactory;
+ }
+
+
/** Listener to the SQL panel. */
private ISQLPanelListener _lis = new SQLPanelListener();
@@ -183,7 +195,7 @@
{
super.initialize();
- _resources = new PluginResources(getClass().getName(), this);
+ _resources = _resourcesFactory.createResource(getClass().getName(), this);
// Folder to store user settings.
try
@@ -288,7 +300,7 @@
new ValidatorGlobalPreferencesTab(_prefs), };
}
- PluginResources getResources()
+ IResources getResources()
{
return _resources;
}
Modified: trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ConnectAction.java
===================================================================
--- trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ConnectAction.java 2011-01-02 22:36:12 UTC (rev 6128)
+++ trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ConnectAction.java 2011-01-02 22:36:38 UTC (rev 6129)
@@ -20,15 +20,13 @@
import javax.swing.JDialog;
-import net.sourceforge.squirrel_sql.fw.util.Resources;
-import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
-import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
-
+import net.sourceforge.squirrel_sql.fw.util.IResources;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.sqlval.LogonDialog;
import net.sourceforge.squirrel_sql.plugins.sqlval.SQLValidatorPlugin;
import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
@@ -57,18 +55,18 @@
* Ctor.
*
* @param app Application API.
- * @param rsrc Resources to build this action from.
+ * @param resources Resources to build this action from.
* @param prefs Plugin preferences.
* @param plugin Plugin
*
* @throws IllegalArgumentException
* Thrown if <TT>null</TT>WebServicePreferences</TT> passed.
*/
- public ConnectAction(IApplication app, Resources rsrc,
+ public ConnectAction(IApplication app, IResources resources,
WebServicePreferences prefs,
SQLValidatorPlugin plugin)
{
- super(app, rsrc);
+ super(app, resources);
if (prefs == null)
{
throw new IllegalArgumentException("WebServicePreferences == null");
Modified: trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/DisconnectAction.java
===================================================================
--- trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/DisconnectAction.java 2011-01-02 22:36:12 UTC (rev 6128)
+++ trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/DisconnectAction.java 2011-01-02 22:36:38 UTC (rev 6129)
@@ -18,16 +18,14 @@
*/
import java.awt.event.ActionEvent;
-import net.sourceforge.squirrel_sql.fw.util.BaseException;
-import net.sourceforge.squirrel_sql.fw.util.Resources;
-import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
-import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
-
+import net.sourceforge.squirrel_sql.fw.util.BaseException;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.sqlval.SQLValidatorPlugin;
import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
@@ -56,18 +54,18 @@
* Ctor.
*
* @param app Application API.
- * @param rsrc Resources to build this action from.
+ * @param resources Resources to build this action from.
* @param prefs Plugin preferences.
* @param plugin Plugin
*
* @throws IllegalArgumentException
* Thrown if <TT>null</TT>WebServicePreferences</TT> passed.
*/
- public DisconnectAction(IApplication app, Resources rsrc,
+ public DisconnectAction(IApplication app, IResources resources,
WebServicePreferences prefs,
SQLValidatorPlugin plugin)
{
- super(app, rsrc);
+ super(app, resources);
if (prefs == null)
{
throw new IllegalArgumentException("WebServicePreferences == null");
Modified: trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ValidateSQLAction.java
===================================================================
--- trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ValidateSQLAction.java 2011-01-02 22:36:12 UTC (rev 6128)
+++ trunk/sql12/plugins/sqlval/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlval/action/ValidateSQLAction.java 2011-01-02 22:36:38 UTC (rev 6129)
@@ -21,7 +21,16 @@
import javax.swing.JDialog;
-import net.sourceforge.squirrel_sql.fw.util.*;
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
+import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
+import net.sourceforge.squirrel_sql.fw.util.ICommand;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.sqlval.LogonDialog;
@@ -29,13 +38,6 @@
import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
import net.sourceforge.squirrel_sql.plugins.sqlval.cmd.ValidateSQLCommand;
-
-import net.sourceforge.squirrel_sql.client.IApplication;
-import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
-import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
-import net.sourceforge.squirrel_sql.client.session.ISession;
-import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
-import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
/**
* This action will validate the current SQL.
*
@@ -64,18 +66,18 @@
* Ctor.
*
* @param app Application API.
- * @param rsrc Resources to build this action from.
+ * @param resources Resources to build this action from.
* @param prefs Plugin preferences.
* @param plugin Plugin
*
* @throws IllegalArgumentException
* Thrown if <TT>null</TT>WebServicePreferences</TT> passed.
*/
- public ValidateSQLAction(IApplication app, Resources rsrc,
+ public ValidateSQLAction(IApplication app, IResources resources,
WebServicePreferences prefs,
SQLValidatorPlugin plugin)
{
- super(app, rsrc);
+ super(app, resources);
if (prefs == null)
{
throw new IllegalArgumentException("WebServicePreferences == null");
Modified: trunk/sql12/plugins/sqlval/src/test/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPluginTest.java
===================================================================
--- trunk/sql12/plugins/sqlval/src/test/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPluginTest.java 2011-01-02 22:36:12 UTC (rev 6128)
+++ trunk/sql12/plugins/sqlval/src/test/java/net/sourceforge/squirrel_sql/plugins/sqlval/SQLValidatorPluginTest.java 2011-01-02 22:36:38 UTC (rev 6129)
@@ -18,25 +18,19 @@
*/
package net.sourceforge.squirrel_sql.plugins.sqlval;
-import net.sourceforge.squirrel_sql.client.plugin.AbstractPluginTest;
+import net.sourceforge.squirrel_sql.client.plugin.AbstractSessionPluginTest;
import net.sourceforge.squirrel_sql.client.plugin.DatabaseProductVersionData;
+import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
-import org.junit.After;
-import org.junit.Before;
-
-public class SQLValidatorPluginTest extends AbstractPluginTest implements DatabaseProductVersionData
+public class SQLValidatorPluginTest extends AbstractSessionPluginTest implements DatabaseProductVersionData
{
- @Before
- public void setUp() throws Exception
+ @Override
+ protected IPlugin getPluginToTest() throws Exception
{
- classUnderTest = new SQLValidatorPlugin();
- }
-
- @After
- public void tearDown() throws Exception
- {
- classUnderTest = null;
+ SQLValidatorPlugin result = new SQLValidatorPlugin();
+ result.setResourcesFactory(mockIPluginResourcesFactory);
+ return result;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|