Fix new test case node not showing up after creation.
1.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestChildren.java Fri Jan 11 07:12:25 2008 +0000
1.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestChildren.java Fri Jan 11 09:13:10 2008 +0000
1.3 @@ -48,7 +48,6 @@
1.4 import java.util.Collections;
1.5 import java.util.Comparator;
1.6 import java.util.List;
1.7 -import org.netbeans.api.project.Project;
1.8 import org.netbeans.modules.compapp.projects.jbi.JbiProject;
1.9 import org.openide.filesystems.FileObject;
1.10 import org.openide.nodes.Children;
1.11 @@ -67,14 +66,12 @@
1.12 private final JbiProject mProject;
1.13
1.14 private static final String[] TEST_PROPERTY_FILES = new String[] {
1.15 - "Invoke.properties", "Concurrent.properties", "Correlation.properties", }; // NOI18N
1.16 + "Invoke.properties", "Concurrent.properties", "Correlation.properties" }; // NOI18N
1.17
1.18
1.19 /**
1.20 * Creates a new TestChildren object.
1.21 *
1.22 - *
1.23 - *
1.24 * @param project DOCUMENT ME!
1.25 */
1.26 public TestChildren(JbiProject project, FileObject testDir) {
1.27 @@ -85,6 +82,7 @@
1.28 /**
1.29 * DOCUMENT ME!
1.30 */
1.31 + @Override
1.32 protected void addNotify() {
1.33 super.addNotify();
1.34 updateKeys();
1.35 @@ -95,7 +93,7 @@
1.36
1.37
1.38 private static boolean isTest(FileObject fo) {
1.39 - if (!fo.isFolder()) {
1.40 + if (!fo.isFolder()) {
1.41 return false;
1.42 }
1.43
1.44 @@ -122,6 +120,7 @@
1.45 public int compare(Object o1, Object o2) {
1.46 return ((FileObject)o1).getName().compareTo(((FileObject)o2).getName());
1.47 }
1.48 + @Override
1.49 public boolean equals(Object obj) {
1.50 return this == obj;
1.51 }
1.52 @@ -132,6 +131,7 @@
1.53 /**
1.54 * DOCUMENT ME!
1.55 */
1.56 + @Override
1.57 protected void removeNotify() {
1.58 //epp.removePropertyChangeListener(this);
1.59 setKeys(Collections.EMPTY_SET);
2.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestNode.java Fri Jan 11 07:12:25 2008 +0000
2.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestNode.java Fri Jan 11 09:13:10 2008 +0000
2.3 @@ -114,14 +114,17 @@
2.4 );
2.5 }
2.6
2.7 + @Override
2.8 public void fileFolderCreated(FileEvent fe) {
2.9 update();
2.10 }
2.11
2.12 + @Override
2.13 public void fileDeleted(FileEvent fe) {
2.14 update();
2.15 }
2.16
2.17 + @Override
2.18 public void fileRenamed(FileRenameEvent fe) {
2.19 update();
2.20 }
2.21 @@ -140,16 +143,19 @@
2.22 }
2.23 }
2.24
2.25 + @Override
2.26 public String getDisplayName() {
2.27 return NbBundle.getMessage(TestNode.class, "LBL_TestNode"); // NOI18N
2.28 }
2.29
2.30 // @overwrite
2.31 + @Override
2.32 public boolean canDestroy() {
2.33 return false;
2.34 }
2.35
2.36 // @overwrite
2.37 + @Override
2.38 public boolean canRename() {
2.39 return false;
2.40 }
2.41 @@ -161,6 +167,7 @@
2.42 *
2.43 * @return DOCUMENT ME!
2.44 */
2.45 + @Override
2.46 public Image getIcon(int type) {
2.47 return computeIcon(false, type);
2.48 }
2.49 @@ -172,6 +179,7 @@
2.50 *
2.51 * @return DOCUMENT ME!
2.52 */
2.53 + @Override
2.54 public Image getOpenedIcon(int type) {
2.55 return computeIcon(true, type);
2.56 }
2.57 @@ -185,6 +193,7 @@
2.58 }
2.59
2.60 // Create the popup menu:
2.61 + @Override
2.62 public Action[] getActions(boolean context) {
2.63 List<Action> actionList = new ArrayList<Action>();
2.64 actionList.add(SystemAction.get(AddTestcaseAction.class));
2.65 @@ -194,6 +203,7 @@
2.66 return actionList.toArray(new Action[0]);
2.67 }
2.68
2.69 + @Override
2.70 public Node.Cookie getCookie(Class type) {
2.71 if (type == TestCookie.class) {
2.72 return mTestCookie;
3.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestcaseNode.java Fri Jan 11 07:12:25 2008 +0000
3.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/TestcaseNode.java Fri Jan 11 09:13:10 2008 +0000
3.3 @@ -322,7 +322,7 @@
3.4 specList.add(PropertySpec.COMPARISON_TYPE);
3.5 specList.add(PropertySpec.FEATURE_STATUS);
3.6
3.7 - // Is there only one property file per test case?
3.8 + // There is only one property file per test case.
3.9 mPropertyFile = testcaseDir.getFileObject("Invoke.properties"); // NOI18N
3.10 if (mPropertyFile == null) {
3.11 mPropertyFile = testcaseDir.getFileObject("Concurrent.properties"); // NOI18N
4.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/actions/AddTestcaseAction.java Fri Jan 11 07:12:25 2008 +0000
4.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/actions/AddTestcaseAction.java Fri Jan 11 09:13:10 2008 +0000
4.3 @@ -54,6 +54,7 @@
4.4
4.5 import java.awt.Component;
4.6 import java.awt.Dialog;
4.7 +import java.io.File;
4.8 import java.io.FileOutputStream;
4.9 import java.text.MessageFormat;
4.10 import java.util.HashMap;
4.11 @@ -66,7 +67,6 @@
4.12 import org.openide.util.NbBundle;
4.13 import org.openide.util.actions.NodeAction;
4.14 import org.openide.filesystems.FileObject;
4.15 -import java.util.logging.Level;
4.16 import javax.swing.JComponent;
4.17 import javax.swing.SwingUtilities;
4.18 import org.netbeans.api.project.Project;
4.19 @@ -87,9 +87,10 @@
4.20 * @author Jun Qian
4.21 */
4.22 public class AddTestcaseAction extends NodeAction implements NewTestcaseConstants {
4.23 +
4.24 private static final java.util.logging.Logger mLog =
4.25 java.util.logging.Logger.getLogger("org.netbeans.modules.compapp.projects.jbi.ui.actions.AddTestcaseAction"); // NOI18N
4.26 -
4.27 +
4.28 /**
4.29 * DOCUMENT ME!
4.30 *
4.31 @@ -103,16 +104,17 @@
4.32 }
4.33 return true;
4.34 }
4.35 -
4.36 +
4.37 /**
4.38 * DOCUMENT ME!
4.39 *
4.40 * @return DOCUMENT ME!
4.41 */
4.42 + @Override
4.43 protected boolean asynchronous() {
4.44 return false;
4.45 }
4.46 -
4.47 +
4.48 /**
4.49 * DOCUMENT ME!
4.50 *
4.51 @@ -126,7 +128,7 @@
4.52 final TestNode testNode = tc.getTestNode();
4.53 JbiProject project = testNode.getProject();
4.54 FileObject testDir = testNode.getTestDir();
4.55 -
4.56 +
4.57 WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels(project, testDir));
4.58 // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
4.59 wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); // NOI18N
4.60 @@ -141,22 +143,22 @@
4.61 mLog.info("User finished the wizard"); // NOI18N
4.62 final String name = (String) wizardDescriptor.getProperty(TESTCASE_NAME);
4.63 mLog.info("Got name in NewSchemaAction: " + name); // NOI18N
4.64 - BindingSupport bindingSupport = (BindingSupport)wizardDescriptor.getProperty(BINDING_SUPPORT);
4.65 - BindingOperation bindingOp = (BindingOperation)wizardDescriptor.getProperty(BINDING_OPERATION);
4.66 + BindingSupport bindingSupport = (BindingSupport) wizardDescriptor.getProperty(BINDING_SUPPORT);
4.67 + BindingOperation bindingOp = (BindingOperation) wizardDescriptor.getProperty(BINDING_OPERATION);
4.68 Map param = new HashMap();
4.69 param.put(BindingSupport.BUILD_OPTIONAL, Boolean.TRUE);
4.70 -
4.71 - try {
4.72 +
4.73 + try {
4.74 String inputStr = bindingSupport.buildRequest(bindingOp, param);
4.75 -
4.76 +
4.77 FileObject testcaseDir = FileUtil.createFolder(testDir, name);
4.78 String fileName = FileUtil.toFile(testcaseDir).getPath() + "/Input.xml"; // NOI18N
4.79 BufferedOutputStream fw = new BufferedOutputStream(new FileOutputStream(fileName));
4.80 fw.write(inputStr.getBytes("UTF-8")); // NOI18N
4.81 fw.close();
4.82 -
4.83 +
4.84 FileUtil.createData(testcaseDir, "Output.xml"); // NOI18N
4.85 -
4.86 +
4.87 // Create the results directory and results/<testcasename> directory now.
4.88 // This is to avoid a threading issue durint first run result checking.
4.89 String resultsDirName = "results"; // NOI18N // FIXME
4.90 @@ -165,11 +167,11 @@
4.91 resultsFO = FileUtil.createFolder(testDir, resultsDirName);
4.92 }
4.93 FileUtil.createFolder(resultsFO, name);
4.94 -
4.95 +
4.96 // Populate properties
4.97 EditableProperties properties = new EditableProperties(true);
4.98 properties.setProperty(PropertySpec.DESCRIPTION.getName(), "testcase " + name); // NOI18N
4.99 -
4.100 +
4.101 String[] endPoints = bindingSupport.getEndpoints();
4.102 if (endPoints == null || endPoints.length == 0) {
4.103 properties.setProperty(PropertySpec.DESTINATION.getName(), ""); // NOI18N
4.104 @@ -186,7 +188,7 @@
4.105 }
4.106 properties.setComment(PropertySpec.DESTINATION.getName(), comment, false);
4.107 }
4.108 -
4.109 +
4.110 String soapActionURI = ""; // NOI18N
4.111 List list = bindingOp.getExtensibilityElements();
4.112 for (Object elem : list) {
4.113 @@ -199,8 +201,8 @@
4.114 }
4.115 }
4.116 }
4.117 -
4.118 - properties.setProperty(PropertySpec.SOAP_ACTION.getName(), soapActionURI);
4.119 +
4.120 + properties.setProperty(PropertySpec.SOAP_ACTION.getName(), soapActionURI);
4.121 properties.setProperty(PropertySpec.INPUT_FILE.getName(), "Input.xml"); // NOI18N
4.122 properties.setProperty(PropertySpec.OUTPUT_FILE.getName(), "Output.xml"); // NOI18N
4.123 properties.setProperty(PropertySpec.CONCURRENT_THREADS.getName(),
4.124 @@ -211,70 +213,57 @@
4.125 PropertySpec.TEST_TIMEOUT.getDefaultValue().toString());
4.126 properties.setProperty(PropertySpec.CALCULATE_THROUGHPUT.getName(),
4.127 PropertySpec.CALCULATE_THROUGHPUT.getDefaultValue().toString());
4.128 -
4.129 +
4.130 properties.setProperty(PropertySpec.COMPARISON_TYPE.getName(),
4.131 PropertySpec.COMPARISON_TYPE.getDefaultValue().toString()); // NOI18N
4.132 properties.setComment(PropertySpec.COMPARISON_TYPE.getName(),
4.133 new String[]{"#" + PropertySpec.COMPARISON_TYPE.getName() + "'s possible values: identical|binary|equals"}, false); // NOI18N
4.134 -
4.135 +
4.136 properties.setProperty(PropertySpec.FEATURE_STATUS.getName(),
4.137 - PropertySpec.FEATURE_STATUS.getDefaultValue().toString());
4.138 + PropertySpec.FEATURE_STATUS.getDefaultValue().toString());
4.139 properties.setComment(PropertySpec.FEATURE_STATUS.getName(),
4.140 new String[]{"#" + PropertySpec.FEATURE_STATUS.getName() + "'s possible values: progress|done"}, false); // NOI18N
4.141 -
4.142 - //Write properties to disk
4.143 - //FileObject propFile = FileUtil.createData(testcaseDir, "Invoke.properties"); // NOI18N
4.144 - //FileObject propFile = FileUtil.createData(testcaseDir, "Concurrent.properties"); // NOI18N
4.145 - //ByteArrayOutputStream baos = new ByteArrayOutputStream();
4.146 - //properties.store(baos);
4.147 - //final byte[] data = baos.toByteArray();
4.148 - //lock = propFile.lock();
4.149 - //FileUtil.copy(new ByteArrayInputStream(data), // NOI18N
4.150 - // propFile.getOutputStream(lock));
4.151 - //lock.releaseLock();
4.152 - fileName = FileUtil.toFile(testcaseDir).getPath() + "/Concurrent.properties"; // NOI18N
4.153 - FileOutputStream outStream = new FileOutputStream(fileName);
4.154 +
4.155 + //Write properties to disk
4.156 + FileObject propFileObject = FileUtil.createData(testcaseDir, "Concurrent.properties"); // NOI18N
4.157 + File propFile = FileUtil.toFile(propFileObject);
4.158 + FileOutputStream outStream = new FileOutputStream(propFile);
4.159 properties.store(outStream);
4.160 outStream.close();
4.161 -
4.162 +
4.163 // Since testcaseDir is created before *.properties,
4.164 // FileChangeListener may be notified before *.properties,
4.165 // hence FileChangeListener may fail to find that the new folder contains *.properties,
4.166 // hence this second notificatioin is necessary.
4.167 - testNode.getFileChangeListener().fileFolderCreated(new FileEvent(testDir));
4.168 + testNode.getFileChangeListener().fileFolderCreated(new FileEvent(testcaseDir));
4.169
4.170 -
4.171 - try {
4.172 - Thread.sleep(100);
4.173 - } catch (InterruptedException ie) {
4.174 - }
4.175 -
4.176 - final Node activatedNode = activatedNodes[0];
4.177 -
4.178 + final Node activatedNode = activatedNodes[0];
4.179 +
4.180 SwingUtilities.invokeLater(new Runnable() {
4.181 -
4.182 +
4.183 public void run() {
4.184 +
4.185 // Automatically expand the Project tree to expose the new input node
4.186 TopComponent topComponent = TopComponent.getRegistry().getActivated();
4.187 -
4.188 +
4.189 if (topComponent.getComponent(0) instanceof TreeView) {
4.190 -
4.191 +
4.192 TreeView treeView = (TreeView) topComponent.getComponent(0);
4.193 -
4.194 +
4.195 // Expand the test node
4.196 if (!treeView.isExpanded(activatedNode)) {
4.197 treeView.expandNode(activatedNode);
4.198 }
4.199 -
4.200 +
4.201 Node testChildNode = activatedNode.getChildren().findChild(name);
4.202 -
4.203 +
4.204 if (testChildNode != null) {
4.205 // Expand the test case node
4.206 treeView.expandNode(testChildNode);
4.207 -
4.208 +
4.209 // Look for TestCaseChild named Input
4.210 Node testCaseChildNode = testChildNode.getChildren().findChild("Input"); // NOI18N
4.211 -
4.212 +
4.213 if (testCaseChildNode != null) {
4.214 //Select the input node and open it
4.215 EditCookie openCookie = (EditCookie) testCaseChildNode.getCookie(EditCookie.class);
4.216 @@ -284,18 +273,19 @@
4.217 }
4.218 }
4.219 }
4.220 - }});
4.221 -
4.222 +
4.223 + }
4.224 + });
4.225 +
4.226 } catch (Exception e) {
4.227 - String msg = NbBundle.getMessage(AddTestcaseAction.class,
4.228 + String msg = NbBundle.getMessage(AddTestcaseAction.class,
4.229 "MSG_Failed_to_Add_Testcase", e.getMessage()); // NOI18N
4.230 -// mLog.log(Level.SEVERE, msg, e);
4.231 NotifyDescriptor d =
4.232 new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
4.233 DialogDisplayer.getDefault().notify(d);
4.234 }
4.235 }
4.236 -
4.237 +
4.238 /**
4.239 * DOCUMENT ME!
4.240 *
4.241 @@ -304,7 +294,7 @@
4.242 public String getName() {
4.243 return NbBundle.getMessage(AddTestcaseAction.class, "LBL_AddTestcaseAction_Name"); // NOI18N
4.244 }
4.245 -
4.246 +
4.247 /**
4.248 * DOCUMENT ME!
4.249 *
4.250 @@ -312,17 +302,17 @@
4.251 */
4.252 public HelpCtx getHelpCtx() {
4.253 return HelpCtx.DEFAULT_HELP;
4.254 -
4.255 - // If you will provide context help then use:
4.256 - // return new HelpCtx(AddTestcaseAction.class);
4.257 +
4.258 + // If you will provide context help then use:
4.259 + // return new HelpCtx(AddTestcaseAction.class);
4.260 }
4.261 -
4.262 +
4.263 /**
4.264 * Initialize panels representing individual wizard's steps and sets
4.265 * various properties for them influencing wizard appearance.
4.266 */
4.267 private WizardDescriptor.Panel[] getPanels(Project project, FileObject testDir) {
4.268 - WizardDescriptor.Panel[] panels = new WizardDescriptor.Panel[] {
4.269 + WizardDescriptor.Panel[] panels = new WizardDescriptor.Panel[]{
4.270 new NewTestcaseNameWizardPanel(testDir),
4.271 new NewTestcaseWsdlWizardPanel(project),
4.272 new NewTestcaseOperationWizardPanel()
4.273 @@ -350,4 +340,4 @@
4.274 }
4.275 return panels;
4.276 }
4.277 -}
4.278 \ No newline at end of file
4.279 +}