use of com.github.drinkjava2.functionstest.entitynet.entities.User in project jSqlBox by drinkjava2.
the class EntityNetQueryTest method testRemoveEntity.
@Test
public void testRemoveEntity() {
System.out.println("==============testRemoveEntity================ ");
new User().put("id", "u1").put("userName", "user1").insert();
new User().put("id", "u2").put("userName", "user2").insert();
EntityNet net = ctx.netLoad(User.class);
Assert.assertEquals(2, net.size());
User u2 = net.getOneEntity(User.class, "u2");
ctx.netRemoveEntity(net, u2);
Assert.assertEquals(1, net.size());
}
use of com.github.drinkjava2.functionstest.entitynet.entities.User in project jSqlBox by drinkjava2.
the class EntityNetQueryTest method testAddEntity.
@Test
public void testAddEntity() {
System.out.println("==============testAddEntity================ ");
new User().put("id", "u1").put("userName", "user1").insert();
EntityNet net = ctx.netLoad(User.class);
Assert.assertEquals(1, net.size());
User u2 = new User();
u2.setId("u2");
u2.setUserName("user2");
u2.insert();
ctx.netAddEntity(net, u2);
Assert.assertEquals(2, net.size());
User u = net.getOneEntity(User.class, "u2");
Assert.assertEquals("user2", u.getUserName());
}
use of com.github.drinkjava2.functionstest.entitynet.entities.User in project jSqlBox by drinkjava2.
the class TinyParserTest method testSpeed.
@Test
public void testSpeed() {
User user = new User();
user.setId("001");
user.setUserName("Tom");
Map<String, Object> preset = new HashMap<String, Object>();
preset.put("FOO", 123);
preset.put("BAR", "456");
long start = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) Assert.assertEquals(true, TinyParser.instance.doParse(user, preset, "(1+2)*3/4>0.1/(9+?) and (userName equals ?) and id equals ? and (200 = ? ) and (FOO = 123 or BAR equals '456')", 100, "Tom", "001", 200));
Double secondsUsed = (System.currentTimeMillis() - start) / 1000.0;
System.out.println("TinyParser repeat 10000 REPEAT_TIMES cost " + secondsUsed + "s");
Assert.assertTrue(secondsUsed < 5);
}
use of com.github.drinkjava2.functionstest.entitynet.entities.User in project jSqlBox by drinkjava2.
the class UsuageAndSpeedTest method xXxxStyle_BasicTemplate.
@Test
public void xXxxStyle_BasicTemplate() {
SqlBoxContextConfig config = new SqlBoxContextConfig();
config.setTemplateEngine(BasicSqlTemplate.instance());
SqlBoxContext ctx = new SqlBoxContext(dataSource, config);
for (int i = 0; i < REPEAT_TIMES; i++) {
UserAR user = new UserAR("Sam", "Canada");
UserAR tom = new UserAR("Tom", "China");
put0("user", user);
ctx.xExecute("insert into users (name, address) values(#{user.name},#{user.address})");
put0("user", tom);
ctx.xExecute("update users set name=#{user.name}, address=#{user.address}");
Assert.assertEquals(1L, ctx.xQueryForObject("select count(*) from users where ${col}=#{name} and address=#{addr}", put0("name", "Tom"), put("addr", "China"), replace("col", "name")));
ctx.xExecute("delete from users where name=#{u.name} or address=#{u.address}", put0("u", tom));
}
}
use of com.github.drinkjava2.functionstest.entitynet.entities.User in project jSqlBox by drinkjava2.
the class UsuageAndSpeedTest method xXxxStyle.
@Test
public void xXxxStyle() {
SqlBoxContext ctx = new SqlBoxContext(dataSource);
for (int i = 0; i < REPEAT_TIMES; i++) {
UserAR user = new UserAR("Sam", "Canada");
UserAR tom = new UserAR("Tom", "China");
put0("user", user);
ctx.xExecute("insert into users (name, address) values(#{user.name},:user.address)");
put0("user", tom);
ctx.xExecute("update users set name=#{user.name}, address=:user.address");
Assert.assertEquals(1L, ctx.xQueryForObject("select count(*) from users where ${col}=#{name} and address=#{addr}", put0("name", "Tom"), put("addr", "China"), replace("col", "name")));
ctx.xExecute("delete from users where name=#{u.name} or address=#{u.address}", put0("u", tom));
}
}
Aggregations