assertEquals("({border:'1px solid black'})", Properties
.wrapPropertiesString("({border:'1px solid black'})"));
}
- public void test() throws NamingException {
- System.out.println( MockInitialContextFactory.class.getName());
- System.setProperty("java.naming.factory.initial", MockInitialContextFactory.class.getName());
- Context mockCtx = new MockContext();
-// UserTransaction mockTrans = createMock(UserTransaction.class);
-// expect(mockCtx.lookup("UserTransaction")).andReturn(mockTrans);
-// replay(mockCtx);
- MockInitialContextFactory.setMockContext(mockCtx);
-
- Context ctx = new InitialContext();
- ctx.lookup("whatever");
-
- }
- public static class MockInitialContextFactory implements
- InitialContextFactory {
- private static Context mockCtx = null;
-
- public static void setMockContext(Context ctx) {
- mockCtx = ctx;
- }
-
- public Context getInitialContext(java.util.Hashtable<?, ?> environment)
- throws NamingException {
- if (mockCtx == null) {
- throw new IllegalStateException("mock context was not set.");
- }
- return mockCtx;
- }
- }
- public static class MockContext implements Context {
-
- public Object addToEnvironment(String propName, Object propVal)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void bind(Name name, Object obj) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void bind(String name, Object obj) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void close() throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public Name composeName(Name name, Name prefix) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String composeName(String name, String prefix)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Context createSubcontext(Name name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Context createSubcontext(String name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void destroySubcontext(Name name) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void destroySubcontext(String name) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public Hashtable<?, ?> getEnvironment() throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getNameInNamespace() throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NameParser getNameParser(Name name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NameParser getNameParser(String name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NamingEnumeration<NameClassPair> list(Name name)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NamingEnumeration<NameClassPair> list(String name)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NamingEnumeration<Binding> listBindings(Name name)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NamingEnumeration<Binding> listBindings(String name)
- throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object lookup(Name name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object lookup(String name) throws NamingException {
- System.out.println("lookup " + name);
- return null;
- }
-
- public Object lookupLink(Name name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object lookupLink(String name) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void rebind(Name name, Object obj) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void rebind(String name, Object obj) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public Object removeFromEnvironment(String propName) throws NamingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void rename(Name oldName, Name newName) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void rename(String oldName, String newName) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void unbind(Name name) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- public void unbind(String name) throws NamingException {
- // TODO Auto-generated method stub
-
- }
-
- }
-
-
}