Normalize line endings VIVO-101

This commit is contained in:
Brian Caruso 2013-07-18 15:19:53 -04:00
parent b097a4d754
commit 54f79f2ea7
587 changed files with 91501 additions and 91501 deletions

View file

@ -1,66 +1,66 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
/**
* Allow the unit test to specify a variety of restrictions
*/
public class PropertyRestrictionPolicyHelperStub extends
PropertyRestrictionPolicyHelper {
/** Don't prohibit or restrict anything. */
public static PropertyRestrictionPolicyHelper getInstance() {
return getInstance(null, null);
}
/** Prohibit some namespaces. */
public static PropertyRestrictionPolicyHelperStub getInstance(
String[] restrictedNamespaces) {
return getInstance(restrictedNamespaces, null);
}
/**
* Prohibit some namespaces and restrict some properties from modification
* by anybody.
*/
public static PropertyRestrictionPolicyHelperStub getInstance(
String[] restrictedNamespaces, String[] restrictedProperties) {
Set<String> namespaceSet = new HashSet<String>();
if (restrictedNamespaces != null) {
namespaceSet.addAll(Arrays.asList(restrictedNamespaces));
}
Map<String, RoleLevel> thresholdMap = new HashMap<String, RoleLevel>();
if (restrictedProperties != null) {
for (String prop : restrictedProperties) {
thresholdMap.put(prop, RoleLevel.NOBODY);
}
}
return new PropertyRestrictionPolicyHelperStub(namespaceSet, null,
null, thresholdMap);
}
private PropertyRestrictionPolicyHelperStub(
Set<String> modifyRestrictedNamespaces,
Set<String> modifyPermittedExceptions,
Map<String, RoleLevel> displayThresholds,
Map<String, RoleLevel> modifyThresholds) {
super(modifyRestrictedNamespaces, modifyPermittedExceptions,
displayThresholds, modifyThresholds, ModelFactory.createDefaultModel());
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.auth.policy.bean;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
/**
* Allow the unit test to specify a variety of restrictions
*/
public class PropertyRestrictionPolicyHelperStub extends
PropertyRestrictionPolicyHelper {
/** Don't prohibit or restrict anything. */
public static PropertyRestrictionPolicyHelper getInstance() {
return getInstance(null, null);
}
/** Prohibit some namespaces. */
public static PropertyRestrictionPolicyHelperStub getInstance(
String[] restrictedNamespaces) {
return getInstance(restrictedNamespaces, null);
}
/**
* Prohibit some namespaces and restrict some properties from modification
* by anybody.
*/
public static PropertyRestrictionPolicyHelperStub getInstance(
String[] restrictedNamespaces, String[] restrictedProperties) {
Set<String> namespaceSet = new HashSet<String>();
if (restrictedNamespaces != null) {
namespaceSet.addAll(Arrays.asList(restrictedNamespaces));
}
Map<String, RoleLevel> thresholdMap = new HashMap<String, RoleLevel>();
if (restrictedProperties != null) {
for (String prop : restrictedProperties) {
thresholdMap.put(prop, RoleLevel.NOBODY);
}
}
return new PropertyRestrictionPolicyHelperStub(namespaceSet, null,
null, thresholdMap);
}
private PropertyRestrictionPolicyHelperStub(
Set<String> modifyRestrictedNamespaces,
Set<String> modifyPermittedExceptions,
Map<String, RoleLevel> displayThresholds,
Map<String, RoleLevel> modifyThresholds) {
super(modifyRestrictedNamespaces, modifyPermittedExceptions,
displayThresholds, modifyThresholds, ModelFactory.createDefaultModel());
}
}

View file

@ -1,466 +1,466 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.beans;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
/**
* Mock the basic functions of Individual for unit tests.
*/
public class IndividualStub implements Individual {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final String uri;
private final Set<DataPropertyStatement> dpsSet = new HashSet<DataPropertyStatement>();
private final Set<ObjectPropertyStatement> opsSet = new HashSet<ObjectPropertyStatement>();
private final Set<VClass> vClasses = new HashSet<VClass>();
private String name = "NoName";
public IndividualStub(String uri) {
this.uri = uri;
}
public void addDataPropertyStatement(String predicateUri, String object) {
dpsSet.add(new DataPropertyStatementImpl(this.uri, predicateUri, object));
}
public void addObjectPropertyStatement(String predicateUri, String objectUri) {
opsSet.add(new ObjectPropertyStatementImpl(this.uri, predicateUri,
objectUri));
}
public void addPopulatedObjectPropertyStatement(String predicateUri,
String objectUri, Individual object) {
ObjectPropertyStatementImpl stmt = new ObjectPropertyStatementImpl(
this.uri, predicateUri, objectUri);
stmt.setObject(object);
opsSet.add(stmt);
}
public void addVclass(String namespace, String localname, String vClassName) {
vClasses.add(new VClass(namespace, localname, vClassName));
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getURI() {
return uri;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public List<DataPropertyStatement> getDataPropertyStatements() {
return new ArrayList<DataPropertyStatement>(dpsSet);
}
@Override
public List<DataPropertyStatement> getDataPropertyStatements(
String propertyUri) {
List<DataPropertyStatement> list = new ArrayList<DataPropertyStatement>();
for (DataPropertyStatement dps : dpsSet) {
if (dps.getDatapropURI().equals(propertyUri)) {
list.add(dps);
}
}
return list;
}
@Override
public String getDataValue(String propertyUri) {
for (DataPropertyStatement dps : dpsSet) {
if (dps.getDatapropURI().equals(propertyUri)) {
return dps.getData();
}
}
return null;
}
@Override
public List<ObjectPropertyStatement> getObjectPropertyStatements() {
return new ArrayList<ObjectPropertyStatement>(opsSet);
}
@Override
public List<ObjectPropertyStatement> getObjectPropertyStatements(
String propertyUri) {
List<ObjectPropertyStatement> list = new ArrayList<ObjectPropertyStatement>();
for (ObjectPropertyStatement ops : opsSet) {
if (ops.getPropertyURI().equals(propertyUri)) {
list.add(ops);
}
}
return list;
}
@Override
public Individual getRelatedIndividual(String propertyUri) {
for (ObjectPropertyStatement ops : opsSet) {
if (ops.getPropertyURI().equals(propertyUri)) {
return ops.getObject();
}
}
return null;
}
@Override
public boolean isVClass(String vclassUri) {
for (VClass vc : vClasses) {
if (vc.getURI().equals(vclassUri)) {
return true;
}
}
return false;
}
@Override
public List<VClass> getVClasses(boolean direct) {
return new ArrayList<VClass>(vClasses);
}
@Override
public void sortForDisplay() {
// does nothing.
}
@Override
public String getLocalName() {
// Useless for now.
return "BOGUS Local Name";
}
@Override
public VClass getVClass() {
for (VClass vc : vClasses) {
return vc;
}
return null;
}
@Override
public String getVClassURI() {
for (VClass vc : vClasses) {
return vc.getURI();
}
return null;
}
@Override
public List<VClass> getVClasses() {
return new ArrayList<VClass>(vClasses);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public boolean isAnonymous() {
throw new RuntimeException(
"ResourceBean.isAnonymous() not implemented.");
}
@Override
public void setURI(String URI) {
throw new RuntimeException("ResourceBean.setURI() not implemented.");
}
@Override
public String getNamespace() {
throw new RuntimeException(
"ResourceBean.getNamespace() not implemented.");
}
@Override
public void setNamespace(String namespace) {
throw new RuntimeException(
"ResourceBean.setNamespace() not implemented.");
}
@Override
public void setLocalName(String localName) {
throw new RuntimeException(
"ResourceBean.setLocalName() not implemented.");
}
@Override
public RoleLevel getHiddenFromDisplayBelowRoleLevel() {
throw new RuntimeException(
"ResourceBean.getHiddenFromDisplayBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) {
throw new RuntimeException(
"ResourceBean.setHiddenFromDisplayBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) {
throw new RuntimeException(
"ResourceBean.setHiddenFromDisplayBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() {
throw new RuntimeException(
"ResourceBean.getProhibitedFromUpdateBelowRoleLevel() not implemented.");
}
@Override
public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) {
throw new RuntimeException(
"ResourceBean.setProhibitedFromUpdateBelowRoleLevel() not implemented.");
}
@Override
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) {
throw new RuntimeException(
"ResourceBean.setProhibitedFromUpdateBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public int compareTo(Individual o) {
throw new RuntimeException(
"Comparable<Individual>.compareTo() not implemented.");
}
@Override
public List<String> getMostSpecificTypeURIs() {
throw new RuntimeException("Individual.getMostSpecificTypeURIs() not implemented.");
}
@Override
public String getRdfsLabel() {
throw new RuntimeException("Individual.getRdfsLabel() not implemented.");
}
@Override
public void setVClassURI(String in) {
throw new RuntimeException("Individual.setVClassURI() not implemented.");
}
@Override
public Timestamp getModTime() {
throw new RuntimeException("Individual.getModTime() not implemented.");
}
@Override
public void setModTime(Timestamp in) {
throw new RuntimeException("Individual.setModTime() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList() {
throw new RuntimeException(
"Individual.getObjectPropertyList() not implemented.");
}
@Override
public void setPropertyList(List<ObjectProperty> propertyList) {
throw new RuntimeException(
"Individual.setPropertyList() not implemented.");
}
@Override
public List<ObjectProperty> getPopulatedObjectPropertyList() {
throw new RuntimeException(
"Individual.getPopulatedObjectPropertyList() not implemented.");
}
@Override
public void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList) {
throw new RuntimeException(
"Individual.setPopulatedObjectPropertyList() not implemented.");
}
@Override
public Map<String, ObjectProperty> getObjectPropertyMap() {
throw new RuntimeException(
"Individual.getObjectPropertyMap() not implemented.");
}
@Override
public void setObjectPropertyMap(Map<String, ObjectProperty> propertyMap) {
throw new RuntimeException(
"Individual.setObjectPropertyMap() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList() {
throw new RuntimeException(
"Individual.getDataPropertyList() not implemented.");
}
@Override
public void setDatatypePropertyList(List<DataProperty> datatypePropertyList) {
throw new RuntimeException(
"Individual.setDatatypePropertyList() not implemented.");
}
@Override
public List<DataProperty> getPopulatedDataPropertyList() {
throw new RuntimeException(
"Individual.getPopulatedDataPropertyList() not implemented.");
}
@Override
public void setPopulatedDataPropertyList(List<DataProperty> dataPropertyList) {
throw new RuntimeException(
"Individual.setPopulatedDataPropertyList() not implemented.");
}
@Override
public Map<String, DataProperty> getDataPropertyMap() {
throw new RuntimeException(
"Individual.getDataPropertyMap() not implemented.");
}
@Override
public void setDataPropertyMap(Map<String, DataProperty> propertyMap) {
throw new RuntimeException(
"Individual.setDataPropertyMap() not implemented.");
}
@Override
public void setDataPropertyStatements(List<DataPropertyStatement> list) {
throw new RuntimeException(
"Individual.setDataPropertyStatements() not implemented.");
}
@Override
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
throw new RuntimeException(
"Individual.getDataPropertyStatement() not implemented.");
}
@Override
public List<String> getDataValues(String propertyUri) {
throw new RuntimeException(
"Individual.getDataValues() not implemented.");
}
@Override
public void setVClass(VClass class1) {
throw new RuntimeException("Individual.setVClass() not implemented.");
}
@Override
public void setVClasses(List<VClass> vClassList, boolean direct) {
throw new RuntimeException("Individual.setVClasses() not implemented.");
}
@Override
public void setObjectPropertyStatements(List<ObjectPropertyStatement> list) {
throw new RuntimeException(
"Individual.setObjectPropertyStatements() not implemented.");
}
@Override
public List<Individual> getRelatedIndividuals(String propertyUri) {
throw new RuntimeException(
"Individual.getRelatedIndividuals() not implemented.");
}
@Override
public List<DataPropertyStatement> getExternalIds() {
throw new RuntimeException(
"Individual.getExternalIds() not implemented.");
}
@Override
public void setExternalIds(List<DataPropertyStatement> externalIds) {
throw new RuntimeException(
"Individual.setExternalIds() not implemented.");
}
@Override
public void setMainImageUri(String mainImageUri) {
throw new RuntimeException(
"Individual.setMainImageUri() not implemented.");
}
@Override
public String getMainImageUri() {
throw new RuntimeException(
"Individual.getMainImageUri() not implemented.");
}
@Override
public String getImageUrl() {
throw new RuntimeException("Individual.getImageUrl() not implemented.");
}
@Override
public String getThumbUrl() {
throw new RuntimeException("Individual.getThumbUrl() not implemented.");
}
@Override
public boolean hasThumb() {
throw new RuntimeException("Individual.hasThumb() not implemented.");
}
@Override
public JSONObject toJSON() throws JSONException {
throw new RuntimeException("Individual.toJSON() not implemented.");
}
@Override
public Float getSearchBoost() {
throw new RuntimeException(
"Individual.getSearchBoost() not implemented.");
}
@Override
public void setSearchBoost(Float boost) {
throw new RuntimeException(
"Individual.setSearchBoost() not implemented.");
}
@Override
public String getSearchSnippet() {
throw new RuntimeException(
"Individual.getSearchSnippet() not implemented.");
}
@Override
public void setSearchSnippet(String snippet) {
throw new RuntimeException(
"Individual.setSearchSnippet() not implemented.");
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.beans;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
/**
* Mock the basic functions of Individual for unit tests.
*/
public class IndividualStub implements Individual {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final String uri;
private final Set<DataPropertyStatement> dpsSet = new HashSet<DataPropertyStatement>();
private final Set<ObjectPropertyStatement> opsSet = new HashSet<ObjectPropertyStatement>();
private final Set<VClass> vClasses = new HashSet<VClass>();
private String name = "NoName";
public IndividualStub(String uri) {
this.uri = uri;
}
public void addDataPropertyStatement(String predicateUri, String object) {
dpsSet.add(new DataPropertyStatementImpl(this.uri, predicateUri, object));
}
public void addObjectPropertyStatement(String predicateUri, String objectUri) {
opsSet.add(new ObjectPropertyStatementImpl(this.uri, predicateUri,
objectUri));
}
public void addPopulatedObjectPropertyStatement(String predicateUri,
String objectUri, Individual object) {
ObjectPropertyStatementImpl stmt = new ObjectPropertyStatementImpl(
this.uri, predicateUri, objectUri);
stmt.setObject(object);
opsSet.add(stmt);
}
public void addVclass(String namespace, String localname, String vClassName) {
vClasses.add(new VClass(namespace, localname, vClassName));
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getURI() {
return uri;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public List<DataPropertyStatement> getDataPropertyStatements() {
return new ArrayList<DataPropertyStatement>(dpsSet);
}
@Override
public List<DataPropertyStatement> getDataPropertyStatements(
String propertyUri) {
List<DataPropertyStatement> list = new ArrayList<DataPropertyStatement>();
for (DataPropertyStatement dps : dpsSet) {
if (dps.getDatapropURI().equals(propertyUri)) {
list.add(dps);
}
}
return list;
}
@Override
public String getDataValue(String propertyUri) {
for (DataPropertyStatement dps : dpsSet) {
if (dps.getDatapropURI().equals(propertyUri)) {
return dps.getData();
}
}
return null;
}
@Override
public List<ObjectPropertyStatement> getObjectPropertyStatements() {
return new ArrayList<ObjectPropertyStatement>(opsSet);
}
@Override
public List<ObjectPropertyStatement> getObjectPropertyStatements(
String propertyUri) {
List<ObjectPropertyStatement> list = new ArrayList<ObjectPropertyStatement>();
for (ObjectPropertyStatement ops : opsSet) {
if (ops.getPropertyURI().equals(propertyUri)) {
list.add(ops);
}
}
return list;
}
@Override
public Individual getRelatedIndividual(String propertyUri) {
for (ObjectPropertyStatement ops : opsSet) {
if (ops.getPropertyURI().equals(propertyUri)) {
return ops.getObject();
}
}
return null;
}
@Override
public boolean isVClass(String vclassUri) {
for (VClass vc : vClasses) {
if (vc.getURI().equals(vclassUri)) {
return true;
}
}
return false;
}
@Override
public List<VClass> getVClasses(boolean direct) {
return new ArrayList<VClass>(vClasses);
}
@Override
public void sortForDisplay() {
// does nothing.
}
@Override
public String getLocalName() {
// Useless for now.
return "BOGUS Local Name";
}
@Override
public VClass getVClass() {
for (VClass vc : vClasses) {
return vc;
}
return null;
}
@Override
public String getVClassURI() {
for (VClass vc : vClasses) {
return vc.getURI();
}
return null;
}
@Override
public List<VClass> getVClasses() {
return new ArrayList<VClass>(vClasses);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public boolean isAnonymous() {
throw new RuntimeException(
"ResourceBean.isAnonymous() not implemented.");
}
@Override
public void setURI(String URI) {
throw new RuntimeException("ResourceBean.setURI() not implemented.");
}
@Override
public String getNamespace() {
throw new RuntimeException(
"ResourceBean.getNamespace() not implemented.");
}
@Override
public void setNamespace(String namespace) {
throw new RuntimeException(
"ResourceBean.setNamespace() not implemented.");
}
@Override
public void setLocalName(String localName) {
throw new RuntimeException(
"ResourceBean.setLocalName() not implemented.");
}
@Override
public RoleLevel getHiddenFromDisplayBelowRoleLevel() {
throw new RuntimeException(
"ResourceBean.getHiddenFromDisplayBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) {
throw new RuntimeException(
"ResourceBean.setHiddenFromDisplayBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) {
throw new RuntimeException(
"ResourceBean.setHiddenFromDisplayBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() {
throw new RuntimeException(
"ResourceBean.getProhibitedFromUpdateBelowRoleLevel() not implemented.");
}
@Override
public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) {
throw new RuntimeException(
"ResourceBean.setProhibitedFromUpdateBelowRoleLevel() not implemented.");
}
@Override
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) {
throw new RuntimeException(
"ResourceBean.setProhibitedFromUpdateBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public int compareTo(Individual o) {
throw new RuntimeException(
"Comparable<Individual>.compareTo() not implemented.");
}
@Override
public List<String> getMostSpecificTypeURIs() {
throw new RuntimeException("Individual.getMostSpecificTypeURIs() not implemented.");
}
@Override
public String getRdfsLabel() {
throw new RuntimeException("Individual.getRdfsLabel() not implemented.");
}
@Override
public void setVClassURI(String in) {
throw new RuntimeException("Individual.setVClassURI() not implemented.");
}
@Override
public Timestamp getModTime() {
throw new RuntimeException("Individual.getModTime() not implemented.");
}
@Override
public void setModTime(Timestamp in) {
throw new RuntimeException("Individual.setModTime() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList() {
throw new RuntimeException(
"Individual.getObjectPropertyList() not implemented.");
}
@Override
public void setPropertyList(List<ObjectProperty> propertyList) {
throw new RuntimeException(
"Individual.setPropertyList() not implemented.");
}
@Override
public List<ObjectProperty> getPopulatedObjectPropertyList() {
throw new RuntimeException(
"Individual.getPopulatedObjectPropertyList() not implemented.");
}
@Override
public void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList) {
throw new RuntimeException(
"Individual.setPopulatedObjectPropertyList() not implemented.");
}
@Override
public Map<String, ObjectProperty> getObjectPropertyMap() {
throw new RuntimeException(
"Individual.getObjectPropertyMap() not implemented.");
}
@Override
public void setObjectPropertyMap(Map<String, ObjectProperty> propertyMap) {
throw new RuntimeException(
"Individual.setObjectPropertyMap() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList() {
throw new RuntimeException(
"Individual.getDataPropertyList() not implemented.");
}
@Override
public void setDatatypePropertyList(List<DataProperty> datatypePropertyList) {
throw new RuntimeException(
"Individual.setDatatypePropertyList() not implemented.");
}
@Override
public List<DataProperty> getPopulatedDataPropertyList() {
throw new RuntimeException(
"Individual.getPopulatedDataPropertyList() not implemented.");
}
@Override
public void setPopulatedDataPropertyList(List<DataProperty> dataPropertyList) {
throw new RuntimeException(
"Individual.setPopulatedDataPropertyList() not implemented.");
}
@Override
public Map<String, DataProperty> getDataPropertyMap() {
throw new RuntimeException(
"Individual.getDataPropertyMap() not implemented.");
}
@Override
public void setDataPropertyMap(Map<String, DataProperty> propertyMap) {
throw new RuntimeException(
"Individual.setDataPropertyMap() not implemented.");
}
@Override
public void setDataPropertyStatements(List<DataPropertyStatement> list) {
throw new RuntimeException(
"Individual.setDataPropertyStatements() not implemented.");
}
@Override
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
throw new RuntimeException(
"Individual.getDataPropertyStatement() not implemented.");
}
@Override
public List<String> getDataValues(String propertyUri) {
throw new RuntimeException(
"Individual.getDataValues() not implemented.");
}
@Override
public void setVClass(VClass class1) {
throw new RuntimeException("Individual.setVClass() not implemented.");
}
@Override
public void setVClasses(List<VClass> vClassList, boolean direct) {
throw new RuntimeException("Individual.setVClasses() not implemented.");
}
@Override
public void setObjectPropertyStatements(List<ObjectPropertyStatement> list) {
throw new RuntimeException(
"Individual.setObjectPropertyStatements() not implemented.");
}
@Override
public List<Individual> getRelatedIndividuals(String propertyUri) {
throw new RuntimeException(
"Individual.getRelatedIndividuals() not implemented.");
}
@Override
public List<DataPropertyStatement> getExternalIds() {
throw new RuntimeException(
"Individual.getExternalIds() not implemented.");
}
@Override
public void setExternalIds(List<DataPropertyStatement> externalIds) {
throw new RuntimeException(
"Individual.setExternalIds() not implemented.");
}
@Override
public void setMainImageUri(String mainImageUri) {
throw new RuntimeException(
"Individual.setMainImageUri() not implemented.");
}
@Override
public String getMainImageUri() {
throw new RuntimeException(
"Individual.getMainImageUri() not implemented.");
}
@Override
public String getImageUrl() {
throw new RuntimeException("Individual.getImageUrl() not implemented.");
}
@Override
public String getThumbUrl() {
throw new RuntimeException("Individual.getThumbUrl() not implemented.");
}
@Override
public boolean hasThumb() {
throw new RuntimeException("Individual.hasThumb() not implemented.");
}
@Override
public JSONObject toJSON() throws JSONException {
throw new RuntimeException("Individual.toJSON() not implemented.");
}
@Override
public Float getSearchBoost() {
throw new RuntimeException(
"Individual.getSearchBoost() not implemented.");
}
@Override
public void setSearchBoost(Float boost) {
throw new RuntimeException(
"Individual.setSearchBoost() not implemented.");
}
@Override
public String getSearchSnippet() {
throw new RuntimeException(
"Individual.getSearchSnippet() not implemented.");
}
@Override
public void setSearchSnippet(String snippet) {
throw new RuntimeException(
"Individual.setSearchSnippet() not implemented.");
}
}

View file

@ -1,66 +1,66 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.config;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
/**
* A version of ConfigurationProperties that we can use for unit tests. Unlike
* the basic implementation, this starts as an empty map, and allows the user to
* add properties as desired.
*
* Call setBean() to store these properties in the ServletContext.
*/
public class ConfigurationPropertiesStub extends ConfigurationProperties {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, String> propertyMap = new HashMap<String, String>();
public void setProperty(String key, String value) {
propertyMap.put(key, value);
}
public void setBean(ServletContext ctx) {
setBean(ctx, this);
}
@Override
public String toString() {
return "ConfigurationPropertiesStub[map=" + propertyMap + "]";
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getProperty(String key) {
return propertyMap.get(key);
}
@Override
public String getProperty(String key, String defaultValue) {
if (propertyMap.containsKey(key)) {
return propertyMap.get(key);
} else {
return defaultValue;
}
}
@Override
public Map<String, String> getPropertyMap() {
return new HashMap<String, String>(propertyMap);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.config;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
/**
* A version of ConfigurationProperties that we can use for unit tests. Unlike
* the basic implementation, this starts as an empty map, and allows the user to
* add properties as desired.
*
* Call setBean() to store these properties in the ServletContext.
*/
public class ConfigurationPropertiesStub extends ConfigurationProperties {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, String> propertyMap = new HashMap<String, String>();
public void setProperty(String key, String value) {
propertyMap.put(key, value);
}
public void setBean(ServletContext ctx) {
setBean(ctx, this);
}
@Override
public String toString() {
return "ConfigurationPropertiesStub[map=" + propertyMap + "]";
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getProperty(String key) {
return propertyMap.get(key);
}
@Override
public String getProperty(String key, String defaultValue) {
if (propertyMap.containsKey(key)) {
return propertyMap.get(key);
} else {
return defaultValue;
}
}
@Override
public Map<String, String> getPropertyMap() {
return new HashMap<String, String>(propertyMap);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
}

View file

@ -1,280 +1,280 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
/**
* A minimal implementation of the DataPropertyDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class DataPropertyDaoStub implements DataPropertyDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, DataProperty> dpMap = new HashMap<String, DataProperty>();
private final Map<String, String> configFilesMap = new HashMap<String, String>();
public void addDataProperty(DataProperty dataProperty) {
if (dataProperty == null) {
throw new NullPointerException("dataProperty may not be null.");
}
String uri = dataProperty.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
dpMap.put(uri, dataProperty);
}
public void setCustomListViewConfigFileName(DataProperty property, String filename) {
if (property == null) {
throw new NullPointerException("property may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
configFilesMap.put(uri, filename);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public DataProperty getDataPropertyByURI(String dataPropertyURI) {
return dpMap.get(dataPropertyURI);
}
@Override
public String getCustomListViewConfigFileName(DataProperty dataProperty) {
if (dataProperty == null) {
return null;
}
String uri = dataProperty.getURI();
if (uri == null) {
return null;
}
return configFilesMap.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void addSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"PropertyDao.addSuperproperty() not implemented.");
}
@Override
public void addSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"PropertyDao.addSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"PropertyDao.removeSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"PropertyDao.removeSuperproperty() not implemented.");
}
@Override
public void addSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"PropertyDao.addSubproperty() not implemented.");
}
@Override
public void addSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"PropertyDao.addSubproperty() not implemented.");
}
@Override
public void removeSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"PropertyDao.removeSubproperty() not implemented.");
}
@Override
public void removeSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"PropertyDao.removeSubproperty() not implemented.");
}
@Override
public void addEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"PropertyDao.addEquivalentProperty() not implemented.");
}
@Override
public void addEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"PropertyDao.addEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"PropertyDao.removeEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"PropertyDao.removeEquivalentProperty() not implemented.");
}
@Override
public List<String> getSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getSubPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getAllSubPropertyURIs() not implemented.");
}
@Override
public List<String> getSuperPropertyURIs(String propertyURI, boolean direct) {
throw new RuntimeException(
"PropertyDao.getSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSuperPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getAllSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getEquivalentPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getEquivalentPropertyURIs() not implemented.");
}
@Override
public List<VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getClassesWithRestrictionOnProperty() not implemented.");
}
@Override
public List getAllDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getAllDataProperties() not implemented.");
}
@Override
public List getAllExternalIdDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getAllExternalIdDataProperties() not implemented.");
}
@Override
public void fillDataPropertiesForIndividual(Individual individual) {
throw new RuntimeException(
"DataPropertyDao.fillDataPropertiesForIndividual() not implemented.");
}
@Override
public List<DataProperty> getDataPropertiesForVClass(String vClassURI) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertiesForVClass() not implemented.");
}
@Override
public Collection<DataProperty> getAllPossibleDatapropsForIndividual(
String individualURI) {
throw new RuntimeException(
"DataPropertyDao.getAllPossibleDatapropsForIndividual() not implemented.");
}
@Override
public String getRequiredDatatypeURI(Individual individual,
DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.getRequiredDatatypeURI() not implemented.");
}
@Override
public String insertDataProperty(DataProperty dataProperty)
throws InsertException {
throw new RuntimeException(
"DataPropertyDao.insertDataProperty() not implemented.");
}
@Override
public void updateDataProperty(DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.updateDataProperty() not implemented.");
}
@Override
public void deleteDataProperty(DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.deleteDataProperty() not implemented.");
}
@Override
public void deleteDataProperty(String dataPropertyURI) {
throw new RuntimeException(
"DataPropertyDao.deleteDataProperty() not implemented.");
}
@Override
public List<DataProperty> getRootDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getRootDataProperties() not implemented.");
}
@Override
public boolean annotateDataPropertyAsExternalIdentifier(
String dataPropertyURI) {
throw new RuntimeException(
"DataPropertyDao.annotateDataPropertyAsExternalIdentifier() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList(Individual subject) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertyList() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList(String subjectUri) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertyList() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
/**
* A minimal implementation of the DataPropertyDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class DataPropertyDaoStub implements DataPropertyDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, DataProperty> dpMap = new HashMap<String, DataProperty>();
private final Map<String, String> configFilesMap = new HashMap<String, String>();
public void addDataProperty(DataProperty dataProperty) {
if (dataProperty == null) {
throw new NullPointerException("dataProperty may not be null.");
}
String uri = dataProperty.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
dpMap.put(uri, dataProperty);
}
public void setCustomListViewConfigFileName(DataProperty property, String filename) {
if (property == null) {
throw new NullPointerException("property may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
configFilesMap.put(uri, filename);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public DataProperty getDataPropertyByURI(String dataPropertyURI) {
return dpMap.get(dataPropertyURI);
}
@Override
public String getCustomListViewConfigFileName(DataProperty dataProperty) {
if (dataProperty == null) {
return null;
}
String uri = dataProperty.getURI();
if (uri == null) {
return null;
}
return configFilesMap.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void addSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"PropertyDao.addSuperproperty() not implemented.");
}
@Override
public void addSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"PropertyDao.addSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"PropertyDao.removeSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"PropertyDao.removeSuperproperty() not implemented.");
}
@Override
public void addSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"PropertyDao.addSubproperty() not implemented.");
}
@Override
public void addSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"PropertyDao.addSubproperty() not implemented.");
}
@Override
public void removeSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"PropertyDao.removeSubproperty() not implemented.");
}
@Override
public void removeSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"PropertyDao.removeSubproperty() not implemented.");
}
@Override
public void addEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"PropertyDao.addEquivalentProperty() not implemented.");
}
@Override
public void addEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"PropertyDao.addEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"PropertyDao.removeEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"PropertyDao.removeEquivalentProperty() not implemented.");
}
@Override
public List<String> getSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getSubPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getAllSubPropertyURIs() not implemented.");
}
@Override
public List<String> getSuperPropertyURIs(String propertyURI, boolean direct) {
throw new RuntimeException(
"PropertyDao.getSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSuperPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getAllSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getEquivalentPropertyURIs(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getEquivalentPropertyURIs() not implemented.");
}
@Override
public List<VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
throw new RuntimeException(
"PropertyDao.getClassesWithRestrictionOnProperty() not implemented.");
}
@Override
public List getAllDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getAllDataProperties() not implemented.");
}
@Override
public List getAllExternalIdDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getAllExternalIdDataProperties() not implemented.");
}
@Override
public void fillDataPropertiesForIndividual(Individual individual) {
throw new RuntimeException(
"DataPropertyDao.fillDataPropertiesForIndividual() not implemented.");
}
@Override
public List<DataProperty> getDataPropertiesForVClass(String vClassURI) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertiesForVClass() not implemented.");
}
@Override
public Collection<DataProperty> getAllPossibleDatapropsForIndividual(
String individualURI) {
throw new RuntimeException(
"DataPropertyDao.getAllPossibleDatapropsForIndividual() not implemented.");
}
@Override
public String getRequiredDatatypeURI(Individual individual,
DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.getRequiredDatatypeURI() not implemented.");
}
@Override
public String insertDataProperty(DataProperty dataProperty)
throws InsertException {
throw new RuntimeException(
"DataPropertyDao.insertDataProperty() not implemented.");
}
@Override
public void updateDataProperty(DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.updateDataProperty() not implemented.");
}
@Override
public void deleteDataProperty(DataProperty dataProperty) {
throw new RuntimeException(
"DataPropertyDao.deleteDataProperty() not implemented.");
}
@Override
public void deleteDataProperty(String dataPropertyURI) {
throw new RuntimeException(
"DataPropertyDao.deleteDataProperty() not implemented.");
}
@Override
public List<DataProperty> getRootDataProperties() {
throw new RuntimeException(
"DataPropertyDao.getRootDataProperties() not implemented.");
}
@Override
public boolean annotateDataPropertyAsExternalIdentifier(
String dataPropertyURI) {
throw new RuntimeException(
"DataPropertyDao.annotateDataPropertyAsExternalIdentifier() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList(Individual subject) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertyList() not implemented.");
}
@Override
public List<DataProperty> getDataPropertyList(String subjectUri) {
throw new RuntimeException(
"DataPropertyDao.getDataPropertyList() not implemented.");
}
}

View file

@ -1,183 +1,183 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
/**
* A minimal implementation of the IndividualDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class IndividualDaoStub implements IndividualDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, Individual> indMap = new HashMap<String, Individual>();
public void addIndividual(Individual individual) {
if (individual == null) {
throw new NullPointerException("individual may not be null.");
}
String uri = individual.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
indMap.put(uri, individual);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public Individual getIndividualByURI(String individualURI) {
return indMap.get(individualURI);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public Collection<DataPropertyStatement> getExternalIds(String individualURI) {
throw new RuntimeException(
"IndividualDaoStub.getExternalIds() not implemented.");
}
@Override
public Collection<DataPropertyStatement> getExternalIds(
String individualURI, String dataPropertyURI) {
throw new RuntimeException(
"IndividualDaoStub.getExternalIds() not implemented.");
}
@Override
public void addVClass(String individualURI, String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.addVClass() not implemented.");
}
@Override
public void removeVClass(String individualURI, String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.removeVClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClass(VClass vclass) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClassURI(String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClassURI() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClassURI(String vclassURI,
int offset, int quantity) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClassURI() not implemented.");
}
@Override
public String insertNewIndividual(Individual individual)
throws InsertException {
throw new RuntimeException(
"IndividualDaoStub.insertNewIndividual() not implemented.");
}
@Override
public int updateIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.updateIndividual() not implemented.");
}
@Override
public int deleteIndividual(String individualURI) {
throw new RuntimeException(
"IndividualDaoStub.deleteIndividual() not implemented.");
}
@Override
public int deleteIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.deleteIndividual() not implemented.");
}
@Override
public void markModified(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.markModified() not implemented.");
}
@Override
public Iterator<String> getAllOfThisTypeIterator() {
throw new RuntimeException(
"IndividualDaoStub.getAllOfThisTypeIterator() not implemented.");
}
@Override
public Iterator<String> getUpdatedSinceIterator(long updatedSince) {
throw new RuntimeException(
"IndividualDaoStub.getUpdatedSinceIterator() not implemented.");
}
@Override
public boolean isIndividualOfClass(String vclassURI, String indURI) {
throw new RuntimeException(
"IndividualDaoStub.isIndividualOfClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByDataProperty(
String dataPropertyUri, String value) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByDataProperty() not implemented.");
}
@Override
public List<Individual> getIndividualsByDataProperty(
String dataPropertyUri, String value, String datatypeUri,
String lang) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByDataProperty() not implemented.");
}
@Override
public void fillVClassForIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.fillVClassForIndividual() not implemented.");
}
@Override
public String getUnusedURI(Individual individual) throws InsertException {
throw new RuntimeException(
"IndividualDaoStub.getUnusedURI() not implemented.");
}
@Override
public EditLiteral getLabelEditLiteral(String individualUri) {
throw new RuntimeException(
"IndividualDaoStub.getLabelLiteral() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
/**
* A minimal implementation of the IndividualDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class IndividualDaoStub implements IndividualDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, Individual> indMap = new HashMap<String, Individual>();
public void addIndividual(Individual individual) {
if (individual == null) {
throw new NullPointerException("individual may not be null.");
}
String uri = individual.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
indMap.put(uri, individual);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public Individual getIndividualByURI(String individualURI) {
return indMap.get(individualURI);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public Collection<DataPropertyStatement> getExternalIds(String individualURI) {
throw new RuntimeException(
"IndividualDaoStub.getExternalIds() not implemented.");
}
@Override
public Collection<DataPropertyStatement> getExternalIds(
String individualURI, String dataPropertyURI) {
throw new RuntimeException(
"IndividualDaoStub.getExternalIds() not implemented.");
}
@Override
public void addVClass(String individualURI, String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.addVClass() not implemented.");
}
@Override
public void removeVClass(String individualURI, String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.removeVClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClass(VClass vclass) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClassURI(String vclassURI) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClassURI() not implemented.");
}
@Override
public List<Individual> getIndividualsByVClassURI(String vclassURI,
int offset, int quantity) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByVClassURI() not implemented.");
}
@Override
public String insertNewIndividual(Individual individual)
throws InsertException {
throw new RuntimeException(
"IndividualDaoStub.insertNewIndividual() not implemented.");
}
@Override
public int updateIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.updateIndividual() not implemented.");
}
@Override
public int deleteIndividual(String individualURI) {
throw new RuntimeException(
"IndividualDaoStub.deleteIndividual() not implemented.");
}
@Override
public int deleteIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.deleteIndividual() not implemented.");
}
@Override
public void markModified(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.markModified() not implemented.");
}
@Override
public Iterator<String> getAllOfThisTypeIterator() {
throw new RuntimeException(
"IndividualDaoStub.getAllOfThisTypeIterator() not implemented.");
}
@Override
public Iterator<String> getUpdatedSinceIterator(long updatedSince) {
throw new RuntimeException(
"IndividualDaoStub.getUpdatedSinceIterator() not implemented.");
}
@Override
public boolean isIndividualOfClass(String vclassURI, String indURI) {
throw new RuntimeException(
"IndividualDaoStub.isIndividualOfClass() not implemented.");
}
@Override
public List<Individual> getIndividualsByDataProperty(
String dataPropertyUri, String value) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByDataProperty() not implemented.");
}
@Override
public List<Individual> getIndividualsByDataProperty(
String dataPropertyUri, String value, String datatypeUri,
String lang) {
throw new RuntimeException(
"IndividualDaoStub.getIndividualsByDataProperty() not implemented.");
}
@Override
public void fillVClassForIndividual(Individual individual) {
throw new RuntimeException(
"IndividualDaoStub.fillVClassForIndividual() not implemented.");
}
@Override
public String getUnusedURI(Individual individual) throws InsertException {
throw new RuntimeException(
"IndividualDaoStub.getUnusedURI() not implemented.");
}
@Override
public EditLiteral getLabelEditLiteral(String individualUri) {
throw new RuntimeException(
"IndividualDaoStub.getLabelLiteral() not implemented.");
}
}

View file

@ -1,278 +1,278 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
/**
* A minimal implementation of the ObjectPropertyDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class ObjectPropertyDaoStub implements ObjectPropertyDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, ObjectProperty> opMap = new HashMap<String, ObjectProperty>();
private final Map<String, String> configFilesMap = new HashMap<String, String>();
public void addObjectProperty(ObjectProperty property) {
if (property == null) {
throw new NullPointerException("predicate may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
opMap.put(uri, property);
}
public void setCustomListViewConfigFileName(ObjectProperty property, String filename) {
if (property == null) {
throw new NullPointerException("property may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
configFilesMap.put(uri, filename);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI) {
if (objectPropertyURI == null) {
return null;
}
return opMap.get(objectPropertyURI);
}
@Override
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI) {
return getObjectPropertyByURI(objectPropertyURI);
}
@Override
public String getCustomListViewConfigFileName(ObjectProperty objectProperty) {
if (objectProperty == null) {
return null;
}
String uri = objectProperty.getURI();
if (uri == null) {
return null;
}
return configFilesMap.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void addSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSuperproperty() not implemented.");
}
@Override
public void addSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSuperproperty() not implemented.");
}
@Override
public void addSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSubproperty() not implemented.");
}
@Override
public void addSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSubproperty() not implemented.");
}
@Override
public void removeSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSubproperty() not implemented.");
}
@Override
public void removeSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSubproperty() not implemented.");
}
@Override
public void addEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addEquivalentProperty() not implemented.");
}
@Override
public void addEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeEquivalentProperty() not implemented.");
}
@Override
public List<String> getAllSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllSubPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSuperPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getEquivalentPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getEquivalentPropertyURIs() not implemented.");
}
@Override
public List<VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getClassesWithRestrictionOnProperty() not implemented.");
}
@Override
public List<ObjectProperty> getAllObjectProperties() {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllObjectProperties() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(
List objectPropertyStatements) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertiesForObjectPropertyStatements() not implemented.");
}
@Override
public List<String> getSuperPropertyURIs(String objectPropertyURI,
boolean direct) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getSubPropertyURIs(String objectPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getSubPropertyURIs() not implemented.");
}
@Override
public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(
ObjectProperty op) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getStatementsUsingObjectProperty() not implemented.");
}
@Override
public void fillObjectPropertiesForIndividual(Individual individual) {
throw new RuntimeException(
"ObjectPropertyDaoStub.fillObjectPropertiesForIndividual() not implemented.");
}
@Override
public int insertObjectProperty(ObjectProperty objectProperty)
throws InsertException {
throw new RuntimeException(
"ObjectPropertyDaoStub.insertObjectProperty() not implemented.");
}
@Override
public void updateObjectProperty(ObjectProperty objectProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.updateObjectProperty() not implemented.");
}
@Override
public void deleteObjectProperty(String objectPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.deleteObjectProperty() not implemented.");
}
@Override
public void deleteObjectProperty(ObjectProperty objectProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.deleteObjectProperty() not implemented.");
}
@Override
public boolean skipEditForm(String predicateURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.skipEditForm() not implemented.");
}
@Override
public List<ObjectProperty> getRootObjectProperties() {
throw new RuntimeException(
"ObjectPropertyDaoStub.getRootObjectProperties() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList(Individual subject) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertyList() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertyList() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
/**
* A minimal implementation of the ObjectPropertyDao.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class ObjectPropertyDaoStub implements ObjectPropertyDao {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private final Map<String, ObjectProperty> opMap = new HashMap<String, ObjectProperty>();
private final Map<String, String> configFilesMap = new HashMap<String, String>();
public void addObjectProperty(ObjectProperty property) {
if (property == null) {
throw new NullPointerException("predicate may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
opMap.put(uri, property);
}
public void setCustomListViewConfigFileName(ObjectProperty property, String filename) {
if (property == null) {
throw new NullPointerException("property may not be null.");
}
String uri = property.getURI();
if (uri == null) {
throw new NullPointerException("uri may not be null.");
}
configFilesMap.put(uri, filename);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI) {
if (objectPropertyURI == null) {
return null;
}
return opMap.get(objectPropertyURI);
}
@Override
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI) {
return getObjectPropertyByURI(objectPropertyURI);
}
@Override
public String getCustomListViewConfigFileName(ObjectProperty objectProperty) {
if (objectProperty == null) {
return null;
}
String uri = objectProperty.getURI();
if (uri == null) {
return null;
}
return configFilesMap.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void addSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSuperproperty() not implemented.");
}
@Override
public void addSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(Property property, Property superproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSuperproperty() not implemented.");
}
@Override
public void removeSuperproperty(String propertyURI, String superpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSuperproperty() not implemented.");
}
@Override
public void addSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSubproperty() not implemented.");
}
@Override
public void addSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addSubproperty() not implemented.");
}
@Override
public void removeSubproperty(Property property, Property subproperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSubproperty() not implemented.");
}
@Override
public void removeSubproperty(String propertyURI, String subpropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeSubproperty() not implemented.");
}
@Override
public void addEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addEquivalentProperty() not implemented.");
}
@Override
public void addEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.addEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(String propertyURI,
String equivalentPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeEquivalentProperty() not implemented.");
}
@Override
public void removeEquivalentProperty(Property property,
Property equivalentProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.removeEquivalentProperty() not implemented.");
}
@Override
public List<String> getAllSubPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllSubPropertyURIs() not implemented.");
}
@Override
public List<String> getAllSuperPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getEquivalentPropertyURIs(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getEquivalentPropertyURIs() not implemented.");
}
@Override
public List<VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getClassesWithRestrictionOnProperty() not implemented.");
}
@Override
public List<ObjectProperty> getAllObjectProperties() {
throw new RuntimeException(
"ObjectPropertyDaoStub.getAllObjectProperties() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(
List objectPropertyStatements) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertiesForObjectPropertyStatements() not implemented.");
}
@Override
public List<String> getSuperPropertyURIs(String objectPropertyURI,
boolean direct) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getSuperPropertyURIs() not implemented.");
}
@Override
public List<String> getSubPropertyURIs(String objectPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getSubPropertyURIs() not implemented.");
}
@Override
public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(
ObjectProperty op) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getStatementsUsingObjectProperty() not implemented.");
}
@Override
public void fillObjectPropertiesForIndividual(Individual individual) {
throw new RuntimeException(
"ObjectPropertyDaoStub.fillObjectPropertiesForIndividual() not implemented.");
}
@Override
public int insertObjectProperty(ObjectProperty objectProperty)
throws InsertException {
throw new RuntimeException(
"ObjectPropertyDaoStub.insertObjectProperty() not implemented.");
}
@Override
public void updateObjectProperty(ObjectProperty objectProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.updateObjectProperty() not implemented.");
}
@Override
public void deleteObjectProperty(String objectPropertyURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.deleteObjectProperty() not implemented.");
}
@Override
public void deleteObjectProperty(ObjectProperty objectProperty) {
throw new RuntimeException(
"ObjectPropertyDaoStub.deleteObjectProperty() not implemented.");
}
@Override
public boolean skipEditForm(String predicateURI) {
throw new RuntimeException(
"ObjectPropertyDaoStub.skipEditForm() not implemented.");
}
@Override
public List<ObjectProperty> getRootObjectProperties() {
throw new RuntimeException(
"ObjectPropertyDaoStub.getRootObjectProperties() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList(Individual subject) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertyList() not implemented.");
}
@Override
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
throw new RuntimeException(
"ObjectPropertyDaoStub.getObjectPropertyList() not implemented.");
}
}

View file

@ -1,111 +1,111 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
/**
* TODO
*/
public class UserAccountsDaoStub implements UserAccountsDao {
private static final Log log = LogFactory.getLog(UserAccountsDaoStub.class);
private final Map<String, UserAccount> userAccountsByUri = new HashMap<String, UserAccount>();
private final Map<String, PermissionSet> permissionSetsByUri = new HashMap<String, PermissionSet>();
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
public void addUser(UserAccount user) {
userAccountsByUri.put(user.getUri(), user);
}
public void addPermissionSet(PermissionSet ps) {
permissionSetsByUri.put(ps.getUri(), ps);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public UserAccount getUserAccountByUri(String uri) {
return userAccountsByUri.get(uri);
}
@Override
public Collection<PermissionSet> getAllPermissionSets() {
return new ArrayList<PermissionSet>(permissionSetsByUri.values());
}
@Override
public PermissionSet getPermissionSetByUri(String uri) {
return permissionSetsByUri.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public UserAccount getUserAccountByEmail(String emailAddress) {
throw new RuntimeException(
"UserAccountsDaoStub.getUserAccountByEmail() not implemented.");
}
@Override
public String insertUserAccount(UserAccount userAccount) {
throw new RuntimeException(
"UserAccountsDaoStub.insertUserAccount() not implemented.");
}
@Override
public void updateUserAccount(UserAccount userAccount) {
throw new RuntimeException(
"UserAccountsDaoStub.updateUserAccount() not implemented.");
}
@Override
public void deleteUserAccount(String userAccountUri) {
throw new RuntimeException(
"UserAccountsDaoStub.deleteUserAccount() not implemented.");
}
@Override
public UserAccount getUserAccountByExternalAuthId(String externalAuthId) {
throw new RuntimeException(
"UserAccountsDao.getUserAccountByExternalAuthId() not implemented.");
}
@Override
public Collection<UserAccount> getAllUserAccounts() {
throw new RuntimeException(
"UserAccountsDao.getAllUserAccounts() not implemented.");
}
@Override
public Collection<UserAccount> getUserAccountsWhoProxyForPage(
String profilePageUri) {
throw new RuntimeException(
"UserAccountsDaoStub.getUserAccountsWhoProxyForPage() not implemented.");
}
@Override
public void setProxyAccountsOnProfile(String profilePageUri,
Collection<String> userAccountUris) {
throw new RuntimeException(
"UserAccountsDaoStub.setProxyAccountsOnProfile() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
/**
* TODO
*/
public class UserAccountsDaoStub implements UserAccountsDao {
private static final Log log = LogFactory.getLog(UserAccountsDaoStub.class);
private final Map<String, UserAccount> userAccountsByUri = new HashMap<String, UserAccount>();
private final Map<String, PermissionSet> permissionSetsByUri = new HashMap<String, PermissionSet>();
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
public void addUser(UserAccount user) {
userAccountsByUri.put(user.getUri(), user);
}
public void addPermissionSet(PermissionSet ps) {
permissionSetsByUri.put(ps.getUri(), ps);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public UserAccount getUserAccountByUri(String uri) {
return userAccountsByUri.get(uri);
}
@Override
public Collection<PermissionSet> getAllPermissionSets() {
return new ArrayList<PermissionSet>(permissionSetsByUri.values());
}
@Override
public PermissionSet getPermissionSetByUri(String uri) {
return permissionSetsByUri.get(uri);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public UserAccount getUserAccountByEmail(String emailAddress) {
throw new RuntimeException(
"UserAccountsDaoStub.getUserAccountByEmail() not implemented.");
}
@Override
public String insertUserAccount(UserAccount userAccount) {
throw new RuntimeException(
"UserAccountsDaoStub.insertUserAccount() not implemented.");
}
@Override
public void updateUserAccount(UserAccount userAccount) {
throw new RuntimeException(
"UserAccountsDaoStub.updateUserAccount() not implemented.");
}
@Override
public void deleteUserAccount(String userAccountUri) {
throw new RuntimeException(
"UserAccountsDaoStub.deleteUserAccount() not implemented.");
}
@Override
public UserAccount getUserAccountByExternalAuthId(String externalAuthId) {
throw new RuntimeException(
"UserAccountsDao.getUserAccountByExternalAuthId() not implemented.");
}
@Override
public Collection<UserAccount> getAllUserAccounts() {
throw new RuntimeException(
"UserAccountsDao.getAllUserAccounts() not implemented.");
}
@Override
public Collection<UserAccount> getUserAccountsWhoProxyForPage(
String profilePageUri) {
throw new RuntimeException(
"UserAccountsDaoStub.getUserAccountsWhoProxyForPage() not implemented.");
}
@Override
public void setProxyAccountsOnProfile(String profilePageUri,
Collection<String> userAccountUris) {
throw new RuntimeException(
"UserAccountsDaoStub.setProxyAccountsOnProfile() not implemented.");
}
}

View file

@ -1,235 +1,235 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.List;
import java.util.Map;
import java.util.Set;
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
/**
* A minimal implementation of the WebappDaoFactory.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class WebappDaoFactoryStub implements WebappDaoFactory {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String defaultNamespace;
private ApplicationDao applicationDao;
private DataPropertyDao dataPropertyDao;
private IndividualDao individualDao;
private MenuDao menuDao;
private ObjectPropertyDao objectPropertyDao;
private ObjectPropertyStatementDao objectPropertyStatementDao;
private OntologyDao ontologyDao;
private UserAccountsDao userAccountsDao;
private VClassDao vClassDao;
public void setDefaultNamespace(String defaultNamespace) {
this.defaultNamespace = defaultNamespace;
}
public void setApplicationDao(ApplicationDao applicationDao) {
this.applicationDao = applicationDao;
}
public void setDataPropertyDao(DataPropertyDao dataPropertyDao) {
this.dataPropertyDao = dataPropertyDao;
}
public void setIndividualDao(IndividualDao individualDao) {
this.individualDao = individualDao;
}
public void setMenuDao(MenuDao menuDao) {
this.menuDao = menuDao;
}
public void setObjectPropertyDao(ObjectPropertyDao objectPropertyDao) {
this.objectPropertyDao = objectPropertyDao;
}
public void setObjectPropertyStatementDao(ObjectPropertyStatementDao objectPropertyStatementDao) {
this.objectPropertyStatementDao = objectPropertyStatementDao;
}
public void setOntologyDao(OntologyDao ontologyDao) {
this.ontologyDao = ontologyDao;
}
public void setUserAccountsDao(UserAccountsDao userAccountsDao) {
this.userAccountsDao = userAccountsDao;
}
public void setVClassDao(VClassDao vClassDao) {
this.vClassDao = vClassDao;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getDefaultNamespace() {
return this.defaultNamespace;
}
@Override
public ApplicationDao getApplicationDao() {
return this.applicationDao;
}
@Override
public DataPropertyDao getDataPropertyDao() {
return this.dataPropertyDao;
}
@Override
public IndividualDao getIndividualDao() {
return this.individualDao;
}
@Override
public MenuDao getMenuDao() {
return this.menuDao;
}
@Override
public ObjectPropertyDao getObjectPropertyDao() {
return this.objectPropertyDao;
}
@Override
public ObjectPropertyStatementDao getObjectPropertyStatementDao() {
return this.objectPropertyStatementDao; }
@Override
public OntologyDao getOntologyDao() {
return this.ontologyDao;
}
@Override
public UserAccountsDao getUserAccountsDao() {
return this.userAccountsDao;
}
@Override
public VClassDao getVClassDao() {
return this.vClassDao;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public String checkURI(String uriStr) {
throw new RuntimeException(
"WebappDaoFactory.checkURI() not implemented.");
}
@Override
public String checkURI(String uriStr, boolean checkUniqueness) {
throw new RuntimeException(
"WebappDaoFactory.checkURI() not implemented.");
}
@Override
public Set<String> getNonuserNamespaces() {
throw new RuntimeException(
"WebappDaoFactory.getNonuserNamespaces() not implemented.");
}
@Override
public List<String> getPreferredLanguages() {
throw new RuntimeException(
"WebappDaoFactory.getPreferredLanguages() not implemented.");
}
@Override
public List<String> getCommentsForResource(String resourceURI) {
throw new RuntimeException(
"WebappDaoFactory.getCommentsForResource() not implemented.");
}
@Override
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
throw new RuntimeException(
"WebappDaoFactory.getUserAwareDaoFactory() not implemented.");
}
@Override
public String getUserURI() {
throw new RuntimeException(
"WebappDaoFactory.getUserURI() not implemented.");
}
@Override
public DatatypeDao getDatatypeDao() {
throw new RuntimeException(
"WebappDaoFactory.getDatatypeDao() not implemented.");
}
@Override
public DataPropertyStatementDao getDataPropertyStatementDao() {
throw new RuntimeException(
"WebappDaoFactory.getDataPropertyStatementDao() not implemented.");
}
@Override
public DisplayModelDao getDisplayModelDao() {
throw new RuntimeException(
"WebappDaoFactory.getDisplayModelDao() not implemented.");
}
@Override
public VClassGroupDao getVClassGroupDao() {
throw new RuntimeException(
"WebappDaoFactory.getVClassGroupDao() not implemented.");
}
@Override
public PropertyGroupDao getPropertyGroupDao() {
throw new RuntimeException(
"WebappDaoFactory.getPropertyGroupDao() not implemented.");
}
@Override
public PropertyInstanceDao getPropertyInstanceDao() {
throw new RuntimeException(
"WebappDaoFactory.getPropertyInstanceDao() not implemented.");
}
@Override
public PageDao getPageDao() {
throw new RuntimeException(
"WebappDaoFactory.getPageDao() not implemented.");
}
@Override
public void close() {
throw new RuntimeException("WebappDaoFactory.close() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
import java.util.List;
import java.util.Map;
import java.util.Set;
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
/**
* A minimal implementation of the WebappDaoFactory.
*
* I have only implemented the methods that I needed. Feel free to implement
* others.
*/
public class WebappDaoFactoryStub implements WebappDaoFactory {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String defaultNamespace;
private ApplicationDao applicationDao;
private DataPropertyDao dataPropertyDao;
private IndividualDao individualDao;
private MenuDao menuDao;
private ObjectPropertyDao objectPropertyDao;
private ObjectPropertyStatementDao objectPropertyStatementDao;
private OntologyDao ontologyDao;
private UserAccountsDao userAccountsDao;
private VClassDao vClassDao;
public void setDefaultNamespace(String defaultNamespace) {
this.defaultNamespace = defaultNamespace;
}
public void setApplicationDao(ApplicationDao applicationDao) {
this.applicationDao = applicationDao;
}
public void setDataPropertyDao(DataPropertyDao dataPropertyDao) {
this.dataPropertyDao = dataPropertyDao;
}
public void setIndividualDao(IndividualDao individualDao) {
this.individualDao = individualDao;
}
public void setMenuDao(MenuDao menuDao) {
this.menuDao = menuDao;
}
public void setObjectPropertyDao(ObjectPropertyDao objectPropertyDao) {
this.objectPropertyDao = objectPropertyDao;
}
public void setObjectPropertyStatementDao(ObjectPropertyStatementDao objectPropertyStatementDao) {
this.objectPropertyStatementDao = objectPropertyStatementDao;
}
public void setOntologyDao(OntologyDao ontologyDao) {
this.ontologyDao = ontologyDao;
}
public void setUserAccountsDao(UserAccountsDao userAccountsDao) {
this.userAccountsDao = userAccountsDao;
}
public void setVClassDao(VClassDao vClassDao) {
this.vClassDao = vClassDao;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getDefaultNamespace() {
return this.defaultNamespace;
}
@Override
public ApplicationDao getApplicationDao() {
return this.applicationDao;
}
@Override
public DataPropertyDao getDataPropertyDao() {
return this.dataPropertyDao;
}
@Override
public IndividualDao getIndividualDao() {
return this.individualDao;
}
@Override
public MenuDao getMenuDao() {
return this.menuDao;
}
@Override
public ObjectPropertyDao getObjectPropertyDao() {
return this.objectPropertyDao;
}
@Override
public ObjectPropertyStatementDao getObjectPropertyStatementDao() {
return this.objectPropertyStatementDao; }
@Override
public OntologyDao getOntologyDao() {
return this.ontologyDao;
}
@Override
public UserAccountsDao getUserAccountsDao() {
return this.userAccountsDao;
}
@Override
public VClassDao getVClassDao() {
return this.vClassDao;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public String checkURI(String uriStr) {
throw new RuntimeException(
"WebappDaoFactory.checkURI() not implemented.");
}
@Override
public String checkURI(String uriStr, boolean checkUniqueness) {
throw new RuntimeException(
"WebappDaoFactory.checkURI() not implemented.");
}
@Override
public Set<String> getNonuserNamespaces() {
throw new RuntimeException(
"WebappDaoFactory.getNonuserNamespaces() not implemented.");
}
@Override
public List<String> getPreferredLanguages() {
throw new RuntimeException(
"WebappDaoFactory.getPreferredLanguages() not implemented.");
}
@Override
public List<String> getCommentsForResource(String resourceURI) {
throw new RuntimeException(
"WebappDaoFactory.getCommentsForResource() not implemented.");
}
@Override
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
throw new RuntimeException(
"WebappDaoFactory.getUserAwareDaoFactory() not implemented.");
}
@Override
public String getUserURI() {
throw new RuntimeException(
"WebappDaoFactory.getUserURI() not implemented.");
}
@Override
public DatatypeDao getDatatypeDao() {
throw new RuntimeException(
"WebappDaoFactory.getDatatypeDao() not implemented.");
}
@Override
public DataPropertyStatementDao getDataPropertyStatementDao() {
throw new RuntimeException(
"WebappDaoFactory.getDataPropertyStatementDao() not implemented.");
}
@Override
public DisplayModelDao getDisplayModelDao() {
throw new RuntimeException(
"WebappDaoFactory.getDisplayModelDao() not implemented.");
}
@Override
public VClassGroupDao getVClassGroupDao() {
throw new RuntimeException(
"WebappDaoFactory.getVClassGroupDao() not implemented.");
}
@Override
public PropertyGroupDao getPropertyGroupDao() {
throw new RuntimeException(
"WebappDaoFactory.getPropertyGroupDao() not implemented.");
}
@Override
public PropertyInstanceDao getPropertyInstanceDao() {
throw new RuntimeException(
"WebappDaoFactory.getPropertyInstanceDao() not implemented.");
}
@Override
public PageDao getPageDao() {
throw new RuntimeException(
"WebappDaoFactory.getPageDao() not implemented.");
}
@Override
public void close() {
throw new RuntimeException("WebappDaoFactory.close() not implemented.");
}
}

View file

@ -1,219 +1,219 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*/
public class ContextStub implements Context {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
/**
* Keep a single context instance for each path.
*/
private static final Map<String, ContextStub> instances = new HashMap<String, ContextStub>();
/**
* Get the context instance for this path. Create one if necessary.
*/
static ContextStub getInstance(String contextPath, InitialContextStub parent) {
if (!instances.containsKey(contextPath)) {
instances.put(contextPath, new ContextStub(contextPath, parent));
}
return instances.get(contextPath);
}
private final String contextPath;
private final InitialContextStub parent;
private ContextStub(String contextPath, InitialContextStub parent) {
this.contextPath = contextPath;
this.parent = parent;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
/**
* Let the parent handle it.
*/
public void rebind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException("ContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException("ContextStub: name may not be empty.");
}
parent.rebind(contextPath + "/" + name, obj);
}
/**
* In most cases, just let the parent handle it.
*/
public Object lookup(String name) throws NamingException {
if (name == null) {
throw new NamingException("ContextStub: name may not be null.");
}
if (isEmpty(name)) {
return this;
}
return parent.lookup(contextPath + "/" + name);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
throw new RuntimeException(
"ContextStub.addToEnvironment() not implemented.");
}
public void bind(Name name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.bind() not implemented.");
}
public void bind(String name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.bind() not implemented.");
}
public void close() throws NamingException {
throw new RuntimeException("ContextStub.close() not implemented.");
}
public Name composeName(Name name, Name prefix) throws NamingException {
throw new RuntimeException("ContextStub.composeName() not implemented.");
}
public String composeName(String name, String prefix)
throws NamingException {
throw new RuntimeException("ContextStub.composeName() not implemented.");
}
public Context createSubcontext(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.createSubcontext() not implemented.");
}
public Context createSubcontext(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.createSubcontext() not implemented.");
}
public void destroySubcontext(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.destroySubcontext() not implemented.");
}
public void destroySubcontext(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.destroySubcontext() not implemented.");
}
public Hashtable<?, ?> getEnvironment() throws NamingException {
throw new RuntimeException(
"ContextStub.getEnvironment() not implemented.");
}
public String getNameInNamespace() throws NamingException {
throw new RuntimeException(
"ContextStub.getNameInNamespace() not implemented.");
}
public NameParser getNameParser(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.getNameParser() not implemented.");
}
public NameParser getNameParser(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.getNameParser() not implemented.");
}
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
throw new RuntimeException("ContextStub.list() not implemented.");
}
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
throw new RuntimeException("ContextStub.list() not implemented.");
}
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
throw new RuntimeException(
"ContextStub.listBindings() not implemented.");
}
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
throw new RuntimeException(
"ContextStub.listBindings() not implemented.");
}
public Object lookup(Name name) throws NamingException {
throw new RuntimeException("ContextStub.lookup() not implemented.");
}
public Object lookupLink(Name name) throws NamingException {
throw new RuntimeException("ContextStub.lookupLink() not implemented.");
}
public Object lookupLink(String name) throws NamingException {
throw new RuntimeException("ContextStub.lookupLink() not implemented.");
}
public void rebind(Name name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.rebind() not implemented.");
}
public Object removeFromEnvironment(String propName) throws NamingException {
throw new RuntimeException(
"ContextStub.removeFromEnvironment() not implemented.");
}
public void rename(Name oldName, Name newName) throws NamingException {
throw new RuntimeException("ContextStub.rename() not implemented.");
}
public void rename(String oldName, String newName) throws NamingException {
throw new RuntimeException("ContextStub.rename() not implemented.");
}
public void unbind(Name name) throws NamingException {
throw new RuntimeException("ContextStub.unbind() not implemented.");
}
public void unbind(String name) throws NamingException {
throw new RuntimeException("ContextStub.unbind() not implemented.");
}
private boolean isEmpty(String string) {
return (string == null || string.trim().length() == 0);
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*/
public class ContextStub implements Context {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
/**
* Keep a single context instance for each path.
*/
private static final Map<String, ContextStub> instances = new HashMap<String, ContextStub>();
/**
* Get the context instance for this path. Create one if necessary.
*/
static ContextStub getInstance(String contextPath, InitialContextStub parent) {
if (!instances.containsKey(contextPath)) {
instances.put(contextPath, new ContextStub(contextPath, parent));
}
return instances.get(contextPath);
}
private final String contextPath;
private final InitialContextStub parent;
private ContextStub(String contextPath, InitialContextStub parent) {
this.contextPath = contextPath;
this.parent = parent;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
/**
* Let the parent handle it.
*/
public void rebind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException("ContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException("ContextStub: name may not be empty.");
}
parent.rebind(contextPath + "/" + name, obj);
}
/**
* In most cases, just let the parent handle it.
*/
public Object lookup(String name) throws NamingException {
if (name == null) {
throw new NamingException("ContextStub: name may not be null.");
}
if (isEmpty(name)) {
return this;
}
return parent.lookup(contextPath + "/" + name);
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
throw new RuntimeException(
"ContextStub.addToEnvironment() not implemented.");
}
public void bind(Name name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.bind() not implemented.");
}
public void bind(String name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.bind() not implemented.");
}
public void close() throws NamingException {
throw new RuntimeException("ContextStub.close() not implemented.");
}
public Name composeName(Name name, Name prefix) throws NamingException {
throw new RuntimeException("ContextStub.composeName() not implemented.");
}
public String composeName(String name, String prefix)
throws NamingException {
throw new RuntimeException("ContextStub.composeName() not implemented.");
}
public Context createSubcontext(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.createSubcontext() not implemented.");
}
public Context createSubcontext(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.createSubcontext() not implemented.");
}
public void destroySubcontext(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.destroySubcontext() not implemented.");
}
public void destroySubcontext(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.destroySubcontext() not implemented.");
}
public Hashtable<?, ?> getEnvironment() throws NamingException {
throw new RuntimeException(
"ContextStub.getEnvironment() not implemented.");
}
public String getNameInNamespace() throws NamingException {
throw new RuntimeException(
"ContextStub.getNameInNamespace() not implemented.");
}
public NameParser getNameParser(Name name) throws NamingException {
throw new RuntimeException(
"ContextStub.getNameParser() not implemented.");
}
public NameParser getNameParser(String name) throws NamingException {
throw new RuntimeException(
"ContextStub.getNameParser() not implemented.");
}
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
throw new RuntimeException("ContextStub.list() not implemented.");
}
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
throw new RuntimeException("ContextStub.list() not implemented.");
}
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
throw new RuntimeException(
"ContextStub.listBindings() not implemented.");
}
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
throw new RuntimeException(
"ContextStub.listBindings() not implemented.");
}
public Object lookup(Name name) throws NamingException {
throw new RuntimeException("ContextStub.lookup() not implemented.");
}
public Object lookupLink(Name name) throws NamingException {
throw new RuntimeException("ContextStub.lookupLink() not implemented.");
}
public Object lookupLink(String name) throws NamingException {
throw new RuntimeException("ContextStub.lookupLink() not implemented.");
}
public void rebind(Name name, Object obj) throws NamingException {
throw new RuntimeException("ContextStub.rebind() not implemented.");
}
public Object removeFromEnvironment(String propName) throws NamingException {
throw new RuntimeException(
"ContextStub.removeFromEnvironment() not implemented.");
}
public void rename(Name oldName, Name newName) throws NamingException {
throw new RuntimeException("ContextStub.rename() not implemented.");
}
public void rename(String oldName, String newName) throws NamingException {
throw new RuntimeException("ContextStub.rename() not implemented.");
}
public void unbind(Name name) throws NamingException {
throw new RuntimeException("ContextStub.unbind() not implemented.");
}
public void unbind(String name) throws NamingException {
throw new RuntimeException("ContextStub.unbind() not implemented.");
}
private boolean isEmpty(String string) {
return (string == null || string.trim().length() == 0);
}
}

View file

@ -1,308 +1,308 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming;
import java.util.Hashtable;
import java.util.Map;
import java.util.TreeMap;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*
* The bindings are static, so you will probablly want to call {@link #reset()}
* before each test.
*/
public class InitialContextStub extends InitialContext {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private static Map<String, Object> bindings = new TreeMap<String, Object>();
/**
* Make sure we start the next test with a fresh instance.
*/
public static void reset() {
bindings.clear();
}
/**
* If we have properties that are bound to a level below this name, then
* this name represents a sub-context.
*/
private boolean isSubContext(String name) {
String path = name.endsWith("/") ? name : name + "/";
for (String key : bindings.keySet()) {
if (key.startsWith(path)) {
return true;
}
}
return false;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
public InitialContextStub() throws NamingException {
super();
}
@Override
protected void init(Hashtable<?, ?> environment) throws NamingException {
}
@Override
protected Context getURLOrDefaultInitCtx(String name)
throws NamingException {
return super.getURLOrDefaultInitCtx(name);
}
@Override
protected Context getDefaultInitCtx() throws NamingException {
return ContextStub.getInstance("", this);
}
private boolean isEmpty(String string) {
return (string == null || string.trim().length() == 0);
}
@Override
public void bind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException(
"InitialContextStub: name may not be empty.");
}
if (bindings.containsKey(name)) {
throw new NamingException(
"InitialContextStub: name is already bound.");
}
bindings.put(name, obj);
}
@Override
public void rebind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException(
"InitialContextStub: name may not be empty.");
}
bindings.put(name, obj);
}
@Override
public Object lookup(String name) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null");
}
if (isEmpty(name)) {
return this;
}
if (bindings.containsKey(name)) {
return bindings.get(name);
}
if (isSubContext(name)) {
return ContextStub.getInstance(name, this);
}
throw new NamingException("InitialContextStub: No binding for '" + name
+ "'");
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.addToEnvironment() not implemented.");
}
@Override
public void bind(Name name, Object obj) throws NamingException {
throw new RuntimeException("InitialContextStub.bind() not implemented.");
}
@Override
public void close() throws NamingException {
throw new RuntimeException(
"InitialContextStub.close() not implemented.");
}
@Override
public Name composeName(Name name, Name prefix) throws NamingException {
throw new RuntimeException(
"InitialContextStub.composeName() not implemented.");
}
@Override
public String composeName(String name, String prefix)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.composeName() not implemented.");
}
@Override
public Context createSubcontext(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.createSubcontext() not implemented.");
}
@Override
public Context createSubcontext(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.createSubcontext() not implemented.");
}
@Override
public void destroySubcontext(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.destroySubcontext() not implemented.");
}
@Override
public void destroySubcontext(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.destroySubcontext() not implemented.");
}
@Override
public Hashtable<?, ?> getEnvironment() throws NamingException {
throw new RuntimeException(
"InitialContextStub.getEnvironment() not implemented.");
}
@Override
public String getNameInNamespace() throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameInNamespace() not implemented.");
}
@Override
public NameParser getNameParser(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameParser() not implemented.");
}
@Override
public NameParser getNameParser(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameParser() not implemented.");
}
@Override
protected Context getURLOrDefaultInitCtx(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getURLOrDefaultInitCtx() not implemented.");
}
@Override
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
throw new RuntimeException("InitialContextStub.list() not implemented.");
}
@Override
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
throw new RuntimeException("InitialContextStub.list() not implemented.");
}
@Override
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.listBindings() not implemented.");
}
@Override
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.listBindings() not implemented.");
}
@Override
public Object lookup(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookup() not implemented.");
}
@Override
public Object lookupLink(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookupLink() not implemented.");
}
@Override
public Object lookupLink(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookupLink() not implemented.");
}
@Override
public void rebind(Name name, Object obj) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rebind() not implemented.");
}
@Override
public Object removeFromEnvironment(String propName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.removeFromEnvironment() not implemented.");
}
@Override
public void rename(Name oldName, Name newName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rename() not implemented.");
}
@Override
public void rename(String oldName, String newName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rename() not implemented.");
}
@Override
public void unbind(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.unbind() not implemented.");
}
@Override
public void unbind(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.unbind() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming;
import java.util.Hashtable;
import java.util.Map;
import java.util.TreeMap;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*
* The bindings are static, so you will probablly want to call {@link #reset()}
* before each test.
*/
public class InitialContextStub extends InitialContext {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private static Map<String, Object> bindings = new TreeMap<String, Object>();
/**
* Make sure we start the next test with a fresh instance.
*/
public static void reset() {
bindings.clear();
}
/**
* If we have properties that are bound to a level below this name, then
* this name represents a sub-context.
*/
private boolean isSubContext(String name) {
String path = name.endsWith("/") ? name : name + "/";
for (String key : bindings.keySet()) {
if (key.startsWith(path)) {
return true;
}
}
return false;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
public InitialContextStub() throws NamingException {
super();
}
@Override
protected void init(Hashtable<?, ?> environment) throws NamingException {
}
@Override
protected Context getURLOrDefaultInitCtx(String name)
throws NamingException {
return super.getURLOrDefaultInitCtx(name);
}
@Override
protected Context getDefaultInitCtx() throws NamingException {
return ContextStub.getInstance("", this);
}
private boolean isEmpty(String string) {
return (string == null || string.trim().length() == 0);
}
@Override
public void bind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException(
"InitialContextStub: name may not be empty.");
}
if (bindings.containsKey(name)) {
throw new NamingException(
"InitialContextStub: name is already bound.");
}
bindings.put(name, obj);
}
@Override
public void rebind(String name, Object obj) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null.");
}
if (isEmpty(name)) {
throw new NamingException(
"InitialContextStub: name may not be empty.");
}
bindings.put(name, obj);
}
@Override
public Object lookup(String name) throws NamingException {
if (name == null) {
throw new NullPointerException(
"InitialContextStub: name may not be null");
}
if (isEmpty(name)) {
return this;
}
if (bindings.containsKey(name)) {
return bindings.get(name);
}
if (isSubContext(name)) {
return ContextStub.getInstance(name, this);
}
throw new NamingException("InitialContextStub: No binding for '" + name
+ "'");
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.addToEnvironment() not implemented.");
}
@Override
public void bind(Name name, Object obj) throws NamingException {
throw new RuntimeException("InitialContextStub.bind() not implemented.");
}
@Override
public void close() throws NamingException {
throw new RuntimeException(
"InitialContextStub.close() not implemented.");
}
@Override
public Name composeName(Name name, Name prefix) throws NamingException {
throw new RuntimeException(
"InitialContextStub.composeName() not implemented.");
}
@Override
public String composeName(String name, String prefix)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.composeName() not implemented.");
}
@Override
public Context createSubcontext(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.createSubcontext() not implemented.");
}
@Override
public Context createSubcontext(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.createSubcontext() not implemented.");
}
@Override
public void destroySubcontext(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.destroySubcontext() not implemented.");
}
@Override
public void destroySubcontext(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.destroySubcontext() not implemented.");
}
@Override
public Hashtable<?, ?> getEnvironment() throws NamingException {
throw new RuntimeException(
"InitialContextStub.getEnvironment() not implemented.");
}
@Override
public String getNameInNamespace() throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameInNamespace() not implemented.");
}
@Override
public NameParser getNameParser(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameParser() not implemented.");
}
@Override
public NameParser getNameParser(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getNameParser() not implemented.");
}
@Override
protected Context getURLOrDefaultInitCtx(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.getURLOrDefaultInitCtx() not implemented.");
}
@Override
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
throw new RuntimeException("InitialContextStub.list() not implemented.");
}
@Override
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
throw new RuntimeException("InitialContextStub.list() not implemented.");
}
@Override
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.listBindings() not implemented.");
}
@Override
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
throw new RuntimeException(
"InitialContextStub.listBindings() not implemented.");
}
@Override
public Object lookup(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookup() not implemented.");
}
@Override
public Object lookupLink(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookupLink() not implemented.");
}
@Override
public Object lookupLink(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.lookupLink() not implemented.");
}
@Override
public void rebind(Name name, Object obj) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rebind() not implemented.");
}
@Override
public Object removeFromEnvironment(String propName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.removeFromEnvironment() not implemented.");
}
@Override
public void rename(Name oldName, Name newName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rename() not implemented.");
}
@Override
public void rename(String oldName, String newName) throws NamingException {
throw new RuntimeException(
"InitialContextStub.rename() not implemented.");
}
@Override
public void unbind(Name name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.unbind() not implemented.");
}
@Override
public void unbind(String name) throws NamingException {
throw new RuntimeException(
"InitialContextStub.unbind() not implemented.");
}
}

View file

@ -1,30 +1,30 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming.spi;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import stubs.javax.naming.InitialContextStub;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*/
public class InitialContextFactoryStub implements InitialContextFactory {
/**
* It's just this easy.
*/
public Context getInitialContext(Hashtable<?, ?> environment)
throws NamingException {
return new InitialContextStub();
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.naming.spi;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import stubs.javax.naming.InitialContextStub;
/**
* In order to use this and the other naming stubs.javax.naming classes, do
* this:
*
* <pre>
* System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
* InitialContextFactoryStub.class.getName());
* </pre>
*/
public class InitialContextFactoryStub implements InitialContextFactory {
/**
* It's just this easy.
*/
public Context getInitialContext(Hashtable<?, ?> environment)
throws NamingException {
return new InitialContextStub();
}
}

View file

@ -1,56 +1,56 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
/**
* A simple stub for testing servlets.
*/
public class ServletConfigStub implements ServletConfig {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private ServletContext servletContext;
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public ServletContext getServletContext() {
return servletContext;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public String getInitParameter(String arg0) {
throw new RuntimeException(
"ServletConfigStub.getInitParameter() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getInitParameterNames() {
throw new RuntimeException(
"ServletConfigStub.getInitParameterNames() not implemented.");
}
@Override
public String getServletName() {
throw new RuntimeException(
"ServletConfigStub.getServletName() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
/**
* A simple stub for testing servlets.
*/
public class ServletConfigStub implements ServletConfig {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private ServletContext servletContext;
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public ServletContext getServletContext() {
return servletContext;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public String getInitParameter(String arg0) {
throw new RuntimeException(
"ServletConfigStub.getInitParameter() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getInitParameterNames() {
throw new RuntimeException(
"ServletConfigStub.getInitParameterNames() not implemented.");
}
@Override
public String getServletName() {
throw new RuntimeException(
"ServletConfigStub.getServletName() not implemented.");
}
}

View file

@ -1,243 +1,243 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A simple stand-in for the {@link ServletContext}, for use in unit tests.
*/
public class ServletContextStub implements ServletContext {
private static final Log log = LogFactory.getLog(ServletContextStub.class);
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String contextPath = ""; // root context returns ""
private final Map<String, Object> attributes = new HashMap<String, Object>();
private final Map<String, String> mockResources = new HashMap<String, String>();
private final Map<String, String> realPaths = new HashMap<String, String>();
public void setContextPath(String contextPath) {
if (contextPath == null) {
throw new NullPointerException("contextPath may not be null.");
}
}
public void setMockResource(String path, String contents) {
if (path == null) {
throw new NullPointerException("path may not be null.");
}
if (contents == null) {
mockResources.remove(path);
} else {
mockResources.put(path, contents);
}
}
public void setRealPath(String path, String filepath) {
if (path == null) {
throw new NullPointerException("path may not be null.");
}
if (filepath == null) {
log.debug("removing real path for '" + path + "'");
realPaths.remove(path);
} else {
log.debug("adding real path for '" + path + "' = '" + filepath
+ "'");
realPaths.put(path, filepath);
}
}
/**
* Call setRealPath for each of the files in this directory (non-recursive).
* The prefix is the "pretend" location that we're mapping these files to,
* e.g. "/config/". Use the prefix and the filename as the path.
*/
public void setRealPaths(String pathPrefix, File dir) {
for (File file : dir.listFiles()) {
setRealPath(pathPrefix + file.getName(), file.getPath());
}
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getContextPath() {
return contextPath;
}
@Override
public Object getAttribute(String name) {
return attributes.get(name);
}
@Override
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(attributes.keySet());
}
@Override
public void removeAttribute(String name) {
attributes.remove(name);
}
@Override
public void setAttribute(String name, Object object) {
if (object == null) {
removeAttribute(name);
} else {
attributes.put(name, object);
}
}
@Override
public InputStream getResourceAsStream(String path) {
if (mockResources.containsKey(path)) {
return new ByteArrayInputStream(mockResources.get(path).getBytes());
} else {
return null;
}
}
@Override
public String getRealPath(String path) {
String real = realPaths.get(path);
log.debug("Real path for '" + path + "' is '" + real + "'");
return real;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public ServletContext getContext(String arg0) {
throw new RuntimeException(
"ServletContextStub.getContext() not implemented.");
}
@Override
public String getInitParameter(String arg0) {
throw new RuntimeException(
"ServletContextStub.getInitParameter() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getInitParameterNames() {
throw new RuntimeException(
"ServletContextStub.getInitParameterNames() not implemented.");
}
@Override
public int getMajorVersion() {
throw new RuntimeException(
"ServletContextStub.getMajorVersion() not implemented.");
}
@Override
public String getMimeType(String arg0) {
throw new RuntimeException(
"ServletContextStub.getMimeType() not implemented.");
}
@Override
public int getMinorVersion() {
throw new RuntimeException(
"ServletContextStub.getMinorVersion() not implemented.");
}
@Override
public RequestDispatcher getNamedDispatcher(String arg0) {
throw new RuntimeException(
"ServletContextStub.getNamedDispatcher() not implemented.");
}
@Override
public RequestDispatcher getRequestDispatcher(String arg0) {
throw new RuntimeException(
"ServletContextStub.getRequestDispatcher() not implemented.");
}
@Override
public URL getResource(String arg0) throws MalformedURLException {
throw new RuntimeException(
"ServletContextStub.getResource() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Set getResourcePaths(String arg0) {
throw new RuntimeException(
"ServletContextStub.getResourcePaths() not implemented.");
}
@Override
public String getServerInfo() {
throw new RuntimeException(
"ServletContextStub.getServerInfo() not implemented.");
}
@Override
public Servlet getServlet(String arg0) throws ServletException {
throw new RuntimeException(
"ServletContextStub.getServlet() not implemented.");
}
@Override
public String getServletContextName() {
throw new RuntimeException(
"ServletContextStub.getServletContextName() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getServletNames() {
throw new RuntimeException(
"ServletContextStub.getServletNames() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getServlets() {
throw new RuntimeException(
"ServletContextStub.getServlets() not implemented.");
}
@Override
public void log(String arg0) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
@Override
public void log(Exception arg0, String arg1) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
@Override
public void log(String arg0, Throwable arg1) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A simple stand-in for the {@link ServletContext}, for use in unit tests.
*/
public class ServletContextStub implements ServletContext {
private static final Log log = LogFactory.getLog(ServletContextStub.class);
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String contextPath = ""; // root context returns ""
private final Map<String, Object> attributes = new HashMap<String, Object>();
private final Map<String, String> mockResources = new HashMap<String, String>();
private final Map<String, String> realPaths = new HashMap<String, String>();
public void setContextPath(String contextPath) {
if (contextPath == null) {
throw new NullPointerException("contextPath may not be null.");
}
}
public void setMockResource(String path, String contents) {
if (path == null) {
throw new NullPointerException("path may not be null.");
}
if (contents == null) {
mockResources.remove(path);
} else {
mockResources.put(path, contents);
}
}
public void setRealPath(String path, String filepath) {
if (path == null) {
throw new NullPointerException("path may not be null.");
}
if (filepath == null) {
log.debug("removing real path for '" + path + "'");
realPaths.remove(path);
} else {
log.debug("adding real path for '" + path + "' = '" + filepath
+ "'");
realPaths.put(path, filepath);
}
}
/**
* Call setRealPath for each of the files in this directory (non-recursive).
* The prefix is the "pretend" location that we're mapping these files to,
* e.g. "/config/". Use the prefix and the filename as the path.
*/
public void setRealPaths(String pathPrefix, File dir) {
for (File file : dir.listFiles()) {
setRealPath(pathPrefix + file.getName(), file.getPath());
}
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getContextPath() {
return contextPath;
}
@Override
public Object getAttribute(String name) {
return attributes.get(name);
}
@Override
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(attributes.keySet());
}
@Override
public void removeAttribute(String name) {
attributes.remove(name);
}
@Override
public void setAttribute(String name, Object object) {
if (object == null) {
removeAttribute(name);
} else {
attributes.put(name, object);
}
}
@Override
public InputStream getResourceAsStream(String path) {
if (mockResources.containsKey(path)) {
return new ByteArrayInputStream(mockResources.get(path).getBytes());
} else {
return null;
}
}
@Override
public String getRealPath(String path) {
String real = realPaths.get(path);
log.debug("Real path for '" + path + "' is '" + real + "'");
return real;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public ServletContext getContext(String arg0) {
throw new RuntimeException(
"ServletContextStub.getContext() not implemented.");
}
@Override
public String getInitParameter(String arg0) {
throw new RuntimeException(
"ServletContextStub.getInitParameter() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getInitParameterNames() {
throw new RuntimeException(
"ServletContextStub.getInitParameterNames() not implemented.");
}
@Override
public int getMajorVersion() {
throw new RuntimeException(
"ServletContextStub.getMajorVersion() not implemented.");
}
@Override
public String getMimeType(String arg0) {
throw new RuntimeException(
"ServletContextStub.getMimeType() not implemented.");
}
@Override
public int getMinorVersion() {
throw new RuntimeException(
"ServletContextStub.getMinorVersion() not implemented.");
}
@Override
public RequestDispatcher getNamedDispatcher(String arg0) {
throw new RuntimeException(
"ServletContextStub.getNamedDispatcher() not implemented.");
}
@Override
public RequestDispatcher getRequestDispatcher(String arg0) {
throw new RuntimeException(
"ServletContextStub.getRequestDispatcher() not implemented.");
}
@Override
public URL getResource(String arg0) throws MalformedURLException {
throw new RuntimeException(
"ServletContextStub.getResource() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Set getResourcePaths(String arg0) {
throw new RuntimeException(
"ServletContextStub.getResourcePaths() not implemented.");
}
@Override
public String getServerInfo() {
throw new RuntimeException(
"ServletContextStub.getServerInfo() not implemented.");
}
@Override
public Servlet getServlet(String arg0) throws ServletException {
throw new RuntimeException(
"ServletContextStub.getServlet() not implemented.");
}
@Override
public String getServletContextName() {
throw new RuntimeException(
"ServletContextStub.getServletContextName() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getServletNames() {
throw new RuntimeException(
"ServletContextStub.getServletNames() not implemented.");
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getServlets() {
throw new RuntimeException(
"ServletContextStub.getServlets() not implemented.");
}
@Override
public void log(String arg0) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
@Override
public void log(Exception arg0, String arg1) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
@Override
public void log(String arg0, Throwable arg1) {
throw new RuntimeException("ServletContextStub.log() not implemented.");
}
}

View file

@ -1,289 +1,289 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet.http;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
/**
* A simple stub for HttpServletResponse
*/
@SuppressWarnings("deprecation")
public class HttpServletResponseStub implements HttpServletResponse {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String redirectLocation;
private int status = 200;
private String errorMessage;
private Map<String, String> headers = new HashMap<String, String>();
private String contentType;
private String charset = "";
private ByteArrayOutputStream outputStream;
private StringWriter outputWriter;
public String getRedirectLocation() {
return redirectLocation;
}
public int getStatus() {
return status;
}
public String getErrorMessage() {
return errorMessage;
}
public String getOutput() {
if (outputStream != null) {
return outputStream.toString();
} else if (outputWriter != null) {
return outputWriter.toString();
} else {
return "";
}
}
public String getHeader(String name) {
return headers.get(name);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public void sendRedirect(String location) throws IOException {
this.redirectLocation = location;
}
@Override
public void setStatus(int status) {
this.status = status;
}
@Override
@SuppressWarnings("hiding")
public void sendError(int status) throws IOException {
this.status = status;
}
@Override
@SuppressWarnings("hiding")
public void sendError(int status, String message) throws IOException {
this.status = status;
this.errorMessage = message;
}
@Override
public PrintWriter getWriter() throws IOException {
if (outputStream != null) {
throw new IllegalStateException(
"Can't get a Writer after getting an OutputStream.");
}
if (outputWriter == null) {
outputWriter = new StringWriter();
}
return new PrintWriter(outputWriter, true);
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
if (outputWriter != null) {
throw new IllegalStateException(
"Can't get an OutputStream after getting a Writer.");
}
if (outputStream == null) {
outputStream = new ByteArrayOutputStream();
}
return new ServletOutputStream() {
@Override
public void write(int thisChar) throws IOException {
outputStream.write(thisChar);
}
};
}
@Override
public void setHeader(String name, String value) {
headers.put(name, value);
}
@Override
public boolean containsHeader(String name) {
return headers.containsKey(name);
}
/**
* Calling setContentType("this/type;charset=UTF-8") is the same as calling
* setContentType("this/type;charset=UTF-8"); setCharacterEncoding("UTF-8")
*/
@Override
public void setContentType(String contentType) {
this.contentType = contentType;
Pattern p = Pattern.compile(";\\scharset=([^;]+)");
Matcher m = p.matcher(contentType);
if (m.find()) {
this.charset = m.group(1);
}
}
@Override
public String getContentType() {
return contentType;
}
@Override
public void setCharacterEncoding(String charset) {
this.charset = charset;
}
@Override
public String getCharacterEncoding() {
return charset;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void flushBuffer() throws IOException {
throw new RuntimeException(
"HttpServletResponseStub.flushBuffer() not implemented.");
}
@Override
public int getBufferSize() {
throw new RuntimeException(
"HttpServletResponseStub.getBufferSize() not implemented.");
}
@Override
public Locale getLocale() {
throw new RuntimeException(
"HttpServletResponseStub.getLocale() not implemented.");
}
@Override
public boolean isCommitted() {
throw new RuntimeException(
"HttpServletResponseStub.isCommitted() not implemented.");
}
@Override
public void reset() {
throw new RuntimeException(
"HttpServletResponseStub.reset() not implemented.");
}
@Override
public void resetBuffer() {
throw new RuntimeException(
"HttpServletResponseStub.resetBuffer() not implemented.");
}
@Override
public void setBufferSize(int arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setBufferSize() not implemented.");
}
@Override
public void setContentLength(int arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setContentLength() not implemented.");
}
@Override
public void setLocale(Locale arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setLocale() not implemented.");
}
@Override
public void addCookie(Cookie arg0) {
throw new RuntimeException(
"HttpServletResponseStub.addCookie() not implemented.");
}
@Override
public void addDateHeader(String arg0, long arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addDateHeader() not implemented.");
}
@Override
public void addHeader(String arg0, String arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addHeader() not implemented.");
}
@Override
public void addIntHeader(String arg0, int arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addIntHeader() not implemented.");
}
@Override
public String encodeRedirectURL(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeRedirectURL() not implemented.");
}
@Override
public String encodeRedirectUrl(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeRedirectUrl() not implemented.");
}
@Override
public String encodeURL(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeURL() not implemented.");
}
@Override
public String encodeUrl(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeUrl() not implemented.");
}
@Override
public void setDateHeader(String arg0, long arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setDateHeader() not implemented.");
}
@Override
public void setIntHeader(String arg0, int arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setIntHeader() not implemented.");
}
@Override
public void setStatus(int arg0, String arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setStatus() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet.http;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
/**
* A simple stub for HttpServletResponse
*/
@SuppressWarnings("deprecation")
public class HttpServletResponseStub implements HttpServletResponse {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String redirectLocation;
private int status = 200;
private String errorMessage;
private Map<String, String> headers = new HashMap<String, String>();
private String contentType;
private String charset = "";
private ByteArrayOutputStream outputStream;
private StringWriter outputWriter;
public String getRedirectLocation() {
return redirectLocation;
}
public int getStatus() {
return status;
}
public String getErrorMessage() {
return errorMessage;
}
public String getOutput() {
if (outputStream != null) {
return outputStream.toString();
} else if (outputWriter != null) {
return outputWriter.toString();
} else {
return "";
}
}
public String getHeader(String name) {
return headers.get(name);
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public void sendRedirect(String location) throws IOException {
this.redirectLocation = location;
}
@Override
public void setStatus(int status) {
this.status = status;
}
@Override
@SuppressWarnings("hiding")
public void sendError(int status) throws IOException {
this.status = status;
}
@Override
@SuppressWarnings("hiding")
public void sendError(int status, String message) throws IOException {
this.status = status;
this.errorMessage = message;
}
@Override
public PrintWriter getWriter() throws IOException {
if (outputStream != null) {
throw new IllegalStateException(
"Can't get a Writer after getting an OutputStream.");
}
if (outputWriter == null) {
outputWriter = new StringWriter();
}
return new PrintWriter(outputWriter, true);
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
if (outputWriter != null) {
throw new IllegalStateException(
"Can't get an OutputStream after getting a Writer.");
}
if (outputStream == null) {
outputStream = new ByteArrayOutputStream();
}
return new ServletOutputStream() {
@Override
public void write(int thisChar) throws IOException {
outputStream.write(thisChar);
}
};
}
@Override
public void setHeader(String name, String value) {
headers.put(name, value);
}
@Override
public boolean containsHeader(String name) {
return headers.containsKey(name);
}
/**
* Calling setContentType("this/type;charset=UTF-8") is the same as calling
* setContentType("this/type;charset=UTF-8"); setCharacterEncoding("UTF-8")
*/
@Override
public void setContentType(String contentType) {
this.contentType = contentType;
Pattern p = Pattern.compile(";\\scharset=([^;]+)");
Matcher m = p.matcher(contentType);
if (m.find()) {
this.charset = m.group(1);
}
}
@Override
public String getContentType() {
return contentType;
}
@Override
public void setCharacterEncoding(String charset) {
this.charset = charset;
}
@Override
public String getCharacterEncoding() {
return charset;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void flushBuffer() throws IOException {
throw new RuntimeException(
"HttpServletResponseStub.flushBuffer() not implemented.");
}
@Override
public int getBufferSize() {
throw new RuntimeException(
"HttpServletResponseStub.getBufferSize() not implemented.");
}
@Override
public Locale getLocale() {
throw new RuntimeException(
"HttpServletResponseStub.getLocale() not implemented.");
}
@Override
public boolean isCommitted() {
throw new RuntimeException(
"HttpServletResponseStub.isCommitted() not implemented.");
}
@Override
public void reset() {
throw new RuntimeException(
"HttpServletResponseStub.reset() not implemented.");
}
@Override
public void resetBuffer() {
throw new RuntimeException(
"HttpServletResponseStub.resetBuffer() not implemented.");
}
@Override
public void setBufferSize(int arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setBufferSize() not implemented.");
}
@Override
public void setContentLength(int arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setContentLength() not implemented.");
}
@Override
public void setLocale(Locale arg0) {
throw new RuntimeException(
"HttpServletResponseStub.setLocale() not implemented.");
}
@Override
public void addCookie(Cookie arg0) {
throw new RuntimeException(
"HttpServletResponseStub.addCookie() not implemented.");
}
@Override
public void addDateHeader(String arg0, long arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addDateHeader() not implemented.");
}
@Override
public void addHeader(String arg0, String arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addHeader() not implemented.");
}
@Override
public void addIntHeader(String arg0, int arg1) {
throw new RuntimeException(
"HttpServletResponseStub.addIntHeader() not implemented.");
}
@Override
public String encodeRedirectURL(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeRedirectURL() not implemented.");
}
@Override
public String encodeRedirectUrl(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeRedirectUrl() not implemented.");
}
@Override
public String encodeURL(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeURL() not implemented.");
}
@Override
public String encodeUrl(String arg0) {
throw new RuntimeException(
"HttpServletResponseStub.encodeUrl() not implemented.");
}
@Override
public void setDateHeader(String arg0, long arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setDateHeader() not implemented.");
}
@Override
public void setIntHeader(String arg0, int arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setIntHeader() not implemented.");
}
@Override
public void setStatus(int arg0, String arg1) {
throw new RuntimeException(
"HttpServletResponseStub.setStatus() not implemented.");
}
}

View file

@ -1,163 +1,163 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet.http;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import stubs.javax.servlet.ServletContextStub;
/**
* A simple stand-in for the HttpSession, for use in unit tests.
*/
public class HttpSessionStub implements HttpSession {
private static final Log log = LogFactory.getLog(HttpSessionStub.class);
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String id = "arbitraryId";
private ServletContext context;
private final Map<String, Object> attributes = new HashMap<String, Object>();
@SuppressWarnings("unused")
private int maxInactiveInterval;
public void setId(String id) {
this.id = id;
}
public void setServletContext(ServletContext context) {
this.context = context;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getId() {
return this.id;
}
@Override
public ServletContext getServletContext() {
if (this.context == null) {
return new ServletContextStub();
} else {
return this.context;
}
}
@Override
public void setAttribute(String name, Object value) {
if (name == null) {
throw new NullPointerException("name may not be null.");
}
if (value == null) {
removeAttribute(name);
}
attributes.put(name, value);
log.debug("setAttribute: " + name + "=" + value);
}
@Override
public void removeAttribute(String name) {
attributes.remove(name);
log.debug("removeAttribute: " + name);
}
@Override
public Object getAttribute(String name) {
return attributes.get(name);
}
/**
* So far, we don't do anything with this, or even confirm that it has been
* set. We just don't throw an exception if someone wants to set it.
*/
@Override
public void setMaxInactiveInterval(int seconds) {
this.maxInactiveInterval = seconds;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
@SuppressWarnings("rawtypes")
public Enumeration getAttributeNames() {
throw new RuntimeException(
"HttpSessionStub.getAttributeNames() not implemented.");
}
@Override
public long getCreationTime() {
throw new RuntimeException(
"HttpSessionStub.getCreationTime() not implemented.");
}
@Override
public long getLastAccessedTime() {
throw new RuntimeException(
"HttpSessionStub.getLastAccessedTime() not implemented.");
}
@Override
public int getMaxInactiveInterval() {
throw new RuntimeException(
"HttpSessionStub.getMaxInactiveInterval() not implemented.");
}
@Deprecated
@Override
public javax.servlet.http.HttpSessionContext getSessionContext() {
throw new RuntimeException(
"HttpSessionStub.getSessionContext() not implemented.");
}
@Override
public Object getValue(String arg0) {
throw new RuntimeException(
"HttpSessionStub.getValue() not implemented.");
}
@Override
public String[] getValueNames() {
throw new RuntimeException(
"HttpSessionStub.getValueNames() not implemented.");
}
@Override
public void invalidate() {
throw new RuntimeException(
"HttpSessionStub.invalidate() not implemented.");
}
@Override
public boolean isNew() {
throw new RuntimeException("HttpSessionStub.isNew() not implemented.");
}
@Override
public void putValue(String arg0, Object arg1) {
throw new RuntimeException(
"HttpSessionStub.putValue() not implemented.");
}
@Override
public void removeValue(String arg0) {
throw new RuntimeException(
"HttpSessionStub.removeValue() not implemented.");
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet.http;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import stubs.javax.servlet.ServletContextStub;
/**
* A simple stand-in for the HttpSession, for use in unit tests.
*/
public class HttpSessionStub implements HttpSession {
private static final Log log = LogFactory.getLog(HttpSessionStub.class);
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private String id = "arbitraryId";
private ServletContext context;
private final Map<String, Object> attributes = new HashMap<String, Object>();
@SuppressWarnings("unused")
private int maxInactiveInterval;
public void setId(String id) {
this.id = id;
}
public void setServletContext(ServletContext context) {
this.context = context;
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
@Override
public String getId() {
return this.id;
}
@Override
public ServletContext getServletContext() {
if (this.context == null) {
return new ServletContextStub();
} else {
return this.context;
}
}
@Override
public void setAttribute(String name, Object value) {
if (name == null) {
throw new NullPointerException("name may not be null.");
}
if (value == null) {
removeAttribute(name);
}
attributes.put(name, value);
log.debug("setAttribute: " + name + "=" + value);
}
@Override
public void removeAttribute(String name) {
attributes.remove(name);
log.debug("removeAttribute: " + name);
}
@Override
public Object getAttribute(String name) {
return attributes.get(name);
}
/**
* So far, we don't do anything with this, or even confirm that it has been
* set. We just don't throw an exception if someone wants to set it.
*/
@Override
public void setMaxInactiveInterval(int seconds) {
this.maxInactiveInterval = seconds;
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
@SuppressWarnings("rawtypes")
public Enumeration getAttributeNames() {
throw new RuntimeException(
"HttpSessionStub.getAttributeNames() not implemented.");
}
@Override
public long getCreationTime() {
throw new RuntimeException(
"HttpSessionStub.getCreationTime() not implemented.");
}
@Override
public long getLastAccessedTime() {
throw new RuntimeException(
"HttpSessionStub.getLastAccessedTime() not implemented.");
}
@Override
public int getMaxInactiveInterval() {
throw new RuntimeException(
"HttpSessionStub.getMaxInactiveInterval() not implemented.");
}
@Deprecated
@Override
public javax.servlet.http.HttpSessionContext getSessionContext() {
throw new RuntimeException(
"HttpSessionStub.getSessionContext() not implemented.");
}
@Override
public Object getValue(String arg0) {
throw new RuntimeException(
"HttpSessionStub.getValue() not implemented.");
}
@Override
public String[] getValueNames() {
throw new RuntimeException(
"HttpSessionStub.getValueNames() not implemented.");
}
@Override
public void invalidate() {
throw new RuntimeException(
"HttpSessionStub.invalidate() not implemented.");
}
@Override
public boolean isNew() {
throw new RuntimeException("HttpSessionStub.isNew() not implemented.");
}
@Override
public void putValue(String arg0, Object arg1) {
throw new RuntimeException(
"HttpSessionStub.putValue() not implemented.");
}
@Override
public void removeValue(String arg0) {
throw new RuntimeException(
"HttpSessionStub.removeValue() not implemented.");
}
}