KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > tools > ClientDeployableTest


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

17
18 package org.apache.geronimo.deployment.tools;
19
20 import java.net.URL JavaDoc;
21 import java.util.Collections JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.Set JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
26 import javax.enterprise.deploy.model.DDBeanRoot JavaDoc;
27
28 import org.apache.geronimo.deployment.tools.loader.ClientDeployable;
29 import junit.framework.TestCase;
30
31 /**
32  *
33  *
34  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
35  */

36 public class ClientDeployableTest extends TestCase {
37     private ClassLoader JavaDoc classLoader;
38
39     public void testLoadClient() throws Exception JavaDoc {
40         URL JavaDoc resource = classLoader.getResource("deployables/app-client1.jar");
41         ClientDeployable deployable = new ClientDeployable(resource);
42         assertEquals(ModuleType.CAR, deployable.getType());
43         Set JavaDoc entrySet = new HashSet JavaDoc(Collections.list(deployable.entries()));
44         Set JavaDoc resultSet = new HashSet JavaDoc();
45         resultSet.add("META-INF/");
46         resultSet.add("META-INF/MANIFEST.MF");
47         resultSet.add("META-INF/application-client.xml");
48         resultSet.add("Main.java");
49         resultSet.add("Main.class");
50         assertEquals(resultSet, entrySet);
51         InputStream JavaDoc entry = deployable.getEntry("META-INF/application-client.xml");
52         assertNotNull(entry);
53         entry.close();
54         Class JavaDoc main = deployable.getClassFromScope("Main");
55         assertEquals("Main", main.getName());
56
57         DDBeanRoot JavaDoc root = deployable.getDDBeanRoot();
58         assertNotNull(root);
59         assertEquals(ModuleType.CAR, root.getType());
60         assertEquals(deployable, root.getDeployableObject());
61     }
62
63     protected void setUp() throws Exception JavaDoc {
64         classLoader = Thread.currentThread().getContextClassLoader();
65     }
66 }
67
Popular Tags