Add some mock objects.
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.test.util/META-INF/MANIFEST.MF
index 653754d..2b817e4 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/META-INF/MANIFEST.MF
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
org.eclipse.jst.j2ee;bundle-version="[1.1.0,1.2.0)",
org.eclipse.jst.j2ee.core;bundle-version="[1.1.0,1.3.0)",
org.eclipse.jst.j2ee.web;bundle-version="[1.1.0,1.2.0)",
@@ -25,9 +25,11 @@
org.eclipse.wst.sse.core,
org.eclipse.wst.xml.core,
org.eclipse.ui.ide;bundle-version="3.4.0",
- org.eclipse.jst.common.project.facet.core;bundle-version="1.4.100"
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.4.100",
+ org.eclipse.core.filesystem;bundle-version="1.3.0";visibility:=reexport
Export-Package: org.eclipse.jst.jsf.test.util,
- org.eclipse.jst.jsf.test.util.junit4
+ org.eclipse.jst.jsf.test.util.junit4,
+ org.eclipse.jst.jsf.test.util.mock
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor.0
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockDataModel.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockDataModel.java
new file mode 100644
index 0000000..9a3bb8a
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockDataModel.java
@@ -0,0 +1,263 @@
+package org.eclipse.jst.jsf.test.util.mock;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+public class MockDataModel implements IDataModel
+{
+ private final String _id;
+ private final Map<String, MockPropertyHolder> _properties;
+
+ public MockDataModel(final String id, final Map<String, MockPropertyHolder> properties)
+ {
+ _id = id;
+ _properties = properties;
+ }
+ public String getID()
+ {
+ return _id;
+ }
+
+ public IDataModelOperation getDefaultOperation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<?> getExtendedContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getProperty(String propertyName)
+ {
+ MockPropertyHolder property = _properties.get(propertyName);
+ if (property != null)
+ {
+ return property.getValue();
+ }
+ return null;
+ }
+
+ public Object getDefaultProperty(String propertyName)
+ {
+ MockPropertyHolder property = _properties.get(propertyName);
+ if (property != null)
+ {
+ return property.getDefaultValue();
+ }
+ return null;
+ }
+
+ public int getIntProperty(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getBooleanProperty(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getStringProperty(String propertyName)
+ {
+ return (String) getProperty(propertyName);
+ }
+
+ public void setProperty(String propertyName, Object propertyValue)
+ {
+ MockPropertyHolder property = _properties.get(propertyName);
+ if (property == null)
+ {
+ property = new MockPropertyHolder();
+ _properties.put(propertyName, property);
+ }
+ property.setValue(propertyValue);
+ }
+
+ public void setIntProperty(String propertyName, int propertyValue)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBooleanProperty(String propertyName, boolean propertyValue)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setStringProperty(String propertyName, String propertyValue)
+ {
+ setProperty(propertyName, propertyValue);
+ }
+
+ public boolean addNestedModel(String nestedModelName, IDataModel dataModel)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IDataModel removeNestedModel(String nestedModelName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isNestedModel(String nestedModelName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IDataModel getNestedModel(String nestedModelName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getNestedModels()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getNestedModelNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getNestingModels()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getBaseProperties()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getNestedProperties()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<?> getAllProperties()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isBaseProperty(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isProperty(String propertyName)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isNestedProperty(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPropertySet(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPropertyEnabled(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPropertyValid(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IStatus validateProperty(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isValid()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IStatus validate()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IStatus validate(boolean stopAtFirstFailure)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public DataModelPropertyDescriptor[] getValidPropertyDescriptors(
+ String propertyName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addListener(IDataModelListener dataModelListener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeListener(IDataModelListener dataModelListener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void notifyPropertyChange(String propertyName, int eventType)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void dispose()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public static class MockPropertyHolder
+ {
+ private Object _value;
+ private final Object _defaultValue;
+ public MockPropertyHolder(Object value, Object defaultValue)
+ {
+ super();
+ _value = value;
+ _defaultValue = defaultValue;
+ }
+ public MockPropertyHolder(Object defaultValue)
+ {
+ this(null, defaultValue);
+ }
+ public MockPropertyHolder()
+ {
+ this(null, null);
+ }
+
+ public Object getValue()
+ {
+ return _value;
+ }
+ public Object getDefaultValue()
+ {
+ return _defaultValue;
+ }
+ public void setValue(Object value)
+ {
+ _value = value;
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockModelProvider.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockModelProvider.java
new file mode 100644
index 0000000..6656e89
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockModelProvider.java
@@ -0,0 +1,46 @@
+package org.eclipse.jst.jsf.test.util.mock;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.IModelProviderListener;
+
+public class MockModelProvider implements IModelProvider
+{
+ private final Object _modelObject;
+
+ public MockModelProvider(final Object modelObject)
+ {
+ _modelObject = modelObject;
+ }
+ public Object getModelObject()
+ {
+ return _modelObject;
+ }
+
+ public Object getModelObject(IPath modelPath)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void modify(Runnable runnable, IPath modelPath)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IStatus validateEdit(IPath modelPath, Object context)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addListener(IModelProviderListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeListener(IModelProviderListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockResource.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockResource.java
new file mode 100644
index 0000000..41a3e91
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockResource.java
@@ -0,0 +1,472 @@
+package org.eclipse.jst.jsf.test.util.mock;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class MockResource implements IResource
+{
+ private final int _type;
+ private final IPath _path;
+ public final static List<Integer> VALID_TYPES;
+
+ static
+ {
+ final List<Integer> list = new ArrayList<Integer>();
+ list.add(IResource.FILE);
+ list.add(IResource.FOLDER);
+ list.add(IResource.PROJECT);
+ list.add(IResource.ROOT);
+ VALID_TYPES = Collections.unmodifiableList(list);
+ }
+
+ public MockResource(final int type, final IPath path)
+ {
+ _path = path;
+ _type = type;
+ Assert.assertTrue(VALID_TYPES.contains(type));
+ }
+
+ public int getType()
+ {
+ return _type;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(final Class adapter)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean contains(final ISchedulingRule rule)
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean isConflicting(final ISchedulingRule rule)
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void accept(final IResourceProxyVisitor visitor, final int memberFlags)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void accept(final IResourceVisitor visitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void accept(final IResourceVisitor visitor, final int depth,
+ final boolean includePhantoms) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void accept(final IResourceVisitor visitor, final int depth, final int memberFlags)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void clearHistory(final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void copy(final IPath destination, final boolean force, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void copy(final IPath destination, final int updateFlags,
+ final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void copy(final IProjectDescription description, final boolean force,
+ final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void copy(final IProjectDescription description, final int updateFlags,
+ final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public IMarker createMarker(final String type) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IResourceProxy createProxy()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void delete(final boolean force, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void delete(final int updateFlags, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void deleteMarkers(final String type, final boolean includeSubtypes, final int depth)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean exists()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IMarker findMarker(final long id) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IMarker[] findMarkers(final String type, final boolean includeSubtypes, final int depth)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int findMaxProblemSeverity(final String type, final boolean includeSubtypes,
+ final int depth) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getFileExtension()
+ {
+ String name = getName();
+ int index = name.lastIndexOf('.');
+ if (index == -1)
+ return null;
+ if (index == (name.length() - 1))
+ return ""; //$NON-NLS-1$
+ return name.substring(index + 1);
+ }
+
+ public IPath getFullPath()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getLocalTimeStamp()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IPath getLocation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public URI getLocationURI()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IMarker getMarker(final long id)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getModificationStamp()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getName()
+ {
+ return _path.lastSegment();
+ }
+
+ public IContainer getParent()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<?,?> getPersistentProperties() throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPersistentProperty(final QualifiedName key) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IProject getProject()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IPath getProjectRelativePath()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IPath getRawLocation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public URI getRawLocationURI()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ResourceAttributes getResourceAttributes()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<?,?> getSessionProperties() throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getSessionProperty(final QualifiedName key) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public IWorkspace getWorkspace()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAccessible()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDerived()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDerived(final int options)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isHidden()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isHidden(final int options)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLinked()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isVirtual()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasFilters()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLinked(final int options)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLocal(final int depth)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPhantom()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isReadOnly()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSynchronized(final int depth)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isTeamPrivateMember()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isTeamPrivateMember(final int options)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void move(final IPath destination, final boolean force, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void move(final IPath destination, final int updateFlags,
+ final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void move(final IProjectDescription description, final boolean force,
+ final boolean keepHistory, final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void move(final IProjectDescription description, final int updateFlags,
+ final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void refreshLocal(final int depth, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void revertModificationStamp(final long value) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setDerived(final boolean isDerived) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setDerived(final boolean isDerived, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setHidden(final boolean isHidden) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setLocal(final boolean flag, final int depth, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public long setLocalTimeStamp(final long value) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setPersistentProperty(final QualifiedName key, final String value)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setReadOnly(final boolean readOnly)
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setResourceAttributes(final ResourceAttributes attributes)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setSessionProperty(final QualifiedName key, final Object value)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setTeamPrivateMember(final boolean isTeamPrivate)
+ throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void touch(final IProgressMonitor monitor) throws CoreException
+ {
+ throw new UnsupportedOperationException();
+
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockWorkspace.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockWorkspace.java
new file mode 100644
index 0000000..578691c
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/MockWorkspace.java
@@ -0,0 +1,8 @@
+package org.eclipse.jst.jsf.test.util.mock;
+
+import org.eclipse.core.internal.resources.Workspace;
+
+public class MockWorkspace extends Workspace
+{
+
+}