mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
updated tests
This commit is contained in:
parent
00e7933da8
commit
42e6a59e34
@ -33,10 +33,11 @@ public class QueryPerformanceTest extends AbstractQueryTest{
|
||||
private List<String> resultLog = new ArrayList<String>(30);
|
||||
|
||||
private List<EBoolean> conditions = Arrays.asList(
|
||||
// cat.ne(otherCat),
|
||||
cat.ne(otherCat),
|
||||
cat.name.ne(otherCat.name).and(otherCat.name.eq("Kate5")),
|
||||
cat.bodyWeight.eq(0).and(otherCat.name.eq("Kate5")),
|
||||
cat.name.ne(otherCat.name).and(otherCat.name.like("Kate5%"))
|
||||
cat.name.ne(otherCat.name).and(otherCat.name.like("Kate5%")),
|
||||
cat.name.like("Bob5%").and(otherCat.name.like("Kate5%"))
|
||||
);
|
||||
|
||||
@Test
|
||||
@ -57,14 +58,13 @@ public class QueryPerformanceTest extends AbstractQueryTest{
|
||||
System.out.println("#" + (i+1) + " order preserved");
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("Times are for " + testIterations + " iterations");
|
||||
|
||||
System.out.println();
|
||||
|
||||
runTest(100);
|
||||
runTest(500);
|
||||
runTest(1000);
|
||||
runTest(5000);
|
||||
// runTest(5000);
|
||||
// runTest(10000);
|
||||
// runTest(50000);
|
||||
|
||||
@ -116,9 +116,9 @@ public class QueryPerformanceTest extends AbstractQueryTest{
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(" #").append(conditions.indexOf(condition)+1).append(" ");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level1), 5)).append(" ms");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level2), 5)).append(" ms");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level3), 5)).append(" ms");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level1 / testIterations), 10)).append(" ms");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level2 / testIterations), 10)).append(" ms");
|
||||
builder.append(StringUtils.leftPad(String.valueOf(level3 / testIterations), 10)).append(" ms");
|
||||
resultLog.add(builder.toString());
|
||||
}
|
||||
resultLog.add("");
|
||||
|
||||
@ -76,19 +76,24 @@ public class FilteredJavaSerializerTest {
|
||||
}
|
||||
@Test
|
||||
public void test12(){
|
||||
assertMatche2Expr("true && otherCat.getName().equals(a1)", cat.name.eq("Bob").and(otherCat.name.eq("Kate")));
|
||||
assertMatches2Expr("true && otherCat.getName().equals(a1)", cat.name.eq("Bob").and(otherCat.name.eq("Kate")));
|
||||
}
|
||||
@Test
|
||||
public void test13(){
|
||||
assertMatche2Expr("true && otherCat.getName().equals(a2)", cat.name.lower().eq("Bob").and(otherCat.name.eq("Kate")));
|
||||
}
|
||||
assertMatches2Expr("true && otherCat.getName().equals(a2)", cat.name.lower().eq("Bob").and(otherCat.name.eq("Kate")));
|
||||
}
|
||||
@Test
|
||||
public void test14(){
|
||||
assertMatches1Expr("true && true", cat.name.ne(otherCat.name).and(otherCat.name.like("Kate5%")));
|
||||
assertMatches1Expr("true && com.mysema.query.grammar.JavaOps.like(cat.getName(),a1)", otherCat.name.ne(cat.name).and(cat.name.like("Kate5%")));
|
||||
}
|
||||
|
||||
private void assertMatches1Expr(String expected, EBoolean where) {
|
||||
JavaSerializer ser = new FilteredJavaSerializer(ops, Collections.<Expr<?>>singletonList(cat));
|
||||
ser.handle(where);
|
||||
Assert.assertEquals(expected, ser.toString());
|
||||
}
|
||||
private void assertMatche2Expr(String expected, EBoolean where) {
|
||||
private void assertMatches2Expr(String expected, EBoolean where) {
|
||||
JavaSerializer ser = new FilteredJavaSerializer(ops, Arrays.<Expr<?>>asList(cat,otherCat));
|
||||
ser.handle(where);
|
||||
Assert.assertEquals(expected, ser.toString());
|
||||
|
||||
@ -6,4 +6,4 @@ log4j.appender.stdout.layout.ConversionPattern=%5p - %m%n
|
||||
|
||||
### set log levels - for more verbose logging change 'info' to 'debug' ###
|
||||
|
||||
log4j.rootLogger=INFO, stdout
|
||||
log4j.rootLogger=WARN, stdout
|
||||
|
||||
Loading…
Reference in New Issue
Block a user