KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > impl > role > test > AbstractMetaInfoManagerTestCase


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.fortress.impl.role.test;
19
20 import junit.framework.TestCase;
21 import org.apache.avalon.fortress.MetaInfoEntry;
22 import org.apache.avalon.fortress.MetaInfoManager;
23
24 /**
25  * AbstractMetaInfoManagerTestCase does XYZ
26  *
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  * @version CVS $ Revision: 1.1 $
29  */

30 public abstract class AbstractMetaInfoManagerTestCase extends TestCase
31 {
32     private boolean m_informixClassExists = false;
33     protected MetaInfoManager m_manager;
34
35     public AbstractMetaInfoManagerTestCase( String JavaDoc name )
36     {
37         super( name );
38
39         try
40         {
41             Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" );
42             m_informixClassExists = true;
43         }
44         catch ( Exception JavaDoc e )
45         {
46             m_informixClassExists = false;
47         }
48     }
49
50     protected boolean isInformixClassExists()
51     {
52         return m_informixClassExists;
53     }
54
55     protected void checkRole( final String JavaDoc shortname,
56                               final String JavaDoc[] roles,
57                               final String JavaDoc className,
58                               final String JavaDoc handlerClassname )
59         throws ClassNotFoundException JavaDoc
60     {
61         final MetaInfoEntry metaEntry = m_manager.getMetaInfoForShortName( shortname );
62         assertNotNull( "MetaInfoEntry", metaEntry );
63
64         assertEquals( "componentClass:",
65             metaEntry.getComponentClass(), Class.forName( className ) );
66
67         for ( int i = 0; i < roles.length; i++ )
68         {
69             assertTrue( "Role:", metaEntry.containsRole( roles[i] ) );
70         }
71         assertEquals( "Handler:",
72             metaEntry.getHandlerClass(), Class.forName( handlerClassname ) );
73     }
74 }
75
Popular Tags