01: /*
02: * PostgresBlobFormatterTest.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.storage;
13:
14: import java.io.ByteArrayOutputStream;
15: import junit.framework.TestCase;
16:
17: /**
18: * @author support@sql-workbench.net
19: */
20: public class PostgresBlobFormatterTest extends TestCase {
21: public PostgresBlobFormatterTest(String testName) {
22: super (testName);
23: }
24:
25: public void testGetBlobLiteral() throws Exception {
26: PostgresBlobFormatter formatter = new PostgresBlobFormatter();
27: ByteArrayOutputStream b = new ByteArrayOutputStream();
28: b.write(255);
29: b.write(0);
30: b.write(16);
31: b.write(15);
32: byte[] blob = b.toByteArray();
33: String literal = formatter.getBlobLiteral(blob).toString();
34:
35: assertEquals("Wrong literal created",
36: "'\\\\377\\\\000\\\\020\\\\017'", literal);
37: }
38: }
|