01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.deployment.tools;
17:
18: import java.net.URL;
19: import java.util.Collections;
20: import java.util.HashSet;
21: import java.util.Set;
22: import java.io.InputStream;
23: import javax.enterprise.deploy.shared.ModuleType;
24: import javax.enterprise.deploy.model.DDBeanRoot;
25:
26: import org.apache.geronimo.deployment.tools.loader.ClientDeployable;
27: import junit.framework.TestCase;
28:
29: /**
30: *
31: *
32: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
33: */
34: public class ClientDeployableTest extends TestCase {
35: private ClassLoader classLoader;
36:
37: public void testLoadClient() throws Exception {
38: URL resource = classLoader
39: .getResource("deployables/app-client1.jar");
40: ClientDeployable deployable = new ClientDeployable(resource);
41: assertEquals(ModuleType.CAR, deployable.getType());
42: Set entrySet = new HashSet(Collections.list(deployable
43: .entries()));
44: Set resultSet = new HashSet();
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 entry = deployable
52: .getEntry("META-INF/application-client.xml");
53: assertNotNull(entry);
54: entry.close();
55: Class main = deployable.getClassFromScope("Main");
56: assertEquals("Main", main.getName());
57:
58: DDBeanRoot root = deployable.getDDBeanRoot();
59: assertNotNull(root);
60: assertEquals(ModuleType.CAR, root.getType());
61: assertEquals(deployable, root.getDeployableObject());
62: }
63:
64: protected void setUp() throws Exception {
65: classLoader = Thread.currentThread().getContextClassLoader();
66: }
67: }
|