Hi,
Yesterday I updated our project from jOOQ 3.9.6 to 3.10.2 and suddenly a
bunch of jUnit tests, that worked fine before, crashed with a
NullPointerException.
It appears that the MockDataProvider, even when my implementation of it
returns no results, returns a row to the test. I've made 2 small jUnit
tests to clarify the differences:
public class JooqTest {
@Test
public void test1() {
MockDataProvider provider = new MockDataProvider() {
@Override
public MockResult[] execute(MockExecuteContext ctx) throws
SQLException {
return new MockResult[0];
}
};
MockConnection connection = new MockConnection(provider);
DSLContext dsl = DSL.using(connection, SQLDialect.ORACLE);
dsl.configuration().set(new Settings().withRenderSchema(false));
dsl.select(MPS_PEOPLE.FIRST_NAME)
.from(MPS_PEOPLE)
.stream()
.forEach(record -> {
System.out.println("test1 FIRST_NAME=" + record.get(
MPS_PEOPLE.FIRST_NAME));
});
}
@Test
public void test2() {
MockDataProvider provider = new MockDataProvider() {
@Override
public MockResult[] execute(MockExecuteContext ctx) throws
SQLException {
return new MockResult[] { new MockResult(0, null) };
}
};
MockConnection connection = new MockConnection(provider);
DSLContext dsl = DSL.using(connection, SQLDialect.ORACLE);
dsl.configuration().set(new Settings().withRenderSchema(false));
dsl.select(MPS_PEOPLE.FIRST_NAME)
.from(MPS_PEOPLE)
.stream()
.forEach(record -> {
System.out.println("test2 FIRST_NAME=" + record.get(
MPS_PEOPLE.FIRST_NAME));
});
}
}
Of course these are no real unit tests, but they provide a quick way of
showing my point. With jOOQ 3.9.6 the console out is as follows:
09:08:04.111 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select "MPS_PEOPLE"."FIRST_NAME" from "MPS_PEOPLE"
09:08:04.138 [main] DEBUG org.jooq.tools.StopWatch - Query executed
: Total: 83.64ms
09:08:04.422 [main] DEBUG org.jooq.tools.StopWatch - Finishing
: Total: 368.938ms, +285.297ms
09:08:04.424 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select "MPS_PEOPLE"."FIRST_NAME" from "MPS_PEOPLE"
09:08:04.424 [main] DEBUG org.jooq.tools.StopWatch - Query executed
: Total: 0.624ms
09:08:04.425 [main] DEBUG org.jooq.tools.StopWatch - Finishing
: Total: 1.238ms, +0.614ms
As you can see, there is no sign of the System.out.println's that are in
the tests, which is as expected.
However, if I run the same tests with jOOQ 3.10.2, the console shows:
09:06:25.673 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select "MPS_PEOPLE"."FIRST_NAME" from "MPS_PEOPLE"
test1 FIRST_NAME=-1
09:06:25.894 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select "MPS_PEOPLE"."FIRST_NAME" from "MPS_PEOPLE"
09:06:25.894 [main] DEBUG org.jooq.tools.LoggerListener - Affected row(s)
: 0
test2 FIRST_NAME=0
Now, each of the tests appears to be able to retrieve a row. How can that
be?
Did I run into a bug, or did I miss something?
Kind regards,
Paul Hamer
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.