01: /*
02: * CommandMapperTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2007, 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;
13:
14: import java.util.regex.Matcher;
15: import java.util.regex.Pattern;
16: import junit.framework.TestCase;
17: import workbench.TestUtil;
18: import workbench.resource.Settings;
19:
20: /**
21: * @author support@sql-workbench.net
22: */
23: public class CommandMapperTest extends TestCase {
24: public CommandMapperTest(String testName) {
25: super (testName);
26: }
27:
28: public void testSelectIntoPattern() {
29: TestUtil util = new TestUtil("testPattern");
30: try {
31: String pgPattern = Settings.getInstance().getProperty(
32: "workbench.db.postgresql.selectinto.pattern", null);
33: assertNotNull(pgPattern);
34:
35: Pattern pg = Pattern.compile(pgPattern,
36: Pattern.CASE_INSENSITIVE);
37: String sql = "select * from table";
38: Matcher m = pg.matcher(sql);
39: assertFalse(m.find());
40:
41: sql = "wbselectblob blob_column into c:/temp/pic.jpg from mytable";
42: m = pg.matcher(sql);
43: assertFalse(m.find());
44:
45: sql = "select col1, col2, col3 INTO new_table FROM existing_table";
46: m = pg.matcher(sql);
47: assertTrue(m.find());
48:
49: } catch (Exception e) {
50: e.printStackTrace();
51: fail(e.getMessage());
52: }
53:
54: try {
55: String informixPattern = Settings
56: .getInstance()
57: .getProperty(
58: "workbench.db.informix_dynamic_server.selectinto.pattern",
59: null);
60: assertNotNull(informixPattern);
61:
62: Pattern ifx = Pattern.compile(informixPattern,
63: Pattern.CASE_INSENSITIVE);
64: String sql = "select * from table";
65: Matcher m = ifx.matcher(sql);
66: assertFalse(m.find());
67:
68: sql = "wbselectblob blob_column into c:/temp/pic.jpg from mytable";
69: m = ifx.matcher(sql);
70: assertFalse(m.find());
71:
72: sql = "select col1, col2, col3 FROM existing_table INTO new_table";
73: m = ifx.matcher(sql);
74: assertTrue(m.find());
75:
76: } catch (Exception e) {
77: e.printStackTrace();
78: fail(e.getMessage());
79: }
80:
81: }
82: }
|