KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > service > EnvironmentBuilderTest


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 package org.apache.geronimo.deployment.service;
18
19 import java.util.LinkedHashSet JavaDoc;
20 import java.beans.PropertyEditor JavaDoc;
21 import java.beans.PropertyEditorManager JavaDoc;
22
23 import junit.framework.TestCase;
24 import org.apache.geronimo.deployment.xbeans.ArtifactType;
25 import org.apache.geronimo.kernel.repository.Artifact;
26 import org.apache.geronimo.kernel.repository.Environment;
27
28 /**
29  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
30  */

31 public class EnvironmentBuilderTest extends TestCase {
32
33     public void testNoParents() throws Exception JavaDoc {
34         LinkedHashSet JavaDoc parentId = EnvironmentBuilder.toArtifacts(new ArtifactType[] {});
35         assertEquals(0, parentId.size());
36     }
37
38     public void testImportParent1() throws Exception JavaDoc {
39         ArtifactType anImport = ArtifactType.Factory.newInstance();
40         anImport.setGroupId("groupId");
41         anImport.setType("type");
42         anImport.setArtifactId("artifactId");
43         anImport.setVersion("version");
44         LinkedHashSet JavaDoc parentId = EnvironmentBuilder.toArtifacts(new ArtifactType[] {anImport});
45         assertEquals(1, parentId.size());
46         assertEquals(new Artifact("groupId", "artifactId", "version", "type"), parentId.iterator().next());
47     }
48
49     private static final String JavaDoc ENV_1 = "<dep:environment xmlns:dep=\"http://geronimo.apache.org/xml/ns/deployment-1.1\">\n" +
50             " <dep:dependencies>\n" +
51             " <dep:dependency>\n" +
52             " <dep:groupId>${pom.groupId}</dep:groupId>\n" +
53             " <dep:artifactId>j2ee-server</dep:artifactId>\n" +
54             " <dep:version>${pom.currentVersion}</dep:version>\n" +
55             " <dep:type>car</dep:type>\n" +
56             " </dep:dependency>\n" +
57             " </dep:dependencies>\n" +
58             " <dep:hidden-classes/>\n" +
59             " <dep:non-overridable-classes/>\n" +
60             "</dep:environment>";
61
62     public void xtestPropertyEditor() throws Exception JavaDoc {
63         PropertyEditor JavaDoc editor = new EnvironmentBuilder();
64         editor.setAsText(ENV_1);
65         Environment environment = (Environment) editor.getValue();
66         editor.setValue(environment);
67         String JavaDoc text = editor.getAsText();
68         assertEquals(text, ENV_1);
69     }
70
71     public void testPropertyEditorRegistration() throws Exception JavaDoc {
72         ServiceConfigBuilder.getGBeanInfo();
73         PropertyEditor JavaDoc propertyEditor = PropertyEditorManager.findEditor(Environment.class);
74         assertTrue(propertyEditor instanceof EnvironmentBuilder);
75     }
76 }
77
Popular Tags