Line 0
Link Here
|
|
|
1 |
/* |
2 |
* Copyright 1999,2004 The Apache Software Foundation. |
3 |
* |
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
* you may not use this file except in compliance with the License. |
6 |
* You may obtain a copy of the License at |
7 |
* |
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
9 |
* |
10 |
* Unless required by applicable law or agreed to in writing, software |
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
* See the License for the specific language governing permissions and |
14 |
* limitations under the License. |
15 |
*/ |
16 |
|
17 |
package org.apache.taglibs.standard.tag.el.sql; |
18 |
|
19 |
import java.sql.*; |
20 |
import javax.servlet.jsp.*; |
21 |
import org.apache.cactus.*; |
22 |
import org.apache.taglibs.standard.testutil.TestUtil; |
23 |
|
24 |
public class Test33054 extends JspTestCase { |
25 |
|
26 |
public Test33054(String name) { |
27 |
super(name); |
28 |
} |
29 |
|
30 |
protected void setUp() throws Exception { |
31 |
super.setUp(); |
32 |
Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); |
33 |
Connection conn = DriverManager.getConnection("jdbc:derby:cactustest;create=true"); |
34 |
Statement stmt = conn.createStatement(); |
35 |
try { stmt.execute("DROP TABLE Bug33054"); } catch(SQLException sqle) { } // ignore |
36 |
stmt.execute("CREATE TABLE Bug33054 ( id int primary key, name varchar(80) )"); |
37 |
stmt.execute("INSERT INTO Bug33054 VALUES(1, 'a')"); |
38 |
|
39 |
ResultSet rs = stmt.executeQuery("SELECT * FROM Bug33054"); |
40 |
rs.next(); |
41 |
assertEquals( 1, rs.getInt(1) ); |
42 |
assertEquals( "a", rs.getString(2) ); |
43 |
|
44 |
rs.close(); |
45 |
stmt.close(); |
46 |
conn.close(); |
47 |
} |
48 |
|
49 |
protected void tearDown() throws Exception { |
50 |
super.tearDown(); |
51 |
Connection conn = DriverManager.getConnection("jdbc:derby:cactustest"); |
52 |
Statement stmt = conn.createStatement(); |
53 |
stmt.execute("DROP TABLE Bug33054"); |
54 |
stmt.close(); |
55 |
conn.close(); |
56 |
} |
57 |
|
58 |
public void test33054() throws Exception { |
59 |
String toInclude = TestUtil.getTestJsp(this); |
60 |
pageContext.include(toInclude); |
61 |
|
62 |
String data = (String) pageContext.getAttribute("bug33054", PageContext.APPLICATION_SCOPE); |
63 |
|
64 |
assertEquals( "ID=1NAME=1" + "ID1=1NAME1=a" + "ID2=1NAME2=a", data ); |
65 |
} |
66 |
} |