diff --git a/pom.xml b/pom.xml
index 98af34f..696ff38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,5 @@
-
4.0.0
net.forwardfire.tpquery
@@ -30,13 +31,13 @@
UTF-8
- 1.8
+ 11
- 0.7.4.201502262128
2.10.3
- 2.8
+ 3.0.0
@@ -51,9 +52,9 @@
3.5
- junit
- junit
- 4.12
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.5.2
ch.qos.logback
@@ -95,12 +96,27 @@
sonar-jacoco-listeners
3.2
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.3.1
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0
+
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-engine
test
@@ -165,22 +181,6 @@
-
- org.apache.maven.plugins
- maven-jdeps-plugin
- 3.0.0
-
-
- validate
-
- jdkinternals
- test-jdkinternals
-
-
-
-
-
-
org.apache.maven.plugins
maven-enforcer-plugin
@@ -198,9 +198,7 @@
(3.0,)
-
+
@@ -380,9 +378,12 @@
Copy project markdown to site.
-
-
-
+
+
+
diff --git a/README.md b/readme.md
similarity index 100%
rename from README.md
rename to readme.md
diff --git a/TODO.md b/todo.md
similarity index 100%
rename from TODO.md
rename to todo.md
diff --git a/tpquery-executor-jdbc/src/test/java/net/forwardfire/tpquery/store/executor/jdbc/TPQExecutorJdbcTest.java b/tpquery-executor-jdbc/src/test/java/net/forwardfire/tpquery/store/executor/jdbc/TPQExecutorJdbcTest.java
index 8885f22..2a88ea0 100644
--- a/tpquery-executor-jdbc/src/test/java/net/forwardfire/tpquery/store/executor/jdbc/TPQExecutorJdbcTest.java
+++ b/tpquery-executor-jdbc/src/test/java/net/forwardfire/tpquery/store/executor/jdbc/TPQExecutorJdbcTest.java
@@ -1,7 +1,8 @@
package net.forwardfire.tpquery.store.executor.jdbc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -11,20 +12,17 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
-import net.forwardfire.tpquery.TPQManager;
-import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.store.executor.jdbc.SQLExceptionRuntime;
-import net.forwardfire.tpquery.store.executor.jdbc.TPQExecutorJdbc;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
+import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
public class TPQExecutorJdbcTest {
- @BeforeClass
+ @BeforeEach
public static void setupLogging() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset(); // disable logging
@@ -84,94 +82,104 @@ public class TPQExecutorJdbcTest {
}
}
- @Test(expected=SQLExceptionRuntime.class)
+ @Test
public void testExecuteUpdateFail() throws Exception {
- try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
- TPQManager store = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
- .createQuery("insertData").appendText("INSERT INTO test_table (data) VALUES (0)").build()
- .createQuery("queryFail").appendText("update test_table tt set tt.data=10/(SELECT sum(t1.data) FROM test_table t1)").build()
- .build()
- .build();
-
- TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
- exe.executeUpdate(connection, "junit.createTable");
- exe.executeUpdate(connection, "junit.insertData");
- exe.executeUpdate(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
+ assertThrows(SQLExceptionRuntime.class, () -> {
+ try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
+ TPQManager store = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
+ .createQuery("insertData").appendText("INSERT INTO test_table (data) VALUES (0)").build()
+ .createQuery("queryFail").appendText("update test_table tt set tt.data=10/(SELECT sum(t1.data) FROM test_table t1)").build()
+ .build()
+ .build();
+
+ TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
+ exe.executeUpdate(connection, "junit.createTable");
+ exe.executeUpdate(connection, "junit.insertData");
+ exe.executeUpdate(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
}
+ });
}
- @Test(expected=SQLExceptionRuntime.class)
+ @Test
public void testExecuteSelectFail() throws Exception {
- try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
-
- TPQManager store = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
- .createQuery("insertData").appendText("INSERT INTO test_table (data) VALUES (0)").build()
- .createQuery("queryFail").appendText("select tt.* from test_table tt where tt.data=10/(SELECT sum(t1.data) FROM test_table t1)").build()
- .build()
- .build();
-
- TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
- exe.executeUpdate(connection, "junit.createTable");
- exe.executeUpdate(connection, "junit.insertData");
- exe.execute(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
- }
+ assertThrows(SQLExceptionRuntime.class, () -> {
+ try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
+
+ TPQManager store = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
+ .createQuery("insertData").appendText("INSERT INTO test_table (data) VALUES (0)").build()
+ .createQuery("queryFail").appendText("select tt.* from test_table tt where tt.data=10/(SELECT sum(t1.data) FROM test_table t1)").build()
+ .build()
+ .build();
+
+ TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
+ exe.executeUpdate(connection, "junit.createTable");
+ exe.executeUpdate(connection, "junit.insertData");
+ exe.execute(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
+ }
+ });
}
- @Test(expected=SQLExceptionRuntime.class)
+ @Test
public void testExecuteSelectFailPrepare() throws Exception {
- try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
- TPQManager store = TPQFactory.createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem:testcaseFail")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("sql-fail").appendText("select * from article").build()
- .build()
- .build();
- TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
- exe.execute(connection, "junit.sql-fail");
- }
+ assertThrows(SQLExceptionRuntime.class, () -> {
+ try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
+ TPQManager store = TPQFactory.createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem:testcaseFail")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("sql-fail").appendText("select * from article").build()
+ .build()
+ .build();
+ TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
+ exe.execute(connection, "junit.sql-fail");
+ }
+ });
}
- @Test(expected=SQLExceptionRuntime.class)
+ @Test
public void testTimeoutFail() throws Exception {
- try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
- TPQManager store = TPQFactory.createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem:test")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
- .createQuery("test").appendText("select * from test_table").build()
- .build()
- .build();
- TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
- exe.executeUpdate(connection, "junit.createTable");
- PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
- ps.close();
- exe.prepareTimeout(ps, 123);
- }
+ assertThrows(SQLExceptionRuntime.class, () -> {
+ try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
+ TPQManager store = TPQFactory.createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem:test")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
+ .createQuery("test").appendText("select * from test_table").build()
+ .build()
+ .build();
+ TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
+ exe.executeUpdate(connection, "junit.createTable");
+ PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
+ ps.close();
+ exe.prepareTimeout(ps, 123);
+ }
+ });
}
- @Test(expected=SQLExceptionRuntime.class)
+ @Test
public void testParameterFail() throws Exception {
- try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
- TPQManager store = TPQFactory.createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem:test")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
- .createQuery("test").appendText("select * from test_table").build()
- .build()
- .build();
- TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
- exe.executeUpdate(connection, "junit.createTable");
- PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
- exe.prepareParameterValue(ps, 1, 123);
- }
+ assertThrows(SQLExceptionRuntime.class, () -> {
+ try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
+ TPQManager store = TPQFactory.createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem:test")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("createTable").appendText("CREATE TABLE test_table (id serial,data int)").build()
+ .createQuery("test").appendText("select * from test_table").build()
+ .build()
+ .build();
+ TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
+ exe.executeUpdate(connection, "junit.createTable");
+ PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
+ exe.prepareParameterValue(ps, 1, 123);
+ }
+ });
}
@Test
diff --git a/tpquery-executor-jpa/src/test/java/net/forwardfire/tpquery/store/executor/jpa/TPQExecutorJpaTest.java b/tpquery-executor-jpa/src/test/java/net/forwardfire/tpquery/store/executor/jpa/TPQExecutorJpaTest.java
index 352505c..14c77e9 100644
--- a/tpquery-executor-jpa/src/test/java/net/forwardfire/tpquery/store/executor/jpa/TPQExecutorJpaTest.java
+++ b/tpquery-executor-jpa/src/test/java/net/forwardfire/tpquery/store/executor/jpa/TPQExecutorJpaTest.java
@@ -1,8 +1,9 @@
package net.forwardfire.tpquery.store.executor.jpa;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.HashMap;
import java.util.List;
@@ -12,44 +13,42 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
-import net.forwardfire.tpquery.TPQManager;
-import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.config.TPQConfig;
-import net.forwardfire.tpquery.statement.AbstractTPQStatementWriter;
-import net.forwardfire.tpquery.statement.TPQStatementWriter;
-import net.forwardfire.tpquery.statement.TPQStatementLanguage;
-import net.forwardfire.tpquery.store.executor.jpa.TPQExecutorJpa;
-import net.forwardfire.tpquery.store.proxy.TPQueryName;
-import net.forwardfire.tpquery.store.proxy.TPQueryProxyFactory;
-import net.forwardfire.tpquery.store.proxy.TPQueryParameterName;
-import net.forwardfire.tpquery.store.proxy.TPQueryProxy;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
+import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
+import net.forwardfire.tpquery.config.TPQConfig;
+import net.forwardfire.tpquery.statement.AbstractTPQStatementWriter;
+import net.forwardfire.tpquery.statement.TPQStatementLanguage;
+import net.forwardfire.tpquery.statement.TPQStatementWriter;
+import net.forwardfire.tpquery.store.proxy.TPQueryName;
+import net.forwardfire.tpquery.store.proxy.TPQueryParameterName;
+import net.forwardfire.tpquery.store.proxy.TPQueryProxy;
+import net.forwardfire.tpquery.store.proxy.TPQueryProxyFactory;
public class TPQExecutorJpaTest {
private EntityManagerFactory emFactory;
private EntityManager em = null;
- @BeforeClass
+ @BeforeAll
public static void setupLogging() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset(); // disable logging
}
- @Before
+ @BeforeEach
public void before() {
emFactory = Persistence.createEntityManagerFactory("junit");
em = emFactory.createEntityManager();
}
- @After
+ @AfterEach
public void close() {
em.close();
emFactory.close();
@@ -116,36 +115,39 @@ public class TPQExecutorJpaTest {
//assertEquals("foobar",resultSingle.name);
}
- @Test(expected=NullPointerException.class)
+ @Test
public void testUnsupportedLanguage() throws Exception {
- TPQConfig config = new TPQConfig();
- config.addStatementLanguage(new TPQStatementLanguage() {
- @Override
- public String getLanguageType() {
- return "XQL";
- }
-
- @Override
- public TPQStatementWriter createQueryWriter(Map parameterData) {
- return new AbstractTPQStatementWriter(parameterData) {
- };
- }
- });
- TPQManager store = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .createQuery("test")
- .setLanguage("XQL")
- .parseStatement("select * from table")
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig config = new TPQConfig();
+ config.addStatementLanguage(new TPQStatementLanguage() {
+ @Override
+ public String getLanguageType() {
+ return "XQL";
+ }
+
+ @Override
+ public TPQStatementWriter createQueryWriter(Map parameterData) {
+ return new AbstractTPQStatementWriter(parameterData) {
+ };
+ }
+ });
+ TPQManager store = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .createQuery("test")
+ .setLanguage("XQL")
+ .parseStatement("select * from table")
+ .build()
.build()
- .build()
- .build();
- TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
- exe.selectList(em, "junit.test", null);
+ .build();
+ TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
+ exe.selectList(em, "junit.test", null);
+ });
}
- @Test()
+ @Test
public void testQueryProxy() throws Exception {
+ assertThrows(NullPointerException.class, () -> {
TPQManager store = TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem")
.setLanguage(TPQFactory.StatementLanguage.HQL)
@@ -196,6 +198,7 @@ public class TPQExecutorJpaTest {
d = foobarService.testFoo();
assertNotNull(d);
+ });
}
@TPQueryProxy(prefix="junit.")
diff --git a/tpquery-store/pom.xml b/tpquery-store/pom.xml
index a6b36ce..4bbd9ae 100644
--- a/tpquery-store/pom.xml
+++ b/tpquery-store/pom.xml
@@ -1,4 +1,5 @@
-
4.0.0
@@ -22,6 +23,21 @@
commons-lang3
compile
+
+ javax.xml.bind
+ jaxb-api
+ compile
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ compile
+
+
+ com.sun.xml.bind
+ jaxb-core
+ compile
+
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQFactoryTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQFactoryTest.java
index d90be41..cb54b1a 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQFactoryTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQFactoryTest.java
@@ -1,11 +1,10 @@
package net.forwardfire.tpquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.config.TPQConfig;
public class TPQFactoryTest {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQSpeedTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQSpeedTest.java
index 772fa0e..a8e38a3 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQSpeedTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/TPQSpeedTest.java
@@ -11,15 +11,14 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
-import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
+import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorContext;
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorStatement;
@@ -28,17 +27,17 @@ public class TPQSpeedTest {
static int loopSize;
static int warmupSize;
static TPQManager queryManager;
- static List result;
+ static List result = new ArrayList<>();;
- @BeforeClass
+ @BeforeAll
static public void initSpeedTest() throws Exception {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset(); // disable logging in speed tests.
warmupSize = 10;
- loopSize = 100000*new Integer(System.getProperty("junit.speedtest.factor", "1"));
- result = new ArrayList<>();
+ loopSize = 100000 * Integer.parseInt(System.getProperty("junit.speedtest.factor", "1"));
+
queryManager = TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem")
.setLanguage(TPQFactory.StatementLanguage.SQL)
@@ -122,7 +121,7 @@ public class TPQSpeedTest {
}
}
- @AfterClass
+ @AfterAll
public static void printResults() {
TPQStoreManagerExecutorContext exeCtx = (TPQStoreManagerExecutorContext)queryManager.getQueryExecutorContext();
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigBuilderTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigBuilderTest.java
index 66f4026..e689325 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigBuilderTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigBuilderTest.java
@@ -1,15 +1,16 @@
package net.forwardfire.tpquery.config;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
public class TPQueryStoreConfigBuilderTest {
@@ -38,9 +39,9 @@ public class TPQueryStoreConfigBuilderTest {
assertNotNull(manager.getQueryStore().getQueryNames());
}
- @Test(expected=IllegalStateException.class)
+ @Test
public void testBuildTreeInvalid() throws Exception {
- TPQFactory
+ assertThrows(IllegalStateException.class, () -> TPQFactory
.createManagerBuilder()
.createQuerySet("junit", "jar:mem:test")
.createQuery("test").parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
@@ -56,7 +57,7 @@ public class TPQueryStoreConfigBuilderTest {
.buildTree()
// buildTree() should be here
.build()
- .build();
+ .build());
}
@Test
@@ -128,17 +129,17 @@ public class TPQueryStoreConfigBuilderTest {
assertNotNull(q.getName());
}
- @Test(expected=TPQConfigException.class)
+ @Test
public void testReadQuerySetFileNotFound() throws Exception {
- TPQFactory.createManagerBuilder()
+ assertThrows(TPQConfigException.class, () -> TPQFactory.createManagerBuilder()
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query.not-found"))
- .build();
+ .build());
}
- @Test(expected=TPQConfigException.class)
+ @Test
public void testReadQuerySetInvalidContext() throws Exception {
- TPQFactory.createManagerBuilder()
+ assertThrows(TPQConfigException.class, () -> TPQFactory.createManagerBuilder()
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query-invalid.xml"))
- .build();
+ .build());
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigTest.java
index 38c8005..eebf5eb 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigTest.java
@@ -1,15 +1,15 @@
package net.forwardfire.tpquery.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.config.TPQConfig;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValue;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
@@ -40,32 +40,40 @@ public class TPQueryStoreConfigTest {
// ---------
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testTemplateTypeAdd() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.addStatementParameter(new TPQStatementParameterValue(TPQFactory.StatementParameter.VALUE));
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.addStatementParameter(new TPQStatementParameterValue(TPQFactory.StatementParameter.VALUE));
+ });
}
- @Test(expected=NullPointerException.class)
+ @Test
public void testTemplateTypeRemove() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
- c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
+ c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
+ });
}
// ---------
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testLanguageTypeAdd() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.addStatementLanguage(new TPQStatementLanguageSql(TPQFactory.StatementLanguage.SQL));
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.addStatementLanguage(new TPQStatementLanguageSql(TPQFactory.StatementLanguage.SQL));
+ });
}
- @Test(expected=NullPointerException.class)
+ @Test
public void testLanguageTypeRemove() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
- c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
+ c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
+ });
}
// ---------
@@ -82,23 +90,29 @@ public class TPQueryStoreConfigTest {
c.addValueType(this.getClass().getName());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testAddValueTypeClassNameError() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.addValueType("net.foo.bar.NoneExcistingClassName");
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.addValueType("net.foo.bar.NoneExcistingClassName");
+ });
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testValueTypeAliasAdd() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.addValueTypeAlias("key", "v0");
- c.addValueTypeAlias("key", "v1");
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.addValueTypeAlias("key", "v0");
+ c.addValueTypeAlias("key", "v1");
+ });
}
- @Test(expected=NullPointerException.class)
+ @Test
public void testValueTypeAliasRemoveIllegalKey() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.removeValueTypeAlias("unknown-key");
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.removeValueTypeAlias("unknown-key");
+ });
}
@Test()
@@ -115,16 +129,20 @@ public class TPQueryStoreConfigTest {
// ---------
- @Test(expected=NullPointerException.class)
+ @Test
public void testQuerySetRemoveIllegalKey() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.removeQuerySet("unknown-key");
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.removeQuerySet("unknown-key");
+ });
}
- @Test(expected=NullPointerException.class)
+ @Test
public void testQuerySetRemoveNull() throws Exception {
- TPQConfig c = TPQFactory.createConfig();
- c.removeQuerySet(null);
+ assertThrows(NullPointerException.class, () -> {
+ TPQConfig c = TPQFactory.createConfig();
+ c.removeQuerySet(null);
+ });
}
@Test()
@@ -204,19 +222,21 @@ public class TPQueryStoreConfigTest {
assertNotNull(q.getName());
}
- @Test(expected=TPQConfigException.class)
+ @Test
public void testWrongClassParameterType() throws Exception {
- TPQManager manager = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", "java.lang.StringFooBar").build()
+ assertThrows(TPQConfigException.class, () -> {
+ TPQManager manager = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", "java.lang.StringFooBar").build()
+ .build()
.build()
- .build()
- .build();
- assertNotNull(manager);
+ .build();
+ assertNotNull(manager);
+ });
}
@Test
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigValidatorTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigValidatorTest.java
index 28ca4ef..88caa70 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigValidatorTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/config/TPQueryStoreConfigValidatorTest.java
@@ -1,46 +1,33 @@
package net.forwardfire.tpquery.config;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.config.validate.TPQConfigValidator;
-import net.forwardfire.tpquery.config.validate.TPQConfigValidatorCheck;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.config.validate.TPQCheckDescriptionNotBlank;
import net.forwardfire.tpquery.config.validate.TPQCheckNamePattern;
import net.forwardfire.tpquery.config.validate.TPQCheckParameterDefaultValueNotBlank;
import net.forwardfire.tpquery.config.validate.TPQCheckParameterNamePattern;
import net.forwardfire.tpquery.config.validate.TPQCheckParameterTypePattern;
import net.forwardfire.tpquery.config.validate.TPQCheckParameterValueTypePattern;
+import net.forwardfire.tpquery.config.validate.TPQConfigValidator;
+import net.forwardfire.tpquery.config.validate.TPQConfigValidatorCheck;
import net.forwardfire.tpquery.model.TPQuery;
public class TPQueryStoreConfigValidatorTest {
-
+
@Test()
public void testPatternValidators() throws Exception {
- TPQConfig config = TPQFactory
- .createConfigBuilder()
- .createQuerySet("junit", "jar:mem:test")
- .createQuery("testCAPS").parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
- .createQuerySetTree("inc")
- .setTemplate(true)
- .createQuery("test")
- .parseStatement("where a=$$a$$ ")
- .createQueryParameter("a", Integer.class)
- .setDefaultValue("1")
- .build()
- .build()
- .createQuerySet("inc")
- .createQuery("test")
- .parseStatement("AND 2=2")
- .build()
- .build()
- .buildTree()
- .build()
- .build();
-
+ TPQConfig config = TPQFactory.createConfigBuilder().createQuerySet("junit", "jar:mem:test")
+ .createQuery("testCAPS")
+ .parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
+ .createQuerySetTree("inc").setTemplate(true).createQuery("test").parseStatement("where a=$$a$$ ")
+ .createQueryParameter("a", Integer.class).setDefaultValue("1").build().build().createQuerySet("inc")
+ .createQuery("test").parseStatement("AND 2=2").build().build().buildTree().build().build();
+
config.addConfigValidator(".*", new TPQCheckNamePattern(".*"));
config.addConfigValidator(".*", new TPQCheckParameterNamePattern(".*"));
config.addConfigValidator(".*", new TPQCheckParameterTypePattern(".*"));
@@ -53,78 +40,84 @@ public class TPQueryStoreConfigValidatorTest {
TPQManager manager = TPQFactory.createManager(config);
assertNotNull(manager);
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testDescriptionNotBlank() throws Exception {
- TPQConfig config = TPQFactory
- .createConfigBuilder()
- .createQuerySet("junit", "jar:mem:test")
- .createQuery("test-oke")
- .setDescription("foobar")
- .parseStatement("select * from table")
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig config = TPQFactory
+ .createConfigBuilder()
+ .createQuerySet("junit", "jar:mem:test")
+ .createQuery("test-oke")
+ .setDescription("foobar")
+ .parseStatement("select * from table")
+ .build()
+ .createQuery("test-fail")
+ .setDescription("")
+ .parseStatement("select * from table")
+ .build()
.build()
- .createQuery("test-fail")
- .setDescription("")
- .parseStatement("select * from table")
- .build()
- .build()
- .build();
-
- TPQConfigValidator t = config.addConfigValidator("junit.test", new TPQCheckDescriptionNotBlank());
- config.removeConfigValidator(t);
-
- config.addConfigValidator(".*", new TPQCheckDescriptionNotBlank());
- TPQManager manager = TPQFactory.createManager(config);
- assertNotNull(manager);
+ .build();
+
+ TPQConfigValidator t = config.addConfigValidator("junit.test", new TPQCheckDescriptionNotBlank());
+ config.removeConfigValidator(t);
+
+ config.addConfigValidator(".*", new TPQCheckDescriptionNotBlank());
+ TPQManager manager = TPQFactory.createManager(config);
+ assertNotNull(manager);
+ });
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testParameterDefaultValueNotBlank() throws Exception {
- TPQConfig config = TPQFactory
- .createConfigBuilder()
- .createQuerySet("junit", "jar:mem:test")
- .createQuery("test-oke")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
- .setDefaultValue("1")
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig config = TPQFactory
+ .createConfigBuilder()
+ .createQuerySet("junit", "jar:mem:test")
+ .createQuery("test-oke")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
+ .setDefaultValue("1")
+ .build()
+ .build()
+ .createQuery("test-fail")
+ .setDescription("")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
+ .setDefaultValue("")
+ .build()
.build()
.build()
- .createQuery("test-fail")
- .setDescription("")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
- .setDefaultValue("")
- .build()
- .build()
- .build()
- .build();
- config.addConfigValidator(".*", new TPQCheckParameterDefaultValueNotBlank());
- TPQManager manager = TPQFactory.createManager(config);
- assertNotNull(manager);
+ .build();
+ config.addConfigValidator(".*", new TPQCheckParameterDefaultValueNotBlank());
+ TPQManager manager = TPQFactory.createManager(config);
+ assertNotNull(manager);
+ });
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testDisableRAWExample() throws Exception {
- TPQConfig config = TPQFactory
- .createConfigBuilder()
- .createQuerySet("junit", "jar:mem:test")
- .createQuery("test-oke")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
- .setType(TPQFactory.StatementParameter.RAW)
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQConfig config = TPQFactory
+ .createConfigBuilder()
+ .createQuerySet("junit", "jar:mem:test")
+ .createQuery("test-oke")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
+ .setType(TPQFactory.StatementParameter.RAW)
+ .build()
+ .build()
+ .createQuery("test-fail")
+ .setDescription("")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
+ .setType(TPQFactory.StatementParameter.RAW)
+ .build()
.build()
.build()
- .createQuery("test-fail")
- .setDescription("")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.INTEGER)
- .setType(TPQFactory.StatementParameter.RAW)
- .build()
- .build()
- .build()
- .build();
- config.addConfigValidator("junit.test-f.*", new TPQCheckParameterTypePattern("!RAW"));
- TPQManager manager = TPQFactory.createManager(config);
- assertNotNull(manager);
+ .build();
+ config.addConfigValidator("junit.test-f.*", new TPQCheckParameterTypePattern("!RAW"));
+ TPQManager manager = TPQFactory.createManager(config);
+ assertNotNull(manager);
+ });
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/executor/TQueryExecutorTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/executor/TQueryExecutorTest.java
index 7f9647f..80b73fc 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/executor/TQueryExecutorTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/executor/TQueryExecutorTest.java
@@ -5,12 +5,12 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.store.executor.AbstractTPQExecutor;
import net.forwardfire.tpquery.store.executor.TPQExecutorContext;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
-import org.junit.Test;
-
public class TQueryExecutorTest {
class TestExecutorConnection {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java
index 27de65d..b404351 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/model/ModelXMLMarshallerTest.java
@@ -1,8 +1,9 @@
package net.forwardfire.tpquery.model;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -12,15 +13,10 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.TPQManager;
-import net.forwardfire.tpquery.model.TPQuery;
-import net.forwardfire.tpquery.model.TPQueryParameter;
-import net.forwardfire.tpquery.model.TPQuerySet;
-import net.forwardfire.tpquery.model.ModelXMLInfoSet;
-import net.forwardfire.tpquery.model.ModelXMLMarshaller;
import net.forwardfire.tpquery.statement.TPQStatementPartInclude;
import net.forwardfire.tpquery.statement.TPQStatementPartParameter;
import net.forwardfire.tpquery.statement.TPQStatementPartText;
@@ -117,9 +113,9 @@ public class ModelXMLMarshallerTest {
assertEquals("false",q.getQueryHints().get("junit"));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testContextException() throws Exception {
- new ModelXMLMarshaller(JaxbContextError.class);
+ assertThrows(IllegalArgumentException.class, () -> new ModelXMLMarshaller(JaxbContextError.class));
}
private static class JaxbContextError {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/model/TPQueryPropertyTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/model/TPQueryPropertyTest.java
index c298faa..233af0d 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/model/TPQueryPropertyTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/model/TPQueryPropertyTest.java
@@ -1,14 +1,14 @@
package net.forwardfire.tpquery.model;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
public class TPQueryPropertyTest {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerAdapterTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerAdapterTest.java
index 2de6889..c32caea 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerAdapterTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerAdapterTest.java
@@ -1,10 +1,9 @@
package net.forwardfire.tpquery.statement;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import net.forwardfire.tpquery.statement.TPQStatementMarshallerAdapter;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TPQueryStatementMarshallerAdapterTest {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerTest.java
index 199af03..3aa16ea 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementMarshallerTest.java
@@ -1,29 +1,26 @@
package net.forwardfire.tpquery.statement;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import net.forwardfire.tpquery.statement.TPQStatement;
-import net.forwardfire.tpquery.statement.TPQStatementMarshaller;
-import net.forwardfire.tpquery.statement.TPQStatementPartInclude;
-import net.forwardfire.tpquery.statement.TPQStatementPartParameter;
-import net.forwardfire.tpquery.statement.TPQStatementPartText;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TPQueryStatementMarshallerTest {
- @Test(expected=NullPointerException.class)
+ @Test
public void testParseNull() throws Exception {
- TPQStatementMarshaller parser = new TPQStatementMarshaller();
- parser.unmarshal(null);
+ assertThrows(NullPointerException.class, () -> {
+ TPQStatementMarshaller parser = new TPQStatementMarshaller();
+ parser.unmarshal(null);
+ });
}
-
+
@Test()
public void testParseEmpty() throws Exception {
TPQStatementMarshaller parser = new TPQStatementMarshaller();
@@ -31,58 +28,58 @@ public class TPQueryStatementMarshallerTest {
assertNotNull(result);
assertTrue(result.isEmpty());
}
-
+
@Test()
public void testParseText() throws Exception {
TPQStatementMarshaller parser = new TPQStatementMarshaller();
List result = parser.unmarshal("foobar");
assertNotNull(result);
assertFalse(result.isEmpty());
- assertTrue(result.size()==1);
+ assertTrue(result.size() == 1);
assertNotNull(result.get(0));
assertTrue(result.get(0) instanceof TPQStatementPartText);
}
-
+
@Test()
public void testParseTemplate() throws Exception {
TPQStatementMarshaller parser = new TPQStatementMarshaller();
List result = parser.unmarshal("$$foobar$$");
assertNotNull(result);
assertFalse(result.isEmpty());
- assertTrue(result.size()==1);
+ assertTrue(result.size() == 1);
assertNotNull(result.get(0));
assertTrue(result.get(0) instanceof TPQStatementPartParameter);
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testParseTemplateNoEnd() throws Exception {
- new TPQStatementMarshaller().unmarshal("$$foobar");
+ assertThrows(IllegalArgumentException.class, () -> new TPQStatementMarshaller().unmarshal("$$foobar"));
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testParseTemplateEmpty() throws Exception {
- new TPQStatementMarshaller().unmarshal("$$$$");
+ assertThrows(IllegalArgumentException.class, () -> new TPQStatementMarshaller().unmarshal("$$$$"));
}
-
+
@Test()
public void testParseTemplateInclude() throws Exception {
TPQStatementMarshaller parser = new TPQStatementMarshaller();
List result = parser.unmarshal("$$inc:foobar$$");
assertNotNull(result);
assertFalse(result.isEmpty());
- assertTrue(result.size()==1);
+ assertTrue(result.size() == 1);
assertNotNull(result.get(0));
assertTrue(result.get(0) instanceof TPQStatementPartInclude);
}
-
-
-
- @Test(expected=NullPointerException.class)
+
+ @Test
public void testPrintNull() throws Exception {
- TPQStatementMarshaller parser = new TPQStatementMarshaller();
- parser.marshal(null);
+ assertThrows(NullPointerException.class, () -> {
+ TPQStatementMarshaller parser = new TPQStatementMarshaller();
+ parser.marshal(null);
+ });
}
-
+
@Test()
public void testPrintEmpty() throws Exception {
List data = new ArrayList<>();
@@ -91,7 +88,7 @@ public class TPQueryStatementMarshallerTest {
assertNotNull(result);
assertTrue(result.isEmpty());
}
-
+
@Test()
public void testPrintText() throws Exception {
List data = new ArrayList<>();
@@ -102,7 +99,6 @@ public class TPQueryStatementMarshallerTest {
String result = parser.marshal(data);
assertNotNull(result);
assertFalse(result.isEmpty());
- assertEquals("p0p1p2",result);
+ assertEquals("p0p1p2", result);
}
}
-
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementPartIncludeTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementPartIncludeTest.java
index 15265b9..1f333d1 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementPartIncludeTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementPartIncludeTest.java
@@ -1,61 +1,64 @@
package net.forwardfire.tpquery.statement;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import net.forwardfire.tpquery.TPQManager;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
-import org.junit.Test;
-
public class TPQueryStatementPartIncludeTest {
-
- @Test(expected=NullPointerException.class)
+
+ @Test
public void testFailInclude() throws Exception {
- TPQFactory.createManagerBuilder()
+ assertThrows(NullPointerException.class, () -> TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem:test")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("include-missing")
- .appendText("select * from foobar")
- .appendInclude("include-missing-query")
- .build()
- .build()
- .build();
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("include-missing")
+ .appendText("select * from foobar")
+ .appendInclude("include-missing-query")
+ .build()
+ .build()
+ .build());
}
-
+
@Test
public void testIncludeMultple() throws Exception {
- TPQManager store = TPQFactory
- .createManagerBuilder()
- .readQuerySet("net/forwardfire/tpquery/test-include-multiple.xml")
- .build();
+ TPQManager store = TPQFactory.createManagerBuilder()
+ .readQuerySet("net/forwardfire/tpquery/test-include-multiple.xml").build();
TPQExecutorStatement q = store.getQueryExecutorContext().prepareQuery("test.multipleInclude", null);
assertNotNull(q.getName());
assertTrue(q.getStatement().contains("price_list"));
assertTrue(q.getStatement().contains("key='stats_correction') AS mrt"));
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testIncludeLoop() throws Exception {
- TPQManager store = TPQFactory
- .createManagerBuilder()
- .readQuerySet("net/forwardfire/tpquery/test-include-loop.xml")
- .build();
- store.getQueryExecutorContext().prepareQuery("test.loopInclude", null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQManager store = TPQFactory
+ .createManagerBuilder()
+ .readQuerySet("net/forwardfire/tpquery/test-include-loop.xml")
+ .build();
+ store.getQueryExecutorContext().prepareQuery("test.loopInclude", null);
+ });
}
-
- @Test(expected=IllegalArgumentException.class)
+
+ @Test
public void testQueryChecked() throws Exception {
- TPQFactory.createManagerBuilder()
+ assertThrows(IllegalArgumentException.class,
+ () -> TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem:test")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .appendText("select * from foobar")
- .build()
- .createQuery("test-fail")
- .appendInclude("junit.test")
- .build()
- .build()
- .build();
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .appendText("select * from foobar")
+ .build()
+ .createQuery("test-fail")
+ .appendInclude("junit.test")
+ .build()
+ .build()
+ .build());
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementWriterTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementWriterTest.java
index 371efbf..a7caf7b 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementWriterTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/TPQueryStatementWriterTest.java
@@ -1,21 +1,20 @@
package net.forwardfire.tpquery.statement;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.config.TPQConfig;
-import net.forwardfire.tpquery.statement.TPQStatementWriter;
import net.forwardfire.tpquery.statement.language.AbstractTPQStatementLanguage;
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
-import org.junit.Test;
-
public class TPQueryStatementWriterTest {
private TPQStatementWriter createWriter() {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageHqlTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageHqlTest.java
index c450ecb..1852bdc 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageHqlTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageHqlTest.java
@@ -1,20 +1,19 @@
package net.forwardfire.tpquery.statement.language;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.statement.TPQStatementWriter;
-import net.forwardfire.tpquery.statement.language.TPQStatementLanguageHql;
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
-import org.junit.Test;
-
public class TPQStatementLanguageHqlTest {
private TPQStatementWriter createWriter() {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageSqlTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageSqlTest.java
index f9dba00..4851fde 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageSqlTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/language/TPQStatementLanguageSqlTest.java
@@ -1,16 +1,15 @@
package net.forwardfire.tpquery.statement.language;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.statement.TPQStatementWriter;
-import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
public class TPQStatementLanguageSqlTest {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterDefaultValueTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterDefaultValueTest.java
index 97e9636..4cb1cf1 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterDefaultValueTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterDefaultValueTest.java
@@ -1,21 +1,22 @@
package net.forwardfire.tpquery.statement.parameter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
-import net.forwardfire.tpquery.TPQManager;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.config.TPQConfig;
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
-import org.junit.Test;
-
public class TPQueryParameterDefaultValueTest {
- @Test()
+ @Test
public void testRawString() throws Exception {
TPQConfig config = TPQFactory
.createConfigBuilder()
@@ -44,7 +45,7 @@ public class TPQueryParameterDefaultValueTest {
.setLanguage(TPQFactory.StatementLanguage.SQL)
.createQuery("test")
.parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.LONG)
+ .createQueryParameter("a", TPQFactory.ParameterValueType.DOUBLE)
.setDefaultValue("js:epoch()")
.build()
.build()
@@ -54,7 +55,7 @@ public class TPQueryParameterDefaultValueTest {
TPQExecutorStatement prepared = store.getQueryExecutorContext().prepareQuery("junit.test", para);
assertTrue(!prepared.getParameters().isEmpty());
assertTrue(prepared.getParameters().get(0) != null);
- assertTrue(prepared.getParameters().get(0) instanceof Long);
+ assertTrue(prepared.getParameters().get(0) instanceof Double);
}
@Test()
@@ -121,20 +122,22 @@ public class TPQueryParameterDefaultValueTest {
assertTrue(prepared.getParameters().get(0) instanceof java.lang.Integer);
}
- @Test(expected=Exception.class)
+ @Test
public void testCreateObjectConstructorWrongClass() throws Exception {
- TPQManager store = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
- .setDefaultValue("js:createObject(java.lang.StringNotFound,'foobar')")
+ assertThrows(Exception.class, () -> {
+ TPQManager store = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .parseStatement("select * from foobar where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
+ .setDefaultValue("js:createObject(java.lang.StringNotFound,'foobar')")
+ .build()
.build()
- .build()
- .build()
- .build();
- store.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ .build()
+ .build();
+ store.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ });
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeListTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeListTest.java
index e571b1f..281a08e 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeListTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeListTest.java
@@ -1,6 +1,7 @@
package net.forwardfire.tpquery.statement.parameter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.ArrayList;
import java.util.Arrays;
@@ -8,10 +9,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.model.TPQuery;
import net.forwardfire.tpquery.model.TPQueryParameter;
import net.forwardfire.tpquery.model.TPQuerySet;
@@ -20,67 +21,73 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
public class TPQueryParameterTypeListTest {
- @Test(expected=NullPointerException.class)
+ @Test
public void testNullValue() throws Exception {
- TPQuery q = new TPQuery();
- q.setName("test");
- q.addQueryPart(new TPQStatementPartParameter("param"));
- TPQueryParameter qp = new TPQueryParameter();
- qp.setType(TPQFactory.StatementParameter.LIST);
- qp.setName("param");
- //qp.setDefaultValue("1,2,3");
- qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
- q.addQueryParameter(qp);
-
- TPQuerySet qs = new TPQuerySet("junit");
- qs.setLanguage(TPQFactory.StatementLanguage.SQL);
- qs.addQuery(q);
- TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
-
- Map para = new HashMap();
- store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ assertThrows(NullPointerException.class, () -> {
+ TPQuery q = new TPQuery();
+ q.setName("test");
+ q.addQueryPart(new TPQStatementPartParameter("param"));
+ TPQueryParameter qp = new TPQueryParameter();
+ qp.setType(TPQFactory.StatementParameter.LIST);
+ qp.setName("param");
+ //qp.setDefaultValue("1,2,3");
+ qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
+ q.addQueryParameter(qp);
+
+ TPQuerySet qs = new TPQuerySet("junit");
+ qs.setLanguage(TPQFactory.StatementLanguage.SQL);
+ qs.addQuery(q);
+ TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
+
+ Map para = new HashMap();
+ store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ });
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testEmptyValue() throws Exception {
- TPQuery q = new TPQuery();
- q.setName("test");
- q.addQueryPart(new TPQStatementPartParameter("param"));
- TPQueryParameter qp = new TPQueryParameter();
- qp.setType(TPQFactory.StatementParameter.LIST);
- qp.setName("param");
- qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
- q.addQueryParameter(qp);
-
- TPQuerySet qs = new TPQuerySet("junit");
- qs.setLanguage(TPQFactory.StatementLanguage.SQL);
- qs.addQuery(q);
- TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
-
- Map para = new HashMap();
- para.put("param", new ArrayList());
- store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQuery q = new TPQuery();
+ q.setName("test");
+ q.addQueryPart(new TPQStatementPartParameter("param"));
+ TPQueryParameter qp = new TPQueryParameter();
+ qp.setType(TPQFactory.StatementParameter.LIST);
+ qp.setName("param");
+ qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
+ q.addQueryParameter(qp);
+
+ TPQuerySet qs = new TPQuerySet("junit");
+ qs.setLanguage(TPQFactory.StatementLanguage.SQL);
+ qs.addQuery(q);
+ TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
+
+ Map para = new HashMap();
+ para.put("param", new ArrayList());
+ store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ });
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testWrongValue() throws Exception {
- TPQuery q = new TPQuery();
- q.setName("test");
- q.addQueryPart(new TPQStatementPartParameter("param"));
- TPQueryParameter qp = new TPQueryParameter();
- qp.setType(TPQFactory.StatementParameter.LIST);
- qp.setName("param");
- qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
- q.addQueryParameter(qp);
-
- TPQuerySet qs = new TPQuerySet("junit");
- qs.setLanguage(TPQFactory.StatementLanguage.SQL);
- qs.addQuery(q);
- TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
-
- Map para = new HashMap();
- para.put("param", new HashMap());
- store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQuery q = new TPQuery();
+ q.setName("test");
+ q.addQueryPart(new TPQStatementPartParameter("param"));
+ TPQueryParameter qp = new TPQueryParameter();
+ qp.setType(TPQFactory.StatementParameter.LIST);
+ qp.setName("param");
+ qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
+ q.addQueryParameter(qp);
+
+ TPQuerySet qs = new TPQuerySet("junit");
+ qs.setLanguage(TPQFactory.StatementLanguage.SQL);
+ qs.addQuery(q);
+ TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:test",qs).build();
+
+ Map para = new HashMap();
+ para.put("param", new HashMap());
+ store.getQueryExecutorContext().prepareQuery("junit.test", para);
+ });
}
@Test()
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeRawTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeRawTest.java
index 62aec26..4e7d802 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeRawTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeRawTest.java
@@ -1,16 +1,16 @@
package net.forwardfire.tpquery.statement.parameter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.model.TPQuery;
import net.forwardfire.tpquery.model.TPQueryParameter;
import net.forwardfire.tpquery.model.TPQuerySet;
@@ -19,7 +19,7 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
public class TPQueryParameterTypeRawTest {
- @Test()
+ @Test
public void testTypeRaw() throws Exception {
TPQuery q = new TPQuery();
q.setName("test");
@@ -49,7 +49,7 @@ public class TPQueryParameterTypeRawTest {
assertEquals(0,queryPreparedValue.getParameters().size());
}
- @Test()
+ @Test
public void testTypeRawNull() throws Exception {
TPQManager store = TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem:test")
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeValueTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeValueTest.java
index e68b2f6..4a2dc99 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeValueTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/statement/parameter/TPQueryParameterTypeValueTest.java
@@ -1,14 +1,15 @@
package net.forwardfire.tpquery.statement.parameter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.model.TPQuery;
import net.forwardfire.tpquery.model.TPQueryParameter;
import net.forwardfire.tpquery.model.TPQuerySet;
@@ -17,36 +18,40 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
public class TPQueryParameterTypeValueTest {
- @Test(expected=NullPointerException.class)
+ @Test
public void testMissingParameter() throws Exception {
- TPQuery q = new TPQuery();
- q.setName("test");
- q.addQueryPart(new TPQStatementPartParameter("missing-param"));
-
- TPQuerySet qs = new TPQuerySet("junit");
- qs.addQuery(q);
- TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:testMissingParameter",qs).build();
- store.getQueryExecutorContext().prepareQuery("junit.test", null);
+ assertThrows(NullPointerException.class, () -> {
+ TPQuery q = new TPQuery();
+ q.setName("test");
+ q.addQueryPart(new TPQStatementPartParameter("missing-param"));
+
+ TPQuerySet qs = new TPQuerySet("junit");
+ qs.addQuery(q);
+ TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:testMissingParameter",qs).build();
+ store.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testTypeParamWrongType() throws Exception {
- TPQuery q = new TPQuery();
- q.setName("test");
- q.addQueryPart(new TPQStatementPartParameter("param"));
- TPQueryParameter qp = new TPQueryParameter();
- qp.setType(TPQFactory.StatementParameter.VALUE);
- qp.setName("param");
- qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
- q.addQueryParameter(qp);
- TPQuerySet qs = new TPQuerySet("junit");
- qs.setLanguage(TPQFactory.StatementLanguage.SQL);
- qs.addQuery(q);
- TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:test",qs).build();
-
- Map paraValue = new HashMap();
- paraValue.put("param", "test");
- store.getQueryExecutorContext().prepareQuery("junit.test", paraValue);
+ assertThrows(IllegalArgumentException.class, () -> {
+ TPQuery q = new TPQuery();
+ q.setName("test");
+ q.addQueryPart(new TPQStatementPartParameter("param"));
+ TPQueryParameter qp = new TPQueryParameter();
+ qp.setType(TPQFactory.StatementParameter.VALUE);
+ qp.setName("param");
+ qp.setValueType(TPQFactory.ParameterValueType.INTEGER);
+ q.addQueryParameter(qp);
+ TPQuerySet qs = new TPQuerySet("junit");
+ qs.setLanguage(TPQFactory.StatementLanguage.SQL);
+ qs.addQuery(q);
+ TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:test",qs).build();
+
+ Map paraValue = new HashMap();
+ paraValue.put("param", "test");
+ store.getQueryExecutorContext().prepareQuery("junit.test", paraValue);
+ });
}
@Test()
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/TPQueryStoreTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/TPQueryStoreTest.java
index 0c0c88a..b297784 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/TPQueryStoreTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/TPQueryStoreTest.java
@@ -1,17 +1,17 @@
package net.forwardfire.tpquery.store;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
-import net.forwardfire.tpquery.TPQManager;
-import net.forwardfire.tpquery.TPQFactory;
-import net.forwardfire.tpquery.config.TPQConfig;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
+import net.forwardfire.tpquery.config.TPQConfig;
public class TPQueryStoreTest {
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerStatementCacheTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerStatementCacheTest.java
index 5bf4f41..c70fc9d 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerStatementCacheTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerStatementCacheTest.java
@@ -1,7 +1,8 @@
package net.forwardfire.tpquery.store.manager;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.io.FileInputStream;
@@ -15,15 +16,15 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
-import net.forwardfire.tpquery.TPQManager;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.config.TPQConfig;
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterListMapper;
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValueMapper;
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
-import org.junit.Test;
-
public class TPQStoreManagerStatementCacheTest {
private Lock createFailingLock(boolean lockOke) {
@@ -40,140 +41,152 @@ public class TPQStoreManagerStatementCacheTest {
}
@SuppressWarnings("serial")
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailPut() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- Map cc = new HashMap() {
- @Override
- public TPQueryStoreStatement put(String key,TPQueryStoreStatement value) {
- throw new IllegalStateException();
- }
- };
- config.setStatementCache(new TPQStoreManagerStatementCache(cc));
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ Map cc = new HashMap() {
+ @Override
+ public TPQueryStoreStatement put(String key,TPQueryStoreStatement value) {
+ throw new IllegalStateException();
+ }
+ };
+ config.setStatementCache(new TPQStoreManagerStatementCache(cc));
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailPutLock() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
- @Override
- protected Lock getWriteLock() {
- return createFailingLock(false);
- }
- });
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
+ @Override
+ protected Lock getWriteLock() {
+ return createFailingLock(false);
+ }
+ });
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailPutUnlock() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
- @Override
- protected Lock getWriteLock() {
- return createFailingLock(true);
- }
- });
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
+ @Override
+ protected Lock getWriteLock() {
+ return createFailingLock(true);
+ }
+ });
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
@SuppressWarnings("serial")
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailGet() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- Map cc = new HashMap() {
- @Override
- public TPQueryStoreStatement get(Object key) {
- throw new IllegalStateException();
- }
- };
- config.setStatementCache(new TPQStoreManagerStatementCache(cc));
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ Map cc = new HashMap() {
+ @Override
+ public TPQueryStoreStatement get(Object key) {
+ throw new IllegalStateException();
+ }
+ };
+ config.setStatementCache(new TPQStoreManagerStatementCache(cc));
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
-
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailGetLock() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
- @Override
- protected Lock getWriteLock() {
- return createFailingLock(false);
- }
- });
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
+ @Override
+ protected Lock getWriteLock() {
+ return createFailingLock(false);
+ }
+ });
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
- @Test(expected=IllegalStateException.class)
+ @Test
public void testCacheFailGetUnlock() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
- @Override
- protected Lock getWriteLock() {
- return createFailingLock(true);
- }
- });
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(IllegalStateException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap()) {
+ @Override
+ protected Lock getWriteLock() {
+ return createFailingLock(true);
+ }
+ });
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ });
}
@@ -217,72 +230,78 @@ public class TPQStoreManagerStatementCacheTest {
assertEquals(cache.size(),cache2.size());
}
- @Test(expected=Exception.class)
+ @Test
public void testCacheStatementReadObjectNoData() throws Exception {
- Map cache = new HashMap<>();
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(cache));
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(Exception.class, () -> {
+ Map cache = new HashMap<>();
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(cache));
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
- TPQueryStoreStatement c = cache.values().iterator().next();
- assertNotNull(c);
- Method m = TPQueryStoreStatement.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
- m.setAccessible(true);
- m.invoke(c, new Object[]{});
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ TPQueryStoreStatement c = cache.values().iterator().next();
+ assertNotNull(c);
+ Method m = TPQueryStoreStatement.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
+ m.setAccessible(true);
+ m.invoke(c, new Object[]{});
+ });
}
- @Test(expected=Exception.class)
+ @Test
public void testCacheValueMapperReadObjectNoData() throws Exception {
- Map cache = new HashMap<>();
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(cache));
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ assertThrows(Exception.class, () -> {
+ Map cache = new HashMap<>();
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(cache));
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setDefaultValue("a").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
- TPQueryStoreStatement c = cache.values().iterator().next();
- assertNotNull(c);
- Method m = TPQStatementParameterValueMapper.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
- m.setAccessible(true);
- m.invoke(c.getValueMapping().get(0), new Object[]{});
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ TPQueryStoreStatement c = cache.values().iterator().next();
+ assertNotNull(c);
+ Method m = TPQStatementParameterValueMapper.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
+ m.setAccessible(true);
+ m.invoke(c.getValueMapping().get(0), new Object[]{});
+ });
}
- @Test(expected=Exception.class)
+ @Test
public void testCacheListMapperReadObjectNoData() throws Exception {
- Map cache = new HashMap<>();
- TPQConfig config = TPQFactory.createConfig();
- config.setStatementCache(new TPQStoreManagerStatementCache(cache));
- TPQManager queryManager = TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:mem:test")
- .setLanguage("SQL")
- .createQuery("test")
- .parseStatement("select * from table where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setType("LIST").setDefaultValue("1,2,3").build()
+ assertThrows(Exception.class, () -> {
+ Map cache = new HashMap<>();
+ TPQConfig config = TPQFactory.createConfig();
+ config.setStatementCache(new TPQStoreManagerStatementCache(cache));
+ TPQManager queryManager = TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:mem:test")
+ .setLanguage("SQL")
+ .createQuery("test")
+ .parseStatement("select * from table where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.STRING).setType("LIST").setDefaultValue("1,2,3").build()
+ .build()
.build()
- .build()
- .build();
- queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
- TPQueryStoreStatement c = cache.values().iterator().next();
- assertNotNull(c);
- Method m = TPQStatementParameterListMapper.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
- m.setAccessible(true);
- m.invoke(c.getValueMapping().get(0), new Object[]{});
+ .build();
+ queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
+ TPQueryStoreStatement c = cache.values().iterator().next();
+ assertNotNull(c);
+ Method m = TPQStatementParameterListMapper.class.getDeclaredMethod("readObjectNoData", new Class>[]{});
+ m.setAccessible(true);
+ m.invoke(c.getValueMapping().get(0), new Object[]{});
+ });
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerTest.java
index fb26b7c..c87c4c5 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/manager/TPQStoreManagerTest.java
@@ -1,71 +1,80 @@
package net.forwardfire.tpquery.store.manager;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import java.util.HashMap;
-import net.forwardfire.tpquery.TPQManager;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
+import net.forwardfire.tpquery.TPQManager;
import net.forwardfire.tpquery.config.TPQConfig;
import net.forwardfire.tpquery.config.TPQConfigException;
import net.forwardfire.tpquery.store.TPQueryStoreScriptEngineException;
-import org.junit.Test;
-
public class TPQStoreManagerTest {
- @Test(expected=TPQueryStoreScriptEngineException.class)
+ @Test
public void testParameterValueScriptError() throws Exception {
- TPQConfig config = TPQFactory.createConfig();
- config.addParameterValueScript("throw 'error'");
- TPQFactory
- .createManagerBuilder(config)
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
- .setDefaultValue("js:time()")
+ assertThrows(TPQueryStoreScriptEngineException.class, () -> {
+ TPQConfig config = TPQFactory.createConfig();
+ config.addParameterValueScript("throw 'error'");
+ TPQFactory
+ .createManagerBuilder(config)
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .parseStatement("select * from foobar where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
+ .setDefaultValue("js:time()")
+ .build()
+ .build()
+ .build()
+ .build();
+ });
+ }
+
+ @Test
+ public void testCompileScriptError() throws Exception {
+ assertThrows(TPQueryStoreScriptEngineException.class, () -> {
+ TPQManager manager = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .parseStatement("select * from foobar where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
+ .setDefaultValue("js:+++++++-------------=========----------+++++++++")
.build()
.build()
- .build()
- .build();
- }
-
- @Test(expected=TPQueryStoreScriptEngineException.class)
- public void testCompileScriptError() throws Exception {
- TPQManager manager = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
- .setDefaultValue("js:+++++++-------------=========----------+++++++++")
- .build()
.build()
- .build()
- .build();
- manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ .build();
+ manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ });
}
- @Test(expected=Exception.class)
+ @Test
public void testRuntimeScriptError() throws Exception {
- TPQManager manager = TPQFactory
- .createManagerBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
- .setDefaultValue("js:throw createObject(java.lang.String,'error')")
+ assertThrows(Exception.class, () -> {
+ TPQManager manager = TPQFactory
+ .createManagerBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .parseStatement("select * from foobar where a=$$a$$")
+ .createQueryParameter("a", TPQFactory.ParameterValueType.SQL_TIME)
+ .setDefaultValue("js:throw createObject(java.lang.String,'error')")
+ .build()
.build()
.build()
- .build()
- .build();
- manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ .build();
+ manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap());
+ });
}
- @Test(expected=TPQConfigException.class)
+ @Test
public void testConfigErrorByTPQStoreManagerConfig() throws Exception {
+ assertThrows(TPQConfigException.class, () ->
TPQFactory.createManagerBuilder()
.createQuerySet("junit", "jar:junit:mem")
.setLanguage(TPQFactory.StatementLanguage.SQL)
@@ -75,26 +84,27 @@ public class TPQStoreManagerTest {
.build()
.build()
.build()
- .build();
+ .build());
}
- @Test(expected=TPQConfigException.class)
+ @Test
public void testConfigErrorByTPQStoreManager() throws Exception {
-
- TPQConfig c = TPQFactory.createConfigBuilder()
- .createQuerySet("junit", "jar:junit:mem")
- .setLanguage(TPQFactory.StatementLanguage.SQL)
- .createQuery("test")
- .parseStatement("select * from foobar where a=$$a$$")
- .createQueryParameter("a", "java.lang.String")
+ assertThrows(TPQConfigException.class, () -> {
+ TPQConfig c = TPQFactory.createConfigBuilder()
+ .createQuerySet("junit", "jar:junit:mem")
+ .setLanguage(TPQFactory.StatementLanguage.SQL)
+ .createQuery("test")
+ .parseStatement("select * from foobar where a=$$a$$")
+ .createQueryParameter("a", "java.lang.String")
+ .build()
.build()
.build()
- .build()
- .build();
- TPQStoreManagerConfig smc = new TPQStoreManagerConfig(c);
-
- smc.getEntries().get("junit.test").getQuery().getQueryParameters().get(0).setValueType("net.foo.bar.NoneExcistingClass");
-
- new TPQStoreManager(smc);
+ .build();
+ TPQStoreManagerConfig smc = new TPQStoreManagerConfig(c);
+
+ smc.getEntries().get("junit.test").getQuery().getQueryParameters().get(0).setValueType("net.foo.bar.NoneExcistingClass");
+
+ new TPQStoreManager(smc);
+ });
}
}
diff --git a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/proxy/TPQueryProxyFactoryTest.java b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/proxy/TPQueryProxyFactoryTest.java
index 0c07817..7b6f7e0 100644
--- a/tpquery-store/src/test/java/net/forwardfire/tpquery/store/proxy/TPQueryProxyFactoryTest.java
+++ b/tpquery-store/src/test/java/net/forwardfire/tpquery/store/proxy/TPQueryProxyFactoryTest.java
@@ -1,15 +1,15 @@
package net.forwardfire.tpquery.store.proxy;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import net.forwardfire.tpquery.TPQFactory;
import net.forwardfire.tpquery.TPQManager;
-import org.junit.Test;
-
public class TPQueryProxyFactoryTest {
@Test()