git://wamblee.org
/
utils
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3fe2e23
)
(no commit message)
author
erik
<erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 30 Jul 2010 18:44:27 +0000
(18:44 +0000)
committer
erik
<erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 30 Jul 2010 18:44:27 +0000
(18:44 +0000)
test/enterprise/src/test/java/org/wamblee/test/jndi/LookupProxyFactoryTest.java
[moved from
test/enterprise/src/test/java/org/wamblee/test/jndi/JndiProxyFactoryTest.java
with 61% similarity]
patch
|
blob
|
history
diff --git
a/test/enterprise/src/test/java/org/wamblee/test/jndi/JndiProxyFactoryTest.java
b/test/enterprise/src/test/java/org/wamblee/test/jndi/LookupProxyFactoryTest.java
similarity index 61%
rename from
test/enterprise/src/test/java/org/wamblee/test/jndi/JndiProxyFactoryTest.java
rename to
test/enterprise/src/test/java/org/wamblee/test/jndi/LookupProxyFactoryTest.java
index 099135ea237b301f056a30658efa2983aa558621..755769d5deccdf29e71627a942f26f18968f2d98 100644
(file)
--- a/
test/enterprise/src/test/java/org/wamblee/test/jndi/JndiProxyFactoryTest.java
+++ b/
test/enterprise/src/test/java/org/wamblee/test/jndi/LookupProxyFactoryTest.java
@@
-23,11
+23,10
@@
import javax.naming.InitialContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.wamblee.test.jndi.JndiProxyFactory;
-import org.wamblee.test.jndi.StubInitialContextFactory;
-import org.wamblee.test.jndi.JndiProxyFactory.JndiWiringException;
+import org.wamblee.test.jndi.LookupProxyFactory.Lookup;
+import org.wamblee.test.jndi.LookupProxyFactory.LookupException;
-public class
Jndi
ProxyFactoryTest {
+public class
Lookup
ProxyFactoryTest {
private static final String NAA_NA_NA_NAA_NA = "naa, na, na, naa, na";
private static final String NAA_NA_NA_NAA_NA = "naa, na, na, naa, na";
@@
-35,61
+34,62
@@
public class JndiProxyFactoryTest {
int execute();
}
int execute();
}
- private static final String JNDI = "jndi/xyz";
private MyInterface intf;
private MyInterface intf;
- private
InitialContext ctx
;
+ private
Lookup lookup
;
private MyInterface proxy;
@Before
public void setUp() throws Exception {
private MyInterface proxy;
@Before
public void setUp() throws Exception {
- StubInitialContextFactory.register();
intf = mock(MyInterface.class);
intf = mock(MyInterface.class);
- ctx = new InitialContext();
- JndiProxyFactory<MyInterface> factory = new JndiProxyFactory<MyInterface>(
- MyInterface.class, JNDI);
+ lookup = mock(Lookup.class);
+
+ LookupProxyFactory<MyInterface> factory = new LookupProxyFactory<MyInterface>(
+ MyInterface.class, lookup);
proxy = factory.getProxy();
}
@After
public void tearDown() throws Exception {
proxy = factory.getProxy();
}
@After
public void tearDown() throws Exception {
- StubInitialContextFactory.unregister();
+ // Empty.
}
@Test
}
@Test
- public void testFoundAtJndi() throws Exception {
- ctx.bind(JNDI, intf);
+ public void testFound() throws Exception {
when(intf.execute()).thenReturn(1);
when(intf.execute()).thenReturn(1);
+ when(lookup.lookup()).thenReturn(intf);
+
assertEquals(1, proxy.execute());
}
assertEquals(1, proxy.execute());
}
- @Test(expected = JndiWiringException.class)
- public void testNotFoundAtJndi() {
+ @Test(expected = LookupException.class)
+ public void testNotFoundAtJndi() throws Exception {
+ when(lookup.lookup()).thenThrow(new RuntimeException("Object not found"));
proxy.execute();
}
proxy.execute();
}
- @Test(expected =
JndiWiring
Exception.class)
+ @Test(expected =
Lookup
Exception.class)
public void testWrongTypeAtJndi() throws Exception {
public void testWrongTypeAtJndi() throws Exception {
-
ctx.bind(JNDI, "a string type
");
+
when(lookup.lookup()).thenReturn("my string
");
when(intf.execute()).thenReturn(1);
when(intf.execute()).thenReturn(1);
-
assertEquals(1, proxy.execute()
);
+
proxy.execute(
);
}
}
- @Test(expected =
JndiWiringException.class
)
+ @Test(expected =
LookupException.class
)
public void testNullAtJndi() throws Exception {
public void testNullAtJndi() throws Exception {
-
ctx.bind(JNDI,
null);
+
when(lookup.lookup()).thenReturn(
null);
when(intf.execute()).thenReturn(1);
when(intf.execute()).thenReturn(1);
-
assertEquals(1, proxy.execute()
);
+
proxy.execute(
);
}
@Test
public void testFoundButInvocationThrowsException() throws Exception {
}
@Test
public void testFoundButInvocationThrowsException() throws Exception {
- ctx.bind(JNDI, intf);
when(intf.execute()).thenThrow(new RuntimeException(NAA_NA_NA_NAA_NA));
when(intf.execute()).thenThrow(new RuntimeException(NAA_NA_NA_NAA_NA));
- try{
- proxy.execute();
- } catch (RuntimeException e) {
- assertEquals(NAA_NA_NA_NAA_NA, e.getMessage());
+ when(lookup.lookup()).thenReturn(intf);
+ try {
+ proxy.execute();
+ } catch (RuntimeException e) {
+ assertEquals(NAA_NA_NA_NAA_NA, e.getMessage());
}
}
}
}