01: /*
02: * LobFileParameterParserTest.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.util;
13:
14: import junit.framework.*;
15:
16: /**
17: *
18: * @author support@sql-workbench.net
19: */
20: public class LobFileParameterParserTest extends TestCase {
21:
22: public LobFileParameterParserTest(String testName) {
23: super (testName);
24: }
25:
26: public void testGetParameters() {
27: try {
28: String sql = "update bla set col = {$blobfile=c:/temp/test.data} where x=1";
29:
30: LobFileParameterParser p = new LobFileParameterParser(sql);
31: LobFileParameter[] parms = p.getParameters();
32: assertNotNull(parms);
33: assertEquals("File not recognized", 1, parms.length);
34: assertEquals("Wrong filename", "c:/temp/test.data",
35: parms[0].getFilename());
36:
37: sql = "update bla set col = {$clobfile=c:/temp/test.data encoding=UTF8} where x=1";
38: p = new LobFileParameterParser(sql);
39: parms = p.getParameters();
40: assertNotNull(parms);
41: assertEquals("File not recognized", 1, parms.length);
42: assertEquals("Wrong filename", "c:/temp/test.data",
43: parms[0].getFilename());
44: assertEquals("Wrong encoding", "UTF8", parms[0]
45: .getEncoding());
46:
47: sql = "update bla set col = {$clobfile='c:/my data/test.data' encoding='UTF-8'} where x=1";
48: p = new LobFileParameterParser(sql);
49: parms = p.getParameters();
50: assertNotNull(parms);
51: assertEquals("File not recognized", 1, parms.length);
52: assertEquals("Wrong filename", "c:/my data/test.data",
53: parms[0].getFilename());
54: assertEquals("Wrong encoding", "UTF-8", parms[0]
55: .getEncoding());
56:
57: sql = "{$blobfile=c:/temp/test.data}";
58: p = new LobFileParameterParser(sql);
59: parms = p.getParameters();
60: assertNotNull(parms);
61: assertEquals("File not recognized", 1, parms.length);
62: assertEquals("Wrong filename returned",
63: "c:/temp/test.data", parms[0].getFilename());
64: } catch (Exception e) {
65: e.printStackTrace();
66: fail("Could not retrieve blobfile parameter");
67: }
68: }
69:
70: }
|