mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
Add tests
This commit is contained in:
parent
dfefd0c982
commit
661d0c8564
@ -13,12 +13,11 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import com.mysema.query.dml.DMLClause;
|
||||
import com.mysema.query.sql.*;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
@ -26,16 +25,13 @@ import com.mysema.query.sql.dml.SQLMergeClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
import com.mysema.query.sql.mysql.MySQLReplaceClause;
|
||||
import com.mysema.query.sql.teradata.TeradataQuery;
|
||||
|
||||
import com.mysema.query.sql.types.XMLAsStringType;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.MethodRule;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mysema.query.dml.DMLClause;
|
||||
|
||||
public abstract class AbstractBaseTest {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(AbstractBaseTest.class);
|
||||
@ -81,6 +77,13 @@ public abstract class AbstractBaseTest {
|
||||
@Nullable
|
||||
protected String expectedQuery;
|
||||
|
||||
public AbstractBaseTest() {
|
||||
// TODO enable registration of (jdbc type, java type) -> usertype mappings
|
||||
if (target == Target.POSTGRES || target == Target.ORACLE) {
|
||||
configuration.register("xml_test", "col", new XMLAsStringType());
|
||||
}
|
||||
}
|
||||
|
||||
@Rule
|
||||
public static MethodRule skipForQuotedRule = new SkipForQuotedRule();
|
||||
|
||||
|
||||
@ -286,6 +286,11 @@ public final class Connections {
|
||||
stmt.execute("drop table if exists DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
stmt.execute("drop table if exists XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
cubridInited = true;
|
||||
}
|
||||
|
||||
@ -341,6 +346,11 @@ public final class Connections {
|
||||
|
||||
dropTable(templates, "DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
derbyInited = true;
|
||||
}
|
||||
|
||||
@ -450,6 +460,11 @@ public final class Connections {
|
||||
dropTable(templates, "DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
firebirdInited = true;
|
||||
}
|
||||
|
||||
@ -517,6 +532,11 @@ public final class Connections {
|
||||
stmt.execute("drop table DATE_TEST if exists");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
h2Inited = true;
|
||||
}
|
||||
|
||||
@ -578,6 +598,11 @@ public final class Connections {
|
||||
stmt.execute("drop table DATE_TEST if exists");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
hsqlInited = true;
|
||||
}
|
||||
|
||||
@ -643,6 +668,11 @@ public final class Connections {
|
||||
stmt.execute("drop table if exists DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
stmt.execute("drop table if exists XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
mysqlInited = true;
|
||||
}
|
||||
|
||||
@ -716,6 +746,11 @@ public final class Connections {
|
||||
// date_test and time_test
|
||||
dropTable(templates, "DATE_TEST");
|
||||
stmt.execute("create table date_test(date_test date)");
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col XMLTYPE)");
|
||||
|
||||
oracleInited = true;
|
||||
}
|
||||
|
||||
@ -803,6 +838,11 @@ public final class Connections {
|
||||
dropTable(templates, "DATE_TEST");
|
||||
stmt.execute(quote(CREATE_TABLE_TIMETEST, "TIME_TEST"));
|
||||
stmt.execute(quote(CREATE_TABLE_DATETEST, "DATE_TEST"));
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table \"XML_TEST\"(\"col\" XML)");
|
||||
|
||||
postgresInited = true;
|
||||
}
|
||||
|
||||
@ -865,6 +905,11 @@ public final class Connections {
|
||||
stmt.execute("drop table if exists DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
stmt.execute("drop table if exists XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col varchar(128))");
|
||||
|
||||
sqliteInited = true;
|
||||
}
|
||||
|
||||
@ -916,6 +961,11 @@ public final class Connections {
|
||||
dropTable(templates, "DATE_TEST");
|
||||
stmt.execute(CREATE_TABLE_TIMETEST);
|
||||
stmt.execute(CREATE_TABLE_DATETEST);
|
||||
|
||||
// xml
|
||||
dropTable(templates, "XML_TEST");
|
||||
stmt.execute("create table XML_TEST(col XML)");
|
||||
|
||||
sqlServerInited = true;
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ public class InsertBase extends AbstractBaseTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws SQLException{
|
||||
public void setUp() throws SQLException {
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -430,4 +430,13 @@ public class InsertBase extends AbstractBaseTest {
|
||||
assertEquals(uuid, query().from(uuids).singleResult(uuids.field));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void XML() {
|
||||
delete(QXmlTest.xmlTest).execute();
|
||||
QXmlTest xmlTest = QXmlTest.xmlTest;
|
||||
String contents = "<html><head></head><body></body></html>";
|
||||
insert(xmlTest).set(xmlTest.col, contents).execute();
|
||||
assertEquals(contents, query().from(xmlTest).singleResult(xmlTest.col));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package com.mysema.query.sql.domain;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.sql.Types;
|
||||
|
||||
import com.mysema.query.sql.ColumnMetadata;
|
||||
import com.mysema.query.sql.spatial.RelationalPathSpatial;
|
||||
import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.PathMetadata;
|
||||
import com.mysema.query.types.path.StringPath;
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* QXmlTest is a Querydsl query type for QXmlTest
|
||||
*/
|
||||
@Generated("com.mysema.query.sql.codegen.MetaDataSerializer")
|
||||
public class QXmlTest extends RelationalPathSpatial<QXmlTest> {
|
||||
|
||||
private static final long serialVersionUID = 574759316;
|
||||
|
||||
public static final QXmlTest xmlTest = new QXmlTest("xml_test");
|
||||
|
||||
public final StringPath col = createString("col");
|
||||
|
||||
public QXmlTest(String variable) {
|
||||
super(QXmlTest.class, forVariable(variable), "public", "xml_test");
|
||||
addMetadata();
|
||||
}
|
||||
|
||||
public QXmlTest(String variable, String schema, String table) {
|
||||
super(QXmlTest.class, forVariable(variable), schema, table);
|
||||
addMetadata();
|
||||
}
|
||||
|
||||
public QXmlTest(Path<? extends QXmlTest> path) {
|
||||
super(path.getType(), path.getMetadata(), "public", "xml_test");
|
||||
addMetadata();
|
||||
}
|
||||
|
||||
public QXmlTest(PathMetadata<?> metadata) {
|
||||
super(QXmlTest.class, metadata, "public", "xml_test");
|
||||
addMetadata();
|
||||
}
|
||||
|
||||
public void addMetadata() {
|
||||
addMetadata(col, ColumnMetadata.named("col").withIndex(1).ofType(Types.SQLXML).withSize(2147483647));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user