Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1524#discussion_r103969033
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutSQL.java
 ---
    @@ -352,6 +352,77 @@ public void 
testUsingTimestampValuesWithFormatAttribute() throws InitializationE
         }
     
         @Test
    +    public void testUsingDateTimeValuesWithFormatAttribute() throws 
InitializationException, ProcessException, SQLException, IOException, 
ParseException {
    +        final TestRunner runner = TestRunners.newTestRunner(PutSQL.class);
    +        try (final Connection conn = service.getConnection()) {
    +            try (final Statement stmt = conn.createStatement()) {
    +                stmt.executeUpdate("CREATE TABLE TIMESTAMPTEST3 (id 
integer primary key, ts1 TIME, ts2 DATE)");
    +            }
    +        }
    +
    +        runner.addControllerService("dbcp", service);
    +        runner.enableControllerService(service);
    +        runner.setProperty(PutSQL.CONNECTION_POOL, "dbcp");
    +
    +        final String dateStr = "2002-02-02";
    +        final String timeStr = "12:02:02";
    +
    +        Map<String, String> attributes = new HashMap<>();
    +        attributes.put("sql.args.1.type", String.valueOf(Types.TIME));
    +        attributes.put("sql.args.1.value", timeStr);
    +        attributes.put("sql.args.1.format", "ISO_LOCAL_TIME");
    +        attributes.put("sql.args.2.type", String.valueOf(Types.DATE));
    +        attributes.put("sql.args.2.value", dateStr);
    +        attributes.put("sql.args.2.format", "ISO_LOCAL_DATE");
    +
    +        runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES 
(1, ?, ?)".getBytes(), attributes);
    +
    +        attributes = new HashMap<>();
    +        attributes.put("sql.args.1.type", String.valueOf(Types.TIME));
    +        attributes.put("sql.args.1.value", "68522000");
    +        attributes.put("sql.args.2.type", String.valueOf(Types.DATE));
    +        attributes.put("sql.args.2.value", "1012633200000");
    +
    +        runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES 
(2, ?, ?)".getBytes(), attributes);
    +
    +        attributes = new HashMap<>();
    +        attributes.put("sql.args.1.type", String.valueOf(Types.TIME));
    +        attributes.put("sql.args.1.value", "120202000");
    +        attributes.put("sql.args.1.format", "HHmmssSSS");
    +        attributes.put("sql.args.2.type", String.valueOf(Types.DATE));
    +        attributes.put("sql.args.2.value", "20020202");
    +        attributes.put("sql.args.2.format", "yyyyMMdd");
    +
    +        runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES 
(3, ?, ?)".getBytes(), attributes);
    +
    +        runner.run();
    +
    +        runner.assertAllFlowFilesTransferred(PutSQL.REL_SUCCESS, 3);
    +
    +        try (final Connection conn = service.getConnection()) {
    +            try (final Statement stmt = conn.createStatement()) {
    +                final ResultSet rs = stmt.executeQuery("SELECT * FROM 
TIMESTAMPTEST3 ORDER BY ID");
    +                assertTrue(rs.next());
    +                assertEquals(1, rs.getInt(1));
    +                assertEquals(68522000L, rs.getTime(2).getTime());
    +                assertEquals(1012633200000L, rs.getDate(3).getTime());
    --- End diff --
    
    Same goes for this guy.  Are the second and third flow files supposed to 
put in UTC-based dates/times? Or will they be local as well? If the latter then 
the same change of constants will be needed for the asserts below.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to