blob: 4b841dab68c21c1a9a94e3fd5471a3df9ec02e6d [file] [log] [blame]
/**
*
* 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 <sys/stat.h>
#undef NDEBUG
#include <cassert>
#include <utility>
#include <chrono>
#include <fstream>
#include <memory>
#include <string>
#include <thread>
#include <type_traits>
#include <vector>
#include <iostream>
#include "HTTPClient.h"
#include "InvokeHTTP.h"
#include "processors/ListenHTTP.h"
#include "processors/LogAttribute.h"
#include <sstream>
#include "TestBase.h"
#include "utils/StringUtils.h"
#include "core/Core.h"
#include "core/logging/Logger.h"
#include "core/ProcessGroup.h"
#include "core/yaml/YamlConfiguration.h"
#include "FlowController.h"
#include "properties/Configure.h"
#include "unit/ProvenanceTestHelper.h"
#include "io/StreamFactory.h"
#include "CivetServer.h"
#include "RemoteProcessorGroupPort.h"
#include "core/ConfigurableComponent.h"
#include "controllers/SSLContextService.h"
#include "../tests/TestServer.h"
#include "HTTPIntegrationBase.h"
class HttpTestHarness : public CoapIntegrationBase {
public:
HttpTestHarness() {
char format[] = "/tmp/ssth.XXXXXX";
dir = testController.createTempDirectory(format);
}
void testSetup() {
LogTestController::getInstance().setDebug<minifi::FlowController>();
LogTestController::getInstance().setDebug<core::ProcessGroup>();
LogTestController::getInstance().setDebug<minifi::SchedulingAgent>();
LogTestController::getInstance().setDebug<core::ProcessContext>();
LogTestController::getInstance().setTrace<processors::InvokeHTTP>();
LogTestController::getInstance().setDebug<utils::HTTPClient>();
LogTestController::getInstance().setDebug<processors::ListenHTTP>();
LogTestController::getInstance().setDebug<processors::ListenHTTP::WriteCallback>();
LogTestController::getInstance().setDebug<processors::ListenHTTP::Handler>();
LogTestController::getInstance().setDebug<processors::LogAttribute>();
LogTestController::getInstance().setDebug<core::Processor>();
LogTestController::getInstance().setDebug<minifi::ThreadedSchedulingAgent>();
LogTestController::getInstance().setDebug<minifi::TimerDrivenSchedulingAgent>();
LogTestController::getInstance().setDebug<minifi::core::ProcessSession>();
std::fstream file;
ss << dir << "/" << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
configuration->set("nifi.flow.engine.threads", "8");
configuration->set("nifi.c2.enable", "false");
}
void cleanup() {
unlink(ss.str().c_str());
}
void runAssertions() {
assert(LogTestController::getInstance().contains("curl performed") == true);
assert(LogTestController::getInstance().contains("Size:1024 Offset:0") == true);
assert(LogTestController::getInstance().contains("Size:0 Offset:0") == false);
}
protected:
std::string dir;
std::stringstream ss;
TestController testController;
};
int main(int argc, char **argv) {
std::string key_dir, test_file_location, url;
if (argc > 1) {
test_file_location = argv[1];
key_dir = argv[2];
}
HttpTestHarness harness;
harness.setKeyDir(key_dir);
harness.run(test_file_location);
return 0;
}