Compare commits
No commits in common. "39a311aac9ce9e07d2729fc97613d097ecfbe09d" and "ccd7320be51cdd970a0ed82c2f7e0d57833f823e" have entirely different histories.
39a311aac9
...
ccd7320be5
63
pom.xml
63
pom.xml
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.forwardfire.tpquery</groupId>
|
<groupId>net.forwardfire.tpquery</groupId>
|
||||||
|
@ -31,13 +30,13 @@
|
||||||
</modules>
|
</modules>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.build.sourceVersion>11</project.build.sourceVersion>
|
<project.build.sourceVersion>1.8</project.build.sourceVersion>
|
||||||
|
|
||||||
<!-- workaround for: [WARNING] 'reporting.plugins.plugin.version' for ... -->
|
<!-- workaround for: [WARNING] 'reporting.plugins.plugin.version' for ... -->
|
||||||
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version><!--
|
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version><!--
|
||||||
invalid format 1007: <version>0.7.5.201505241946</version> -->
|
invalid format 1007: <version>0.7.5.201505241946</version> -->
|
||||||
<maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
|
<maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
|
||||||
<maven-project-info-reports-plugin>3.0.0</maven-project-info-reports-plugin>
|
<maven-project-info-reports-plugin>2.8</maven-project-info-reports-plugin>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -52,9 +51,9 @@
|
||||||
<version>3.5</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>5.5.2</version>
|
<version>4.12</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
@ -96,27 +95,12 @@
|
||||||
<artifactId>sonar-jacoco-listeners</artifactId>
|
<artifactId>sonar-jacoco-listeners</artifactId>
|
||||||
<version>3.2</version>
|
<version>3.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
<version>2.3.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-impl</artifactId>
|
|
||||||
<version>2.3.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-core</artifactId>
|
|
||||||
<version>2.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -181,6 +165,22 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jdeps-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jdkinternals</goal> <!-- verify main classes -->
|
||||||
|
<goal>test-jdkinternals</goal> <!-- verify test classes -->
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
@ -198,7 +198,9 @@
|
||||||
<requireMavenVersion>
|
<requireMavenVersion>
|
||||||
<version>(3.0,)</version>
|
<version>(3.0,)</version>
|
||||||
</requireMavenVersion>
|
</requireMavenVersion>
|
||||||
<!-- jdk9 check <banDuplicateClasses></banDuplicateClasses> -->
|
<!-- jdk9 check
|
||||||
|
<banDuplicateClasses></banDuplicateClasses>
|
||||||
|
-->
|
||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -378,12 +380,9 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<echo>Copy project markdown to site.</echo>
|
<echo>Copy project markdown to site.</echo>
|
||||||
<copy verbose="true" file="readme.md"
|
<copy verbose="true" file="readme.md" toFile="src/site/markdown/index.md" />
|
||||||
toFile="src/site/markdown/index.md" />
|
<copy verbose="true" file="todo.md" todir="src/site/markdown" />
|
||||||
<copy verbose="true" file="todo.md"
|
<copy verbose="true" file="build.md" todir="src/site/markdown" />
|
||||||
todir="src/site/markdown" />
|
|
||||||
<copy verbose="true" file="build.md"
|
|
||||||
todir="src/site/markdown" />
|
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package net.forwardfire.tpquery.store.executor.jdbc;
|
package net.forwardfire.tpquery.store.executor.jdbc;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
@ -12,17 +11,20 @@ import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
import org.junit.jupiter.api.Test;
|
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.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
|
||||||
|
|
||||||
public class TPQExecutorJdbcTest {
|
public class TPQExecutorJdbcTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeClass
|
||||||
public static void setupLogging() {
|
public static void setupLogging() {
|
||||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
lc.reset(); // disable logging
|
lc.reset(); // disable logging
|
||||||
|
@ -82,9 +84,8 @@ public class TPQExecutorJdbcTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=SQLExceptionRuntime.class)
|
||||||
public void testExecuteUpdateFail() throws Exception {
|
public void testExecuteUpdateFail() throws Exception {
|
||||||
assertThrows(SQLExceptionRuntime.class, () -> {
|
|
||||||
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
||||||
TPQManager store = TPQFactory
|
TPQManager store = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
|
@ -101,12 +102,10 @@ public class TPQExecutorJdbcTest {
|
||||||
exe.executeUpdate(connection, "junit.insertData");
|
exe.executeUpdate(connection, "junit.insertData");
|
||||||
exe.executeUpdate(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
|
exe.executeUpdate(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=SQLExceptionRuntime.class)
|
||||||
public void testExecuteSelectFail() throws Exception {
|
public void testExecuteSelectFail() throws Exception {
|
||||||
assertThrows(SQLExceptionRuntime.class, () -> {
|
|
||||||
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
||||||
|
|
||||||
TPQManager store = TPQFactory
|
TPQManager store = TPQFactory
|
||||||
|
@ -124,12 +123,10 @@ public class TPQExecutorJdbcTest {
|
||||||
exe.executeUpdate(connection, "junit.insertData");
|
exe.executeUpdate(connection, "junit.insertData");
|
||||||
exe.execute(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
|
exe.execute(connection, "junit.queryFail"); // runtime data failure, as prepared will go correctly
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=SQLExceptionRuntime.class)
|
||||||
public void testExecuteSelectFailPrepare() throws Exception {
|
public void testExecuteSelectFailPrepare() throws Exception {
|
||||||
assertThrows(SQLExceptionRuntime.class, () -> {
|
|
||||||
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem:testcaseFail")
|
.createQuerySet("junit", "jar:junit:mem:testcaseFail")
|
||||||
|
@ -140,12 +137,10 @@ public class TPQExecutorJdbcTest {
|
||||||
TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
|
TPQExecutorJdbc exe = new TPQExecutorJdbc(store.getQueryExecutorContext());
|
||||||
exe.execute(connection, "junit.sql-fail");
|
exe.execute(connection, "junit.sql-fail");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=SQLExceptionRuntime.class)
|
||||||
public void testTimeoutFail() throws Exception {
|
public void testTimeoutFail() throws Exception {
|
||||||
assertThrows(SQLExceptionRuntime.class, () -> {
|
|
||||||
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem:test")
|
.createQuerySet("junit", "jar:junit:mem:test")
|
||||||
|
@ -160,12 +155,10 @@ public class TPQExecutorJdbcTest {
|
||||||
ps.close();
|
ps.close();
|
||||||
exe.prepareTimeout(ps, 123);
|
exe.prepareTimeout(ps, 123);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=SQLExceptionRuntime.class)
|
||||||
public void testParameterFail() throws Exception {
|
public void testParameterFail() throws Exception {
|
||||||
assertThrows(SQLExceptionRuntime.class, () -> {
|
|
||||||
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;")) {
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem:test")
|
.createQuerySet("junit", "jar:junit:mem:test")
|
||||||
|
@ -179,7 +172,6 @@ public class TPQExecutorJdbcTest {
|
||||||
PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
|
PreparedStatement ps = exe.createPreparedStatement(connection, "junit.test", null);
|
||||||
exe.prepareParameterValue(ps, 1, 123);
|
exe.prepareParameterValue(ps, 1, 123);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package net.forwardfire.tpquery.store.executor.jpa;
|
package net.forwardfire.tpquery.store.executor.jpa;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,42 +12,44 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.Persistence;
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
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.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
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 {
|
public class TPQExecutorJpaTest {
|
||||||
|
|
||||||
private EntityManagerFactory emFactory;
|
private EntityManagerFactory emFactory;
|
||||||
private EntityManager em = null;
|
private EntityManager em = null;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeClass
|
||||||
public static void setupLogging() {
|
public static void setupLogging() {
|
||||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
lc.reset(); // disable logging
|
lc.reset(); // disable logging
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
emFactory = Persistence.createEntityManagerFactory("junit");
|
emFactory = Persistence.createEntityManagerFactory("junit");
|
||||||
em = emFactory.createEntityManager();
|
em = emFactory.createEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@After
|
||||||
public void close() {
|
public void close() {
|
||||||
em.close();
|
em.close();
|
||||||
emFactory.close();
|
emFactory.close();
|
||||||
|
@ -115,9 +116,8 @@ public class TPQExecutorJpaTest {
|
||||||
//assertEquals("foobar",resultSingle.name);
|
//assertEquals("foobar",resultSingle.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testUnsupportedLanguage() throws Exception {
|
public void testUnsupportedLanguage() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig config = new TPQConfig();
|
TPQConfig config = new TPQConfig();
|
||||||
config.addStatementLanguage(new TPQStatementLanguage() {
|
config.addStatementLanguage(new TPQStatementLanguage() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,12 +142,10 @@ public class TPQExecutorJpaTest {
|
||||||
.build();
|
.build();
|
||||||
TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
|
TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
|
||||||
exe.selectList(em, "junit.test", null);
|
exe.selectList(em, "junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test()
|
||||||
public void testQueryProxy() throws Exception {
|
public void testQueryProxy() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.HQL)
|
.setLanguage(TPQFactory.StatementLanguage.HQL)
|
||||||
|
@ -198,7 +196,6 @@ public class TPQExecutorJpaTest {
|
||||||
|
|
||||||
d = foobarService.testFoo();
|
d = foobarService.testFoo();
|
||||||
assertNotNull(d);
|
assertNotNull(d);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TPQueryProxy(prefix="junit.")
|
@TPQueryProxy(prefix="junit.")
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -23,21 +22,6 @@
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-impl</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-core</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package net.forwardfire.tpquery;
|
package net.forwardfire.tpquery;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
|
|
||||||
public class TPQFactoryTest {
|
public class TPQFactoryTest {
|
||||||
|
|
|
@ -11,14 +11,15 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.AfterClass;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
||||||
|
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
|
||||||
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorContext;
|
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorContext;
|
||||||
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorStatement;
|
import net.forwardfire.tpquery.store.manager.TPQStoreManagerExecutorStatement;
|
||||||
|
|
||||||
|
@ -27,17 +28,17 @@ public class TPQSpeedTest {
|
||||||
static int loopSize;
|
static int loopSize;
|
||||||
static int warmupSize;
|
static int warmupSize;
|
||||||
static TPQManager queryManager;
|
static TPQManager queryManager;
|
||||||
static List<String> result = new ArrayList<>();;
|
static List<String> result;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeClass
|
||||||
static public void initSpeedTest() throws Exception {
|
static public void initSpeedTest() throws Exception {
|
||||||
|
|
||||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
lc.reset(); // disable logging in speed tests.
|
lc.reset(); // disable logging in speed tests.
|
||||||
|
|
||||||
warmupSize = 10;
|
warmupSize = 10;
|
||||||
loopSize = 100000 * Integer.parseInt(System.getProperty("junit.speedtest.factor", "1"));
|
loopSize = 100000*new Integer(System.getProperty("junit.speedtest.factor", "1"));
|
||||||
|
result = new ArrayList<>();
|
||||||
queryManager = TPQFactory.createManagerBuilder()
|
queryManager = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
|
@ -121,7 +122,7 @@ public class TPQSpeedTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterClass
|
||||||
public static void printResults() {
|
public static void printResults() {
|
||||||
|
|
||||||
TPQStoreManagerExecutorContext exeCtx = (TPQStoreManagerExecutorContext)queryManager.getQueryExecutorContext();
|
TPQStoreManagerExecutorContext exeCtx = (TPQStoreManagerExecutorContext)queryManager.getQueryExecutorContext();
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package net.forwardfire.tpquery.config;
|
package net.forwardfire.tpquery.config;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
public class TPQueryStoreConfigBuilderTest {
|
public class TPQueryStoreConfigBuilderTest {
|
||||||
|
@ -39,9 +38,9 @@ public class TPQueryStoreConfigBuilderTest {
|
||||||
assertNotNull(manager.getQueryStore().getQueryNames());
|
assertNotNull(manager.getQueryStore().getQueryNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testBuildTreeInvalid() throws Exception {
|
public void testBuildTreeInvalid() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> TPQFactory
|
TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:mem:test")
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
.createQuery("test").parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
|
.createQuery("test").parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
|
||||||
|
@ -57,7 +56,7 @@ public class TPQueryStoreConfigBuilderTest {
|
||||||
.buildTree()
|
.buildTree()
|
||||||
// buildTree() should be here
|
// buildTree() should be here
|
||||||
.build()
|
.build()
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -129,17 +128,17 @@ public class TPQueryStoreConfigBuilderTest {
|
||||||
assertNotNull(q.getName());
|
assertNotNull(q.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQConfigException.class)
|
||||||
public void testReadQuerySetFileNotFound() throws Exception {
|
public void testReadQuerySetFileNotFound() throws Exception {
|
||||||
assertThrows(TPQConfigException.class, () -> TPQFactory.createManagerBuilder()
|
TPQFactory.createManagerBuilder()
|
||||||
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query.not-found"))
|
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query.not-found"))
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQConfigException.class)
|
||||||
public void testReadQuerySetInvalidContext() throws Exception {
|
public void testReadQuerySetInvalidContext() throws Exception {
|
||||||
assertThrows(TPQConfigException.class, () -> TPQFactory.createManagerBuilder()
|
TPQFactory.createManagerBuilder()
|
||||||
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query-invalid.xml"))
|
.readQuerySet(new File("./src/test/resources/net/forwardfire/tpquery/test-query-invalid.xml"))
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package net.forwardfire.tpquery.config;
|
package net.forwardfire.tpquery.config;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
|
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
|
||||||
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValue;
|
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValue;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
@ -40,40 +40,32 @@ public class TPQueryStoreConfigTest {
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testTemplateTypeAdd() throws Exception {
|
public void testTemplateTypeAdd() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.addStatementParameter(new TPQStatementParameterValue(TPQFactory.StatementParameter.VALUE));
|
c.addStatementParameter(new TPQStatementParameterValue(TPQFactory.StatementParameter.VALUE));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testTemplateTypeRemove() throws Exception {
|
public void testTemplateTypeRemove() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
|
c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
|
||||||
c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
|
c.removeStatementParameter(TPQFactory.StatementParameter.VALUE);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testLanguageTypeAdd() throws Exception {
|
public void testLanguageTypeAdd() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.addStatementLanguage(new TPQStatementLanguageSql(TPQFactory.StatementLanguage.SQL));
|
c.addStatementLanguage(new TPQStatementLanguageSql(TPQFactory.StatementLanguage.SQL));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testLanguageTypeRemove() throws Exception {
|
public void testLanguageTypeRemove() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
|
c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
|
||||||
c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
|
c.removeStatementLanguage(TPQFactory.StatementLanguage.SQL);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
|
@ -90,29 +82,23 @@ public class TPQueryStoreConfigTest {
|
||||||
c.addValueType(this.getClass().getName());
|
c.addValueType(this.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testAddValueTypeClassNameError() throws Exception {
|
public void testAddValueTypeClassNameError() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.addValueType("net.foo.bar.NoneExcistingClassName");
|
c.addValueType("net.foo.bar.NoneExcistingClassName");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testValueTypeAliasAdd() throws Exception {
|
public void testValueTypeAliasAdd() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.addValueTypeAlias("key", "v0");
|
c.addValueTypeAlias("key", "v0");
|
||||||
c.addValueTypeAlias("key", "v1");
|
c.addValueTypeAlias("key", "v1");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testValueTypeAliasRemoveIllegalKey() throws Exception {
|
public void testValueTypeAliasRemoveIllegalKey() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.removeValueTypeAlias("unknown-key");
|
c.removeValueTypeAlias("unknown-key");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -129,20 +115,16 @@ public class TPQueryStoreConfigTest {
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testQuerySetRemoveIllegalKey() throws Exception {
|
public void testQuerySetRemoveIllegalKey() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.removeQuerySet("unknown-key");
|
c.removeQuerySet("unknown-key");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testQuerySetRemoveNull() throws Exception {
|
public void testQuerySetRemoveNull() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfig();
|
TPQConfig c = TPQFactory.createConfig();
|
||||||
c.removeQuerySet(null);
|
c.removeQuerySet(null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -222,9 +204,8 @@ public class TPQueryStoreConfigTest {
|
||||||
assertNotNull(q.getName());
|
assertNotNull(q.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQConfigException.class)
|
||||||
public void testWrongClassParameterType() throws Exception {
|
public void testWrongClassParameterType() throws Exception {
|
||||||
assertThrows(TPQConfigException.class, () -> {
|
|
||||||
TPQManager manager = TPQFactory
|
TPQManager manager = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:mem:test")
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
|
@ -236,7 +217,6 @@ public class TPQueryStoreConfigTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
assertNotNull(manager);
|
assertNotNull(manager);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,32 +1,45 @@
|
||||||
package net.forwardfire.tpquery.config;
|
package net.forwardfire.tpquery.config;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
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.config.validate.TPQCheckDescriptionNotBlank;
|
import net.forwardfire.tpquery.config.validate.TPQCheckDescriptionNotBlank;
|
||||||
import net.forwardfire.tpquery.config.validate.TPQCheckNamePattern;
|
import net.forwardfire.tpquery.config.validate.TPQCheckNamePattern;
|
||||||
import net.forwardfire.tpquery.config.validate.TPQCheckParameterDefaultValueNotBlank;
|
import net.forwardfire.tpquery.config.validate.TPQCheckParameterDefaultValueNotBlank;
|
||||||
import net.forwardfire.tpquery.config.validate.TPQCheckParameterNamePattern;
|
import net.forwardfire.tpquery.config.validate.TPQCheckParameterNamePattern;
|
||||||
import net.forwardfire.tpquery.config.validate.TPQCheckParameterTypePattern;
|
import net.forwardfire.tpquery.config.validate.TPQCheckParameterTypePattern;
|
||||||
import net.forwardfire.tpquery.config.validate.TPQCheckParameterValueTypePattern;
|
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;
|
import net.forwardfire.tpquery.model.TPQuery;
|
||||||
|
|
||||||
public class TPQueryStoreConfigValidatorTest {
|
public class TPQueryStoreConfigValidatorTest {
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
public void testPatternValidators() throws Exception {
|
public void testPatternValidators() throws Exception {
|
||||||
TPQConfig config = TPQFactory.createConfigBuilder().createQuerySet("junit", "jar:mem:test")
|
TPQConfig config = TPQFactory
|
||||||
.createQuery("testCAPS")
|
.createConfigBuilder()
|
||||||
.parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
.createQuerySetTree("inc").setTemplate(true).createQuery("test").parseStatement("where a=$$a$$ ")
|
.createQuery("testCAPS").parseStatement("select * from table $$inc:junit.inc.test$$ $$inc:junit.inc.inc.test$$").build()
|
||||||
.createQueryParameter("a", Integer.class).setDefaultValue("1").build().build().createQuerySet("inc")
|
.createQuerySetTree("inc")
|
||||||
.createQuery("test").parseStatement("AND 2=2").build().build().buildTree().build().build();
|
.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 TPQCheckNamePattern(".*"));
|
||||||
config.addConfigValidator(".*", new TPQCheckParameterNamePattern(".*"));
|
config.addConfigValidator(".*", new TPQCheckParameterNamePattern(".*"));
|
||||||
|
@ -41,9 +54,8 @@ public class TPQueryStoreConfigValidatorTest {
|
||||||
assertNotNull(manager);
|
assertNotNull(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testDescriptionNotBlank() throws Exception {
|
public void testDescriptionNotBlank() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory
|
TPQConfig config = TPQFactory
|
||||||
.createConfigBuilder()
|
.createConfigBuilder()
|
||||||
.createQuerySet("junit", "jar:mem:test")
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
|
@ -64,12 +76,10 @@ public class TPQueryStoreConfigValidatorTest {
|
||||||
config.addConfigValidator(".*", new TPQCheckDescriptionNotBlank());
|
config.addConfigValidator(".*", new TPQCheckDescriptionNotBlank());
|
||||||
TPQManager manager = TPQFactory.createManager(config);
|
TPQManager manager = TPQFactory.createManager(config);
|
||||||
assertNotNull(manager);
|
assertNotNull(manager);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testParameterDefaultValueNotBlank() throws Exception {
|
public void testParameterDefaultValueNotBlank() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory
|
TPQConfig config = TPQFactory
|
||||||
.createConfigBuilder()
|
.createConfigBuilder()
|
||||||
.createQuerySet("junit", "jar:mem:test")
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
|
@ -91,12 +101,10 @@ public class TPQueryStoreConfigValidatorTest {
|
||||||
config.addConfigValidator(".*", new TPQCheckParameterDefaultValueNotBlank());
|
config.addConfigValidator(".*", new TPQCheckParameterDefaultValueNotBlank());
|
||||||
TPQManager manager = TPQFactory.createManager(config);
|
TPQManager manager = TPQFactory.createManager(config);
|
||||||
assertNotNull(manager);
|
assertNotNull(manager);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testDisableRAWExample() throws Exception {
|
public void testDisableRAWExample() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory
|
TPQConfig config = TPQFactory
|
||||||
.createConfigBuilder()
|
.createConfigBuilder()
|
||||||
.createQuerySet("junit", "jar:mem:test")
|
.createQuerySet("junit", "jar:mem:test")
|
||||||
|
@ -118,6 +126,5 @@ public class TPQueryStoreConfigValidatorTest {
|
||||||
config.addConfigValidator("junit.test-f.*", new TPQCheckParameterTypePattern("!RAW"));
|
config.addConfigValidator("junit.test-f.*", new TPQCheckParameterTypePattern("!RAW"));
|
||||||
TPQManager manager = TPQFactory.createManager(config);
|
TPQManager manager = TPQFactory.createManager(config);
|
||||||
assertNotNull(manager);
|
assertNotNull(manager);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.store.executor.AbstractTPQExecutor;
|
import net.forwardfire.tpquery.store.executor.AbstractTPQExecutor;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorContext;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorContext;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TQueryExecutorTest {
|
public class TQueryExecutorTest {
|
||||||
|
|
||||||
class TestExecutorConnection {
|
class TestExecutorConnection {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package net.forwardfire.tpquery.model;
|
package net.forwardfire.tpquery.model;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -13,10 +12,15 @@ import java.util.Map;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
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.TPQStatementPartInclude;
|
||||||
import net.forwardfire.tpquery.statement.TPQStatementPartParameter;
|
import net.forwardfire.tpquery.statement.TPQStatementPartParameter;
|
||||||
import net.forwardfire.tpquery.statement.TPQStatementPartText;
|
import net.forwardfire.tpquery.statement.TPQStatementPartText;
|
||||||
|
@ -113,9 +117,9 @@ public class ModelXMLMarshallerTest {
|
||||||
assertEquals("false",q.getQueryHints().get("junit"));
|
assertEquals("false",q.getQueryHints().get("junit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testContextException() throws Exception {
|
public void testContextException() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new ModelXMLMarshaller(JaxbContextError.class));
|
new ModelXMLMarshaller(JaxbContextError.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class JaxbContextError {
|
private static class JaxbContextError {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package net.forwardfire.tpquery.model;
|
package net.forwardfire.tpquery.model;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
public class TPQueryPropertyTest {
|
public class TPQueryPropertyTest {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package net.forwardfire.tpquery.statement;
|
package net.forwardfire.tpquery.statement;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import net.forwardfire.tpquery.statement.TPQStatementMarshallerAdapter;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class TPQueryStatementMarshallerAdapterTest {
|
public class TPQueryStatementMarshallerAdapterTest {
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
package net.forwardfire.tpquery.statement;
|
package net.forwardfire.tpquery.statement;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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;
|
||||||
|
|
||||||
public class TPQueryStatementMarshallerTest {
|
public class TPQueryStatementMarshallerTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testParseNull() throws Exception {
|
public void testParseNull() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQStatementMarshaller parser = new TPQStatementMarshaller();
|
TPQStatementMarshaller parser = new TPQStatementMarshaller();
|
||||||
parser.unmarshal(null);
|
parser.unmarshal(null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -35,7 +38,7 @@ public class TPQueryStatementMarshallerTest {
|
||||||
List<TPQStatement> result = parser.unmarshal("foobar");
|
List<TPQStatement> result = parser.unmarshal("foobar");
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
assertTrue(result.size() == 1);
|
assertTrue(result.size()==1);
|
||||||
assertNotNull(result.get(0));
|
assertNotNull(result.get(0));
|
||||||
assertTrue(result.get(0) instanceof TPQStatementPartText);
|
assertTrue(result.get(0) instanceof TPQStatementPartText);
|
||||||
}
|
}
|
||||||
|
@ -46,19 +49,19 @@ public class TPQueryStatementMarshallerTest {
|
||||||
List<TPQStatement> result = parser.unmarshal("$$foobar$$");
|
List<TPQStatement> result = parser.unmarshal("$$foobar$$");
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
assertTrue(result.size() == 1);
|
assertTrue(result.size()==1);
|
||||||
assertNotNull(result.get(0));
|
assertNotNull(result.get(0));
|
||||||
assertTrue(result.get(0) instanceof TPQStatementPartParameter);
|
assertTrue(result.get(0) instanceof TPQStatementPartParameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testParseTemplateNoEnd() throws Exception {
|
public void testParseTemplateNoEnd() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new TPQStatementMarshaller().unmarshal("$$foobar"));
|
new TPQStatementMarshaller().unmarshal("$$foobar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testParseTemplateEmpty() throws Exception {
|
public void testParseTemplateEmpty() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new TPQStatementMarshaller().unmarshal("$$$$"));
|
new TPQStatementMarshaller().unmarshal("$$$$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -67,17 +70,17 @@ public class TPQueryStatementMarshallerTest {
|
||||||
List<TPQStatement> result = parser.unmarshal("$$inc:foobar$$");
|
List<TPQStatement> result = parser.unmarshal("$$inc:foobar$$");
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
assertTrue(result.size() == 1);
|
assertTrue(result.size()==1);
|
||||||
assertNotNull(result.get(0));
|
assertNotNull(result.get(0));
|
||||||
assertTrue(result.get(0) instanceof TPQStatementPartInclude);
|
assertTrue(result.get(0) instanceof TPQStatementPartInclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
|
|
||||||
|
@Test(expected=NullPointerException.class)
|
||||||
public void testPrintNull() throws Exception {
|
public void testPrintNull() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQStatementMarshaller parser = new TPQStatementMarshaller();
|
TPQStatementMarshaller parser = new TPQStatementMarshaller();
|
||||||
parser.marshal(null);
|
parser.marshal(null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -99,6 +102,7 @@ public class TPQueryStatementMarshallerTest {
|
||||||
String result = parser.marshal(data);
|
String result = parser.marshal(data);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
assertEquals("p0p1p2", result);
|
assertEquals("p0p1p2",result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package net.forwardfire.tpquery.statement;
|
package net.forwardfire.tpquery.statement;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.Assert.assertTrue;
|
||||||
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.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQueryStatementPartIncludeTest {
|
public class TPQueryStatementPartIncludeTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testFailInclude() throws Exception {
|
public void testFailInclude() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> TPQFactory.createManagerBuilder()
|
TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem:test")
|
.createQuerySet("junit", "jar:junit:mem:test")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
.createQuery("include-missing")
|
.createQuery("include-missing")
|
||||||
|
@ -22,34 +20,33 @@ public class TPQueryStatementPartIncludeTest {
|
||||||
.appendInclude("include-missing-query")
|
.appendInclude("include-missing-query")
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncludeMultple() throws Exception {
|
public void testIncludeMultple() throws Exception {
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory
|
||||||
.readQuerySet("net/forwardfire/tpquery/test-include-multiple.xml").build();
|
.createManagerBuilder()
|
||||||
|
.readQuerySet("net/forwardfire/tpquery/test-include-multiple.xml")
|
||||||
|
.build();
|
||||||
TPQExecutorStatement q = store.getQueryExecutorContext().prepareQuery("test.multipleInclude", null);
|
TPQExecutorStatement q = store.getQueryExecutorContext().prepareQuery("test.multipleInclude", null);
|
||||||
assertNotNull(q.getName());
|
assertNotNull(q.getName());
|
||||||
assertTrue(q.getStatement().contains("price_list"));
|
assertTrue(q.getStatement().contains("price_list"));
|
||||||
assertTrue(q.getStatement().contains("key='stats_correction') AS mrt"));
|
assertTrue(q.getStatement().contains("key='stats_correction') AS mrt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testIncludeLoop() throws Exception {
|
public void testIncludeLoop() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQManager store = TPQFactory
|
TPQManager store = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.readQuerySet("net/forwardfire/tpquery/test-include-loop.xml")
|
.readQuerySet("net/forwardfire/tpquery/test-include-loop.xml")
|
||||||
.build();
|
.build();
|
||||||
store.getQueryExecutorContext().prepareQuery("test.loopInclude", null);
|
store.getQueryExecutorContext().prepareQuery("test.loopInclude", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testQueryChecked() throws Exception {
|
public void testQueryChecked() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class,
|
TPQFactory.createManagerBuilder()
|
||||||
() -> TPQFactory.createManagerBuilder()
|
|
||||||
.createQuerySet("junit", "jar:junit:mem:test")
|
.createQuerySet("junit", "jar:junit:mem:test")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
.createQuery("test")
|
.createQuery("test")
|
||||||
|
@ -59,6 +56,6 @@ public class TPQueryStatementPartIncludeTest {
|
||||||
.appendInclude("junit.test")
|
.appendInclude("junit.test")
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
package net.forwardfire.tpquery.statement;
|
package net.forwardfire.tpquery.statement;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
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.AbstractTPQStatementLanguage;
|
||||||
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
|
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQueryStatementWriterTest {
|
public class TPQueryStatementWriterTest {
|
||||||
|
|
||||||
private TPQStatementWriter createWriter() {
|
private TPQStatementWriter createWriter() {
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package net.forwardfire.tpquery.statement.language;
|
package net.forwardfire.tpquery.statement.language;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
||||||
|
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageHql;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQStatementLanguageHqlTest {
|
public class TPQStatementLanguageHqlTest {
|
||||||
|
|
||||||
private TPQStatementWriter createWriter() {
|
private TPQStatementWriter createWriter() {
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package net.forwardfire.tpquery.statement.language;
|
package net.forwardfire.tpquery.statement.language;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
||||||
|
import net.forwardfire.tpquery.statement.language.TPQStatementLanguageSql;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
import net.forwardfire.tpquery.store.TPQueryStoreStatementMapper;
|
||||||
|
|
||||||
public class TPQStatementLanguageSqlTest {
|
public class TPQStatementLanguageSqlTest {
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package net.forwardfire.tpquery.statement.parameter;
|
package net.forwardfire.tpquery.statement.parameter;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQueryParameterDefaultValueTest {
|
public class TPQueryParameterDefaultValueTest {
|
||||||
|
|
||||||
@Test
|
@Test()
|
||||||
public void testRawString() throws Exception {
|
public void testRawString() throws Exception {
|
||||||
TPQConfig config = TPQFactory
|
TPQConfig config = TPQFactory
|
||||||
.createConfigBuilder()
|
.createConfigBuilder()
|
||||||
|
@ -45,7 +44,7 @@ public class TPQueryParameterDefaultValueTest {
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
.createQuery("test")
|
.createQuery("test")
|
||||||
.parseStatement("select * from foobar where a=$$a$$")
|
.parseStatement("select * from foobar where a=$$a$$")
|
||||||
.createQueryParameter("a", TPQFactory.ParameterValueType.DOUBLE)
|
.createQueryParameter("a", TPQFactory.ParameterValueType.LONG)
|
||||||
.setDefaultValue("js:epoch()")
|
.setDefaultValue("js:epoch()")
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
|
@ -55,7 +54,7 @@ public class TPQueryParameterDefaultValueTest {
|
||||||
TPQExecutorStatement prepared = store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
TPQExecutorStatement prepared = store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
||||||
assertTrue(!prepared.getParameters().isEmpty());
|
assertTrue(!prepared.getParameters().isEmpty());
|
||||||
assertTrue(prepared.getParameters().get(0) != null);
|
assertTrue(prepared.getParameters().get(0) != null);
|
||||||
assertTrue(prepared.getParameters().get(0) instanceof Double);
|
assertTrue(prepared.getParameters().get(0) instanceof Long);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -122,9 +121,8 @@ public class TPQueryParameterDefaultValueTest {
|
||||||
assertTrue(prepared.getParameters().get(0) instanceof java.lang.Integer);
|
assertTrue(prepared.getParameters().get(0) instanceof java.lang.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=Exception.class)
|
||||||
public void testCreateObjectConstructorWrongClass() throws Exception {
|
public void testCreateObjectConstructorWrongClass() throws Exception {
|
||||||
assertThrows(Exception.class, () -> {
|
|
||||||
TPQManager store = TPQFactory
|
TPQManager store = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
|
@ -138,6 +136,5 @@ public class TPQueryParameterDefaultValueTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
store.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.forwardfire.tpquery.statement.parameter;
|
package net.forwardfire.tpquery.statement.parameter;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -9,10 +8,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.model.TPQuery;
|
import net.forwardfire.tpquery.model.TPQuery;
|
||||||
import net.forwardfire.tpquery.model.TPQueryParameter;
|
import net.forwardfire.tpquery.model.TPQueryParameter;
|
||||||
import net.forwardfire.tpquery.model.TPQuerySet;
|
import net.forwardfire.tpquery.model.TPQuerySet;
|
||||||
|
@ -21,9 +20,8 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
public class TPQueryParameterTypeListTest {
|
public class TPQueryParameterTypeListTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testNullValue() throws Exception {
|
public void testNullValue() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
q.addQueryPart(new TPQStatementPartParameter("param"));
|
q.addQueryPart(new TPQStatementPartParameter("param"));
|
||||||
|
@ -41,12 +39,10 @@ public class TPQueryParameterTypeListTest {
|
||||||
|
|
||||||
Map<String,Object> para = new HashMap<String,Object>();
|
Map<String,Object> para = new HashMap<String,Object>();
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testEmptyValue() throws Exception {
|
public void testEmptyValue() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
q.addQueryPart(new TPQStatementPartParameter("param"));
|
q.addQueryPart(new TPQStatementPartParameter("param"));
|
||||||
|
@ -64,12 +60,10 @@ public class TPQueryParameterTypeListTest {
|
||||||
Map<String,Object> para = new HashMap<String,Object>();
|
Map<String,Object> para = new HashMap<String,Object>();
|
||||||
para.put("param", new ArrayList<String>());
|
para.put("param", new ArrayList<String>());
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testWrongValue() throws Exception {
|
public void testWrongValue() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
q.addQueryPart(new TPQStatementPartParameter("param"));
|
q.addQueryPart(new TPQStatementPartParameter("param"));
|
||||||
|
@ -87,7 +81,6 @@ public class TPQueryParameterTypeListTest {
|
||||||
Map<String,Object> para = new HashMap<String,Object>();
|
Map<String,Object> para = new HashMap<String,Object>();
|
||||||
para.put("param", new HashMap<String,String>());
|
para.put("param", new HashMap<String,String>());
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
store.getQueryExecutorContext().prepareQuery("junit.test", para);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package net.forwardfire.tpquery.statement.parameter;
|
package net.forwardfire.tpquery.statement.parameter;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.model.TPQuery;
|
import net.forwardfire.tpquery.model.TPQuery;
|
||||||
import net.forwardfire.tpquery.model.TPQueryParameter;
|
import net.forwardfire.tpquery.model.TPQueryParameter;
|
||||||
import net.forwardfire.tpquery.model.TPQuerySet;
|
import net.forwardfire.tpquery.model.TPQuerySet;
|
||||||
|
@ -19,7 +19,7 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
public class TPQueryParameterTypeRawTest {
|
public class TPQueryParameterTypeRawTest {
|
||||||
|
|
||||||
@Test
|
@Test()
|
||||||
public void testTypeRaw() throws Exception {
|
public void testTypeRaw() throws Exception {
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
|
@ -49,7 +49,7 @@ public class TPQueryParameterTypeRawTest {
|
||||||
assertEquals(0,queryPreparedValue.getParameters().size());
|
assertEquals(0,queryPreparedValue.getParameters().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test()
|
||||||
public void testTypeRawNull() throws Exception {
|
public void testTypeRawNull() throws Exception {
|
||||||
TPQManager store = TPQFactory.createManagerBuilder()
|
TPQManager store = TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem:test")
|
.createQuerySet("junit", "jar:junit:mem:test")
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package net.forwardfire.tpquery.statement.parameter;
|
package net.forwardfire.tpquery.statement.parameter;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.model.TPQuery;
|
import net.forwardfire.tpquery.model.TPQuery;
|
||||||
import net.forwardfire.tpquery.model.TPQueryParameter;
|
import net.forwardfire.tpquery.model.TPQueryParameter;
|
||||||
import net.forwardfire.tpquery.model.TPQuerySet;
|
import net.forwardfire.tpquery.model.TPQuerySet;
|
||||||
|
@ -18,9 +17,8 @@ import net.forwardfire.tpquery.store.executor.TPQExecutorStatement;
|
||||||
|
|
||||||
public class TPQueryParameterTypeValueTest {
|
public class TPQueryParameterTypeValueTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected=NullPointerException.class)
|
||||||
public void testMissingParameter() throws Exception {
|
public void testMissingParameter() throws Exception {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
q.addQueryPart(new TPQStatementPartParameter("missing-param"));
|
q.addQueryPart(new TPQStatementPartParameter("missing-param"));
|
||||||
|
@ -29,12 +27,10 @@ public class TPQueryParameterTypeValueTest {
|
||||||
qs.addQuery(q);
|
qs.addQuery(q);
|
||||||
TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:testMissingParameter",qs).build();
|
TPQManager store = TPQFactory.createManagerBuilder().addQuerySet("jar:junit:mem:testMissingParameter",qs).build();
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", null);
|
store.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testTypeParamWrongType() throws Exception {
|
public void testTypeParamWrongType() throws Exception {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
TPQuery q = new TPQuery();
|
TPQuery q = new TPQuery();
|
||||||
q.setName("test");
|
q.setName("test");
|
||||||
q.addQueryPart(new TPQStatementPartParameter("param"));
|
q.addQueryPart(new TPQStatementPartParameter("param"));
|
||||||
|
@ -51,7 +47,6 @@ public class TPQueryParameterTypeValueTest {
|
||||||
Map<String,Object> paraValue = new HashMap<String,Object>();
|
Map<String,Object> paraValue = new HashMap<String,Object>();
|
||||||
paraValue.put("param", "test");
|
paraValue.put("param", "test");
|
||||||
store.getQueryExecutorContext().prepareQuery("junit.test", paraValue);
|
store.getQueryExecutorContext().prepareQuery("junit.test", paraValue);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package net.forwardfire.tpquery.store;
|
package net.forwardfire.tpquery.store;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQueryStoreTest {
|
public class TPQueryStoreTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package net.forwardfire.tpquery.store.manager;
|
package net.forwardfire.tpquery.store.manager;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -16,15 +15,15 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterListMapper;
|
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterListMapper;
|
||||||
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValueMapper;
|
import net.forwardfire.tpquery.statement.parameter.TPQStatementParameterValueMapper;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
|
import net.forwardfire.tpquery.store.TPQueryStoreStatement;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQStoreManagerStatementCacheTest {
|
public class TPQStoreManagerStatementCacheTest {
|
||||||
|
|
||||||
private Lock createFailingLock(boolean lockOke) {
|
private Lock createFailingLock(boolean lockOke) {
|
||||||
|
@ -41,9 +40,8 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailPut() throws Exception {
|
public void testCacheFailPut() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
Map<String,TPQueryStoreStatement> cc = new HashMap<String,TPQueryStoreStatement>() {
|
Map<String,TPQueryStoreStatement> cc = new HashMap<String,TPQueryStoreStatement>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,12 +61,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailPutLock() throws Exception {
|
public void testCacheFailPutLock() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,12 +83,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailPutUnlock() throws Exception {
|
public void testCacheFailPutUnlock() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,13 +105,11 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailGet() throws Exception {
|
public void testCacheFailGet() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
Map<String,TPQueryStoreStatement> cc = new HashMap<String,TPQueryStoreStatement>() {
|
Map<String,TPQueryStoreStatement> cc = new HashMap<String,TPQueryStoreStatement>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -138,12 +130,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailGetLock() throws Exception {
|
public void testCacheFailGetLock() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -162,12 +152,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testCacheFailGetUnlock() throws Exception {
|
public void testCacheFailGetUnlock() throws Exception {
|
||||||
assertThrows(IllegalStateException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
config.setStatementCache(new TPQStoreManagerStatementCache(new HashMap<String,TPQueryStoreStatement>()) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,7 +174,6 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
queryManager.getQueryExecutorContext().prepareQuery("junit.test", null);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -230,9 +217,8 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
assertEquals(cache.size(),cache2.size());
|
assertEquals(cache.size(),cache2.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=Exception.class)
|
||||||
public void testCacheStatementReadObjectNoData() throws Exception {
|
public void testCacheStatementReadObjectNoData() throws Exception {
|
||||||
assertThrows(Exception.class, () -> {
|
|
||||||
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
||||||
|
@ -252,12 +238,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
Method m = TPQueryStoreStatement.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
Method m = TPQueryStoreStatement.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
m.invoke(c, new Object[]{});
|
m.invoke(c, new Object[]{});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=Exception.class)
|
||||||
public void testCacheValueMapperReadObjectNoData() throws Exception {
|
public void testCacheValueMapperReadObjectNoData() throws Exception {
|
||||||
assertThrows(Exception.class, () -> {
|
|
||||||
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
||||||
|
@ -277,12 +261,10 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
Method m = TPQStatementParameterValueMapper.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
Method m = TPQStatementParameterValueMapper.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
m.invoke(c.getValueMapping().get(0), new Object[]{});
|
m.invoke(c.getValueMapping().get(0), new Object[]{});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=Exception.class)
|
||||||
public void testCacheListMapperReadObjectNoData() throws Exception {
|
public void testCacheListMapperReadObjectNoData() throws Exception {
|
||||||
assertThrows(Exception.class, () -> {
|
|
||||||
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
Map<String,TPQueryStoreStatement> cache = new HashMap<>();
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
config.setStatementCache(new TPQStoreManagerStatementCache(cache));
|
||||||
|
@ -302,6 +284,5 @@ public class TPQStoreManagerStatementCacheTest {
|
||||||
Method m = TPQStatementParameterListMapper.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
Method m = TPQStatementParameterListMapper.class.getDeclaredMethod("readObjectNoData", new Class<?>[]{});
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
m.invoke(c.getValueMapping().get(0), new Object[]{});
|
m.invoke(c.getValueMapping().get(0), new Object[]{});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
package net.forwardfire.tpquery.store.manager;
|
package net.forwardfire.tpquery.store.manager;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.config.TPQConfig;
|
import net.forwardfire.tpquery.config.TPQConfig;
|
||||||
import net.forwardfire.tpquery.config.TPQConfigException;
|
import net.forwardfire.tpquery.config.TPQConfigException;
|
||||||
import net.forwardfire.tpquery.store.TPQueryStoreScriptEngineException;
|
import net.forwardfire.tpquery.store.TPQueryStoreScriptEngineException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQStoreManagerTest {
|
public class TPQStoreManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQueryStoreScriptEngineException.class)
|
||||||
public void testParameterValueScriptError() throws Exception {
|
public void testParameterValueScriptError() throws Exception {
|
||||||
assertThrows(TPQueryStoreScriptEngineException.class, () -> {
|
|
||||||
TPQConfig config = TPQFactory.createConfig();
|
TPQConfig config = TPQFactory.createConfig();
|
||||||
config.addParameterValueScript("throw 'error'");
|
config.addParameterValueScript("throw 'error'");
|
||||||
TPQFactory
|
TPQFactory
|
||||||
|
@ -31,12 +28,10 @@ public class TPQStoreManagerTest {
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQueryStoreScriptEngineException.class)
|
||||||
public void testCompileScriptError() throws Exception {
|
public void testCompileScriptError() throws Exception {
|
||||||
assertThrows(TPQueryStoreScriptEngineException.class, () -> {
|
|
||||||
TPQManager manager = TPQFactory
|
TPQManager manager = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
|
@ -50,12 +45,10 @@ public class TPQStoreManagerTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=Exception.class)
|
||||||
public void testRuntimeScriptError() throws Exception {
|
public void testRuntimeScriptError() throws Exception {
|
||||||
assertThrows(Exception.class, () -> {
|
|
||||||
TPQManager manager = TPQFactory
|
TPQManager manager = TPQFactory
|
||||||
.createManagerBuilder()
|
.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
|
@ -69,12 +62,10 @@ public class TPQStoreManagerTest {
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
manager.getQueryExecutorContext().prepareQuery("junit.test", new HashMap<String,Object>());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQConfigException.class)
|
||||||
public void testConfigErrorByTPQStoreManagerConfig() throws Exception {
|
public void testConfigErrorByTPQStoreManagerConfig() throws Exception {
|
||||||
assertThrows(TPQConfigException.class, () ->
|
|
||||||
TPQFactory.createManagerBuilder()
|
TPQFactory.createManagerBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
|
@ -84,12 +75,12 @@ public class TPQStoreManagerTest {
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
.build()
|
.build()
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=TPQConfigException.class)
|
||||||
public void testConfigErrorByTPQStoreManager() throws Exception {
|
public void testConfigErrorByTPQStoreManager() throws Exception {
|
||||||
assertThrows(TPQConfigException.class, () -> {
|
|
||||||
TPQConfig c = TPQFactory.createConfigBuilder()
|
TPQConfig c = TPQFactory.createConfigBuilder()
|
||||||
.createQuerySet("junit", "jar:junit:mem")
|
.createQuerySet("junit", "jar:junit:mem")
|
||||||
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
.setLanguage(TPQFactory.StatementLanguage.SQL)
|
||||||
|
@ -105,6 +96,5 @@ public class TPQStoreManagerTest {
|
||||||
smc.getEntries().get("junit.test").getQuery().getQueryParameters().get(0).setValueType("net.foo.bar.NoneExcistingClass");
|
smc.getEntries().get("junit.test").getQuery().getQueryParameters().get(0).setValueType("net.foo.bar.NoneExcistingClass");
|
||||||
|
|
||||||
new TPQStoreManager(smc);
|
new TPQStoreManager(smc);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package net.forwardfire.tpquery.store.proxy;
|
package net.forwardfire.tpquery.store.proxy;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import net.forwardfire.tpquery.TPQFactory;
|
import net.forwardfire.tpquery.TPQFactory;
|
||||||
import net.forwardfire.tpquery.TPQManager;
|
import net.forwardfire.tpquery.TPQManager;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TPQueryProxyFactoryTest {
|
public class TPQueryProxyFactoryTest {
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
|
Loading…
Reference in a new issue