KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > util > env > EnvTest


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

16
17 package org.apache.avalon.util.env;
18
19 import junit.framework.TestCase;
20
21
22 /**
23  * Env tests.
24  *
25  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
26  * @version $Revision: 1.4 $
27  */

28 public class EnvTest extends TestCase
29 {
30     public static void main(String JavaDoc[] args)
31     {
32         junit.textui.TestRunner.run(EnvTest.class);
33     }
34
35     
36     /*
37      * @see TestCase#setUp()
38      */

39     protected void setUp() throws Exception JavaDoc
40     {
41         super.setUp();
42     }
43
44     
45     /*
46      * @see TestCase#tearDown()
47      */

48     protected void tearDown() throws Exception JavaDoc
49     {
50         super.tearDown();
51     }
52     
53
54     /**
55      * Constructor for EnvTest.
56      * @param arg0
57      */

58     public EnvTest(String JavaDoc arg0)
59     {
60         super(arg0);
61     }
62
63     
64     final public void testEnvVariable()
65         throws Exception JavaDoc
66     {
67         if ( Env.isUnix() )
68         {
69             assertNotNull( Env.getEnvVariable( "PATH" ) ) ;
70         }
71         
72         if ( Env.isWindows() )
73         {
74             assertNotNull( Env.getEnvVariable( "Path" ) ) ;
75         }
76         
77         assertNull( Env.getEnvVariable( "PAT" ) ) ;
78     }
79
80     
81     public void testEnv()
82         throws EnvAccessException
83     {
84         Env l_env = new Env() ;
85         assertNull( l_env.getProperty( "PAT" ) ) ;
86         
87         if ( Env.isUnix() )
88         {
89             assertNotNull( l_env.getProperty( "PATH" ) ) ;
90         }
91         
92         if ( Env.isWindows() )
93         {
94             assertNotNull( l_env.getProperty( "PROMPT" ) ) ;
95         }
96     }
97 }
98
Popular Tags