1 17 package org.apache.geronimo.deployment.service; 18 19 import java.util.LinkedHashSet ; 20 import java.beans.PropertyEditor ; 21 import java.beans.PropertyEditorManager ; 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 31 public class EnvironmentBuilderTest extends TestCase { 32 33 public void testNoParents() throws Exception { 34 LinkedHashSet parentId = EnvironmentBuilder.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.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 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 { 63 PropertyEditor editor = new EnvironmentBuilder(); 64 editor.setAsText(ENV_1); 65 Environment environment = (Environment) editor.getValue(); 66 editor.setValue(environment); 67 String text = editor.getAsText(); 68 assertEquals(text, ENV_1); 69 } 70 71 public void testPropertyEditorRegistration() throws Exception { 72 ServiceConfigBuilder.getGBeanInfo(); 73 PropertyEditor propertyEditor = PropertyEditorManager.findEditor(Environment.class); 74 assertTrue(propertyEditor instanceof EnvironmentBuilder); 75 } 76 } 77 | Popular Tags |