1 22 package org.objectweb.petals.jbi.transport.mock; 23 24 import java.util.Hashtable ; 25 import java.util.Map ; 26 27 import javax.naming.Binding ; 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.naming.Name ; 31 import javax.naming.NameClassPair ; 32 import javax.naming.NameParser ; 33 import javax.naming.NamingException ; 34 35 39 public class MockInitialContext extends InitialContext { 40 41 protected boolean unbind; 42 43 private MockContext context; 44 45 public MockInitialContext() throws NamingException { 46 super(); 47 context = new MockContext(); 48 } 49 50 public Object addToEnvironment(String propName, Object propVal) 51 throws NamingException { 52 return context.addToEnvironment(propName, propVal); 53 } 54 55 public void bind(Name name, Object obj) throws NamingException { 56 context.bind(name, obj); 57 } 58 59 public void bind(String name, Object obj) throws NamingException { 60 context.bind(name, obj); 61 } 62 63 public void close() throws NamingException { 64 context.close(); 65 } 66 67 public Name composeName(Name name, Name prefix) throws NamingException { 68 return context.composeName(name, prefix); 69 } 70 71 public String composeName(String name, String prefix) 72 throws NamingException { 73 return context.composeName(name, prefix); 74 } 75 76 public Context createSubcontext(Name name) throws NamingException { 77 return context.createSubcontext(name); 78 } 79 80 public Context createSubcontext(String name) throws NamingException { 81 return context.createSubcontext(name); 82 } 83 84 public void destroySubcontext(Name name) throws NamingException { 85 context.destroySubcontext(name); 86 } 87 88 public void destroySubcontext(String name) throws NamingException { 89 context.destroySubcontext(name); 90 } 91 92 public boolean equals(Object obj) { 93 return context.equals(obj); 94 } 95 96 public Map <String , Object > getBindings() { 97 return context.getBindings(); 98 } 99 100 public Hashtable <?, ?> getEnvironment() throws NamingException { 101 return context.getEnvironment(); 102 } 103 104 public String getNameInNamespace() throws NamingException { 105 return context.getNameInNamespace(); 106 } 107 108 public NameParser getNameParser(Name name) throws NamingException { 109 return context.getNameParser(name); 110 } 111 112 public NameParser getNameParser(String name) throws NamingException { 113 return context.getNameParser(name); 114 } 115 116 public int hashCode() { 117 return context.hashCode(); 118 } 119 120 public boolean isUnbind() { 121 return unbind; 122 } 123 124 public MockNamingEnumeration<NameClassPair > list(Name name) 125 throws NamingException { 126 return context.list(name); 127 } 128 129 public MockNamingEnumeration<NameClassPair > list(String name) 130 throws NamingException { 131 return context.list(name); 132 } 133 134 public MockNamingEnumeration<Binding > listBindings(Name name) 135 throws NamingException { 136 return context.listBindings(name); 137 } 138 139 public MockNamingEnumeration<Binding > listBindings(String name) 140 throws NamingException { 141 return context.listBindings(name); 142 } 143 144 public Object lookup(Name name) throws NamingException { 145 return context.lookup(name); 146 } 147 148 public Object lookup(String name) throws NamingException { 149 return context.lookup(name); 150 } 151 152 public Object lookupLink(Name name) throws NamingException { 153 return context.lookupLink(name); 154 } 155 156 public Object lookupLink(String name) throws NamingException { 157 return context.lookupLink(name); 158 } 159 160 public void rebind(Name name, Object obj) throws NamingException { 161 context.rebind(name, obj); 162 } 163 164 public void rebind(String name, Object obj) throws NamingException { 165 context.rebind(name, obj); 166 } 167 168 public Object removeFromEnvironment(String propName) throws NamingException { 169 return context.removeFromEnvironment(propName); 170 } 171 172 public void rename(Name oldName, Name newName) throws NamingException { 173 context.rename(oldName, newName); 174 } 175 176 public void rename(String oldName, String newName) throws NamingException { 177 context.rename(oldName, newName); 178 } 179 180 public void setBindings(Map <String , Object > bindings) { 181 context.setBindings(bindings); 182 } 183 184 public void setUnbind(boolean unbind) { 185 this.unbind = unbind; 186 } 187 188 public String toString() { 189 return context.toString(); 190 } 191 192 public void unbind(Name name) throws NamingException { 193 context.unbind(name); 194 } 195 196 protected boolean throwsException; 197 198 public void unbind(String name) throws NamingException { 199 if (throwsException) { 200 throw new NamingException (); 201 } 202 context.unbind(name); 203 unbind = true; 204 } 205 206 public boolean isThrowsException() { 207 return throwsException; 208 } 209 210 public void setThrowsException(boolean throwsException) { 211 this.throwsException = throwsException; 212 } 213 214 public MockContext getContext() { 215 return context; 216 } 217 218 public void setContext(MockContext context) { 219 this.context = context; 220 } 221 222 } 223 | Popular Tags |