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

    https://github.com/apache/nifi/pull/2101#discussion_r164212552
  
    --- Diff: 
nifi-nar-bundles/nifi-influxdb-bundle/nifi-influxdb-processors/src/test/java/org/apache/nifi/processors/influxdb/ITPutInfluxDBTest.java
 ---
    @@ -0,0 +1,189 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.processors.influxdb;
    +
    +import static org.junit.Assert.assertEquals;
    +import java.util.List;
    +import org.apache.nifi.util.MockFlowFile;
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.influxdb.InfluxDB;
    +import org.influxdb.InfluxDBFactory;
    +import org.influxdb.dto.Query;
    +import org.influxdb.dto.QueryResult;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +
    +/**
    + * Integration test for InfluxDB. Please ensure that the InfluxDB is 
running
    + * on local host with default port and has database test with table test. 
Please set user
    + * and password if applicable before running the integration tests.
    + */
    +@Ignore("Comment this out for running tests against a real instance of 
InfluxDB")
    +public class ITPutInfluxDBTest {
    +    private TestRunner runner;
    +    private InfluxDB influxDB;
    +    private String dbName = "test";
    +    private String dbUrl = "http://localhost:8086";;
    +    private String user = "admin";
    +    private String password = "admin";
    +
    +    @Before
    +    public void setUp() throws Exception {
    +        runner = TestRunners.newTestRunner(PutInfluxDB.class);
    +        runner.setProperty(PutInfluxDB.DB_NAME, dbName);
    +        runner.setProperty(PutInfluxDB.USERNAME, user);
    +        runner.setProperty(PutInfluxDB.PASSWORD, password);
    +        runner.setProperty(PutInfluxDB.INFLUX_DB_URL, dbUrl);
    +        runner.setProperty(PutInfluxDB.CHARSET, "UTF-8");
    +        
runner.setProperty(PutInfluxDB.CONSISTENCY_LEVEL,PutInfluxDB.CONSISTENCY_LEVEL_ONE.getValue());
    +        runner.setProperty(PutInfluxDB.RETENTION_POLICY,"autogen");
    +        runner.setProperty(PutInfluxDB.MAX_RECORDS_SIZE, "1 KB");
    +        runner.assertValid();
    +
    +        influxDB = InfluxDBFactory.connect(dbUrl,user,password);
    +
    +        if ( influxDB.databaseExists(dbName) ) {
    +            QueryResult result = influxDB.query(new Query("DROP 
measurement water", dbName));
    +            checkError(result);
    +            result = influxDB.query(new Query("DROP measurement testm", 
dbName));
    +            checkError(result);
    +        } else {
    +            influxDB.createDatabase(dbName);
    +            int max = 10;
    +            while (!influxDB.databaseExists(dbName) && (max-- < 0)) {
    +                Thread.sleep(5);
    +            }
    +            if ( ! influxDB.databaseExists(dbName) ) {
    +                throw new Exception("unable to create database " + dbName);
    +            }
    +        }
    +    }
    +
    +    protected void checkError(QueryResult result) {
    +        if ( result.hasError() )
    --- End diff --
    
    Please add curly brackets.


---

Reply via email to