1 19 20 package org.netbeans.modules.apisupport.project.ui.wizard.updatecenter; 21 22 import java.io.File ; 23 import java.util.Arrays ; 24 import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; 25 import org.netbeans.modules.apisupport.project.CreatedModifiedFilesTest; 26 import org.netbeans.modules.apisupport.project.NbModuleProject; 27 import org.netbeans.modules.apisupport.project.TestBase; 28 import org.netbeans.modules.apisupport.project.layers.LayerTestBase; 29 import org.netbeans.modules.project.uiapi.ProjectChooserFactory; 30 import org.openide.WizardDescriptor; 31 import org.openide.WizardDescriptor.Panel; 32 33 38 public class DataModelTest extends LayerTestBase { 39 NbModuleProject project = null; 40 41 public DataModelTest(String name) { 42 super(name); 43 } 44 45 protected void setUp() throws Exception { 46 super.setUp(); 47 TestBase.initializeBuildProperties(getWorkDir(), getDataDir()); 48 project = TestBase.generateStandaloneModule (getWorkDir(), "module1"); 49 } 50 51 private void testAddUpdateCenter (String pathToSettingsFile, String [] supposedContent) throws Exception { 52 WizardDescriptor wd = new WizardDescriptor (new Panel [] {}); 53 wd.putProperty (ProjectChooserFactory.WIZARD_KEY_PROJECT, project); 54 DataModel data = new DataModel (wd); 55 56 UpdateCenterRegistrationPanel p = new UpdateCenterRegistrationPanel (wd, data); 58 p.updateData (); 59 60 CreatedModifiedFiles cmf = data.refreshCreatedModifiedFiles (); 61 assertEquals ( 62 Arrays.asList (new String [] {pathToSettingsFile}), 63 Arrays.asList (cmf.getCreatedPaths ())); 64 assertEquals( 65 Arrays.asList(new String [] {"nbproject/project.xml", "src/org/example/module1/resources/Bundle.properties", "src/org/example/module1/resources/layer.xml"}), 66 Arrays.asList(cmf.getModifiedPaths())); 67 68 cmf.run(); 69 70 CreatedModifiedFilesTest.assertLayerContent(supposedContent, 71 new File (getWorkDir(), "module1/src/org/example/module1/resources/layer.xml")); 72 } 73 74 public void testAddUpdateCenterWithDefaultValues () throws Exception { 75 String [] supposedContent = new String [] { 76 "<filesystem>", 77 "<folder name=\"Services\">", 78 "<folder name=\"AutoupdateType\">", 79 "<file name=\"org_example_module1_update_center.settings\" url=\"org_example_module1_update_centerSettings.xml\">", 80 "<attr name=\"SystemFileSystem.localizingBundle\" stringvalue=\"org.example.module1.resources.Bundle\"/>", 81 "<attr name=\"enabled\" boolvalue=\"true\"/>", 82 "<attr name=\"url_key\" stringvalue=\"org_example_module1_update_center\"/>", 83 "</file>", 84 "</folder>", 85 "</folder>", 86 "</filesystem>" 87 }; 88 89 testAddUpdateCenter ("src/org/example/module1/resources/org_example_module1_update_centerSettings.xml", supposedContent); 90 } 91 92 public void testAddUpdateCenterDouble () throws Exception { 93 String [] supposedContent = new String [] { 94 "<filesystem>", 95 "<folder name=\"Services\">", 96 "<folder name=\"AutoupdateType\">", 97 "<file name=\"org_example_module1_update_center.settings\" url=\"org_example_module1_update_centerSettings.xml\">", 98 "<attr name=\"SystemFileSystem.localizingBundle\" stringvalue=\"org.example.module1.resources.Bundle\"/>", 99 "<attr name=\"enabled\" boolvalue=\"true\"/>", 100 "<attr name=\"url_key\" stringvalue=\"org_example_module1_update_center\"/>", 101 "</file>", 102 "<file name=\"org_example_module1_update_center_1.settings\" url=\"org_example_module1_update_center_1Settings.xml\">", 103 "<attr name=\"SystemFileSystem.localizingBundle\" stringvalue=\"org.example.module1.resources.Bundle\"/>", 104 "<attr name=\"enabled\" boolvalue=\"true\"/>", 105 "<attr name=\"url_key\" stringvalue=\"org_example_module1_update_center_1\"/>", 106 "</file>", 107 "</folder>", 108 "</folder>", 109 "</filesystem>" 110 }; 111 112 testAddUpdateCenterWithDefaultValues (); 113 testAddUpdateCenter ("src/org/example/module1/resources/org_example_module1_update_center_1Settings.xml", supposedContent); 114 } 115 116 } 117 118 | Popular Tags |