Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master 3facf2c56 -> f38859e43


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/ProvenanceTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/ProvenanceTests.cpp 
b/libminifi/test/unit/ProvenanceTests.cpp
new file mode 100644
index 0000000..d78de47
--- /dev/null
+++ b/libminifi/test/unit/ProvenanceTests.cpp
@@ -0,0 +1,96 @@
+/**
+ *
+ * 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.
+ */
+
+
+#ifndef PROVENANCE_TESTS
+#define PROVENANCE_TESTS
+#include "../TestBase.h"
+
+#include "ProvenanceTestHelper.h"
+#include "Provenance.h"
+#include "FlowFileRecord.h"
+
+
+
+TEST_CASE("Test Provenance record create", "[TestProvenanceEventRecord]"){
+
+       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CREATE,"blah","blahblah");
+       REQUIRE( record1.getAttributes().size() == 0);
+       REQUIRE( record1.getAlternateIdentifierUri().length() == 0);
+
+}
+
+
+TEST_CASE("Test Provenance record serialization", 
"[TestProvenanceEventRecordSerializeDeser]"){
+
+       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CREATE,"componentid","componenttype");
+
+       std::string eventId = record1.getEventId();
+       
+       std::string smileyface = ":)" ;
+       record1.setDetails(smileyface);
+
+       ProvenanceTestRepository repo;
+       uint64_t sample = 65555;
+       ProvenanceRepository *testRepository = 
dynamic_cast<ProvenanceRepository*>(&repo);
+       record1.setEventDuration(sample);
+
+       record1.Serialize(testRepository);
+       ProvenanceEventRecord record2;
+       REQUIRE( record2.DeSerialize(testRepository,eventId) == true);
+       REQUIRE( record2.getEventId() == record1.getEventId());
+       REQUIRE( record2.getComponentId() == record1.getComponentId());
+       REQUIRE( record2.getComponentType() == record1.getComponentType());
+       REQUIRE( record2.getDetails() == record1.getDetails());
+       REQUIRE( record2.getDetails() == smileyface);
+       REQUIRE( record2.getEventDuration() == sample);
+}
+
+
+TEST_CASE("Test Flowfile record added to provenance", "[TestFlowAndProv1]"){
+
+       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CLONE,"componentid","componenttype");
+       std::string eventId = record1.getEventId();
+       std::map<std::string, std::string> attributes;
+       
attributes.insert(std::pair<std::string,std::string>("potato","potatoe"));
+       
attributes.insert(std::pair<std::string,std::string>("tomato","tomatoe"));
+       FlowFileRecord ffr1(attributes);
+
+       record1.addChildFlowFile(&ffr1);
+
+       ProvenanceTestRepository repo;
+       uint64_t sample = 65555;
+       ProvenanceRepository *testRepository = 
dynamic_cast<ProvenanceRepository*>(&repo);
+       record1.setEventDuration(sample);
+
+       record1.Serialize(testRepository);
+       ProvenanceEventRecord record2;
+       REQUIRE( record2.DeSerialize(testRepository,eventId) == true);
+       REQUIRE( record1.getChildrenUuids().size() == 1);
+       REQUIRE( record2.getChildrenUuids().size() == 1);
+       std::string childId = record2.getChildrenUuids().at(0);
+       REQUIRE( childId == ffr1.getUUIDStr());
+       record2.removeChildUuid(childId);
+       REQUIRE( record2.getChildrenUuids().size() == 0);
+
+
+}
+
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/ProvenanceTests.h
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/ProvenanceTests.h 
b/libminifi/test/unit/ProvenanceTests.h
deleted file mode 100644
index d78de47..0000000
--- a/libminifi/test/unit/ProvenanceTests.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * 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.
- */
-
-
-#ifndef PROVENANCE_TESTS
-#define PROVENANCE_TESTS
-#include "../TestBase.h"
-
-#include "ProvenanceTestHelper.h"
-#include "Provenance.h"
-#include "FlowFileRecord.h"
-
-
-
-TEST_CASE("Test Provenance record create", "[TestProvenanceEventRecord]"){
-
-       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CREATE,"blah","blahblah");
-       REQUIRE( record1.getAttributes().size() == 0);
-       REQUIRE( record1.getAlternateIdentifierUri().length() == 0);
-
-}
-
-
-TEST_CASE("Test Provenance record serialization", 
"[TestProvenanceEventRecordSerializeDeser]"){
-
-       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CREATE,"componentid","componenttype");
-
-       std::string eventId = record1.getEventId();
-       
-       std::string smileyface = ":)" ;
-       record1.setDetails(smileyface);
-
-       ProvenanceTestRepository repo;
-       uint64_t sample = 65555;
-       ProvenanceRepository *testRepository = 
dynamic_cast<ProvenanceRepository*>(&repo);
-       record1.setEventDuration(sample);
-
-       record1.Serialize(testRepository);
-       ProvenanceEventRecord record2;
-       REQUIRE( record2.DeSerialize(testRepository,eventId) == true);
-       REQUIRE( record2.getEventId() == record1.getEventId());
-       REQUIRE( record2.getComponentId() == record1.getComponentId());
-       REQUIRE( record2.getComponentType() == record1.getComponentType());
-       REQUIRE( record2.getDetails() == record1.getDetails());
-       REQUIRE( record2.getDetails() == smileyface);
-       REQUIRE( record2.getEventDuration() == sample);
-}
-
-
-TEST_CASE("Test Flowfile record added to provenance", "[TestFlowAndProv1]"){
-
-       ProvenanceEventRecord 
record1(ProvenanceEventRecord::ProvenanceEventType::CLONE,"componentid","componenttype");
-       std::string eventId = record1.getEventId();
-       std::map<std::string, std::string> attributes;
-       
attributes.insert(std::pair<std::string,std::string>("potato","potatoe"));
-       
attributes.insert(std::pair<std::string,std::string>("tomato","tomatoe"));
-       FlowFileRecord ffr1(attributes);
-
-       record1.addChildFlowFile(&ffr1);
-
-       ProvenanceTestRepository repo;
-       uint64_t sample = 65555;
-       ProvenanceRepository *testRepository = 
dynamic_cast<ProvenanceRepository*>(&repo);
-       record1.setEventDuration(sample);
-
-       record1.Serialize(testRepository);
-       ProvenanceEventRecord record2;
-       REQUIRE( record2.DeSerialize(testRepository,eventId) == true);
-       REQUIRE( record1.getChildrenUuids().size() == 1);
-       REQUIRE( record2.getChildrenUuids().size() == 1);
-       std::string childId = record2.getChildrenUuids().at(0);
-       REQUIRE( childId == ffr1.getUUIDStr());
-       record2.removeChildUuid(childId);
-       REQUIRE( record2.getChildrenUuids().size() == 0);
-
-
-}
-
-
-
-#endif

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/SerializationTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/SerializationTests.cpp 
b/libminifi/test/unit/SerializationTests.cpp
new file mode 100644
index 0000000..6b6e81e
--- /dev/null
+++ b/libminifi/test/unit/SerializationTests.cpp
@@ -0,0 +1,83 @@
+/**
+ *
+ * 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.
+ */
+
+
+
+#include "Site2SitePeer.h"
+#include "Site2SiteClientProtocol.h"
+#include <uuid/uuid.h>
+#include <algorithm>
+#include <string>
+#include <memory>
+#include "../TestBase.h"
+#define FMT_DEFAULT fmt_lower
+
+
+
+TEST_CASE("TestSetPortId", "[S2S1]"){
+
+
+       Site2SitePeer peer(std::unique_ptr<DataStream>(new 
DataStream()),"fake_host",65433);
+
+       Site2SiteClientProtocol protocol(&peer);
+
+
+       std::string uuid_str = "c56a4180-65aa-42ec-a945-5fd21dec0538";
+
+       uuid_t fakeUUID;
+
+       uuid_parse(uuid_str.c_str(),fakeUUID);
+
+       protocol.setPortId(fakeUUID);
+
+       REQUIRE( uuid_str == protocol.getPortId() );
+
+
+
+}
+
+TEST_CASE("TestSetPortIdUppercase", "[S2S2]"){
+
+
+       Site2SitePeer peer(std::unique_ptr<DataStream>(new 
DataStream()),"fake_host",65433);
+
+       Site2SiteClientProtocol protocol(&peer);
+
+
+       std::string uuid_str = "C56A4180-65AA-42EC-A945-5FD21DEC0538";
+
+       uuid_t fakeUUID;
+
+       uuid_parse(uuid_str.c_str(),fakeUUID);
+
+       protocol.setPortId(fakeUUID);
+
+       REQUIRE( uuid_str != protocol.getPortId() );
+
+       
std::transform(uuid_str.begin(),uuid_str.end(),uuid_str.begin(),::tolower);
+
+       REQUIRE( uuid_str == protocol.getPortId() );
+
+
+
+}
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/SerializationTests.h
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/SerializationTests.h 
b/libminifi/test/unit/SerializationTests.h
deleted file mode 100644
index e444f4a..0000000
--- a/libminifi/test/unit/SerializationTests.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- * 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.
- */
-
-
-#ifndef DERSER_TESTS
-#define DERSER_TESTS
-
-#include "Site2SitePeer.h"
-#include "Site2SiteClientProtocol.h"
-#include <uuid/uuid.h>
-#include <algorithm>
-#include <string>
-#include <memory>
-
-#define FMT_DEFAULT fmt_lower
-
-
-
-TEST_CASE("TestSetPortId", "[S2S1]"){
-
-
-       Site2SitePeer peer(std::unique_ptr<DataStream>(new 
DataStream()),"fake_host",65433);
-
-       Site2SiteClientProtocol protocol(&peer);
-
-
-       std::string uuid_str = "c56a4180-65aa-42ec-a945-5fd21dec0538";
-
-       uuid_t fakeUUID;
-
-       uuid_parse(uuid_str.c_str(),fakeUUID);
-
-       protocol.setPortId(fakeUUID);
-
-       REQUIRE( uuid_str == protocol.getPortId() );
-
-
-
-}
-
-TEST_CASE("TestSetPortIdUppercase", "[S2S2]"){
-
-
-       Site2SitePeer peer(std::unique_ptr<DataStream>(new 
DataStream()),"fake_host",65433);
-
-       Site2SiteClientProtocol protocol(&peer);
-
-
-       std::string uuid_str = "C56A4180-65AA-42EC-A945-5FD21DEC0538";
-
-       uuid_t fakeUUID;
-
-       uuid_parse(uuid_str.c_str(),fakeUUID);
-
-       protocol.setPortId(fakeUUID);
-
-       REQUIRE( uuid_str != protocol.getPortId() );
-
-       
std::transform(uuid_str.begin(),uuid_str.end(),uuid_str.begin(),::tolower);
-
-       REQUIRE( uuid_str == protocol.getPortId() );
-
-
-
-}
-
-
-
-
-
-
-
-#endif

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/SocketTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/SocketTests.cpp 
b/libminifi/test/unit/SocketTests.cpp
new file mode 100644
index 0000000..39e8bb5
--- /dev/null
+++ b/libminifi/test/unit/SocketTests.cpp
@@ -0,0 +1,186 @@
+/**
+ *
+ * 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.
+ */
+
+#include "../TestBase.h"
+#include "../../include/io/ClientSocket.h"
+TEST_CASE("TestSocket", "[TestSocket1]") {
+
+       Socket socket("localhost",8183);
+       REQUIRE(-1 == socket.initialize() );
+       REQUIRE("localhost" == socket.getHostname());
+       socket.closeStream();
+
+}
+
+TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") {
+
+       Socket socket(Socket::getMyHostName(),8183);
+       REQUIRE(-1 == socket.initialize() );
+
+       socket.writeData(0,0);
+
+       std::vector<uint8_t> buffer;
+       buffer.push_back('a');
+
+       REQUIRE(-1 == socket.writeData(buffer,1));
+
+       socket.closeStream();   
+
+}
+
+TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") {
+
+               std::vector<uint8_t> buffer;
+       buffer.push_back('a');
+
+       Socket server(Socket::getMyHostName(),9183,1);
+
+       REQUIRE(-1 != server.initialize() );
+
+       Socket client(Socket::getMyHostName(),9183);
+
+       REQUIRE(-1 != client.initialize() );
+
+       REQUIRE( 1 == client.writeData(buffer,1) );
+
+       std::vector<uint8_t> readBuffer;
+       readBuffer.resize(1);
+
+       REQUIRE( 1== server.readData(readBuffer,1) );
+
+       REQUIRE( readBuffer == buffer );
+
+       server.closeStream();
+       
+       
+       client.closeStream();   
+
+}
+
+TEST_CASE("TestGetHostName", "[TestSocket4]") {
+
+       REQUIRE( Socket::getMyHostName().length() > 0 );
+
+
+
+}
+
+TEST_CASE("TestWriteEndian64", "[TestSocket4]") {
+
+               std::vector<uint8_t> buffer;
+       buffer.push_back('a');
+
+       Socket server(Socket::getMyHostName(),9183,1);
+
+       REQUIRE(-1 != server.initialize() );
+
+       Socket client(Socket::getMyHostName(),9183);
+
+       REQUIRE(-1 != client.initialize() );
+
+       uint64_t negative_one = -1;
+       REQUIRE( 8 == client.write(negative_one) );
+
+
+       uint64_t negative_two = 0;
+       REQUIRE( 8 == server.read(negative_two) );
+
+       REQUIRE( negative_two == negative_one );
+
+
+       server.closeStream();
+       
+       
+       client.closeStream();   
+
+}
+
+TEST_CASE("TestWriteEndian32", "[TestSocket5]") {
+
+               std::vector<uint8_t> buffer;
+       buffer.push_back('a');
+
+       Socket server(Socket::getMyHostName(),9183,1);
+
+       REQUIRE(-1 != server.initialize() );
+
+       Socket client(Socket::getMyHostName(),9183);
+
+       REQUIRE(-1 != client.initialize() );
+
+       {
+       uint32_t negative_one = -1;
+       REQUIRE( 4 == client.write(negative_one) );
+
+
+       uint32_t negative_two = 0;
+       REQUIRE( 4 == server.read(negative_two) );
+
+       REQUIRE( negative_two == negative_one );
+       }
+       
+       {
+       uint16_t negative_one = -1;
+       REQUIRE( 2 == client.write(negative_one) );
+
+
+       uint16_t negative_two = 0;
+       REQUIRE( 2 == server.read(negative_two) );
+
+       REQUIRE( negative_two == negative_one );
+       }
+       server.closeStream();
+       
+       
+       client.closeStream();   
+
+}
+
+
+TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket6]") {
+
+               std::vector<uint8_t> buffer;
+       buffer.push_back('a');
+
+       Socket server(Socket::getMyHostName(),9183,1);
+
+       REQUIRE(-1 != server.initialize() );
+
+       Socket client(Socket::getMyHostName(),9183);
+
+       REQUIRE(-1 != client.initialize() );
+
+       REQUIRE( 1 == client.writeData(buffer,1) );
+
+       std::vector<uint8_t> readBuffer;
+       readBuffer.resize(1);
+
+       REQUIRE( 1== server.readData(readBuffer,1) );
+
+       REQUIRE( readBuffer == buffer );
+       
+       client.closeStream();
+       
+       REQUIRE( -1 == client.writeData(buffer,1) );    
+       
+       server.closeStream();
+
+
+
+}
+

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/SocketTests.h
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/SocketTests.h 
b/libminifi/test/unit/SocketTests.h
deleted file mode 100644
index ec7e9e3..0000000
--- a/libminifi/test/unit/SocketTests.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- *
- * 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.
- */
-
-#ifndef LIBMINIFI_TEST_UNIT_REALTIMEDATACOLLECTOR_H_
-#define LIBMINIFI_TEST_UNIT_REALTIMEDATACOLLECTOR_H_
-
-#include "../../include/io/ClientSocket.h"
-TEST_CASE("TestSocket", "[TestSocket1]") {
-
-       Socket socket("localhost",8183);
-       REQUIRE(-1 == socket.initialize() );
-       REQUIRE("localhost" == socket.getHostname());
-       socket.closeStream();
-
-}
-
-TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") {
-
-       Socket socket(Socket::getMyHostName(),8183);
-       REQUIRE(-1 == socket.initialize() );
-
-       socket.writeData(0,0);
-
-       std::vector<uint8_t> buffer;
-       buffer.push_back('a');
-
-       REQUIRE(-1 == socket.writeData(buffer,1));
-
-       socket.closeStream();   
-
-}
-
-TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") {
-
-               std::vector<uint8_t> buffer;
-       buffer.push_back('a');
-
-       Socket server(Socket::getMyHostName(),9183,1);
-
-       REQUIRE(-1 != server.initialize() );
-
-       Socket client(Socket::getMyHostName(),9183);
-
-       REQUIRE(-1 != client.initialize() );
-
-       REQUIRE( 1 == client.writeData(buffer,1) );
-
-       std::vector<uint8_t> readBuffer;
-       readBuffer.resize(1);
-
-       REQUIRE( 1== server.readData(readBuffer,1) );
-
-       REQUIRE( readBuffer == buffer );
-
-       server.closeStream();
-       
-       
-       client.closeStream();   
-
-}
-
-TEST_CASE("TestGetHostName", "[TestSocket4]") {
-
-       REQUIRE( Socket::getMyHostName().length() > 0 );
-
-
-
-}
-
-TEST_CASE("TestWriteEndian64", "[TestSocket4]") {
-
-               std::vector<uint8_t> buffer;
-       buffer.push_back('a');
-
-       Socket server(Socket::getMyHostName(),9183,1);
-
-       REQUIRE(-1 != server.initialize() );
-
-       Socket client(Socket::getMyHostName(),9183);
-
-       REQUIRE(-1 != client.initialize() );
-
-       uint64_t negative_one = -1;
-       REQUIRE( 8 == client.write(negative_one) );
-
-
-       uint64_t negative_two = 0;
-       REQUIRE( 8 == server.read(negative_two) );
-
-       REQUIRE( negative_two == negative_one );
-
-
-       server.closeStream();
-       
-       
-       client.closeStream();   
-
-}
-
-TEST_CASE("TestWriteEndian32", "[TestSocket5]") {
-
-               std::vector<uint8_t> buffer;
-       buffer.push_back('a');
-
-       Socket server(Socket::getMyHostName(),9183,1);
-
-       REQUIRE(-1 != server.initialize() );
-
-       Socket client(Socket::getMyHostName(),9183);
-
-       REQUIRE(-1 != client.initialize() );
-
-       {
-       uint32_t negative_one = -1;
-       REQUIRE( 4 == client.write(negative_one) );
-
-
-       uint32_t negative_two = 0;
-       REQUIRE( 4 == server.read(negative_two) );
-
-       REQUIRE( negative_two == negative_one );
-       }
-       
-       {
-       uint16_t negative_one = -1;
-       REQUIRE( 2 == client.write(negative_one) );
-
-
-       uint16_t negative_two = 0;
-       REQUIRE( 2 == server.read(negative_two) );
-
-       REQUIRE( negative_two == negative_one );
-       }
-       server.closeStream();
-       
-       
-       client.closeStream();   
-
-}
-
-
-TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket6]") {
-
-               std::vector<uint8_t> buffer;
-       buffer.push_back('a');
-
-       Socket server(Socket::getMyHostName(),9183,1);
-
-       REQUIRE(-1 != server.initialize() );
-
-       Socket client(Socket::getMyHostName(),9183);
-
-       REQUIRE(-1 != client.initialize() );
-
-       REQUIRE( 1 == client.writeData(buffer,1) );
-
-       std::vector<uint8_t> readBuffer;
-       readBuffer.resize(1);
-
-       REQUIRE( 1== server.readData(readBuffer,1) );
-
-       REQUIRE( readBuffer == buffer );
-       
-       client.closeStream();
-       
-       REQUIRE( -1 == client.writeData(buffer,1) );    
-       
-       server.closeStream();
-
-
-
-}
-
-
-#endif /* LIBMINIFI_TEST_UNIT_REALTIMEDATACOLLECTOR_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/Tests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/Tests.cpp b/libminifi/test/unit/Tests.cpp
index 1089a6c..a826f3a 100644
--- a/libminifi/test/unit/Tests.cpp
+++ b/libminifi/test/unit/Tests.cpp
@@ -19,10 +19,10 @@
 #define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do 
