EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveutils.test]

COVERAGE SUMMARY FOR SOURCE FILE [HivemindIntegrationTestCase.java]

nameclass, %method, %block, %line, %
HivemindIntegrationTestCase.java100% (1/1)100% (4/4)81%  (59/73)92%  (12/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HivemindIntegrationTestCase100% (1/1)100% (4/4)81%  (59/73)92%  (12/13)
getResource (String): Resource 100% (1/1)46%  (12/26)75%  (3/4)
HivemindIntegrationTestCase (): void 100% (1/1)100% (3/3)100% (1/1)
buildFrameworkRegistry (String []): Registry 100% (1/1)100% (35/35)100% (7/7)
buildFrameworkRegistry (String): Registry 100% (1/1)100% (9/9)100% (1/1)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
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 implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveutils.test;
16 
17import java.net.URL;
18import java.util.Locale;
19 
20import org.apache.hivemind.ClassResolver;
21import org.apache.hivemind.Registry;
22import org.apache.hivemind.Resource;
23import org.apache.hivemind.impl.DefaultClassResolver;
24import org.apache.hivemind.impl.RegistryBuilder;
25import org.apache.hivemind.impl.XmlModuleDescriptorProvider;
26import org.apache.hivemind.util.URLResource;
27 
28/**
29 * Utility class that integration test cases can inherit in order to have better
30 * support for HiveMind tests.
31 * This code was just excerpted from HiveMind <code>HiveMindTestCase</code>.
32 *
33 * @author Howard Lewis Ship
34 * @author Jean-Francois Poilpret
35 */
36public class HivemindIntegrationTestCase extends HivemindUnitTestCase
37{
38    /**
39     * Returns the given file as a <code>Resource</code> from the classpath.
40     * Typically, this is to find files in the same folder as the invoking class.
41     */
42        protected Resource getResource(String file)
43        {
44                URL url = getClass().getResource(file);
45                if (url == null)
46                {
47                        throw new NullPointerException("No resource named '" + file + "'.");
48                }
49                return new URLResource(url);
50        }
51        
52    /**
53     * Convienience method for invoking
54     * {@link #buildFrameworkRegistry(String[])} with only a single file.
55     */
56        protected Registry buildFrameworkRegistry(String file) throws Exception
57        {
58                return buildFrameworkRegistry(new String[] {file});
59        }
60        
61    /**
62     * Builds a minimal registry, containing only the specified files, plus
63     * the master module descriptor (ie, those visible on the classpath).
64     * Files are resolved using {@link #getResource(String)}.
65     */
66        protected Registry buildFrameworkRegistry(String[] files) throws Exception
67        {
68                ClassResolver resolver = new DefaultClassResolver();
69                RegistryBuilder builder = new RegistryBuilder();
70                for (int i = 0; i < files.length; i++)
71                {
72                        Resource resource = getResource(files[i]);
73                        builder.addModuleDescriptorProvider(
74                                                new XmlModuleDescriptorProvider(resolver, resource));
75                }
76                builder.addDefaultModuleDescriptorProvider();
77                return builder.constructRegistry(Locale.getDefault());
78        }
79}

[all classes][net.sourceforge.hiveutils.test]
EMMA 2.0.5312 (C) Vladimir Roubtsov