From: Jeff M. <cus...@us...> - 2003-03-18 14:28:50
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming/directory In directory sc8-pr-cvs1:/tmp/cvs-serv22955/src/j2ee/common/com/mockobjects/naming/directory Modified Files: MockAttribute.java MockDirContext.java Log Message: Pepper Mocks with ReturnValue Index: MockAttribute.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming/directory/MockAttribute.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockAttribute.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockAttribute.java 18 Mar 2003 14:28:44 -0000 1.2 @@ -5,7 +5,7 @@ import javax.naming.*; public class MockAttribute extends MockObject implements Attribute{ - private Object myObjectToReturn; + private final ReturnValue myObjectToReturn = new ReturnValue("object"); public NamingEnumeration getAll() throws NamingException{ notImplemented(); @@ -13,11 +13,11 @@ } public void setupGet(Object aObjectToReturn){ - this.myObjectToReturn = aObjectToReturn; + this.myObjectToReturn.setValue(aObjectToReturn); } public Object get() throws NamingException{ - return myObjectToReturn; + return myObjectToReturn.getValue(); } public int size(){ Index: MockDirContext.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming/directory/MockDirContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockDirContext.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockDirContext.java 18 Mar 2003 14:28:44 -0000 1.2 @@ -2,59 +2,60 @@ import javax.naming.*; import javax.naming.directory.*; + import com.mockobjects.*; import com.mockobjects.naming.*; -public class MockDirContext extends MockContext implements DirContext{ - private Attributes myAttributeToReturn; - private ExpectationValue myName = new ExpectationValue("myName"); +public class MockDirContext extends MockContext implements DirContext { + private final ReturnValue myAttributeToReturn = new ReturnValue("attribute"); + private final ExpectationValue myName = new ExpectationValue("myName"); private ExpectationValue mySearchName = new ExpectationValue("mySearchName"); - private ExpectationValue myAttributes = + private final ExpectationValue myAttributes = new ExpectationValue("myAttributes"); - private ExpectationValue myModificationOperation = + private final ExpectationValue myModificationOperation = new ExpectationValue("myModificationOperation"); - private ExpectationValue myFilter = new ExpectationValue("myFilter"); - private ExpectationValue mySearchControls = new ExpectationValue("mySearchControls"); - private NamingEnumeration myResults; + private final ExpectationValue myFilter = new ExpectationValue("myFilter"); + private final ExpectationValue mySearchControls = new ExpectationValue("mySearchControls"); + private final ReturnValue myResults = new ReturnValue("results"); private ExpectationCounter myAttributesCallCount = new ExpectationCounter("getAttributes"); - public void setupAttributes(Attributes anAttributeToReturn){ - this.myAttributeToReturn = anAttributeToReturn; + public void setupAttributes(Attributes anAttributeToReturn) { + this.myAttributeToReturn.setValue(anAttributeToReturn); } - public void setExpectedGetAttributesName(Object aName){ + public void setExpectedGetAttributesName(Object aName) { this.myName.setExpected(aName); } - public void setExpectedGetAttributesCount(int callCount){ + public void setExpectedGetAttributesCount(int callCount) { this.myAttributesCallCount.setExpected(callCount); } - public Attributes getAttributes(Name aName) throws NamingException{ + public Attributes getAttributes(Name aName) throws NamingException { return getAttributes(aName.toString()); } - public Attributes getAttributes(String aName) throws NamingException{ + public Attributes getAttributes(String aName) throws NamingException { return getAttributes(aName, null); } public Attributes getAttributes(Name aName, String[] attrIds) - throws NamingException{ + throws NamingException { return getAttributes(aName.toString(), attrIds); } public Attributes getAttributes(String aName, String[] attrIds) - throws NamingException{ + throws NamingException { this.myName.setActual(aName); this.myAttributesCallCount.inc(); - return myAttributeToReturn; + return (Attributes) myAttributeToReturn.getValue(); } public void setExpectedModifyAttributes(String aName, - int aModificationOperation, Attributes attributes){ + int aModificationOperation, Attributes attributes) { this.myName.setExpected(aName); this.myModificationOperation.setExpected(aModificationOperation); @@ -62,13 +63,13 @@ } public void modifyAttributes(Name aName, int aModificationOperation, - Attributes attributes) throws NamingException{ + Attributes attributes) throws NamingException { modifyAttributes(aName.toString(), aModificationOperation, attributes); } public void modifyAttributes(String aName, int aModificationOperation, - Attributes attributes) throws NamingException{ + Attributes attributes) throws NamingException { this.myName.setActual(aName); this.myModificationOperation.setActual(aModificationOperation); @@ -76,121 +77,121 @@ } public void modifyAttributes(Name aName, ModificationItem[] mods) - throws NamingException{ + throws NamingException { notImplemented(); } public void modifyAttributes(String aName, ModificationItem[] mods) - throws NamingException{ + throws NamingException { notImplemented(); } public void bind(Name aName, Object object, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); } public void bind(String aName, Object object, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); } public void rebind(Name aName, Object object, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); } public void rebind(String aName, Object object, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); } public DirContext createSubcontext(Name aName, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); return null; } public DirContext createSubcontext(String aName, Attributes attributes) - throws NamingException{ + throws NamingException { notImplemented(); return null; } - public DirContext getSchema(Name aName) throws NamingException{ + public DirContext getSchema(Name aName) throws NamingException { notImplemented(); return null; } - public DirContext getSchema(String aName) throws NamingException{ + public DirContext getSchema(String aName) throws NamingException { notImplemented(); return null; } public DirContext getSchemaClassDefinition(Name aName) - throws NamingException{ + throws NamingException { notImplemented(); return null; } public DirContext getSchemaClassDefinition(String aName) - throws NamingException{ + throws NamingException { notImplemented(); return null; } public NamingEnumeration search(Name aName, Attributes attributes, - String[] anAttributeToReturn) throws NamingException{ - return myResults; + String[] anAttributeToReturn) throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(String aName, Attributes attributes, - String[] anAttributeToReturn) throws NamingException{ - return myResults; + String[] anAttributeToReturn) throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(Name aName, Attributes attributes) - throws NamingException{ - return myResults; + throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(String aName, Attributes attributes) - throws NamingException{ - return myResults; + throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(Name aName, String aFilter, - SearchControls cons) throws NamingException{ - return myResults; + SearchControls cons) throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public void setExpectedSearch(String aSearchName, String aFilter, - SearchControls searchControls){ + SearchControls searchControls) { this.mySearchName.setExpected(aSearchName); this.myFilter.setExpected(aFilter); this.mySearchControls.setExpected(searchControls); } - public void setupSearchResult(NamingEnumeration results){ - this.myResults = results; + public void setupSearchResult(NamingEnumeration results) { + this.myResults.setValue(results); } public NamingEnumeration search(String aSearchName, String aFilter, - SearchControls searchControls) throws NamingException{ + SearchControls searchControls) throws NamingException { this.mySearchName.setActual(aSearchName); this.myFilter.setActual(aFilter); this.mySearchControls.setActual(searchControls); - return myResults; + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(Name aName, String aFilter, - Object[] filterArgs, SearchControls cons) throws NamingException{ - return myResults; + Object[] filterArgs, SearchControls cons) throws NamingException { + return (NamingEnumeration) myResults.getValue(); } public NamingEnumeration search(String aName, String aFilter, - Object[] filterArgs, SearchControls cons) throws NamingException{ - return myResults; + Object[] filterArgs, SearchControls cons) throws NamingException { + return (NamingEnumeration) myResults.getValue(); } } |