KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > SunDeploymentManagerTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * SunDeploymentManagerTest.java
21  * JUnit based test
22  *
23  * Created on December 24, 2003, 11:34 AM
24  */

25
26 package org.netbeans.modules.j2ee.sun.share;
27
28 import java.io.File JavaDoc;
29 import java.io.FileInputStream JavaDoc;
30 import java.io.InputStream JavaDoc;
31 //import java.util.Locale;
32
//import javax.enterprise.deploy.model.DeployableObject;
33
//import javax.enterprise.deploy.spi.Target;
34
//import javax.enterprise.deploy.spi.TargetModuleID;
35
//import javax.enterprise.deploy.spi.status.ProgressObject;
36
//import javax.enterprise.deploy.spi.status.ProgressListener;
37
//import javax.enterprise.deploy.spi.status.ProgressEvent;
38
//import javax.enterprise.deploy.spi.status.DeploymentStatus;
39
//import javax.enterprise.deploy.shared.DConfigBeanVersionType;
40
//import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
41
import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
42 //import javax.enterprise.deploy.spi.DeploymentConfiguration;
43
//import javax.enterprise.deploy.shared.ModuleType;
44
//import javax.enterprise.deploy.spi.exceptions.TargetException;
45
//import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration;
46
//import java.util.jar.JarOutputStream;
47
//import java.io.FileOutputStream;
48
//import org.netbeans.modules.j2ee.sun.share.plan.Util;
49
import junit.framework.*;
50
51 /**
52  *
53  * @author vkraemer
54  */

55 public class SunDeploymentManagerTest extends TestCase {
56     
57     //String validPlan1 = "<deployment-plan></deployment-plan>";
58

59     public void testGetInternalPlanFileWithNotWellFormedString() {
60         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
61         InputStream JavaDoc is1 = new java.io.StringBufferInputStream JavaDoc(TestConstants.invalidPlan1);
62         try {
63             File JavaDoc retVal = dm.getInternalPlanFile(is1);
64             retVal.delete();
65             fail("The file was was not well formed. I should not get here");
66         }
67         catch (IllegalStateException JavaDoc ise) {
68             assertEquals("file handling issues", ise.getMessage());
69             //ise.printStackTrace();
70
}
71     }
72     
73     
74     public void testGetInternalPlanFileInvalidContentString() {
75         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
76         InputStream JavaDoc is1 = new java.io.StringBufferInputStream JavaDoc(TestConstants.invalidPlan2);
77         try {
78             File JavaDoc retVal = dm.getInternalPlanFile(is1);
79             retVal.delete();
80             fail("The file was was not a valid plan. I should not get here");
81         }
82         catch (IllegalStateException JavaDoc ise) {
83             assertEquals("file handling issues", ise.getMessage());
84             //ise.printStackTrace();
85
}
86     }
87
88     public void testGetInternalPlanFileWithDPString() {
89         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
90         InputStream JavaDoc is1 = new java.io.StringBufferInputStream JavaDoc(TestConstants.validPlan2);
91         File JavaDoc retVal = dm.getInternalPlanFile(is1);
92         assertNotNull(retVal);
93         retVal.delete();
94     }
95     
96     public void testGetInternalPlanFileWithSWAString() {
97         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
98         InputStream JavaDoc is1 = new java.io.StringBufferInputStream JavaDoc(TestConstants.validPlan3);
99         File JavaDoc retVal = dm.getInternalPlanFile(is1);
100         assertNotNull(retVal);
101         retVal.delete();
102     }
103     
104
105     public void testGetInternalPlanFileWithDPFile() {
106         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
107         InputStream JavaDoc is1 = null;
108         File JavaDoc myTestFile = new File JavaDoc("validDeploymentPlan.xml");
109         System.out.println("path to file:"+myTestFile.getAbsolutePath());
110         try {
111             is1 = new FileInputStream JavaDoc(myTestFile);
112             File JavaDoc retVal = dm.getInternalPlanFile(is1);
113             assertNotNull(retVal);
114         }
115         catch (java.io.FileNotFoundException JavaDoc fnfe) {
116             fail("file not found issue");
117         }
118     }
119     public void testGetInternalPlanFileWithSWAFile() {
120         SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager JavaDoc) null, (SunDeploymentFactory) null, "", 0);
121         InputStream JavaDoc is1 = null;
122         File JavaDoc myTestFile = new File JavaDoc("validSunWebApp.xml");
123         System.out.println("path to file:"+myTestFile.getAbsolutePath());
124         try {
125             is1 = new FileInputStream JavaDoc(myTestFile);
126             File JavaDoc retVal = dm.getInternalPlanFile(is1);
127             assertNotNull(retVal);
128         }
129         catch (java.io.FileNotFoundException JavaDoc fnfe) {
130             fail("file not found issue");
131         }
132     }
133     
134     public SunDeploymentManagerTest(java.lang.String JavaDoc testName) {
135         super(testName);
136     }
137     
138 }
139
Popular Tags