Skip to content

Commit

Permalink
more test for issue nutzam#312
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Aug 31, 2012
1 parent ea718e8 commit 868e9a2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/org/nutz/trans/SimpleTransTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.sql.Connection;

import javax.sql.DataSource;

import org.junit.Before;
import org.junit.Test;
import org.nutz.dao.ConnCallback;
Expand Down Expand Up @@ -84,7 +86,23 @@ public void invoke(Connection conn) throws Exception {
conns[1] = conn;
}
});
//必然是同一个对象
assertEquals(conns[0], conns[1]);
assertTrue(conns[0] == conns[1]);
try {
//必然是同一个对象
assertEquals(Trans.get().getConnection(ioc.get(DataSource.class)), conns[1]);
assertEquals(Trans.get().getConnection(ioc.get(DataSource.class)), conns[1]);
assertEquals(Trans.get().getConnection(ioc.get(DataSource.class)), conns[1]);
assertEquals(Trans.get().getConnection(ioc.get(DataSource.class)), conns[1]);

assertEquals(Trans.get().getConnection(ioc.get(DataSource.class)), Trans.get().getConnection(ioc.get(DataSource.class)));

assertTrue(Trans.get().getConnection(ioc.get(DataSource.class)) == Trans.get().getConnection(ioc.get(DataSource.class)));
}
catch (Throwable e) {
throw Lang.wrapThrow(e);
}
}
});
}
Expand Down

0 comments on commit 868e9a2

Please sign in to comment.