1 19 20 package org.netbeans.modules.apisupport.project.ui.wizard.librarydescriptor; 21 22 import org.netbeans.api.project.libraries.LibraryManager; 23 import org.netbeans.modules.apisupport.project.NbModuleProject; 24 import org.netbeans.modules.apisupport.project.TestBase; 25 import org.netbeans.modules.apisupport.project.layers.LayerTestBase; 26 import org.netbeans.modules.apisupport.project.layers.LayerUtils; 27 import org.netbeans.modules.project.uiapi.ProjectChooserFactory; 28 import org.openide.WizardDescriptor; 29 import org.openide.WizardDescriptor.Panel; 30 import org.openide.filesystems.FileObject; 31 import org.openide.filesystems.FileSystem; 32 import org.openide.filesystems.FileUtil; 33 34 39 public class DataModelTest extends LayerTestBase { 40 public DataModelTest(String name) { 41 super(name); 42 } 43 44 protected void setUp() throws Exception { 45 super.setUp(); 46 TestBase.initializeBuildProperties(getWorkDir(), getDataDir()); 47 LibraryManager lbm = LibraryManager.getDefault(); 48 } 49 50 public void testValidityOfDataModel() throws Exception { 51 NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module1"); 52 WizardDescriptor wd = new WizardDescriptor(new Panel[] {}); 53 wd.putProperty(ProjectChooserFactory.WIZARD_KEY_PROJECT, project); 54 NewLibraryDescriptor.DataModel data = new NewLibraryDescriptor.DataModel(wd); 55 56 assertEquals(project, data.getProject()); 57 58 assertFalse(data.isValidLibraryDisplayName()); 59 assertFalse(data.isValidLibraryName()); 60 61 data.setLibraryName(""); 62 assertFalse(data.isValidLibraryName()); 63 64 data.setLibraryDisplayName(""); 65 assertFalse(data.isValidLibraryDisplayName()); 66 67 data.setLibraryName("mylibrary"); 68 assertTrue(data.isValidLibraryName()); 69 70 data.setLibraryDisplayName("mylibrary is great"); 71 assertTrue(data.isValidLibraryDisplayName()); 72 73 74 assertFalse(data.libraryAlreadyExists()); 75 LayerUtils.LayerHandle h = LayerUtils.layerForProject(data.getProject()); 76 FileSystem fs = h.layer(true); 77 FileObject fo = FileUtil.createData(fs.getRoot(),CreatedModifiedFilesProvider.getLibraryDescriptorEntryPath(data.getLibraryName())); 78 assertNotNull(fo); 79 assertTrue(data.libraryAlreadyExists()); 80 } 81 } 82 83 | Popular Tags |