this in one cpp file
 
 
-#include "ProvenanceTests.h"
-#include "ProcessorTests.h"
-#include "SerializationTests.h"
-#include "PropertyTests.h"
-#include "SocketTests.h"
-#include "TimeUtilsTest.h"
-#include "CRCTests.h"
+
+#include "utils/TimeUtil.h"
+#include "../TestBase.h"
+
+TEST_CASE("Test time conversion", "[testtimeconversion]"){
+       REQUIRE ( "2017-02-16 20:14:56.196" == getTimeStr(1487276096196,true) );
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/libminifi/test/unit/TimeUtilsTest.h
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/TimeUtilsTest.h 
b/libminifi/test/unit/TimeUtilsTest.h
deleted file mode 100644
index a4b1c44..0000000
--- a/libminifi/test/unit/TimeUtilsTest.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- *
- * 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.
- */
-
-#ifndef LIBMINIFI_TEST_UNIT_TIMEUTILSTEST_H_
-#define LIBMINIFI_TEST_UNIT_TIMEUTILSTEST_H_
-
-#include "utils/TimeUtil.h"
-
-TEST_CASE("Test time conversion", "[testtimeconversion]"){
-       REQUIRE ( "2017-02-16 20:14:56.196" == getTimeStr(1487276096196,true) );
-}
-
-
-
-#endif /* LIBMINIFI_TEST_UNIT_TIMEUTILSTEST_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f38859e4/main/MiNiFiMain.cpp
----------------------------------------------------------------------
diff --git a/main/MiNiFiMain.cpp b/main/MiNiFiMain.cpp
index 9b99ee6..3e5202d 100644
--- a/main/MiNiFiMain.cpp
+++ b/main/MiNiFiMain.cpp
@@ -27,6 +27,9 @@
 #include <unistd.h>
 #include <yaml-cpp/yaml.h>
 #include <iostream>
+
+#include "../libminifi/include/BaseLogger.h"
+#include "../libminifi/include/LogAppenders.h"
 #include "spdlog/spdlog.h"
 
 #include "Logger.h"
@@ -64,91 +67,78 @@ static FlowController *controller = NULL;
  * a signal handler. Consequently we will use the semaphore to avoid thread
  * safety issues and.
  */
-void sigHandler(int signal)
-{
+void sigHandler(int signal) {
 
-       if (signal == SIGINT || signal == SIGTERM)
-       {
+       if (signal == SIGINT || signal == SIGTERM) {
                // avoid stopping the controller here.
                sem_post(running);
        }
 }
 
-int main(int argc, char **argv)
-{
-       Logger *logger = Logger::getLogger();
-       logger->setLogLevel(info);
+int main(int argc, char **argv) {
+       std::shared_ptr<Logger> logger = Logger::getLogger();
 
+       logger->setLogLevel(info);
 
        uint16_t stop_wait_time = STOP_WAIT_TIME_MS;
 
        std::string graceful_shutdown_seconds = "";
-       std::string configured_log_level = "";
 
-       running = sem_open("MiNiFiMain",O_CREAT,0644,0);
-       if (running == SEM_FAILED || running == 0)
-       {
+       running = sem_open("MiNiFiMain", O_CREAT, 0644, 0);
+       if (running == SEM_FAILED || running == 0) {
 
                logger->log_error("could not initialize semaphore");
                perror("initialization failure");
        }
-    // assumes POSIX compliant environment
-    std::string minifiHome;
-    if (const char* env_p = std::getenv(MINIFI_HOME_ENV_KEY))
-    {
-        minifiHome = env_p;
-    }
-    else
-    {
-        logger->log_info("MINIFI_HOME was not found, determining based on 
executable path.");
-        char *path = NULL;
-        char full_path[PATH_MAX];
-        path = realpath(argv[0], full_path);
-        std::string minifiHomePath(path);
-        minifiHomePath = minifiHomePath.substr(0, 
minifiHomePath.find_last_of("/\\")); //Remove /minifi from path
-        minifiHome = minifiHomePath.substr(0, 
minifiHomePath.find_last_of("/\\"));     //Remove /bin from path
-    }
-
-
-       if (signal(SIGINT, sigHandler) == SIG_ERR || signal(SIGTERM, 
sigHandler) == SIG_ERR || signal(SIGPIPE, SIG_IGN) == SIG_ERR)
-       {
+       // assumes POSIX compliant environment
+       std::string minifiHome;
+       if (const char* env_p = std::getenv(MINIFI_HOME_ENV_KEY)) {
+               minifiHome = env_p;
+       } else {
+               logger->log_info(
+                               "MINIFI_HOME was not found, determining based 
on executable path.");
+               char *path = NULL;
+               char full_path[PATH_MAX];
+               path = realpath(argv[0], full_path);
+               std::string minifiHomePath(path);
+               minifiHomePath = minifiHomePath.substr(0,
+                               minifiHomePath.find_last_of("/\\")); //Remove 
/minifi from path
+               minifiHome = minifiHomePath.substr(0,
+                               minifiHomePath.find_last_of("/\\"));    
//Remove /bin from path
+       }
+
+       if (signal(SIGINT, sigHandler) == SIG_ERR
+                       || signal(SIGTERM, sigHandler) == SIG_ERR
+                       || signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
                logger->log_error("Can not install signal handler");
                return -1;
        }
 
-    Configure *configure = Configure::getConfigure();
-    configure->setHome(minifiHome);
-    configure->loadConfigureFile(DEFAULT_NIFI_PROPERTIES_FILE);
-
-
-    if 
(configure->get(Configure::nifi_graceful_shutdown_seconds,graceful_shutdown_seconds))
-    {
-       try
-       {
-               stop_wait_time = std::stoi(graceful_shutdown_seconds);
-       }
-       catch(const std::out_of_range &e)
-       {
-               logger->log_error("%s is out of range. 
%s",Configure::nifi_graceful_shutdown_seconds,e.what());
-       }
-       catch(const std::invalid_argument &e)
-       {
-               logger->log_error("%s contains an invalid argument set. 
%s",Configure::nifi_graceful_shutdown_seconds,e.what());
-       }
-    }
-    else
-    {
-       logger->log_debug("%s not set, defaulting to 
%d",Configure::nifi_graceful_shutdown_seconds,STOP_WAIT_TIME_MS);
-    }
-
-    if (configure->get(Configure::nifi_log_level,configured_log_level))
-       {
-               std::cout << "log level is " << configured_log_level << 
std::endl;
-                       logger->setLogLevel(configured_log_level);
-
+       Configure *configure = Configure::getConfigure();
+       configure->setHome(minifiHome);
+       configure->loadConfigureFile(DEFAULT_NIFI_PROPERTIES_FILE);
+
+       if (configure->get(Configure::nifi_graceful_shutdown_seconds,
+                       graceful_shutdown_seconds)) {
+               try {
+                       stop_wait_time = std::stoi(graceful_shutdown_seconds);
+               } catch (const std::out_of_range &e) {
+                       logger->log_error("%s is out of range. %s",
+                                       
Configure::nifi_graceful_shutdown_seconds, e.what());
+               } catch (const std::invalid_argument &e) {
+                       logger->log_error("%s contains an invalid argument set. 
%s",
+                                       
Configure::nifi_graceful_shutdown_seconds, e.what());
+               }
+       } else {
+               logger->log_debug("%s not set, defaulting to %d",
+                               Configure::nifi_graceful_shutdown_seconds, 
STOP_WAIT_TIME_MS);
        }
 
+       // set the log configuration.
+       std::unique_ptr<BaseLogger> configured_logger = 
LogInstance::getConfiguredLogger(
+                       configure);
 
+       logger->updateLogger(std::move(configured_logger));
 
        controller = FlowControllerFactory::getFlowController();
 
@@ -164,10 +154,9 @@ int main(int argc, char **argv)
         * yield without the need for a more complex construct and
         * a spin lock
         */
-       if ( sem_wait(running) != -1 )
+       if (sem_wait(running) != -1)
                perror("sem_wait");
 
-
        sem_unlink("MiNiFiMain");
 
        /**
@@ -179,7 +168,5 @@ int main(int argc, char **argv)
 
        logger->log_info("MiNiFi exit");
 
-
-
        return 0;
 }

Reply via email to