1 /*
2  * This file is part of the LibreOffice project.
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
10  *   Licensed to the Apache Software Foundation (ASF) under one or more
11  *   contributor license agreements. See the NOTICE file distributed
12  *   with this work for additional information regarding copyright
13  *   ownership. The ASF licenses this file to you under the Apache
14  *   License, Version 2.0 (the "License"); you may not use this file
15  *   except in compliance with the License. You may obtain a copy of
16  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17  */
18 package complex.dbaccess;
19 
20 import com.sun.star.sdb.XSingleSelectQueryComposer;
21 import connectivity.tools.CRMDatabase;
22 
23 // ---------- junit imports -----------------
24 import org.junit.After;
25 import org.junit.Before;
26 
27 
28 public abstract class CRMBasedTestCase extends TestCase
29 {
30     protected   CRMDatabase m_database;
31 
createTestCase()32     protected void createTestCase() throws Exception
33     {
34         m_database = new CRMDatabase( getMSF(), false );
35     }
36 
37 
38     @Before
39     @Override
before()40     public void before() throws Exception
41     {
42         createTestCase();
43     }
44 
45 
46     @After
47     @Override
after()48     public void after() throws Exception
49     {
50         if ( m_database != null )
51         {
52             m_database.saveAndClose();
53         }
54     }
55 
56 
57     /** creates a SingleSelectQueryComposer for our connection
58      */
createQueryComposer()59     protected final XSingleSelectQueryComposer createQueryComposer() throws com.sun.star.uno.Exception
60     {
61         return m_database.getConnection().createSingleSelectQueryComposer();
62     }
63 }
64