mirror of https://github.com/apache/nifi.git
[NIFI-1411] - TestJdbcTypesDerby: java.sql.SQLSyntaxErrorException: TYPE 'DATETIME' does not exist
This commit is contained in:
parent
9ebcc9e4fa
commit
e1588d4136
|
@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -44,14 +43,17 @@ import org.apache.avro.generic.GenericRecord;
|
|||
import org.apache.avro.io.DatumReader;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
public class TestJdbcCommon {
|
||||
|
||||
final static String DB_LOCATION = "target/db";
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
|
@ -65,10 +67,9 @@ public class TestJdbcCommon {
|
|||
public void testCreateSchema() throws ClassNotFoundException, SQLException {
|
||||
|
||||
// remove previous test database, if any
|
||||
final File dbLocation = new File(DB_LOCATION);
|
||||
dbLocation.delete();
|
||||
folder.delete();
|
||||
|
||||
final Connection con = createConnection();
|
||||
final Connection con = createConnection(folder.getRoot().getAbsolutePath());
|
||||
final Statement st = con.createStatement();
|
||||
|
||||
try {
|
||||
|
@ -102,10 +103,9 @@ public class TestJdbcCommon {
|
|||
@Test
|
||||
public void testConvertToBytes() throws ClassNotFoundException, SQLException, IOException {
|
||||
// remove previous test database, if any
|
||||
final File dbLocation = new File(DB_LOCATION);
|
||||
dbLocation.delete();
|
||||
folder.delete();
|
||||
|
||||
final Connection con = createConnection();
|
||||
final Connection con = createConnection(folder.getRoot().getAbsolutePath());
|
||||
final Statement st = con.createStatement();
|
||||
|
||||
try {
|
||||
|
@ -136,8 +136,8 @@ public class TestJdbcCommon {
|
|||
|
||||
final InputStream instream = new ByteArrayInputStream(serializedBytes);
|
||||
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<GenericRecord>(instream, datumReader)) {
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<>(instream, datumReader)) {
|
||||
GenericRecord record = null;
|
||||
while (dataFileReader.hasNext()) {
|
||||
// Reuse record object by passing it to next(). This saves us from
|
||||
|
@ -282,8 +282,8 @@ public class TestJdbcCommon {
|
|||
|
||||
final InputStream instream = new ByteArrayInputStream(serializedBytes);
|
||||
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<GenericRecord>(instream, datumReader)) {
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<>(instream, datumReader)) {
|
||||
GenericRecord record = null;
|
||||
while (dataFileReader.hasNext()) {
|
||||
record = dataFileReader.next(record);
|
||||
|
@ -300,11 +300,9 @@ public class TestJdbcCommon {
|
|||
assertNotNull(clazz);
|
||||
}
|
||||
|
||||
private Connection createConnection() throws ClassNotFoundException, SQLException {
|
||||
|
||||
private Connection createConnection(String location) throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
final Connection con = DriverManager.getConnection("jdbc:derby:" + DB_LOCATION + ";create=true");
|
||||
return con;
|
||||
return DriverManager.getConnection("jdbc:derby:" + location + ";create=true");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.nifi.processors.standard.util;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -36,7 +35,9 @@ import org.apache.avro.generic.GenericDatumReader;
|
|||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.avro.io.DatumReader;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
/**
|
||||
* Test streaming using large number of result set rows. 1. Read data from
|
||||
|
@ -52,7 +53,8 @@ import org.junit.Test;
|
|||
*/
|
||||
public class TestJdbcHugeStream {
|
||||
|
||||
final static String DB_LOCATION = "target/db";
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
|
@ -63,10 +65,9 @@ public class TestJdbcHugeStream {
|
|||
public void readSend2StreamHuge_FileBased() throws ClassNotFoundException, SQLException, IOException {
|
||||
|
||||
// remove previous test database, if any
|
||||
final File dbLocation = new File(DB_LOCATION);
|
||||
dbLocation.delete();
|
||||
folder.delete();
|
||||
|
||||
try (final Connection con = createConnection()) {
|
||||
try (final Connection con = createConnection(folder.getRoot().getAbsolutePath())) {
|
||||
loadTestData2Database(con, 100, 100, 100);
|
||||
|
||||
try (final Statement st = con.createStatement()) {
|
||||
|
@ -127,17 +128,17 @@ public class TestJdbcHugeStream {
|
|||
// tables may not exist, this is not serious problem.
|
||||
try {
|
||||
st.executeUpdate(dropPersons);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
st.executeUpdate(dropProducts);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
st.executeUpdate(dropRelationships);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
|
||||
st.executeUpdate(createPersons);
|
||||
|
@ -186,10 +187,9 @@ public class TestJdbcHugeStream {
|
|||
return new String(text);
|
||||
}
|
||||
|
||||
private Connection createConnection() throws ClassNotFoundException, SQLException {
|
||||
private Connection createConnection(String location) throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
final Connection con = DriverManager.getConnection("jdbc:derby:" + DB_LOCATION + ";create=true");
|
||||
return con;
|
||||
return DriverManager.getConnection("jdbc:derby:" + location + ";create=true");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
|
@ -35,7 +34,9 @@ import org.apache.avro.generic.GenericRecord;
|
|||
import org.apache.avro.io.DatumReader;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
/**
|
||||
* Useless test, Derby is so much different from MySQL
|
||||
|
@ -46,7 +47,8 @@ import org.junit.Test;
|
|||
@Ignore
|
||||
public class TestJdbcTypesDerby {
|
||||
|
||||
final static String DB_LOCATION = "target/db";
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
|
@ -59,9 +61,9 @@ public class TestJdbcTypesDerby {
|
|||
+ " password varchar(255) DEFAULT NULL, "
|
||||
+ " activation_code varchar(255) DEFAULT NULL, "
|
||||
+ " forgotten_password_code varchar(255) DEFAULT NULL, "
|
||||
+ " forgotten_password_time datetime DEFAULT NULL, "
|
||||
+ " created datetime NOT NULL, "
|
||||
+ " active tinyint NOT NULL DEFAULT 0, "
|
||||
+ " forgotten_password_time DATE DEFAULT NULL, "
|
||||
+ " created DATE NOT NULL, "
|
||||
+ " active CHAR NOT NULL DEFAULT 'N', "
|
||||
+ " home_module_id int DEFAULT NULL, "
|
||||
+ " PRIMARY KEY (id) ) " ;
|
||||
|
||||
|
@ -70,10 +72,9 @@ public class TestJdbcTypesDerby {
|
|||
@Test
|
||||
public void testSQLTypesMapping() throws ClassNotFoundException, SQLException, IOException {
|
||||
// remove previous test database, if any
|
||||
final File dbLocation = new File(DB_LOCATION);
|
||||
dbLocation.delete();
|
||||
folder.delete();
|
||||
|
||||
final Connection con = createConnection();
|
||||
final Connection con = createConnection(folder.getRoot().getAbsolutePath());
|
||||
final Statement st = con.createStatement();
|
||||
|
||||
try {
|
||||
|
@ -103,8 +104,8 @@ public class TestJdbcTypesDerby {
|
|||
|
||||
final InputStream instream = new ByteArrayInputStream(serializedBytes);
|
||||
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<GenericRecord>(instream, datumReader)) {
|
||||
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
|
||||
try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<>(instream, datumReader)) {
|
||||
GenericRecord record = null;
|
||||
while (dataFileReader.hasNext()) {
|
||||
// Reuse record object by passing it to next(). This saves us from
|
||||
|
@ -123,11 +124,10 @@ public class TestJdbcTypesDerby {
|
|||
assertNotNull(clazz);
|
||||
}
|
||||
|
||||
private Connection createConnection() throws ClassNotFoundException, SQLException {
|
||||
private Connection createConnection(String location) throws ClassNotFoundException, SQLException {
|
||||
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
final Connection con = DriverManager.getConnection("jdbc:derby:" + DB_LOCATION + ";create=true");
|
||||
return con;
|
||||
return DriverManager.getConnection("jdbc:derby:" + location + ";create=true");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue