001: /*
002: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
003: * (license2)
004: * Initial Developer: H2 Group
005: */
006: package org.h2.test.server;
007:
008: import org.h2.test.TestBase;
009: import org.h2.tools.Server;
010:
011: /**
012: * Tests the H2 Console application.
013: */
014: public class TestWeb extends TestBase {
015:
016: public void test() throws Exception {
017: Server server = Server.createWebServer(new String[] {
018: "-webPort", "8182" });
019: server.start();
020: String url = server.getURL();
021: WebClient client = new WebClient();
022: String result = client.get(url);
023: client.readSessionId(result);
024: client.get(url, "login.jsp");
025: client.get(url, "stylesheet.css");
026: client.get(url, "admin.do");
027: // does not stop the server because it is not started from the command line
028: client.get(url, "adminShutdown.do");
029: client.get(url, "adminSave.do");
030: result = client.get(url, "index.do?language=de");
031: result = client.get(url, "login.jsp");
032: checkContains(result, "Einstellung");
033: result = client.get(url, "index.do?language=en");
034: result = client.get(url, "login.jsp");
035: check(result.indexOf("Einstellung") < 0);
036: result = client
037: .get(url,
038: "test.do?driver=abc&url=jdbc:abc:mem:web&user=sa&password=sa&name=_test_");
039: checkContains(result, "Exception");
040: result = client
041: .get(
042: url,
043: "test.do?driver=org.h2.Driver&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_");
044: check(result.indexOf("Exception") < 0);
045: result = client
046: .get(
047: url,
048: "login.do?driver=org.h2.Driver&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_");
049: result = client.get(url, "header.jsp");
050: result = client.get(url, "tables.do");
051: result = client.get(url, "query.jsp");
052: result = client.get(url, "query.do?sql=select * from test");
053: result = client.get(url,
054: "query.do?sql=drop table test if exists");
055: result = client
056: .get(
057: url,
058: "query.do?sql=create table test(id int primary key, name varchar);insert into test values(1, 'Hello')");
059: result = client.get(url, "query.do?sql=select * from test");
060: checkContains(result, "Hello");
061: result = client.get(url,
062: "query.do?sql=@META select * from test");
063: checkContains(result, "typeName");
064: result = client.get(url, "query.do?sql=delete from test");
065: result = client
066: .get(url,
067: "query.do?sql=@LOOP 1000 insert into test values(?, 'Hello ' || ?/*RND*/)");
068: checkContains(result, "1000 * (Prepared)");
069: result = client.get(url, "query.do?sql=select * from test");
070: result = client.get(url, "query.do?sql=@HISTORY");
071: result = client.get(url, "getHistory.do?id=4");
072: checkContains(result, "select * from test");
073: result = client.get(url, "autoCompleteList.do?query=se");
074: checkContains(result, "select");
075: checkContains(result, "set");
076: result = client.get(url, "tables.do");
077: checkContains(result, "TEST");
078: result = client.get(url,
079: "autoCompleteList.do?query=select * from ");
080: checkContains(result, "test");
081: result = client.get(url,
082: "autoCompleteList.do?query=from test t select t.");
083: checkContains(result, "id");
084: result = client
085: .get(url,
086: "autoCompleteList.do?query=select id x from test te where t");
087: checkContains(result, "te");
088:
089: result = client.get(url, "query.do?sql=delete from test");
090: result = client
091: .get(url,
092: "query.do?sql=@LOOP 10 @STATEMENT insert into test values(?, 'Hello')");
093: result = client.get(url, "query.do?sql=select * from test");
094: checkContains(result, "8");
095: result = client.get(url,
096: "query.do?sql=@EDIT select * from test");
097: checkContains(result, "editRow");
098:
099: result = client.get(url, "query.do?sql=@AUTOCOMMIT TRUE");
100: result = client.get(url, "query.do?sql=@AUTOCOMMIT FALSE");
101: result = client.get(url, "query.do?sql=@TRANSACTION_ISOLATION");
102: result = client.get(url, "query.do?sql=@SET MAXROWS 1");
103: result = client.get(url,
104: "query.do?sql=select * from test order by id");
105: result = client.get(url, "query.do?sql=@SET MAXROWS 1000");
106: result = client.get(url, "query.do?sql=@TABLES");
107: checkContains(result, "TEST");
108: result = client
109: .get(url, "query.do?sql=@COLUMNS null null TEST");
110: checkContains(result, "ID");
111: result = client.get(url,
112: "query.do?sql=@INDEX_INFO null null TEST");
113: checkContains(result, "PRIMARY");
114: result = client.get(url, "query.do?sql=@CATALOG");
115: checkContains(result, "PUBLIC");
116: result = client.get(url, "query.do?sql=@MEMORY");
117: checkContains(result, "Used");
118: result = client.get(url, "query.do?sql=@UDTS");
119:
120: result = client.get(url, "query.do?sql=@INFO");
121: checkContains(result, "getCatalog");
122:
123: result = client.get(url, "logout.do");
124: result = client.get(url, "settingRemove.do?name=_test_");
125: server.stop();
126: }
127:
128: }
|