当前位置: 首页>>代码示例>>Java>>正文


Java Server.setOut方法代码示例

本文整理汇总了Java中org.h2.tools.Server.setOut方法的典型用法代码示例。如果您正苦于以下问题:Java Server.setOut方法的具体用法?Java Server.setOut怎么用?Java Server.setOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.tools.Server的用法示例。


在下文中一共展示了Server.setOut方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runServer

import org.h2.tools.Server; //导入方法依赖的package包/类
private String runServer(int exitCode, String... args) {
    ByteArrayOutputStream buff = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(buff);
    server = new Server();
    server.setOut(ps);
    int result = 0;
    try {
        server.runTool(args);
    } catch (SQLException e) {
        result = 1;
        e.printStackTrace(ps);
    }
    assertEquals(exitCode, result);
    ps.flush();
    String s = new String(buff.toByteArray());
    return s;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:TestTools.java

示例2: testTransfer

import org.h2.tools.Server; //导入方法依赖的package包/类
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);
        new File("transfer/testUpload.txt").delete();
        client.upload(url + "/transfer/testUpload.txt",
                "testUpload.txt", new ByteArrayInputStream(
                "Hallo Welt".getBytes()));
        byte[] d = IOUtils.readBytesAndClose(
                new FileInputStream("transfer/testUpload.txt"), -1);
        assertEquals("Hallo Welt", new String(d));
        new File("transfer/testUpload.txt").delete();
    } finally {
        server.shutdown();
        FileUtils.deleteRecursive("transfer", true);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:30,代码来源:TestWeb.java

示例3: testServer

import org.h2.tools.Server; //导入方法依赖的package包/类
private void testServer() throws Exception {
    Server server = new Server();
    server.setOut(new PrintStream(new ByteArrayOutputStream()));
    server.runTool("-web", "-webPort", "8182", "-properties",
            "null", "-tcp", "-tcpPort", "9101");
    try {
        String url = "http://localhost:8182";
        WebClient client;
        String result;
        client = new WebClient();
        client.setAcceptLanguage("de-de,de;q=0.5");
        result = client.get(url);
        client.readSessionId(result);
        result = client.get(url, "login.jsp");
        assertEquals("text/html", client.getContentType());
        assertContains(result, "Einstellung");
        client.get(url, "favicon.ico");
        assertEquals("image/x-icon", client.getContentType());
        client.get(url, "ico_ok.gif");
        assertEquals("image/gif", client.getContentType());
        client.get(url, "tree.js");
        assertEquals("text/javascript", client.getContentType());
        client.get(url, "stylesheet.css");
        assertEquals("text/css", client.getContentType());
        client.get(url, "admin.do");
        try {
            client.get(url, "adminShutdown.do");
        } catch (IOException e) {
            // expected
            Thread.sleep(1000);
        }
    } finally {
        server.shutdown();
    }
    // it should be stopped now
    server = Server.createTcpServer("-tcpPort", "9101");
    server.start();
    server.stop();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:40,代码来源:TestWeb.java

示例4: testIfExists

import org.h2.tools.Server; //导入方法依赖的package包/类
private void testIfExists() throws Exception {
    Connection conn = getConnection("jdbc:h2:mem:webExists",
            getUser(), getPassword());
    Server server = new Server();
    server.setOut(new PrintStream(new ByteArrayOutputStream()));
    server.runTool("-ifExists", "-web", "-webPort", "8182",
            "-properties", "null", "-tcp", "-tcpPort", "9101");
    try {
        String url = "http://localhost:8182";
        WebClient client;
        String result;
        client = new WebClient();
        result = client.get(url);
        client.readSessionId(result);
        result = client.get(url, "login.jsp");
        result = client.get(url, "test.do?driver=org.h2.Driver" +
                "&url=jdbc:h2:mem:webExists" +
                "&user=" + getUser() + "&password=" +
                getPassword() + "&name=_test_");
        assertTrue(result.indexOf("Exception") < 0);
        result = client.get(url, "test.do?driver=org.h2.Driver" +
                "&url=jdbc:h2:mem:web" +
                "&user=" + getUser() + "&password=" +
                getPassword() + "&name=_test_");
        assertContains(result, "Exception");
    } finally {
        server.shutdown();
        conn.close();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:TestWeb.java

示例5: testTools

import org.h2.tools.Server; //导入方法依赖的package包/类
private void testTools() throws Exception {
    if (config.memory || config.cipher != null) {
        return;
    }
    deleteDb("web");
    Connection conn = getConnection("web");
    conn.createStatement().execute(
            "create table test(id int) as select 1");
    conn.close();
    Server server = new Server();
    server.setOut(new PrintStream(new ByteArrayOutputStream()));
    server.runTool("-web", "-webPort", "8182",
            "-properties", "null", "-tcp", "-tcpPort", "9101");
    try {
        String url = "http://localhost:8182";
        WebClient client;
        String result;
        client = new WebClient();
        result = client.get(url);
        client.readSessionId(result);
        result = client.get(url, "tools.jsp");
        FileUtils.delete(getBaseDir() + "/backup.zip");
        result = client.get(url, "tools.do?tool=Backup&args=-dir," +
                getBaseDir() + ",-db,web,-file," +
                getBaseDir() + "/backup.zip");
        deleteDb("web");
        assertTrue(FileUtils.exists(getBaseDir() + "/backup.zip"));
        result = client.get(url,
                "tools.do?tool=DeleteDbFiles&args=-dir," +
                getBaseDir() + ",-db,web");
        String fn = getBaseDir() + "/web";
        if (config.mvStore) {
            fn += Constants.SUFFIX_MV_FILE;
        } else {
            fn += Constants.SUFFIX_PAGE_FILE;
        }
        assertFalse(FileUtils.exists(fn));
        result = client.get(url, "tools.do?tool=Restore&args=-dir," +
                getBaseDir() + ",-db,web,-file," + getBaseDir() +
                "/backup.zip");
        assertTrue(FileUtils.exists(fn));
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        FileUtils.delete(getBaseDir() + "/backup.zip");
        result = client.get(url, "tools.do?tool=Recover&args=-dir," +
                getBaseDir() + ",-db,web");
        assertTrue(FileUtils.exists(getBaseDir() + "/web.h2.sql"));
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        result = client.get(url, "tools.do?tool=RunScript&args=-script," +
                getBaseDir() + "/web.h2.sql,-url," + getURL("web", true) +
                ",-user," + getUser() + ",-password," + getPassword());
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        assertTrue(FileUtils.exists(fn));
        deleteDb("web");
    } finally {
        server.shutdown();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:58,代码来源:TestWeb.java


注:本文中的org.h2.tools.Server.setOut方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。