KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > junit > Oracle8Test


1 /*
2  * Copyright 2003, 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.ws.jaxme.sqls.junit;
18
19 import org.apache.ws.jaxme.sqls.BooleanConstraint;
20 import org.apache.ws.jaxme.sqls.CombinedConstraint;
21 import org.apache.ws.jaxme.sqls.SQLFactory;
22 import org.apache.ws.jaxme.sqls.SQLGenerator;
23 import org.apache.ws.jaxme.sqls.SelectTableReference;
24 import org.apache.ws.jaxme.sqls.Table;
25 import org.apache.ws.jaxme.sqls.oracle.OraColumnReference;
26 import org.apache.ws.jaxme.sqls.oracle.OraSQLFactoryImpl;
27 import org.apache.ws.jaxme.sqls.oracle.OraSQLGenerator;
28 import org.apache.ws.jaxme.sqls.oracle.OraSQLGeneratorImpl;
29 import org.apache.ws.jaxme.sqls.oracle.OraSelectStatement;
30
31
32 /**
33  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
34  */

35 public class Oracle8Test extends CreateTest {
36     /** <p>Creates a new instance of Oracle8Test.</p>
37      */

38     public Oracle8Test(String JavaDoc pName) {
39         super(pName);
40     }
41     
42     protected SQLFactory newSQLFactory() {
43         return new OraSQLFactoryImpl();
44     }
45     
46     protected SQLGenerator newSQLGenerator() {
47         OraSQLGenerator gen = new OraSQLGeneratorImpl();
48         gen.setOracle8Compatibility(true);
49         return gen;
50     }
51     
52     protected String JavaDoc getTestJoinResult() {
53         return "SELECT OtherTable.MyIndex, RefIndex, Company FROM MySchema.OtherTable, MySchema.MyTable WHERE RefIndex=MyTable.MyIndex AND OtherTable.MyIndex=?";
54     }
55     
56     protected String JavaDoc getTestLeftOuterJoinResult() {
57         return "SELECT OtherTable.MyIndex, RefIndex, Company FROM MySchema.OtherTable, MySchema.MyTable WHERE RefIndex=MyTable.MyIndex(+) AND OtherTable.MyIndex=?";
58     }
59
60     public void testConnectByPrior() {
61         Table table = getBasicTable();
62         OraSelectStatement selectStatement = (OraSelectStatement) table.getSelectStatement();
63         SelectTableReference ref = selectStatement.getSelectTableReference();
64         CombinedConstraint startWith = selectStatement.getStartWith();
65         BooleanConstraint bc = startWith.createEQ();
66         bc.addPart(ref.newColumnReference("MyIndex"));
67         bc.addPart(1);
68         CombinedConstraint connectByPrior = selectStatement.getConnectBy();
69         bc = connectByPrior.createEQ();
70         OraColumnReference oraRef = (OraColumnReference) ref.newColumnReference("MyIndex");
71         oraRef.setPrior(true);
72         bc.addPart(oraRef);
73         bc.addPart(ref.newColumnReference("MyName"));
74         SQLGenerator gen = getSQLGenerator();
75         String JavaDoc query = gen.getQuery(selectStatement);
76         assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable START WITH MyIndex=1 CONNECT BY PRIOR MyIndex=MyName", query);
77     }
78
79     protected String JavaDoc getBulkInsertResult() {
80         return "INSERT INTO MySchema.MyTable (MyTable.MyIndex, MyTable.MyName, MyTable.MyDate) (SELECT MyTable0.MyIndex, MyTable0.MyName, MyTable0.MyDate FROM MySchema.MyTable MyTable0)";
81     }
82 }
83
Popular Tags