1 19 25 26 package org.netbeans.modules.j2ee.sun.share; 27 28 import java.io.File ; 29 import java.io.FileInputStream ; 30 import java.io.InputStream ; 31 import javax.enterprise.deploy.spi.DeploymentManager ; 42 import junit.framework.*; 50 51 55 public class SunDeploymentManagerTest extends TestCase { 56 57 59 public void testGetInternalPlanFileWithNotWellFormedString() { 60 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 61 InputStream is1 = new java.io.StringBufferInputStream (TestConstants.invalidPlan1); 62 try { 63 File 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 ise) { 68 assertEquals("file handling issues", ise.getMessage()); 69 } 71 } 72 73 74 public void testGetInternalPlanFileInvalidContentString() { 75 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 76 InputStream is1 = new java.io.StringBufferInputStream (TestConstants.invalidPlan2); 77 try { 78 File 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 ise) { 83 assertEquals("file handling issues", ise.getMessage()); 84 } 86 } 87 88 public void testGetInternalPlanFileWithDPString() { 89 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 90 InputStream is1 = new java.io.StringBufferInputStream (TestConstants.validPlan2); 91 File retVal = dm.getInternalPlanFile(is1); 92 assertNotNull(retVal); 93 retVal.delete(); 94 } 95 96 public void testGetInternalPlanFileWithSWAString() { 97 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 98 InputStream is1 = new java.io.StringBufferInputStream (TestConstants.validPlan3); 99 File retVal = dm.getInternalPlanFile(is1); 100 assertNotNull(retVal); 101 retVal.delete(); 102 } 103 104 105 public void testGetInternalPlanFileWithDPFile() { 106 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 107 InputStream is1 = null; 108 File myTestFile = new File ("validDeploymentPlan.xml"); 109 System.out.println("path to file:"+myTestFile.getAbsolutePath()); 110 try { 111 is1 = new FileInputStream (myTestFile); 112 File retVal = dm.getInternalPlanFile(is1); 113 assertNotNull(retVal); 114 } 115 catch (java.io.FileNotFoundException fnfe) { 116 fail("file not found issue"); 117 } 118 } 119 public void testGetInternalPlanFileWithSWAFile() { 120 SunDeploymentManager dm = new SunDeploymentManager((DeploymentManager ) null, (SunDeploymentFactory) null, "", 0); 121 InputStream is1 = null; 122 File myTestFile = new File ("validSunWebApp.xml"); 123 System.out.println("path to file:"+myTestFile.getAbsolutePath()); 124 try { 125 is1 = new FileInputStream (myTestFile); 126 File retVal = dm.getInternalPlanFile(is1); 127 assertNotNull(retVal); 128 } 129 catch (java.io.FileNotFoundException fnfe) { 130 fail("file not found issue"); 131 } 132 } 133 134 public SunDeploymentManagerTest(java.lang.String testName) { 135 super(testName); 136 } 137 138 } 139 | Popular Tags |