KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > blog > logic > EntryControllerTest


1 /*
2  * Copyright (c) 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenChronicle
5  *
6  * $Id: EntryControllerTest.java,v 1.2 2007/02/20 03:59:55 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.blog.logic;
23
24 import junit.extensions.TestSetup;
25 import junit.framework.Test;
26 import junit.framework.TestSuite;
27
28 import org.opensubsystems.blog.persist.db.BlogDatabaseSchema;
29 import org.opensubsystems.blog.persist.db.EntryListDatabaseTestUtils;
30 import org.opensubsystems.core.error.OSSException;
31 import org.opensubsystems.core.persist.db.Database;
32 import org.opensubsystems.core.persist.db.DatabaseImpl;
33 import org.opensubsystems.core.persist.db.DatabaseSchemaManager;
34 import org.opensubsystems.core.persist.db.DatabaseTestSetup;
35 import org.opensubsystems.core.persist.db.DatabaseTestSuite;
36 import org.opensubsystems.patterns.listdata.logic.ListControllerTest;
37
38 /**
39  * Test for ListController interface functionality when accessing entries.
40  *
41  * @version $Id: EntryControllerTest.java,v 1.2 2007/02/20 03:59:55 bastafidli Exp $
42  * @author Miro Halas
43  * @code.reviewer Miro Halas
44  * @code.reviewed 1.1 2007/02/01 07:31:06 bastafidli
45  */

46 public final class EntryControllerTest
47 {
48    // Constructors /////////////////////////////////////////////////////////////
49

50    /**
51     * Private constructor since this class cannot be instantiated
52     */

53    private EntryControllerTest(
54    )
55    {
56       // Do nothing
57
}
58
59    // Public methods ///////////////////////////////////////////////////////////
60

61    /**
62     * Create the suite for this test since this is the only way how to create
63     * test setup which can initialize and shutdown the database for us
64     *
65     * @return Test - suite of tests to run for this database
66     */

67    public static Test suite(
68    )
69    {
70       TestSuite suite = new DatabaseTestSuite("EntryControllerTest");
71       suite.addTestSuite(EntryControllerTestInternal.class);
72       TestSetup wrapper = new DatabaseTestSetup(suite);
73
74       return wrapper;
75    }
76
77    /**
78     * Internal class which can be included in other test suites directly without
79     * including the above suite. This allows us to group multiple tests
80     * together and the execute the DatabaseTestSetup only once
81     */

82    public static class EntryControllerTestInternal extends ListControllerTest
83    {
84       // Constructors /////////////////////////////////////////////////////////////
85

86       /**
87        * Static initializer.
88        */

89       static
90       {
91          Database dbDatabase;
92          try
93          {
94             dbDatabase = DatabaseImpl.getInstance();
95             dbDatabase.add(DatabaseSchemaManager.getInstance(BlogDatabaseSchema.class));
96          }
97          catch (OSSException bfeExc)
98          {
99             throw new RuntimeException JavaDoc("Unexpected exception.", bfeExc);
100          }
101       }
102
103       /**
104        * Constructor
105        *
106        * @param strTestName - name of the test
107        * @throws Exception - an error has occured
108        */

109       public EntryControllerTestInternal(
110          String JavaDoc strTestName
111       ) throws Exception JavaDoc
112       {
113          super(strTestName, new EntryListDatabaseTestUtils());
114       }
115
116       // Tests ////////////////////////////////////////////////////////////////////
117

118       // There are no tests since all manipulation of entries is handled by
119
// BlogController. This test class is here to purely invoke tests for
120
// the ListController provided by the base class
121
}
122 }
123
Popular Tags