提交 834c39f4 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improve code coverage (test H2 Console transfer).

上级 2d4dd6fd
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
package org.h2.test.server; package org.h2.test.server;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.sql.Connection; import java.sql.Connection;
...@@ -33,6 +35,7 @@ public class TestWeb extends TestBase { ...@@ -33,6 +35,7 @@ public class TestWeb extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testTransfer();
testAlreadyRunning(); testAlreadyRunning();
testStartWebServerWithConnection(); testStartWebServerWithConnection();
testAutoComplete(); testAutoComplete();
...@@ -54,6 +57,28 @@ public class TestWeb extends TestBase { ...@@ -54,6 +57,28 @@ public class TestWeb extends TestBase {
server.stop(); server.stop();
} }
private void testTransfer() throws Exception {
Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream()));
server.runTool("-web", "-webPort", "8182", "-properties", "null");
File transfer = new File("transfer");
transfer.mkdirs();
try {
FileOutputStream f = new FileOutputStream("transfer/test.txt");
f.write("Hello World".getBytes());
f.close();
WebClient client = new WebClient();
String url = "http://localhost:8182";
String result = client.get(url);
client.readSessionId(result);
String test = client.get(url, "transfer/test.txt");
assertEquals("Hello World", test);
server.shutdown();
} finally {
transfer.delete();
}
}
private void testAutoComplete() throws Exception { private void testAutoComplete() throws Exception {
Server server = new Server(); Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream())); server.setOut(new PrintStream(new ByteArrayOutputStream()));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论