Permalink
Browse files

Added easymock for mocking objects

EasyMock is already being used on the HaskellCorePluginTest, but we need
to gradully convert other tests to use it.

EclipseFP's developer SDK is getting quite large. There are at least two
Eclipse plugins already (antlr and easymock). Maybe we should package this as
a feature or something.

darcs-hash:20060510143547-49d33-e40b59ee1e1d1e1356b0d6800ed1ff103fb35b5b.gz
  • Loading branch information...
1 parent 7693409 commit dbe565ac0ff930dc34429ef7f9f392816f9cb226 @thiagoarrais thiagoarrais committed May 10, 2006
View
1 net.sf.eclipsefp.haskell.core.test/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 0.10.0
Bundle-Vendor: eclipsefp.sourceforge.net
Bundle-Localization: plugin
Require-Bundle: org.junit,
+ org.easymock,
org.eclipse.jface.text,
org.eclipse.core.resources,
org.eclipse.core.runtime,
View
19 ...psefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/HaskellCorePluginTest.java
@@ -1,22 +1,33 @@
package net.sf.eclipsefp.haskell.core.test;
import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
-import net.sf.eclipsefp.haskell.core.test.internal.doubles.MockWorkspace;
import net.sf.eclipsefp.haskell.core.test.internal.doubles.StubBundleContext;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Plugin;
import junit.framework.TestCase;
+import static org.easymock.EasyMock.*;
public class HaskellCorePluginTest extends TestCase {
public void testRegistersResourceChangeListener() throws Exception {
- //TODO use a mock library here
- MockWorkspace workspace = new MockWorkspace();
+ IWorkspace workspace = createMock(IWorkspace.class);
+
+ workspace.addResourceChangeListener((IResourceChangeListener) anyObject(), anyInt());
+ expectLastCall().times(1);
+
+ expect(workspace.getRoot()).
+ andReturn(ResourcesPlugin.getWorkspace().getRoot());
+
+ replay(workspace);
+
Plugin corePlugin = new HaskellCorePlugin(workspace);
corePlugin.start(new StubBundleContext());
- workspace.verify();
+ verify(workspace);
}
}
View
226 ...kell.core.test/src/net/sf/eclipsefp/haskell/core/test/internal/doubles/MockWorkspace.java
@@ -1,226 +0,0 @@
-package net.sf.eclipsefp.haskell.core.test.internal.doubles;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IPathVariableManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IProjectNatureDescriptor;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.ISaveParticipant;
-import org.eclipse.core.resources.ISavedState;
-import org.eclipse.core.resources.ISynchronizer;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.WorkspaceLock;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-public class MockWorkspace implements IWorkspace {
-
- private IWorkspace fDelegateWorspace = ResourcesPlugin.getWorkspace();
-
- private int fTimesAddListenerCalled = 0;
-
- public void verify() {
- Assert.assertEquals(1, fTimesAddListenerCalled);
- }
-
- public void addResourceChangeListener(IResourceChangeListener listener) {
- fTimesAddListenerCalled++;
- fDelegateWorspace.addResourceChangeListener(listener);
- }
-
- public void addResourceChangeListener(IResourceChangeListener listener, int eventMask) {
- fTimesAddListenerCalled++;
- fDelegateWorspace.addResourceChangeListener(listener, eventMask);
- }
-
- public ISavedState addSaveParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException {
- return fDelegateWorspace.addSaveParticipant(plugin, participant);
- }
-
- public void build(int kind, IProgressMonitor monitor) throws CoreException {
- fDelegateWorspace.build(kind, monitor);
- }
-
- public void checkpoint(boolean build) {
- fDelegateWorspace.checkpoint(build);
- }
-
- public IProject[][] computePrerequisiteOrder(IProject[] projects) {
- return fDelegateWorspace.computePrerequisiteOrder(projects);
- }
-
- public ProjectOrder computeProjectOrder(IProject[] projects) {
- return fDelegateWorspace.computeProjectOrder(projects);
- }
-
- public IStatus copy(IResource[] resources, IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.copy(resources, destination, force, monitor);
- }
-
- public IStatus copy(IResource[] resources, IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.copy(resources, destination, updateFlags, monitor);
- }
-
- public IStatus delete(IResource[] resources, boolean force, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.delete(resources, force, monitor);
- }
-
- public IStatus delete(IResource[] resources, int updateFlags, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.delete(resources, updateFlags, monitor);
- }
-
- public void deleteMarkers(IMarker[] markers) throws CoreException {
- fDelegateWorspace.deleteMarkers(markers);
- }
-
- public void forgetSavedTree(String pluginId) {
- fDelegateWorspace.forgetSavedTree(pluginId);
- }
-
- public Object getAdapter(Class adapter) {
- return fDelegateWorspace.getAdapter(adapter);
- }
-
- public Map getDanglingReferences() {
- return fDelegateWorspace.getDanglingReferences();
- }
-
- public IWorkspaceDescription getDescription() {
- return fDelegateWorspace.getDescription();
- }
-
- public IProjectNatureDescriptor getNatureDescriptor(String natureId) {
- return fDelegateWorspace.getNatureDescriptor(natureId);
- }
-
- public IProjectNatureDescriptor[] getNatureDescriptors() {
- return fDelegateWorspace.getNatureDescriptors();
- }
-
- public IPathVariableManager getPathVariableManager() {
- return fDelegateWorspace.getPathVariableManager();
- }
-
- public IWorkspaceRoot getRoot() {
- return fDelegateWorspace.getRoot();
- }
-
- public IResourceRuleFactory getRuleFactory() {
- return fDelegateWorspace.getRuleFactory();
- }
-
- public ISynchronizer getSynchronizer() {
- return fDelegateWorspace.getSynchronizer();
- }
-
- public boolean isAutoBuilding() {
- return fDelegateWorspace.isAutoBuilding();
- }
-
- public boolean isTreeLocked() {
- return fDelegateWorspace.isTreeLocked();
- }
-
- public IProjectDescription loadProjectDescription(InputStream projectDescriptionFile) throws CoreException {
- return fDelegateWorspace.loadProjectDescription(projectDescriptionFile);
- }
-
- public IProjectDescription loadProjectDescription(IPath projectDescriptionFile) throws CoreException {
- return fDelegateWorspace.loadProjectDescription(projectDescriptionFile);
- }
-
- public IStatus move(IResource[] resources, IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.move(resources, destination, force, monitor);
- }
-
- public IStatus move(IResource[] resources, IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.move(resources, destination, updateFlags, monitor);
- }
-
- public IProjectDescription newProjectDescription(String projectName) {
- return fDelegateWorspace.newProjectDescription(projectName);
- }
-
- public void removeResourceChangeListener(IResourceChangeListener listener) {
- fDelegateWorspace.removeResourceChangeListener(listener);
- }
-
- public void removeSaveParticipant(Plugin plugin) {
- fDelegateWorspace.removeSaveParticipant(plugin);
- }
-
- public void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
- fDelegateWorspace.run(action, monitor);
- }
-
- public void run(IWorkspaceRunnable action, ISchedulingRule rule, int flags, IProgressMonitor monitor) throws CoreException {
- fDelegateWorspace.run(action, rule, flags, monitor);
- }
-
- public IStatus save(boolean full, IProgressMonitor monitor) throws CoreException {
- return fDelegateWorspace.save(full, monitor);
- }
-
- public void setDescription(IWorkspaceDescription description) throws CoreException {
- fDelegateWorspace.setDescription(description);
- }
-
- public void setWorkspaceLock(WorkspaceLock lock) {
- fDelegateWorspace.setWorkspaceLock(lock);
- }
-
- public String[] sortNatureSet(String[] natureIds) {
- return fDelegateWorspace.sortNatureSet(natureIds);
- }
-
- public IStatus validateEdit(IFile[] files, Object context) {
- return fDelegateWorspace.validateEdit(files, context);
- }
-
- public IStatus validateLinkLocation(IResource resource, IPath location) {
- return fDelegateWorspace.validateLinkLocation(resource, location);
- }
-
- public IStatus validateLinkLocationURI(IResource resource, URI location) {
- return fDelegateWorspace.validateLinkLocationURI(resource, location);
- }
-
- public IStatus validateName(String segment, int typeMask) {
- return fDelegateWorspace.validateName(segment, typeMask);
- }
-
- public IStatus validateNatureSet(String[] natureIds) {
- return fDelegateWorspace.validateNatureSet(natureIds);
- }
-
- public IStatus validatePath(String path, int typeMask) {
- return fDelegateWorspace.validatePath(path, typeMask);
- }
-
- public IStatus validateProjectLocation(IProject project, IPath location) {
- return fDelegateWorspace.validateProjectLocation(project, location);
- }
-
- public IStatus validateProjectLocationURI(IProject project, URI location) {
- return fDelegateWorspace.validateProjectLocationURI(project, location);
- }
-
-}
View
3 net.sf.eclipsefp.test/INTERNAL/launches/eclipsefp-alltests.eclipse-3.2.linux.launch
@@ -3,7 +3,7 @@
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<stringAttribute key="bootstrap" value=""/>
<booleanAttribute key="useProduct" value="false"/>
-<stringAttribute key="deselected_workspace_plugins" value="net.sf.eclipsefp.haskell.refactoring,net.sf.eclipsefp.haskell.haddock,net.sf.eclipsefp.common.doc,org.eclipse.update.scheduler,de.leiffrenzel.fp.haskell,org.eclipse.jdt,org.eclipse.jdt.core,org.eclipse.jdt.core.manipulation,org.eclipse.jdt.debug.ui,de.leiffrenzel.fp.haskell.doc.user,org.eclipse.jdt.debug,org.eclipse.jdt.junit.runtime,org.eclipse.jdt.doc.user,org.eclipse.jdt.junit,de.leiffrenzel.fp.haskell.ghccompiler,org.eclipse.jdt.ui,org.eclipse.update.configurator,org.eclipse.update.ui,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.core,org.eclipse.update.core,org.eclipse.jdt.launching,net.sf.eclipsefp.haskell.hugs,org.eclipse.update.core.linux"/>
+<stringAttribute key="deselected_workspace_plugins" value="net.sf.eclipsefp.haskell.refactoring,net.sf.eclipsefp.haskell.haddock,org.eclipse.update.scheduler,net.sf.eclipsefp.common.doc,de.leiffrenzel.fp.haskell,org.eclipse.jdt,org.eclipse.jdt.core,org.eclipse.jdt.core.manipulation,org.eclipse.jdt.debug.ui,de.leiffrenzel.fp.haskell.doc.user,org.eclipse.jdt.doc.user,de.leiffrenzel.fp.haskell.ghccompiler,org.eclipse.jdt.ui,org.eclipse.jdt.doc.isv,org.eclipse.jdt.junit4.runtime,org.eclipse.update.configurator,org.eclipse.update.ui,org.eclipse.jdt.apt.ui,org.eclipse.update.core,org.eclipse.jdt.apt.core,org.eclipse.jdt.source,org.eclipse.jdt.launching,net.sf.eclipsefp.haskell.hugs,org.eclipse.update.core.linux"/>
<booleanAttribute key="tracing" value="false"/>
<stringAttribute key="selected_target_plugins" value="com.ibm.icu,org.apache.ant,org.apache.lucene,org.eclipse.ant.core,org.eclipse.compare,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.filebuffers,org.eclipse.core.filesystem,org.eclipse.core.filesystem.linux.x86,org.eclipse.core.jobs,org.eclipse.core.resources,org.eclipse.core.resources.compatibility,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.core.variables,org.eclipse.debug.core,org.eclipse.debug.ui,org.eclipse.equinox.common,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.help.appserver,org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.jface,org.eclipse.jface.text,org.eclipse.ltk.core.refactoring,org.eclipse.ltk.ui.refactoring,org.eclipse.osgi,org.eclipse.search,org.eclipse.swt,org.eclipse.swt.gtk.linux.x86,org.eclipse.team.core,org.eclipse.team.ui,org.eclipse.text,org.eclipse.ui,org.eclipse.ui.cheatsheets,org.eclipse.ui.console,org.eclipse.ui.editors,org.eclipse.ui.forms,org.eclipse.ui.ide,org.eclipse.ui.navigator,org.eclipse.ui.navigator.resources,org.eclipse.ui.views,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.workbench,org.eclipse.ui.workbench.texteditor,org.eclipse.update.configurator,org.eclipse.update.core,org.eclipse.update.core.linux,org.eclipse.update.ui,org.junit"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
@@ -27,4 +27,5 @@
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="net.sf.eclipsefp.test"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration>
View
7 org.easymock/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" sourcepath="/tmp/easymock2.2/src.zip" kind="lib" path="lib/easymock.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
View
28 org.easymock/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.easymock</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
9 org.easymock/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Easymock
+Bundle-SymbolicName: org.easymock
+Bundle-Version: 2.2
+Bundle-Vendor: eclipsefp.sourceforge.net
+Bundle-Localization: plugin
+Bundle-ClassPath: lib/easymock.jar
+Export-Package: org.easymock
View
6 org.easymock/build.properties
@@ -0,0 +1,6 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ lib/,\
+ lib/easymock.jar
+src.includes = lib/
View
BIN org.easymock/lib/easymock.jar
Binary file not shown.

0 comments on commit dbe565a

Please sign in to comment.