[Task-3]-updated java11 and junit5
This commit is contained in:
parent
ccd7320be5
commit
e8fb5b6181
28 changed files with 873 additions and 798 deletions
|
|
@ -1,8 +1,9 @@
|
|||
package net.forwardfire.tpquery.store.executor.jpa;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -12,44 +13,42 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
import net.forwardfire.tpquery.TPQManager;
|
||||
import net.forwardfire.tpquery.TPQFactory;
|
||||
import net.forwardfire.tpquery.config.TPQConfig;
|
||||
import net.forwardfire.tpquery.statement.AbstractTPQStatementWriter;
|
||||
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
||||
import net.forwardfire.tpquery.statement.TPQStatementLanguage;
|
||||
import net.forwardfire.tpquery.store.executor.jpa.TPQExecutorJpa;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryName;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryProxyFactory;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryParameterName;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryProxy;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import net.forwardfire.tpquery.TPQFactory;
|
||||
import net.forwardfire.tpquery.TPQManager;
|
||||
import net.forwardfire.tpquery.config.TPQConfig;
|
||||
import net.forwardfire.tpquery.statement.AbstractTPQStatementWriter;
|
||||
import net.forwardfire.tpquery.statement.TPQStatementLanguage;
|
||||
import net.forwardfire.tpquery.statement.TPQStatementWriter;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryName;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryParameterName;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryProxy;
|
||||
import net.forwardfire.tpquery.store.proxy.TPQueryProxyFactory;
|
||||
|
||||
public class TPQExecutorJpaTest {
|
||||
|
||||
private EntityManagerFactory emFactory;
|
||||
private EntityManager em = null;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setupLogging() {
|
||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
lc.reset(); // disable logging
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
emFactory = Persistence.createEntityManagerFactory("junit");
|
||||
em = emFactory.createEntityManager();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void close() {
|
||||
em.close();
|
||||
emFactory.close();
|
||||
|
|
@ -116,36 +115,39 @@ public class TPQExecutorJpaTest {
|
|||
//assertEquals("foobar",resultSingle.name);
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test
|
||||
public void testUnsupportedLanguage() throws Exception {
|
||||
TPQConfig config = new TPQConfig();
|
||||
config.addStatementLanguage(new TPQStatementLanguage() {
|
||||
@Override
|
||||
public String getLanguageType() {
|
||||
return "XQL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TPQStatementWriter createQueryWriter(Map<String, Object> parameterData) {
|
||||
return new AbstractTPQStatementWriter(parameterData) {
|
||||
};
|
||||
}
|
||||
});
|
||||
TPQManager store = TPQFactory
|
||||
.createManagerBuilder(config)
|
||||
.createQuerySet("junit", "jar:mem:test")
|
||||
.createQuery("test")
|
||||
.setLanguage("XQL")
|
||||
.parseStatement("select * from table")
|
||||
assertThrows(NullPointerException.class, () -> {
|
||||
TPQConfig config = new TPQConfig();
|
||||
config.addStatementLanguage(new TPQStatementLanguage() {
|
||||
@Override
|
||||
public String getLanguageType() {
|
||||
return "XQL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TPQStatementWriter createQueryWriter(Map<String, Object> parameterData) {
|
||||
return new AbstractTPQStatementWriter(parameterData) {
|
||||
};
|
||||
}
|
||||
});
|
||||
TPQManager store = TPQFactory
|
||||
.createManagerBuilder(config)
|
||||
.createQuerySet("junit", "jar:mem:test")
|
||||
.createQuery("test")
|
||||
.setLanguage("XQL")
|
||||
.parseStatement("select * from table")
|
||||
.build()
|
||||
.build()
|
||||
.build()
|
||||
.build();
|
||||
TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
|
||||
exe.selectList(em, "junit.test", null);
|
||||
.build();
|
||||
TPQExecutorJpa exe = new TPQExecutorJpa(store.getQueryExecutorContext());
|
||||
exe.selectList(em, "junit.test", null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test
|
||||
public void testQueryProxy() throws Exception {
|
||||
assertThrows(NullPointerException.class, () -> {
|
||||
TPQManager store = TPQFactory.createManagerBuilder()
|
||||
.createQuerySet("junit", "jar:junit:mem")
|
||||
.setLanguage(TPQFactory.StatementLanguage.HQL)
|
||||
|
|
@ -196,6 +198,7 @@ public class TPQExecutorJpaTest {
|
|||
|
||||
d = foobarService.testFoo();
|
||||
assertNotNull(d);
|
||||
});
|
||||
}
|
||||
|
||||
@TPQueryProxy(prefix="junit.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue