You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2016/01/20 22:53:31 UTC
nifi git commit: [NIFI-1411] - TestJdbcTypesDerby:
java.sql.SQLSyntaxErrorException: TYPE 'DATETIME' does not exist
Repository: nifi
Updated Branches:
refs/heads/master 9ebcc9e4f -> e1588d413
[NIFI-1411] - TestJdbcTypesDerby: java.sql.SQLSyntaxErrorException: TYPE 'DATETIME' does not exist
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/e1588d41
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/e1588d41
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/e1588d41
Branch: refs/heads/master
Commit: e1588d41367287af05ab3b5bd33dc1df80960024
Parents: 9ebcc9e
Author: smarthi <sm...@apache.org>
Authored: Tue Jan 19 12:00:02 2016 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed Jan 20 16:51:58 2016 -0500
----------------------------------------------------------------------
.../standard/util/TestJdbcCommon.java | 30 +++++++++-----------
.../standard/util/TestJdbcHugeStream.java | 22 +++++++-------
.../standard/util/TestJdbcTypesDerby.java | 26 ++++++++---------
3 files changed, 38 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/e1588d41/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcCommon.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcCommon.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcCommon.java
index 266d426..7b29cf8 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcCommon.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcCommon.java
@@ -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");
}
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e1588d41/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcHugeStream.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcHugeStream.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcHugeStream.java
index 0eb7dce..19161ee 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcHugeStream.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcHugeStream.java
@@ -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");
}
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/e1588d41/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcTypesDerby.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcTypesDerby.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcTypesDerby.java
index fc2bccd..79a1c84 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcTypesDerby.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/TestJdbcTypesDerby.java
@@ -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");
}
}