01: /*
02: * WbFeedbackTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.sql.wbcommands;
13:
14: import workbench.sql.commands.*;
15: import junit.framework.*;
16: import workbench.TestUtil;
17: import workbench.resource.ResourceMgr;
18: import workbench.sql.DefaultStatementRunner;
19: import workbench.sql.StatementRunnerResult;
20:
21: /**
22: *
23: * @author support@sql-workbench.net
24: */
25: public class WbFeedbackTest extends TestCase {
26:
27: public WbFeedbackTest(String testName) {
28: super (testName);
29: }
30:
31: public void testEcho() throws Exception {
32: try {
33: TestUtil util = new TestUtil("testEchoExec");
34: util.prepareEnvironment();
35: DefaultStatementRunner runner = new DefaultStatementRunner();
36: WbFeedback echo = new WbFeedback("ECHO");
37: runner.addCommand(echo);
38: String sql = "--this is a test\n\techo\t off";
39: runner.runStatement(sql, 0, 0);
40: StatementRunnerResult result = runner.getResult();
41: assertEquals("Echo command not run", true, result
42: .isSuccess());
43: assertEquals("Feedback not turned off", false, runner
44: .getVerboseLogging());
45:
46: sql = "--this is a test\n\techo\t on";
47: runner.runStatement(sql, 0, 0);
48: result = runner.getResult();
49: assertEquals("Echo command not run", true, result
50: .isSuccess());
51: assertEquals("Feedback not turned off", true, runner
52: .getVerboseLogging());
53:
54: sql = "--this is a test\n\techo\t bla";
55: runner.runStatement(sql, 0, 0);
56: result = runner.getResult();
57: assertEquals("Echo command did not report an error", false,
58: result.isSuccess());
59:
60: sql = "--this is a test\n\techo";
61: runner.runStatement(sql, 0, 0);
62: result = runner.getResult();
63: String msg = result.getMessageBuffer().toString().trim();
64: String expected = ResourceMgr
65: .getString("MsgFeedbackEnabled");
66: assertEquals("Wrong message returned", expected, msg);
67: assertEquals("Echo command not successful", true, result
68: .isSuccess());
69: } catch (Exception e) {
70: e.printStackTrace();
71: fail(e.getMessage());
72: }
73: }
74:
75: }
|