Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming/directory
In directory usw-pr-cvs1:/tmp/cvs-serv13797/com/mockobjects/naming/directory
Added Files:
MockAttribute.java MockAttributes.java MockDirContext.java
MockNamingEnumeration.java
Log Message:
Setup files common to all j2ee versions
--- NEW FILE: MockAttribute.java ---
package com.mockobjects.naming.directory;
import com.mockobjects.*;
import javax.naming.directory.*;
import javax.naming.*;
public class MockAttribute extends MockObject implements Attribute{
private Object myObjectToReturn;
public NamingEnumeration getAll() throws NamingException{
notImplemented();
return null;
}
public void setupGet(Object aObjectToReturn){
this.myObjectToReturn = aObjectToReturn;
}
public Object get() throws NamingException{
return myObjectToReturn;
}
public int size(){
notImplemented();
return 0;
}
public String getID(){
notImplemented();
return null;
}
public boolean contains(Object object){
notImplemented();
return false;
}
public boolean add(Object object){
notImplemented();
return false;
}
public boolean remove(Object object){
notImplemented();
return false;
}
public void clear(){
notImplemented();
}
public DirContext getAttributeSyntaxDefinition() throws NamingException{
notImplemented();
return null;
}
public DirContext getAttributeDefinition() throws NamingException{
notImplemented();
return null;
}
public Object clone(){
notImplemented();
return null;
}
public boolean isOrdered(){
notImplemented();
return false;
}
public Object get(int index) throws NamingException{
notImplemented();
return null;
}
public Object remove(int index){
notImplemented();
return null;
}
public void add(int index, Object object){
notImplemented();
}
public Object set(int index, Object object){
notImplemented();
return null;
}
public String toString(){
if(myObjectToReturn==null){
return "null";
}else{
return myObjectToReturn.toString();
}
}
}
--- NEW FILE: MockAttributes.java ---
package com.mockobjects.naming.directory;
import javax.naming.directory.Attributes;
import javax.naming.directory.Attribute;
import javax.naming.NamingEnumeration;
import com.mockobjects.*;
import java.util.*;
public class MockAttributes extends MockObject implements Attributes{
private List myAttributes = new ArrayList();
public boolean isCaseIgnored(){
notImplemented();
return false;
}
public int size(){
notImplemented();
return 0;
}
public void setupAddGet(Attribute attribute){
myAttributes.add(attribute);
}
public Attribute get(String name){
return (Attribute)myAttributes.remove(0);
}
public NamingEnumeration getAll(){
notImplemented();
return null;
}
public NamingEnumeration getIDs(){
notImplemented();
return null;
}
public Attribute put(String name, Object object){
notImplemented();
return null;
}
public Attribute put(Attribute attribute){
notImplemented();
return null;
}
public Attribute remove(String attributeName){
notImplemented();
return null;
}
public Object clone(){
notImplemented();
return null;
}
public String toString(){
return myAttributes.toString();
}
}
--- NEW FILE: MockDirContext.java ---
package com.mockobjects.naming.directory;
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");
private ExpectationValue mySearchName =
new ExpectationValue("mySearchName");
private ExpectationValue myAttributes =
new ExpectationValue("myAttributes");
private ExpectationValue myModificationOperation =
new ExpectationValue("myModificationOperation");
private ExpectationValue myFilter = new ExpectationValue("myFilter");
private ExpectationValue mySearchControls = new ExpectationValue("mySearchControls");
private NamingEnumeration myResults;
private ExpectationCounter myAttributesCallCount =
new ExpectationCounter("getAttributes");
public void setupAttributes(Attributes anAttributeToReturn){
this.myAttributeToReturn = anAttributeToReturn;
}
public void setExpectedGetAttributesName(Object aName){
this.myName.setExpected(aName);
}
public void setExpectedGetAttributesCount(int callCount){
this.myAttributesCallCount.setExpected(callCount);
}
public Attributes getAttributes(Name aName) throws NamingException{
return getAttributes(aName.toString());
}
public Attributes getAttributes(String aName) throws NamingException{
return getAttributes(aName, null);
}
public Attributes getAttributes(Name aName, String[] attrIds)
throws NamingException{
return getAttributes(aName.toString(), attrIds);
}
public Attributes getAttributes(String aName, String[] attrIds)
throws NamingException{
this.myName.setActual(aName);
this.myAttributesCallCount.inc();
return myAttributeToReturn;
}
public void setExpectedModifyAttributes(String aName,
int aModificationOperation, Attributes attributes){
this.myName.setExpected(aName);
this.myModificationOperation.setExpected(aModificationOperation);
this.myAttributes.setExpected(attributes);
}
public void modifyAttributes(Name aName, int aModificationOperation,
Attributes attributes) throws NamingException{
modifyAttributes(aName.toString(), aModificationOperation, attributes);
}
public void modifyAttributes(String aName, int aModificationOperation,
Attributes attributes) throws NamingException{
this.myName.setActual(aName);
this.myModificationOperation.setActual(aModificationOperation);
this.myAttributes.setActual(attributes);
}
public void modifyAttributes(Name aName, ModificationItem[] mods)
throws NamingException{
notImplemented();
}
public void modifyAttributes(String aName, ModificationItem[] mods)
throws NamingException{
notImplemented();
}
public void bind(Name aName, Object object, Attributes attributes)
throws NamingException{
notImplemented();
}
public void bind(String aName, Object object, Attributes attributes)
throws NamingException{
notImplemented();
}
public void rebind(Name aName, Object object, Attributes attributes)
throws NamingException{
notImplemented();
}
public void rebind(String aName, Object object, Attributes attributes)
throws NamingException{
notImplemented();
}
public DirContext createSubcontext(Name aName, Attributes attributes)
throws NamingException{
notImplemented();
return null;
}
public DirContext createSubcontext(String aName, Attributes attributes)
throws NamingException{
notImplemented();
return null;
}
public DirContext getSchema(Name aName) throws NamingException{
notImplemented();
return null;
}
public DirContext getSchema(String aName) throws NamingException{
notImplemented();
return null;
}
public DirContext getSchemaClassDefinition(Name aName)
throws NamingException{
notImplemented();
return null;
}
public DirContext getSchemaClassDefinition(String aName)
throws NamingException{
notImplemented();
return null;
}
public NamingEnumeration search(Name aName, Attributes attributes,
String[] anAttributeToReturn) throws NamingException{
return myResults;
}
public NamingEnumeration search(String aName, Attributes attributes,
String[] anAttributeToReturn) throws NamingException{
return myResults;
}
public NamingEnumeration search(Name aName, Attributes attributes)
throws NamingException{
return myResults;
}
public NamingEnumeration search(String aName, Attributes attributes)
throws NamingException{
return myResults;
}
public NamingEnumeration search(Name aName, String aFilter,
SearchControls cons) throws NamingException{
return myResults;
}
public void setExpectedSearch(String aSearchName, String aFilter,
SearchControls searchControls){
this.mySearchName.setExpected(aSearchName);
this.myFilter.setExpected(aFilter);
this.mySearchControls.setExpected(searchControls);
}
public void setupSearchResult(NamingEnumeration results){
this.myResults = results;
}
public NamingEnumeration search(String aSearchName, String aFilter,
SearchControls searchControls) throws NamingException{
this.mySearchName.setActual(aSearchName);
this.myFilter.setActual(aFilter);
this.mySearchControls.setActual(searchControls);
return myResults;
}
public NamingEnumeration search(Name aName, String aFilter,
Object[] filterArgs, SearchControls cons) throws NamingException{
return myResults;
}
public NamingEnumeration search(String aName, String aFilter,
Object[] filterArgs, SearchControls cons) throws NamingException{
return myResults;
}
}
--- NEW FILE: MockNamingEnumeration.java ---
package com.mockobjects.naming.directory;
import com.mockobjects.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;
public class MockNamingEnumeration extends MockObject
implements NamingEnumeration{
private List mySearchResults = new ArrayList();
private boolean hasMore = true;
public void setupAddSearchResult(Object object){
mySearchResults.add(object);
}
public Object next() throws NamingException{
return mySearchResults.remove(0);
}
public boolean hasMore() throws NamingException{
return mySearchResults.size()>0;
}
public void close() throws NamingException{
}
public boolean hasMoreElements(){
return mySearchResults.size()>0;
}
public Object nextElement(){
return mySearchResults.remove(0);
}
}
|