001: /*
002: * CreateFromEar.java
003: *
004: * Created on June 5, 2006, 3:45 PM
005: *
006: * To change this template, choose Tools | Template Manager
007: * and open the template in the editor.
008: */
009:
010: package org.netbeans.modules.j2ee.archive.xtests;
011:
012: import java.io.File;
013: import java.io.IOException;
014: import org.netbeans.api.project.Project;
015: import org.netbeans.api.project.ProjectManager;
016: import org.netbeans.junit.NbTestCase;
017: import org.netbeans.junit.NbTestSuite;
018: import org.netbeans.modules.j2ee.archive.project.ArchiveProjectProperties;
019: import org.netbeans.modules.j2ee.archive.ui.JavaEePlatformUiSupport;
020: import org.netbeans.modules.j2ee.archive.wizard.*;
021: import org.netbeans.spi.project.ui.CustomizerProvider;
022: import org.netbeans.spi.project.ui.support.ProjectChooser;
023: import org.openide.WizardDescriptor;
024: import org.openide.filesystems.FileObject;
025: import org.openide.filesystems.FileUtil;
026:
027: /**
028: *
029: * @author vbk
030: */
031: public class CreateProjectsTest extends NbTestCase {
032:
033: /** Creates a new instance of CreateFromEar */
034: public CreateProjectsTest(String testName) {
035: super (testName);
036: }
037:
038: public void createFromOne4Ear() {
039: TestUtil.createProjectFromArchive("jbearwebbean.ear",
040: ArchiveProjectProperties.PROJECT_TYPE_VALUE_EAR, 15000);
041: File f = new File(System.getProperty("xtest.tmpdir")
042: + File.separator + "jbearwebbean.ear");
043: if (!f.exists())
044: fail("directory missing: " + f.getAbsolutePath());
045: Project p = null;
046: try {
047: p = ProjectManager.getDefault().findProject(
048: FileUtil.toFileObject(f));
049: } catch (IllegalArgumentException ex) {
050: fail(ex.getMessage());
051: } catch (IOException ex) {
052: fail(ex.getMessage());
053: }
054: CustomizerProvider cp = (CustomizerProvider) p.getLookup()
055: .lookup(CustomizerProvider.class);
056: //cp.
057: }
058:
059: public void createFromBadOne4Ear() {
060: TestUtil.createProjectFromArchive("BADcmpcustomer.ear",
061: ArchiveProjectProperties.PROJECT_TYPE_VALUE_EAR, 20000);
062: File f = new File(System.getProperty("xtest.tmpdir")
063: + File.separator + "BADcmpcustomer.ear");
064: if (f.exists())
065: fail("directory wasn't deleted: " + f.getAbsolutePath());
066: }
067:
068: public void createFromFiveEar() {
069: TestUtil.createProjectFromArchive("noddjavaee5.ear",
070: ArchiveProjectProperties.PROJECT_TYPE_VALUE_EAR, 15000);
071: File f = new File(System.getProperty("xtest.tmpdir")
072: + File.separator + "noddjavaee5.ear");
073: if (!f.exists())
074: fail("directory missing: " + f.getAbsolutePath());
075: }
076:
077: public void createFromOne4EjbJar() {
078: TestUtil.createProjectFromArchive("jbrejb14.jar",
079: ArchiveProjectProperties.PROJECT_TYPE_VALUE_JAR, 20000);
080: File f = new File(System.getProperty("xtest.tmpdir")
081: + File.separator + "jbrejb14.jar");
082: if (!f.exists())
083: fail("directory missing: " + f.getAbsolutePath());
084: f = new File(System.getProperty("xtest.tmpdir")
085: + File.separator + "jbrejb14.jar" + File.separator
086: + "tmpproj" + File.separator + "src" + File.separator
087: + "conf" + File.separator + "sun-ejb-jar.xml");
088: if (!f.exists())
089: fail("descriptor missing: " + f.getAbsolutePath());
090: if (f.length() < 300)
091: fail("descriptor is too short: " + f.length());
092:
093: }
094:
095: public void createFromOne4War() {
096: TestUtil.createProjectFromArchive("tcwa14.war",
097: ArchiveProjectProperties.PROJECT_TYPE_VALUE_WAR, 15000);
098: File f = new File(System.getProperty("xtest.tmpdir")
099: + File.separator + "tcwa14.war");
100: if (!f.exists())
101: fail("directory missing: " + f.getAbsolutePath());
102: f = new File(System.getProperty("xtest.tmpdir")
103: + File.separator + "tcwa14.war" + File.separator
104: + "tmpproj" + File.separator + "web" + File.separator
105: + "WEB-INF" + File.separator + "sun-web.xml");
106: if (!f.exists())
107: fail("descriptor missing: " + f.getAbsolutePath());
108: if (f.length() < 300)
109: fail("descriptor is too short: " + f.length());
110: }
111:
112: public void createFromRar() {
113: TestUtil.createProjectFromArchive("mailconnector.rar",
114: ArchiveProjectProperties.PROJECT_TYPE_VALUE_RAR, 15000);
115: File f = new File(System.getProperty("xtest.tmpdir")
116: + File.separator + "mailconnector.rar");
117: if (!f.exists())
118: fail("directory missing: " + f.getAbsolutePath());
119: }
120:
121: public static NbTestSuite suite() {
122: NbTestSuite suite = new NbTestSuite("CreateProjectsTest");
123: suite.addTest(new AddRemoveSjsasInstance4Test(
124: "addSjsasInstance"));
125: suite.addTest(new CreateProjectsTest("createFromOne4Ear"));
126: suite.addTest(new CreateProjectsTest("createFromBadOne4Ear"));
127: suite.addTest(new CreateProjectsTest("createFromFiveEar"));
128: suite.addTest(new CreateProjectsTest("createFromOne4EjbJar"));
129: suite.addTest(new CreateProjectsTest("createFromOne4War"));
130: suite.addTest(new CreateProjectsTest("createFromRar"));
131: return suite;
132: }
133: }
|