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.service;
17:
18: import java.util.LinkedHashSet;
19: import java.beans.PropertyEditor;
20: import java.beans.PropertyEditorManager;
21:
22: import junit.framework.TestCase;
23: import org.apache.geronimo.deployment.xbeans.ArtifactType;
24: import org.apache.geronimo.kernel.repository.Artifact;
25: import org.apache.geronimo.kernel.repository.Environment;
26:
27: /**
28: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
29: */
30: public class EnvironmentBuilderTest extends TestCase {
31:
32: public void testNoParents() throws Exception {
33: LinkedHashSet parentId = EnvironmentBuilder
34: .toArtifacts(new ArtifactType[] {});
35: assertEquals(0, parentId.size());
36: }
37:
38: public void testImportParent1() throws Exception {
39: ArtifactType anImport = ArtifactType.Factory.newInstance();
40: anImport.setGroupId("groupId");
41: anImport.setType("type");
42: anImport.setArtifactId("artifactId");
43: anImport.setVersion("version");
44: LinkedHashSet parentId = EnvironmentBuilder
45: .toArtifacts(new ArtifactType[] { anImport });
46: assertEquals(1, parentId.size());
47: assertEquals(new Artifact("groupId", "artifactId", "version",
48: "type"), parentId.iterator().next());
49: }
50:
51: private static final String ENV_1 = "<dep:environment xmlns:dep=\"http://geronimo.apache.org/xml/ns/deployment-1.1\">\n"
52: + " <dep:dependencies>\n"
53: + " <dep:dependency>\n"
54: + " <dep:groupId>${pom.groupId}</dep:groupId>\n"
55: + " <dep:artifactId>j2ee-server</dep:artifactId>\n"
56: + " <dep:version>${pom.currentVersion}</dep:version>\n"
57: + " <dep:type>car</dep:type>\n"
58: + " </dep:dependency>\n"
59: + " </dep:dependencies>\n"
60: + " <dep:hidden-classes/>\n"
61: + " <dep:non-overridable-classes/>\n"
62: + "</dep:environment>";
63:
64: public void xtestPropertyEditor() throws Exception {
65: PropertyEditor editor = new EnvironmentBuilder();
66: editor.setAsText(ENV_1);
67: Environment environment = (Environment) editor.getValue();
68: editor.setValue(environment);
69: String text = editor.getAsText();
70: assertEquals(text, ENV_1);
71: }
72:
73: public void testPropertyEditorRegistration() throws Exception {
74: ServiceConfigBuilder.getGBeanInfo();
75: PropertyEditor propertyEditor = PropertyEditorManager
76: .findEditor(Environment.class);
77: assertTrue(propertyEditor instanceof EnvironmentBuilder);
78: }
79: }
|