KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > jorm > rdb > TestRdbNavigatorNodeFactory


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2002 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, S. Chassande-Barrioz, A. Lefebvre
22  */

23 package org.objectweb.medor.query.jorm.rdb;
24
25 import junit.framework.Test;
26 import junit.framework.TestSuite;
27 import junit.textui.TestRunner;
28 import org.objectweb.jorm.api.PException;
29 import org.objectweb.jorm.api.PMapper;
30 import org.objectweb.jorm.mapper.rdb.lib.MapperJDBC;
31 import org.objectweb.jorm.mapper.rdb.lib.ConnectionSpecJDBC;
32 import org.objectweb.medor.lib.Log;
33 import org.objectweb.medor.optim.jorm.JormFlatten2Rdb;
34 import org.objectweb.medor.optim.api.QueryRewriter;
35 import org.objectweb.medor.optim.lib.FlattenQueryTreeRule;
36 import org.objectweb.medor.optim.lib.BasicQueryRewriter;
37 import org.objectweb.medor.query.jorm.TestNavigatorNodeFactory;
38
39 import java.util.ArrayList JavaDoc;
40
41 /**
42  * @author S.Chassande-Barrioz
43  */

44 public class TestRdbNavigatorNodeFactory extends TestNavigatorNodeFactory {
45
46     /**
47      * main method to launch the tests manually
48      */

49     public static void main(String JavaDoc[] args) {
50         TestRunner.run(suite());
51     }
52
53     /**
54      * This method creates a TestSuite object with the current tests
55      */

56     public static Test suite() {
57         return new TestSuite(TestRdbNavigatorNodeFactory.class);
58     }
59
60     public TestRdbNavigatorNodeFactory() {
61         super("TestRdbNavigatorNodeFactory", Log.MEDOR_PREFIX + ".query.jorm.rdb.navigatornode");
62     }
63
64     public TestRdbNavigatorNodeFactory(String JavaDoc testName) {
65         super(testName, Log.MEDOR_PREFIX + ".query.jorm.rdb.navigatornode");
66     }
67
68
69     public PMapper newMappper() {
70         PMapper m = null;
71
72         try {
73             m = new MapperJDBC();
74             ConnectionSpecJDBC cs =
75                 new ConnectionSpecJDBC("jdbc:product:basename", "java.lang.String");
76             m.setConnectionFactory(cs);
77         }
78         catch (PException e) {
79             e.printStackTrace();
80         }
81         return m;
82     }
83
84     public QueryRewriter createQueryRewriter() {
85         ArrayList JavaDoc rules = new ArrayList JavaDoc(2);
86         rules.add(new FlattenQueryTreeRule());
87         rules.add(new JormFlatten2Rdb());
88         return new BasicQueryRewriter(rules);
89     }
90 }
91
Popular Tags