01: //jTDS JDBC Driver for Microsoft SQL Server and Sybase
02: //Copyright (C) 2004 The jTDS Project
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: //
18: package net.sourceforge.jtds.test;
19:
20: import java.sql.ResultSet;
21: import java.sql.Statement;
22:
23: /**
24: * Test for SSL TLS.
25: *
26: * @author Mike Hutchinson
27: * @version $Id: TlsTest.java,v 1.1 2005/04/15 13:03:43 alin_sinpalean Exp $
28: */
29: public class TlsTest extends DatabaseTestCase {
30:
31: public TlsTest(String name) {
32: super (name);
33: }
34:
35: /**
36: * Test for problem resuming TLS session with SQL Server (bug [1102505] SSL
37: * TLS resume failure).
38: */
39: public void testTLSResume() throws Exception {
40: // This connection will have established the session key
41: Statement stmt = con.createStatement();
42: ResultSet rs = stmt.executeQuery("SELECT 'Hello'");
43: rs.next();
44: assertEquals("Hello", rs.getString(1));
45: con.close();
46: // This connection will attempt to resume the TLS session
47: con = getConnection();
48: stmt = con.createStatement();
49: rs = stmt.executeQuery("SELECT 'World'");
50: rs.next();
51: assertEquals("World", rs.getString(1));
52: }
53:
54: public static void main(String[] args) {
55: junit.textui.TestRunner.run(TlsTest.class);
56: }
57: }
|