KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > model > MRoleTest


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.model;
15
16 import junit.framework.TestCase;
17
18 import org.compiere.util.*;
19
20 /**
21  * The class <code>MRoleTest</code> contains tests for the class {@link
22  * <code>MRole</code>}
23  * <p>
24  * @author Jorg Janke
25  * @version $Id: MRoleTest.java,v 1.1 2003/11/06 07:09:09 jjanke Exp $
26  */

27 public class MRoleTest extends TestCase
28 {
29     /**
30      * Construct new test instance
31      * @param name the test name
32      */

33     public MRoleTest(String JavaDoc name)
34     {
35         super(name);
36     }
37
38     private MRole m_role = null;
39
40     /**
41      * Perform pre-test initialization
42      * @throws Exception
43      * @see TestCase#setUp()
44      */

45     protected void setUp() throws Exception JavaDoc, Exception JavaDoc
46     {
47         org.compiere.Compiere.startupClient();
48         m_role = MRole.getDefault(Env.getCtx(), false);
49         super.setUp();
50     }
51
52     /**
53      * Perform post-test clean up
54      *
55      * @throws Exception
56      *
57      * @see TestCase#tearDown()
58      */

59     protected void tearDown() throws Exception JavaDoc
60     {
61         super.tearDown();
62     }
63
64     /**
65      * Run the String addAccessSQL(String, String, boolean, boolean) method
66      * test
67      */

68     public void testAddAccessSQL()
69     {
70         // add test code here
71
String JavaDoc sql = m_role.addAccessSQL(
72             "SELECT r.a,r.b,r.c FROM AD_Role r WHERE EXISTS "
73             + "(SELECT AD_Column c WHERE c.a=c.b) ORDER BY 1",
74             "r",
75             MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
76         System.out.println(sql);
77         assertEquals(sql, "SELECT r.a,r.b,r.c FROM AD_Role r WHERE EXISTS (SELECT AD_Column c WHERE c.a=c.b) AND r.AD_Client_ID=0 AND r.AD_Org_ID=0 ORDER BY 1");
78     }
79
80
81     /**
82      * Launch the test.
83      * @param args String[]
84      */

85     public static void main(String JavaDoc[] args)
86     {
87         junit.textui.TestRunner.run(MRoleTest.class);
88     }
89
90 } // MRoleTest
91
Popular Tags