use of com.questdb.ServerConfiguration in project questdb by bluestreak01.
the class HttpServerTest method testMaxConnections.
@Test
public void testMaxConnections() throws Exception {
final ServerConfiguration configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
BootstrapEnv env = new BootstrapEnv();
env.configuration = configuration;
env.configuration.setHttpMaxConnections(1);
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
Assert.assertNotNull(clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html")));
try {
clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html"));
Assert.fail("Expected server to reject connection");
} catch (Exception ignored) {
}
} finally {
server.halt();
}
}
use of com.questdb.ServerConfiguration in project questdb by bluestreak01.
the class HttpServerTest method testUpload.
@Test
public void testUpload() throws Exception {
final File dir = temp.newFolder();
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration();
env.matcher = new SimpleUrlMatcher() {
{
put("/upload", new UploadHandler(dir));
}
};
HttpServer server = new HttpServer(env);
server.start();
File expected = resourceFile("/csv/test-import.csv");
File actual = new File(dir, "test-import.csv");
upload(expected);
TestUtils.assertEquals(expected, actual);
server.halt();
}
use of com.questdb.ServerConfiguration in project questdb by bluestreak01.
the class HttpServerTest method testNativeNotModified.
@Test
public void testNativeNotModified() throws Exception {
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
env.configuration.getSslConfig().setSecure(false);
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
assertNotModified(env.configuration, server);
}
use of com.questdb.ServerConfiguration in project questdb by bluestreak01.
the class HttpServerTest method testImportNumericHeader.
@Test
public void testImportNumericHeader() throws Exception {
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration();
env.factory = getFactory();
env.typeProbeCollection = TYPE_PROBE_COLLECTION;
env.matcher = new SimpleUrlMatcher() {
{
put("/imp", new ImportHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
StringSink sink = new StringSink();
RecordSourcePrinter printer = new RecordSourcePrinter(sink);
QueryCompiler qc = new QueryCompiler(env);
Assert.assertEquals(200, HttpTestUtils.upload("/csv/test-numeric-headers.csv", "http://localhost:9000/imp?name=test-import.csv&overwrite=true&durable=true&forceHeader=true", null, null));
printer.print(qc.compile(getFactory(), "select count() from 'test-import.csv'"), getFactory());
// expect first line to be treated as header
TestUtils.assertEquals("2\n", sink);
} finally {
server.halt();
}
}
use of com.questdb.ServerConfiguration in project questdb by bluestreak01.
the class HttpServerTest method testImportUtf8.
@Test
public void testImportUtf8() throws Exception {
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration();
env.factory = getFactory();
env.typeProbeCollection = TYPE_PROBE_COLLECTION;
env.matcher = new SimpleUrlMatcher() {
{
put("/imp", new ImportHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
StringSink sink = new StringSink();
RecordSourcePrinter printer = new RecordSourcePrinter(sink);
QueryCompiler qc = new QueryCompiler(env);
Assert.assertEquals(200, HttpTestUtils.upload("/csv/test-import-utf8.csv", "http://localhost:9000/imp?overwrite=true&durable=true", null, null));
printer.print(qc.compile(getFactory(), "'test-import-utf8.csv'"), getFactory());
// expect first line to be treated as header
TestUtils.assertEquals("авг\tавг\n", sink);
} finally {
server.halt();
}
}
Aggregations