KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > MavenTestUtils


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

18
19 import org.codehaus.classworlds.ClassRealm;
20 import org.codehaus.classworlds.ClassWorld;
21 import org.codehaus.plexus.DefaultPlexusContainer;
22 import org.codehaus.plexus.PlexusContainer;
23
24 import java.io.File JavaDoc;
25
26 /**
27  * This is a utility class for helping to configure a PlexusTestCase for testing with maven.
28  *
29  * @author <a HREF="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
30  * @version $Id: MavenTestUtils.java 187639 2005-06-07 00:37:01Z jdcasey $
31  */

32 public class MavenTestUtils
33 {
34     private MavenTestUtils()
35     {
36     }
37
38     public static PlexusContainer getContainerInstance()
39     {
40         return new DefaultPlexusContainer();
41     }
42
43     public static void customizeContext( PlexusContainer container, File JavaDoc basedir, File JavaDoc mavenHome, File JavaDoc mavenHomeLocal )
44         throws Exception JavaDoc
45     {
46         ClassWorld classWorld = new ClassWorld();
47
48         ClassRealm rootClassRealm = classWorld.newRealm( "root", Thread.currentThread().getContextClassLoader() );
49
50         container.addContextValue( "rootClassRealm", rootClassRealm );
51
52         container.addContextValue( "maven.home", mavenHome.getAbsolutePath() );
53
54         container.addContextValue( "maven.home.local", mavenHomeLocal.getAbsolutePath() );
55     }
56 }
57
Popular Tags