Revision: 6235
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6235&view=rev
Author: manningr
Date: 2011-04-12 20:10:54 +0000 (Tue, 12 Apr 2011)
Log Message:
-----------
Removed all remaining stub objects save for MockSession.
Modified Paths:
--------------
trunk/sql12/squirrelsql-integration-environment/pom.xml
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSession.java
Removed Paths:
-------------
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/MockApplication.java
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSessionManager.java
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/fw/util/
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/mo/sql/
Modified: trunk/sql12/squirrelsql-integration-environment/pom.xml
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/pom.xml 2011-04-11 21:29:12 UTC (rev 6234)
+++ trunk/sql12/squirrelsql-integration-environment/pom.xml 2011-04-12 20:10:54 UTC (rev 6235)
@@ -102,16 +102,6 @@
<type>test-jar</type>
</dependency>
<dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-jdk1.4</artifactId>
- <version>0.09</version>
- </dependency>
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-core</artifactId>
- <version>0.09</version>
- </dependency>
- <dependency>
<groupId>net.sf.squirrel-sql.plugins</groupId>
<artifactId>db2</artifactId>
<version>${squirrel-sql-version}</version>
Deleted: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/MockApplication.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/MockApplication.java 2011-04-11 21:29:12 UTC (rev 6234)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/MockApplication.java 2011-04-12 20:10:54 UTC (rev 6235)
@@ -1,239 +0,0 @@
-/*
- * Copyright (C) 2006 Rob Manning
- * man...@us...
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package net.sourceforge.squirrel_sql.client;
-
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JMenu;
-
-import net.sourceforge.squirrel_sql.client.action.ActionCollection;
-import net.sourceforge.squirrel_sql.client.gui.WindowManager;
-import net.sourceforge.squirrel_sql.client.gui.db.DataCache;
-import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.DesktopStyle;
-import net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrame;
-import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
-import net.sourceforge.squirrel_sql.client.plugin.IPluginManager;
-import net.sourceforge.squirrel_sql.client.plugin.PluginManager;
-import net.sourceforge.squirrel_sql.client.preferences.PreferenceType;
-import net.sourceforge.squirrel_sql.client.preferences.SquirrelPreferences;
-import net.sourceforge.squirrel_sql.client.resources.SquirrelResources;
-import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanelFactory;
-import net.sourceforge.squirrel_sql.client.session.MockSessionManager;
-import net.sourceforge.squirrel_sql.client.session.SessionManager;
-import net.sourceforge.squirrel_sql.client.session.mainpanel.SQLHistory;
-import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
-import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
-import net.sourceforge.squirrel_sql.fw.util.MockMessageHandler;
-import net.sourceforge.squirrel_sql.fw.util.TaskThreadPool;
-
-public class MockApplication implements IApplication {
-
- TaskThreadPool threadPool = null;
- IPluginManager pluginManager = null;
- ActionCollection actions = null;
- SquirrelResources resource = null;
- SquirrelPreferences prefs = null;
- SQLHistory history = null;
- IMessageHandler messageHandler = null;
- MockSessionManager sessionHandler = null;
- FontInfoStore fontInfoStore = null;
-
- public MockApplication() {
- resource =
- new SquirrelResources("net.sourceforge.squirrel_sql.client.resources.squirrel");
- prefs = SquirrelPreferences.load();
- threadPool = new TaskThreadPool();
- pluginManager = new PluginManager(this);
- actions = new ActionCollection(this);
- history = new SQLHistory();
- messageHandler = new MockMessageHandler();
- sessionHandler = new MockSessionManager(this);
- fontInfoStore = new FontInfoStore();
- }
-
- public MockSessionManager getMockSessionManager() {
- return sessionHandler;
- }
-
- public IPlugin getDummyAppPlugin() {
-
- System.err.println("MockApplication.getDummyAppPlugin: stub not yet implemented");
- return null;
- }
-
- public IPluginManager getPluginManager() {
- return pluginManager;
- }
-
- public WindowManager getWindowManager() {
-
- System.err.println("MockApplication.getWindowManager: stub not yet implemented");
- return null;
- }
-
- public ActionCollection getActionCollection() {
- return actions;
- }
-
- public SQLDriverManager getSQLDriverManager() {
-
- System.err.println("MockApplication.getSQLDriverManager: stub not yet implemented");
- return null;
- }
-
- public DataCache getDataCache() {
-
- System.err.println("MockApplication.getDataCache: stub not yet implemented");
- return null;
- }
-
- public SquirrelPreferences getSquirrelPreferences() {
- return prefs;
- }
-
- public SquirrelResources getResources() {
- return resource;
- }
-
- public IMessageHandler getMessageHandler() {
- return messageHandler;
- }
-
- public SessionManager getSessionManager() {
- return sessionHandler;
- }
-
- public void showErrorDialog(String msg) {
-
- System.err.println("MockApplication.showErrorDialog(String): stub not yet implemented");
- }
-
- public void showErrorDialog(Throwable th) {
-
- System.err.println("MockApplication.showErrorDialog(Throwable): stub not yet implemented");
- }
-
- public void showErrorDialog(String msg, Throwable th) {
-
- System.err.println("MockApplication.showErrorDialog(String, Throwable): stub not yet implemented");
- }
-
- public MainFrame getMainFrame() {
-
- //System.err.println("MockApplication.getMainFrame: stub not yet implemented");
- return null;
- }
-
- public TaskThreadPool getThreadPool() {
- return threadPool;
- }
-
- public FontInfoStore getFontInfoStore() {
- return fontInfoStore;
- }
-
- public ISQLEntryPanelFactory getSQLEntryPanelFactory() {
- return null;
- }
-
- public SQLHistory getSQLHistory() {
- return history;
- }
-
- public void setSQLEntryPanelFactory(ISQLEntryPanelFactory factory) {
-
- System.err.println("MockApplication.setSQLEntryPanelFactory: stub not yet implemented");
- }
-
- public void addToMenu(int menuId, JMenu menu) {
-
- System.err.println("MockApplication.addToMenu(int, JMenu): stub not yet implemented");
- }
-
- public void addToMenu(int menuId, Action action) {
-
- System.err.println("MockApplication.addToMenu(int, Action): stub not yet implemented");
- }
-
- public void addToStatusBar(JComponent comp) {
-
- System.err.println("MockApplication.addToStatusBar: stub not yet implemented");
- }
-
- public void removeFromStatusBar(JComponent comp) {
-
- System.err.println("MockApplication.removeFromStatusBar: stub not yet implemented");
- }
-
- public void startup() {
-
- System.err.println("MockApplication.startup: stub not yet implemented");
- }
-
- public boolean shutdown() {
-
- System.err.println("MockApplication.shutdown: stub not yet implemented");
- return false;
- }
-
- public void openURL(String url) {
-
- System.err.println("MockApplication.openURL: stub not yet implemented");
- }
-
-
- /**
- * @see net.sourceforge.squirrel_sql.client.IApplication#saveApplicationState()
- */
- public void saveApplicationState() {
-
-
- }
-
- /**
- * @see net.sourceforge.squirrel_sql.client.IApplication#savePreferences(net.sourceforge.squirrel_sql.client.preferences.PreferenceType)
- */
- public void savePreferences(PreferenceType preferenceType) {
-
-
- }
-
- /**
- * @see net.sourceforge.squirrel_sql.client.IApplication#addApplicationListener(net.sourceforge.squirrel_sql.client.ApplicationListener)
- */
- public void addApplicationListener(ApplicationListener l)
- {
-
-
- }
-
- /**
- * @see net.sourceforge.squirrel_sql.client.IApplication#removeApplicationListener(net.sourceforge.squirrel_sql.client.ApplicationListener)
- */
- public void removeApplicationListener(ApplicationListener l)
- {
-
-
- }
-
- public DesktopStyle getDesktopStyle()
- {
- return new DesktopStyle(getSquirrelPreferences());
- }
-}
Modified: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSession.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSession.java 2011-04-11 21:29:12 UTC (rev 6234)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSession.java 2011-04-12 20:10:54 UTC (rev 6235)
@@ -18,6 +18,7 @@
*/
package net.sourceforge.squirrel_sql.client.session;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.sql.Connection;
@@ -27,9 +28,7 @@
import javax.swing.Action;
import javax.swing.JComponent;
-import net.sourceforge.squirrel_sql.client.AppTestUtil;
import net.sourceforge.squirrel_sql.client.IApplication;
-import net.sourceforge.squirrel_sql.client.MockApplication;
import net.sourceforge.squirrel_sql.client.gui.builders.UIFactory;
import net.sourceforge.squirrel_sql.client.gui.db.ISQLAliasExt;
import net.sourceforge.squirrel_sql.client.gui.db.SQLAlias;
@@ -53,30 +52,18 @@
import net.sourceforge.squirrel_sql.fw.sql.SQLConnection;
import net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter;
import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
-import net.sourceforge.squirrel_sql.fw.util.MockMessageHandler;
-import net.sourceforge.squirrel_sql.mo.sql.MockDatabaseMetaData;
-import org.mockito.Mockito;
-
-import com.mockobjects.sql.MockConnection2;
-
public class MockSession implements ISession
{
ISQLAliasExt sqlAlias = null;
- ISQLDriver sqlDriver = Mockito.mock(ISQLDriver.class);
+ ISQLDriver sqlDriver = mock(ISQLDriver.class);
SQLConnection con = null;
- MockDatabaseMetaData mdata = null;
-
- MockApplication app = null;
-
SessionProperties props = null;
- IMessageHandler messageHandler = null;
-
SchemaInfo schemaInfo = null;
SessionPanel sessionPanel = null;
@@ -87,18 +74,19 @@
boolean closed;
- ISQLPanelAPI panelApi = AppTestUtil.getEasyMockSqlPanelApi();
-
// These tell the Dialect test runner where tables that it creates can be found.
private String defaultCatalog = "";
private String defaultSchema = "";
- public MockSession()
- {
- init(true);
- }
+ private ISQLPanelAPI mockPanelApi = mock(ISQLPanelAPI.class);
+
+ private IApplication mockApplication = mock(IApplication.class);
+
+ private SessionManager mockSessionManager = mock(SessionManager.class);
+ private IMessageHandler mockMessageHandler = mock(IMessageHandler.class);
+
public MockSession(String className, String jdbcUrl, String u, String p) throws Exception
{
System.out.println("Attempting to load class=" + className);
@@ -107,7 +95,7 @@
Connection c = DriverManager.getConnection(jdbcUrl, u, p);
initMockDriver(className, jdbcUrl);
con = new SQLConnection(c, null, sqlDriver);
- init(false);
+ init();
sqlAlias.setUrl(jdbcUrl);
sqlAlias.setUserName(u);
sqlAlias.setPassword(p);
@@ -121,51 +109,35 @@
when(sqlDriver.getName()).thenReturn("MockitoSQLDriver");
}
- private void init(boolean initConnection)
+ private void init() throws SQLException
{
- if (initConnection)
- {
- // MockConnection2 mockCon = getMockConnection();
- con = new SQLConnection(getMockConnection(), null, sqlDriver);
- }
id = new UidIdentifier();
- messageHandler = new MockMessageHandler();
+
props = new SessionProperties();
props.setLoadSchemasCatalogs(false);
- app = new MockApplication();
- app.getMockSessionManager().setSession(this);
+
+ when(mockApplication.getSessionManager()).thenReturn(mockSessionManager);
+
+ when(mockSessionManager.getActiveSession()).thenReturn(this);
+ when(mockSessionManager.getSession(id)).thenReturn(this);
+ when(mockSessionManager.getNextSession(this)).thenReturn(this);
+ when(mockSessionManager.getPreviousSession(this)).thenReturn(this);
+ when(mockSessionManager.getAllowedSchemas(this)).thenReturn(con.getSQLMetaData().getSchemas());
+
sqlAlias = new SQLAlias(new UidIdentifier());
- schemaInfo = new SchemaInfo(app);
+ schemaInfo = new SchemaInfo(mockApplication);
schemaInfo.initialLoad(this);
- prefs = app.getSquirrelPreferences();
+ prefs = mockApplication.getSquirrelPreferences();
try
{
- UIFactory.initialize(prefs, app);
+ UIFactory.initialize(prefs, mockApplication);
}
catch (Throwable e)
{
}
- // If we are connecting to a database, then this is fine. However, when
- // using MockObjects, this is problematic since there are many
- // unimplemented methods in the MockObjects implementation that are
- // required by this.
- if (!initConnection)
- {
- // sessionPanel = new SessionPanel(this);
- }
}
- private MockConnection2 getMockConnection()
- {
- MockConnection2 result = new MockConnection2();
- initMockDriver("JUnitTestClassName", "JUnitJDBCURL");
- mdata = new MockDatabaseMetaData();
- mdata.setupDriverName("junit");
- result.setupMetaData(mdata);
- return result;
- }
-
/**
* @see net.sourceforge.squirrel_sql.client.session.ISession#getExceptionFormatter()
*/
@@ -192,7 +164,7 @@
public IApplication getApplication()
{
- return app;
+ return mockApplication;
}
public ISQLConnection getSQLConnection()
@@ -286,12 +258,12 @@
public void setMessageHandler(IMessageHandler handler)
{
- messageHandler = handler;
+ mockMessageHandler = handler;
}
public IMessageHandler getMessageHandler()
{
- return messageHandler;
+ return mockMessageHandler;
}
public SessionPanel getSessionSheet()
@@ -306,9 +278,6 @@
return null;
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.client.session.ISession#getSchemaInfo()
- */
public SchemaInfo getSchemaInfo()
{
return schemaInfo;
@@ -394,7 +363,7 @@
public ISQLPanelAPI getSQLPanelAPIOfActiveSessionWindow()
{
- return panelApi;
+ return mockPanelApi;
}
public IObjectTreeAPI getObjectTreeAPIOfActiveSessionWindow()
@@ -429,11 +398,6 @@
return id;
}
- public MockDatabaseMetaData getMockDatabaseMetaData()
- {
- return mdata;
- }
-
/**
* @param defaultCatalog
* the defaultCatalog to set
Deleted: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSessionManager.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSessionManager.java 2011-04-11 21:29:12 UTC (rev 6234)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/client/session/MockSessionManager.java 2011-04-12 20:10:54 UTC (rev 6235)
@@ -1,24 +0,0 @@
-package net.sourceforge.squirrel_sql.client.session;
-
-import net.sourceforge.squirrel_sql.client.IApplication;
-import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
-
-public class MockSessionManager extends SessionManager {
-
- ISession session = null;
-
- public MockSessionManager(IApplication app) {
- super(app);
- }
-
- public void setSession(ISession aSession) {
- session = aSession;
- }
-
- public ISession getSession(IIdentifier sessionID) {
- return session;
- }
-
-
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|