IdeCommandEvent
*/
public void checkStatus (IdeCommandEvent anEvent)
{
RwiElement element = XPTestIDEHelper.getSelectedElement (
XPTestIDEHelper.getActiveDiagram (anEvent));
RwiPackage pkg = XPTestIDEHelper.getSelectedPackage ();
XPTestIDEHelper.setItemVisibility (IXPTestCommands.CONFIGURE,
(element != null) || (pkg != null));
}
/**
* Opens the config editor.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void actionPerformed (IdeCommandEvent anEvent)
{
IdeAccess.getConfigManager ().showConfigEditor (null, IdeConfigLevel.PROJECT, IXPTestProperties.MODULE, true);
//new ConfigureModel ();
}
}
PK
Kñ*Y
ÿõ, , / com/togethersoft/modules/xp/ConfigureModel.java/**
* Title: ConfigureModel
* Description: This class is the model for the configuration dialog used in
* the XPTest module
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: ConfigureModel.java,v 1.8 2001/07/17 07:24:10 tpinos Exp $
*
* $Log: ConfigureModel.java,v $
* Revision 1.8 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.7 2001/07/13 10:54:51 aheilwag
* added comments for Unix port
*
* Revision 1.6 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
* Revision 1.5 2001/07/11 10:29:45 tpinos
* name of the created test package now matches the user input;
* property for JUnitX jar dropped from config dialog (it's in the project CP);
* "Test" command works now (checks the selection, recognizes test packages)
*
* Revision 1.4 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.3 2001/06/21 11:11:16 tpinos
* new style-code modifications; bugfixing (run test action, ...);
* refactoring (not all constants are hardcoded now)
*
* Revision 1.2 2001/06/20 10:35:12 tpinos
* UI modified (config dialog, capitalization, ...)
*
* Revision 1.1.1.1 2001/06/08 05:35:18 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.4 2001/06/01 07:46:40 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.11 2001/05/21 19:57:39 aheilwag
* fixed syntax errors.
*
* Revision 1.10 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.9 2001/05/19 19:53:09 aheilwag
* included patches by TogetherSoft to match their UI guidelines.
*
* Revision 1.8 2000/12/04 17:54:37 aheilwag
* switched to cross-platform look & feel.
*
* Revision 1.7 2000/11/28 22:56:14 aheilwag
* added support for configuring and catching stdout/stderr for JUnitX on Win32.
*
* Revision 1.6 2000/11/26 10:52:43 aheilwag
* Removed the warning message if the config dialog could not load the props.
*
* Revision 1.5 2000/11/18 20:17:47 aheilwag
* fixed null-filename for loading XPTestProperties.
*
* Revision 1.4 2000/11/17 13:09:55 aheilwag
* improved documentation and code readability.
*
* Revision 1.3 2000/11/13 12:39:39 aheilwag
* switched from prefix 'm' to '_' for class attributes.
* moved property support into class XPTestProperties.
* added parameters 'Default Test location' and 'Test package'.
* added support for help dialog.
*
* Revision 1.2 2000/11/10 20:05:46 aheilwag
* added cvs tags
*
*/
package com.togethersoft.modules.xp;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.message.*;
import com.togethersoft.openapi.ide.project.*;
import com.togethersoft.openapi.ide.window.*;
import com.togethersoft.openapi.util.ui.DialogHelper;
/**
* ConfigureModel is the model for the configuration dialog.
*/
public class ConfigureModel
{
private ConfigureUI _configUI = null;
/**
* This constructor configures and opens the UI.
*/
public ConfigureModel ()
{
_configUI = new ConfigureUI (this);
setUIFields ();
_configUI.getDialog ().setVisible (true);
}
/**
* initializes the fields of the UI.
*/
private void setUIFields ()
{
String testLoc = XPTestProperties.get ("TestLocation");
String guiType = XPTestProperties.get ("GuiType");
_configUI._vmField.setText (XPTestProperties.get ("VM"));
/* (he) unix port to be done by Andreas Heilwagen
if (!XPTestJavaHelper.isWin ())
{
_configUI._stdoutField.setText (XPTestProperties.get ("stdout"));
_configUI._stderrField.setText (XPTestProperties.get ("stderr"));
}
*/
_configUI._vmParamsField.setText (XPTestProperties.get ("VMParams"));
// _configUI._junitxJarField.setText (XPTestProperties.get ("JUnitXJar"));
_configUI._forceJUnitCompatibility.getModel().setSelected(XPTestProperties.get(IXPTestProperties.FORCE_JUNIT_COMPATIBILITY).equals("true"));
_configUI._testPkgField.setText (XPTestProperties.get ("TestPkg"));
if (testLoc.equals ("Parallel hierarchy"))
_configUI._parallelButton.setSelected (true);
if (testLoc.equals ("Same package"))
_configUI._samePkgButton.setSelected (true);
if (testLoc.equals ("Subpackage"))
_configUI._subPkgButton.setSelected (true);
if (guiType.equals ("Text UI"))
_configUI._textUIButton.setSelected (true);
if (guiType.equals ("Swing UI"))
_configUI._swingUIButton.setSelected (true);
}
/**
* shows a file chooser.
*
* @param aField an instance of JTextField
* @param aMode JFileChooser.FILES_ONLY etc.
* @param aFilter a filter
*/
private void chooseFile (JTextField aField, int aMode, FileFilter aFilter)
{
IdeFileChooser chooser = IdeWindowManagerAccess.getWindowManager ().createFileChooser (aField.getText ());
chooser.setFileSelectionMode (aMode);
chooser.setFileFilter(aFilter);
if (chooser.showDialog (_configUI.getDialog ()) == IdeFileChooserConstant.APPROVE_OPTION)
{
aField.setText (chooser.getSelectedFile ().getPath ());
aField.update (aField.getGraphics ());
}
}
/**
* shows a file chooser for the selection of a virtual machine.
*/
public void selectVM ()
{
chooseFile (_configUI._vmField, IdeFileChooserConstant.FILES_ONLY, IdeFileFilterConstant.ALL_FILES_FILTER);
}
/**
* shows a file chooser to select the path and file of JUnitX.
*/
/* (he) to be removed by Andreas Heilwagen soon
public void selectJUnitXJar ()
{
chooseFile (_configUI._junitxJarField, IdeFileChooserConstant.FILES_ONLY, IdeFileFilterConstant.ARCHIVE_FILES_FILTER);
}
*/
/**
* shows the help dialog.
*/
public void help ()
{
IdeAccess.getIdeManager().showHelp("dialogs_xp_test_module_configuration_dialog_htm", true, _configUI.getDialog());
/* (he) to be removed by Andreas Heilwagen soon
HelpDialog help = new HelpDialog ();
help._helpDialog.setModal (true);
help._helpDialog.setLocation (300, 300);
help._helpDialog.show ();
*/
}
/*
* retrieves the configuration from the UI and stores it to a properties file.
*/
public void done ()
{
XPTestProperties.put ("VM", _configUI._vmField.getText ());
XPTestProperties.put ("VMParams", _configUI._vmParamsField.getText ());
// XPTestProperties.put ("JUnitXJar", _configUI._junitxJarField.getText ());
XPTestProperties.put ("TestPkg", _configUI._testPkgField.getText ());
XPTestProperties.put (IXPTestProperties.FORCE_JUNIT_COMPATIBILITY,
_configUI._forceJUnitCompatibility.getModel().isSelected()
? "true" : "false");
if (!XPTestJavaHelper.isWin ())
{
/* (he) to be ported to Unix by Andreas Heilwagen
XPTestProperties.put ("stdout", _configUI._stdoutField.getText ());
XPTestProperties.put ("stderr", _configUI._stderrField.getText ());
XPTestProperties.put ("OutPath", _configUI._outPathField.getText ());
XPTestProperties.put ("ClassPath", _configUI._classPathField.getText ());
*/
}
/* (he) why is this code commented out?
XPTestProperties.put ("TestCase.createTests", ((JCheckBox)(_configUI._radioPanel.getComponent(0))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestPackage.recurse", ((JCheckBox)(_configUI._radioPanel.getComponent(1))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestCase.accessPrivate", ((JCheckBox)(_configUI._radioPanel.getComponent(2))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestCase.createSuite", ((JCheckBox)(_configUI._radioPanel.getComponent(3))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestCase.createLink", ((JCheckBox)(_configUI._radioPanel.getComponent(4))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestCase.createTearDown", ((JCheckBox)(_configUI._radioPanel.getComponent(5))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestCase.createSetUp", ((JCheckBox)(_configUI._radioPanel.getComponent(6))).isSelected() ? "true" : "false");
XPTestProperties.put ("TestPackage.VAJSupport", ((JCheckBox)(_configUI._radioPanel.getComponent(7))).isSelected() ? "true" : "false");
*/
if (_configUI._parallelButton.isSelected ())
XPTestProperties.put ("TestLocation", "Parallel hierarchy");
if (_configUI._samePkgButton.isSelected ())
XPTestProperties.put ("TestLocation", "Same package");
if (_configUI._subPkgButton.isSelected ())
XPTestProperties.put ("TestLocation", "Subpackage");
if (_configUI._textUIButton.isSelected ())
XPTestProperties.put ("GuiType", "Text UI");
if (_configUI._swingUIButton.isSelected ())
XPTestProperties.put ("GuiType", "Swing UI");
/*
if (!XPTestProperties.store ())
IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR_MODAL,
"Could not save configuration to\n" + XPTestProperties.getDefaultFile ());
*/
destroy ();
}
/**
* removes the dialog.
*/
public void escape ()
{
destroy ();
}
/**
* destroy all models and UIs
*/
public void destroy ()
{
_configUI.getDialog ().setVisible (false);
_configUI.getDialog ().dispose ();
_configUI = null;
}
}
PK
sô*ÐÌëzX2 X2 , com/togethersoft/modules/xp/ConfigureUI.java/**
* Title: ConfigureUI
* Description: This class is the UI for the configuration dialog used for
* the XPTest module
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: ConfigureUI.java,v 1.7 2001/07/20 12:24:55 aheilwag Exp $
*
* $Log: ConfigureUI.java,v $
* Revision 1.7 2001/07/20 12:24:55 aheilwag
* reviewed code
*
* Revision 1.6 2001/07/13 11:01:48 aheilwag
* adjusted tab formatting
*
* Revision 1.5 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
* Revision 1.4 2001/07/11 10:29:45 tpinos
* name of the created test package now matches the user input;
* property for JUnitX jar dropped from config dialog (it's in the project CP);
* "Test" command works now (checks the selection, recognizes test packages)
*
* Revision 1.3 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.2 2001/06/20 10:35:12 tpinos
* UI modified (config dialog, capitalization, ...)
*
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.4 2001/06/01 07:46:40 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.8 2001/05/21 19:57:39 aheilwag
* fixed syntax errors.
*
* Revision 1.7 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.6 2001/05/19 19:53:35 aheilwag
* included patches from TogetherSoft to match their UI guidelines
*
* Revision 1.5 2000/11/28 22:56:14 aheilwag
* added support for configuring and catching stdout/stderr for JUnitX on Win32.
*
* Revision 1.4 2000/11/17 13:11:57 aheilwag
* improved the documentation and the readability of the source.
*
* Revision 1.3 2000/11/13 12:41:27 aheilwag
* switched from prefix 'm' to '_' for class attributes.
* removed support for environment settings for test execution.
* removed support for AWT JUnit UI.
* added support for 'Default Test location' and 'Test Package'.
* added Help button.
* changed dialog size.
*
* Revision 1.2 2000/11/10 20:05:52 aheilwag
* added cvs tags
*
*/
package com.togethersoft.modules.xp;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import com.togethersoft.openapi.ide.IdeAccess;
import com.togethersoft.openapi.ide.window.*;
import com.togethersoft.openapi.util.ui.*;
/**
* This is the UI for the configuration dialog.
* (he) after the major rewrite some options which are commented out in the
* remaining source maybe no longer reflected here.
*/
public class ConfigureUI
{
static private ConfigureModel _model;
private JDialog _dialog;
JTextField _vmField;
JTextField _vmParamsField;
//JTextField _junitxJarField;
JCheckBox _forceJUnitCompatibility;
JRadioButton _parallelButton;
JRadioButton _samePkgButton;
JRadioButton _subPkgButton;
JRadioButton _textUIButton;
JRadioButton _swingUIButton;
JTextField _testPkgField;
/**
* constructor
*/
public ConfigureUI (ConfigureModel _model)
{
// initialize basic stuff
ConfigureUI._model = _model;
_dialog = IdeAccess.getWindowManager ().createDialog (null);
fillContentPane(_dialog.getContentPane());
_dialog.setModal (true);
_dialog.setTitle ("XPTest module configuration");
_dialog.pack ();
_dialog.setResizable (true);
}
/**
* @return the current dialog.
*/
public JDialog getDialog ()
{
return _dialog;
}
/**
* fills the content pane
*
* @param aContentPane a Container
*/
private void fillContentPane (Container aContentPane)
{
aContentPane.add (createMainPane (), BorderLayout.NORTH);
aContentPane.add (createButtonPane (), BorderLayout.SOUTH);
}
/**
* creates the main pane.
*
* @return the main pane (JPanel)
*/
private JPanel createMainPane ()
{
JPanel mainPanel = new JPanel ();
mainPanel.setLayout (new BoxLayout (mainPanel, BoxLayout.Y_AXIS));
mainPanel.add (createTopPane ());
mainPanel.add (Box.createVerticalStrut (11));
mainPanel.add (createBottomPane ());
mainPanel.setBorder (BorderFactory.createEmptyBorder (12, 0, 16, 0));
return mainPanel;
}
/**
* creates the top pane.
*
* @return the top pane (JPanel)
*/
private JPanel createTopPane ()
{
_vmField = new JTextField ("");
_vmParamsField = new JTextField ("");
// _junitxJarField = new JTextField ("");
ExtendedControl extControl1 =
new ExtendedControl (
ExtendedControl.FILE_CHOOSER_BUTTON,
_vmField,
new java.awt.event.ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
ConfigureUI._model.selectVM ();
}
});
ExtendedControl extControl2 =
new ExtendedControl (
ExtendedControl.MULTILINE_TEXT_CHOOSER_BUTTON,
_vmParamsField,
null);
/*
ExtendedControl extControl3 =
new ExtendedControl (
ExtendedControl.FILE_CHOOSER_BUTTON,
_junitxJarField,
new java.awt.event.ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
ConfigureUI._model.selectJUnitXJar ();
}
});
*/
_forceJUnitCompatibility = new JCheckBox ();
JLabel label1 = new JLabel ("Virtual Machine:");
label1.setDisplayedMnemonic ('M');
label1.setLabelFor (_vmField);
JLabel label2 = new JLabel ("VM Parameters:");
label2.setDisplayedMnemonic ('T');
label2.setLabelFor (_vmParamsField);
/*
JLabel label3 = new JLabel ("JUnitX Jar:");
label3.setDisplayedMnemonic ('J');
label3.setLabelFor (_junitxJarField);
*/
JLabel label4 = new JLabel ("Force JUnit Compatibility: ");
label4.setDisplayedMnemonic ('C');
label4.setLabelFor (_forceJUnitCompatibility);
JPanel labels = new JPanel (new GridLayout (3, 1, 0, 11));
labels.add (label1);
labels.add (label2);
// labels.add (label3);
labels.add (label4);
JPanel fields = new JPanel (new GridLayout (3, 1, 0, 11));
fields.add (extControl1);
fields.add (extControl2);
// fields.add (extControl3);
fields.add (_forceJUnitCompatibility);
JPanel topPanel = new JPanel (new BorderLayout ());
topPanel.add (labels,BorderLayout.WEST);
topPanel.add (fields);
return topPanel;
}
/**
* creates the bottom pane.
*
* @return the bottom pane (JPanel)
*/
private JPanel createBottomPane ()
{
JPanel bottomPanel = new JPanel ();
bottomPanel.setLayout (new BoxLayout (bottomPanel, BoxLayout.X_AXIS));
ToggleButtonPanel first = new ToggleButtonPanel ("Default Test Location");
JPanel comp1 = new JPanel ();
comp1.setLayout (new BoxLayout (comp1, BoxLayout.X_AXIS));
_parallelButton = new JRadioButton ("Parallel hierachy");
_parallelButton.setMnemonic ('r');
_samePkgButton = new JRadioButton ("Same package");
_samePkgButton.setMnemonic ('p');
_subPkgButton = new JRadioButton ("Subpackage");
_subPkgButton.setMnemonic ('b');
comp1.add (_parallelButton);
comp1.add (Box.createHorizontalGlue ());
comp1.add (new JLabel ("Test Package Name:"));
first.addComponent (comp1);
JPanel comp2 = new JPanel ();
comp2.setLayout (new BoxLayout (comp2, BoxLayout.X_AXIS));
comp2.add (_samePkgButton);
comp2.add (Box.createHorizontalGlue ());
JPanel comp3 = new JPanel ();
comp3.setLayout (new BoxLayout (comp3, BoxLayout.X_AXIS));
comp3.add (_subPkgButton);
comp3.add (Box.createHorizontalGlue ());
_testPkgField = new JTextField ("test");
comp2.add (_testPkgField);
first.addComponent (comp2);
first.addComponent (comp3);
bottomPanel.add (first);
first.getButtonGroup ().add (_parallelButton);
first.getButtonGroup ().add (_samePkgButton);
first.getButtonGroup ().add (_subPkgButton);
ActionListener radioListener = new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
JRadioButton button = (JRadioButton)e.getSource ();
_testPkgField.setEnabled(button != _samePkgButton);
}
};
_parallelButton.addActionListener (radioListener);
_samePkgButton.addActionListener (radioListener);
_subPkgButton.addActionListener (radioListener);
ToggleButtonPanel second = new ToggleButtonPanel ("Default GUI");
JPanel uiComp = new JPanel ();
uiComp.setLayout (new BoxLayout (uiComp, BoxLayout.Y_AXIS));
_textUIButton = new JRadioButton ("Text UI");
_textUIButton.setMnemonic ('x');
_swingUIButton = new JRadioButton ("Swing UI");
_swingUIButton.setMnemonic ('s');
uiComp.add (_textUIButton);
uiComp.add (_swingUIButton);
second.addComponent (uiComp);
second.getButtonGroup ().add (_textUIButton);
second.getButtonGroup ().add (_swingUIButton);
bottomPanel.add (Box.createHorizontalStrut (10));
bottomPanel.add (second);
return bottomPanel;
}
/**
* creates the button pane.
*
* @return the button pane (JPanel)
*/
private JPanel createButtonPane ()
{
IdeDialogButtonGroup buttonGroup = IdeAccess.getWindowManager ().createButtonGroup ();
JButton okButton = (JButton)IdeWindowManagerAccess.getWindowManager ().setupStandardButton (
new JButton (), IdeButtonType.OK);
okButton.addActionListener (new DoneActionListener ());
DialogHelper.setDefaultButton (_dialog, okButton);
JButton cancelButton = (JButton)IdeWindowManagerAccess.getWindowManager ().setupStandardButton (
new JButton (), IdeButtonType.CANCEL);
cancelButton.addActionListener (new EscapeActionListener ());
JButton helpButton = (JButton)IdeWindowManagerAccess.getWindowManager ().setupStandardButton (
new JButton (), IdeButtonType.HELP);
helpButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent event)
{
ConfigureUI._model.help ();
}
});
buttonGroup.add (okButton);
buttonGroup.add (cancelButton);
buttonGroup.add (helpButton);
return new IdeDialogButtonPanel (buttonGroup);
}
/**
* listener for the done button
*/
private final class DoneActionListener implements java.awt.event.ActionListener
{
private DoneActionListener ()
{
DialogHelper.bindEnterKeyAction (_dialog, this);
}
public void actionPerformed (java.awt.event.ActionEvent e)
{
ConfigureUI._model.done ();
}
}
/**
* listener for the escape button
*/
private final class EscapeActionListener implements java.awt.event.ActionListener
{
private EscapeActionListener ()
{
DialogHelper.bindEscapeKeyAction (_dialog, this);
}
public void actionPerformed (java.awt.event.ActionEvent e)
{
ConfigureUI._model.escape ();
}
}
}
PK
{N+÷'> 2 com/togethersoft/modules/xp/CreateTestCaseCmd.java/**
* Title: CreateTestCaseCmd
* Description: This class controls the visibility of the "create test case"
* option in the XPTest context menu. If the user selects the
* menu item, the actionPerformed() method of this class will
* be executed.
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: CreateTestCaseCmd.java,v 1.9 2001/08/22 07:51:54 tpinos Exp $
*
* $Log: CreateTestCaseCmd.java,v $
* Revision 1.9 2001/08/22 07:51:54 tpinos
* bugfixing - package prefix bug
*
* Revision 1.8 2001/07/24 11:07:20 tpinos
* XPTest enabled only for Java language;
* XPTest old-style config dialog dropped;
* bugfixing
*
* Revision 1.7 2001/07/20 12:27:14 aheilwag
* reviewed code
*
* $Log: CreateTestCaseCmd.java,v $
* Revision 1.9 2001/08/22 07:51:54 tpinos
* bugfixing - package prefix bug
*
* Revision 1.8 2001/07/24 11:07:20 tpinos
* XPTest enabled only for Java language;
* XPTest old-style config dialog dropped;
* bugfixing
*
* Revision 1.6 2001/07/20 12:11:16 tpinos
* bugfixing (ClassCastException in getClasses)
*
* Revision 1.5 2001/07/19 04:04:26 tpinos
* testcase and testedclass tags added to the modified sources;
* options for junit.jar and junitx.jar location created - these two jars will
* be add now to the project;
* test command invoked on tested class will try to find the test case
* (via the new tags)
*
* Revision 1.4 2001/07/17 09:23:06 tpinos
* creates test cases for all selected classes
*
* Revision 1.3 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.2 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.2 2001/06/01 07:46:39 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.5 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.4 2000/11/26 11:12:15 aheilwag
* moved from XPTestUtils fo XPTestIDEHelper and XPTestJavaHelper.
*
* Revision 1.3 2000/11/18 20:18:48 aheilwag
* fixed destination package for test case.
* added creation of a TestProxy.
*
* Revision 1.2 2000/11/17 17:45:00 aheilwag
* fixed a typo.
*
* Revision 1.1 2000/11/17 13:19:14 aheilwag
* added class to support "create test case" context menu item.
*
*/
package com.togethersoft.modules.xp;
import java.io.IOException;
import java.util.*;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.command.*;
import com.togethersoft.openapi.ide.diagram.*;
import com.togethersoft.openapi.ide.diagram.enum.*;
import com.togethersoft.openapi.ide.util.*;
import com.togethersoft.openapi.rwi.*;
import com.togethersoft.openapi.sci.*;
import com.togethersoft.modules.patterns.JAVA.CLASS.XP.TestCase.Pattern;
/**
* This class controls the visibility of the "create test case" option in the
* XPTest context menu. If the user selects the menu item, the
* actionPerformed() method of this class will be executed.
*/
public class CreateTestCaseCmd extends IdeCommandAdapter
{
/**
* controls the visibility and enabled state of the menu item connected to
* this command.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void checkStatus (IdeCommandEvent anEvent)
{
SciClass[] classes = getClasses (anEvent);
boolean tag = (classes != null) && (classes.length > 0);
XPTestIDEHelper.setItemVisibility (IXPTestCommands.CREATE_TEST_CASE, tag);
}
/**
* perform command since the user has selected the command
*
* @param anEvent an instance of IdeCommandEvent
*/
public void actionPerformed (IdeCommandEvent anEvent)
{
SciClass[] classes = getClasses (anEvent);
if (classes == null)
return;
for (int i = 0; i < classes.length; i++)
createTestCase (classes[i]);
}
private void createTestCase(SciClass clazz)
{
Pattern.createTestCase(clazz);
}
/**
* gets the selected classes based on an IdeCommandEvent.
*
* @param anEvent an instance of IdeCommandEvent
*/
private SciClass[] getClasses (IdeCommandEvent anEvent)
{
ArrayList l = new ArrayList();
IdeElement[] ideElements = anEvent.getElementContext().getElements();
for (int i = 0; i < ideElements.length; i++)
{
if (ideElements[i] instanceof RwiElementService)
{
RwiElementService service = (RwiElementService)ideElements[i];
RwiElement rwiElement = service.getRwiElement ();
if (rwiElement.getProperty (RwiProperty.SHAPE_TYPE).equals (RwiShapeType.CLASS))
l.add((SciClass)rwiElement.getCodeElement ());
}
}
SciClass[] classes = new SciClass[l.size ()];
l.toArray (classes);
return classes;
}
}
PK
Kñ*â….ù ù 5 com/togethersoft/modules/xp/CreateTestPackageCmd.java/**
* Title: CreateTestPackageCmd
* Description: This class controls the visibility of the "create test
* package" option in the XPTest context menu. If the user clicks
* on the itm, the actionPerformed() method will be executed.
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: CreateTestPackageCmd.java,v 1.3 2001/07/17 07:24:10 tpinos Exp $
*
* $Log: CreateTestPackageCmd.java,v $
* Revision 1.3 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.2 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.2 2001/06/01 07:46:39 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.4 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.3 2000/11/26 11:12:15 aheilwag
* moved from XPTestUtils fo XPTestIDEHelper and XPTestJavaHelper.
*
* Revision 1.2 2000/11/17 17:45:12 aheilwag
* fixed a typo.
*
* Revision 1.1 2000/11/17 13:24:14 aheilwag
* added class to support the "create test package" context menu option.
*
*/
package com.togethersoft.modules.xp;
import java.io.IOException;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.command.*;
import com.togethersoft.openapi.ide.diagram.*;
import com.togethersoft.openapi.ide.diagram.enum.*;
import com.togethersoft.openapi.rwi.*;
import com.togethersoft.openapi.sci.*;
import com.togethersoft.modules.patterns.JAVA.CLASS.XP.TestPackage.Pattern;
/**
* This class controls the visibility of the "create test package" option in
* the XPTest context menu. If the user clicks on the itm, the
* actionPerformed() method will be executed.
*/
public class CreateTestPackageCmd extends IdeCommandAdapter
{
/**
* controls the visibility and enabled state of the menu item connected to
* this command.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void checkStatus (IdeCommandEvent anEvent)
{
XPTestIDEHelper.setItemVisibility (IXPTestCommands.CREATE_TEST_PACKAGE,
!XPTestProperties.get(IXPTestProperties.FORCE_JUNIT_COMPATIBILITY).equals("true") &&
(XPTestIDEHelper.getSelectedPackage () != null));
}
/**
* performs the command.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void actionPerformed (IdeCommandEvent anEvent)
{
Pattern.createTestPackage (
XPTestIDEHelper.getSelectedPackageName (),
XPTestProperties.get ("TestPackage.classname"),
XPTestProperties.get ("TestPackage.classname") + " test suite",
XPTestProperties.get ("TestPackage.createMain"),
XPTestProperties.get ("TestPackage.recurse").equals ("true"),
XPTestProperties.get ("TestPackage.VAJSupport").equals ("true"));
}
}
PK
Kñ*µ!#
3 com/togethersoft/modules/xp/CreateTestProxyCmd.java/**
* Title: CreateTestProxyCmd
* Description: This class controls the visibility of the "create test proxy"
* option in the XPTest context menu. If the user selected the
* item, actionPerformed() will be executed.
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: CreateTestProxyCmd.java,v 1.3 2001/07/17 07:24:10 tpinos Exp $
*
* $Log: CreateTestProxyCmd.java,v $
* Revision 1.3 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.2 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.2 2001/06/01 07:46:39 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.3 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.2 2000/11/26 11:12:15 aheilwag
* moved from XPTestUtils fo XPTestIDEHelper and XPTestJavaHelper.
*
* Revision 1.1 2000/11/17 13:27:50 aheilwag
* added class to support the "create test proxy" context menu option.
*
*/
package com.togethersoft.modules.xp;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.command.*;
import com.togethersoft.openapi.ide.diagram.*;
import com.togethersoft.openapi.ide.diagram.enum.*;
import com.togethersoft.openapi.rwi.*;
import com.togethersoft.openapi.sci.*;
import com.togethersoft.modules.patterns.JAVA.CLASS.XP.TestProxy.Pattern;
/**
* This class controls the visibility of the "create test proxy" option in the
* XPTest context menu. If the user selected the item, actionPerformed() will
* be executed.
*/
public class CreateTestProxyCmd extends IdeCommandAdapter
{
/**
* controls the visibility and enabled state of the menu item connected to
* this command.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void checkStatus (IdeCommandEvent anEvent)
{
XPTestIDEHelper.setItemVisibility (IXPTestCommands.CREATE_TEST_PROXY,
!XPTestProperties.get(IXPTestProperties.FORCE_JUNIT_COMPATIBILITY).equals("true") &&
(XPTestIDEHelper.getSelectedPackage () != null));
}
/**
* performs the command.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void actionPerformed (IdeCommandEvent anEvent)
{
Pattern.createProxy (XPTestIDEHelper.getSelectedPackageName ());
}
}
PK
šhí*úÄšd d 3 com/togethersoft/modules/xp/DefaultXPTestEvent.java/**
* Title: DefaultXPTestEvent
* Description: Default implementation for an IXPTestEvent.
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: DefaultXPTestEvent.java,v 1.5 2001/07/13 11:04:52 aheilwag Exp $
*
* $Log: DefaultXPTestEvent.java,v $
* Revision 1.5 2001/07/13 11:04:52 aheilwag
* documented and reorganized class.
*
* Revision 1.4 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
public class DefaultXPTestEvent implements IXPTestEvent
{
private String _testQualifiedName;
private XPTestType _testType;
private XPTestEventType _type;
/**
* constructor.
*
* @param aType an instance of XPTestEventType
* @param aTestType an instance of XPTestType
* @param aTestName a qualified name of a test
*/
public DefaultXPTestEvent (XPTestEventType aType, XPTestType aTestType,
String aTestQualifiedName)
{
_type = aType;
_testType = aTestType;
_testQualifiedName = aTestQualifiedName;
}
/**
* @return the qualified test name
*/
public String getTestQualifiedName ()
{
return _testQualifiedName;
}
/**
* @return the test type
*/
public XPTestType getTestType ()
{
return _testType;
}
/**
* @return the type
*/
public XPTestEventType getType ()
{
return _type;
}
}
PK
i<È*"ÁïO O + com/togethersoft/modules/xp/HelpDialog.java/**
* Title: HelpDialog
* Description: Help dialog for the XPTest configuration dialog
* Copyright: Copyright (c) Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: HelpDialog.java,v 1.1.1.1 2001/06/08 05:35:19 fisakov Exp $
*
* $Log: HelpDialog.java,v $
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.5 2001/06/01 07:46:38 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.4 2001/05/21 19:22:06 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.3 2001/05/19 19:54:13 aheilwag
* included patches from TogetherSoft to match their UI guidelines
*
* Revision 1.2 2000/11/28 22:56:14 aheilwag
* added support for configuring and catching stdout/stderr for JUnitX on Win32.
*
* Revision 1.1 2000/11/13 12:50:54 aheilwag
* added class to repository.
*
*/
package com.togethersoft.modules.xp;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.togethersoft.openapi.ide.IdeAccess;
import com.togethersoft.openapi.ide.window.IdeButtonType;
/**
* Help dialog for the XPTest configuration dialog
*/
class HelpDialog
{
private JPanel _contentPane;
private JTextArea _text = new JTextArea ();
private JScrollPane _scrollPane = new JScrollPane (_text);
public JDialog _helpDialog;
/**
* constructor
*/
public HelpDialog ()
{
try
{
init ();
}
catch (Exception e)
{
e.printStackTrace ();
}
}
/**
* initialize swing components
*/
private void init ()
throws Exception
{
_helpDialog = IdeAccess.getWindowManager ().createDialog (null);
_contentPane = (JPanel)_helpDialog.getContentPane ();
_helpDialog.setTitle ("How to ...");
_text.setText ("\n"
+ " XPTest needs some parameters in order to instantiate\n"
+ " patterns and execute tests:\n"
+ "\n"
+ " 1. Virtual Machine, stdout and stderr\n"
+ " The binary of the Java VM you want to use. If\n"
+ " it is not contained in the PATH the path to the\n"
+ " VM has to be given here too.\n"
+ " If you want to catch stdout and stderr in\n"
+ " message panes of Together, you can rely on the\n"
+ " automatic solution for most Unix flavours. For\n"
+ " other flavours and Windows start the VM using\n"
+ " the oistart wrapper of Together. On Windows\n"
+ " this can be achived using a VM parameter like\n\n"
+ " oistart -normal -r -o stdout -e stderr\n\n"
+ " For Windows, XPTest provides default values.\n"
+ "\n"
+ " 2. VM Params\n"
+ " Optional parameter to the Java VM used when\n"
+ " running JUnitX-based tests.\n"
+ "\n"
+ " 3. JUnitX Jar\n"
+ " Full path and name of the JUnitX Jar archive.\n"
+ "\n"
+ " 4. Compiled classes\n"
+ " Path to the compiled classes beeing part of\n"
+ " the tests to be executed.\n"
+ "\n"
+ " 5. CLASSPATH\n"
+ " CLASSPATH to be used for the tests. For\n"
+ " Windows, XPTest provides default values.\n"
+ " There's no need to add any paths on CLASSPATH,\n"
+ " it's possible to do that in the Together\n"
+ " project file.\n"
+ "\n"
+ " 6. Default Test location\n"
+ " The package proposed by XPTest for the\n"
+ " generated test class of a production class can\n"
+ " either be the same package, a sub package or a\n"
+ " package in a parallel test hierarchy. The name\n"
+ " of a subpackage has to be given in the next\n"
+ " field of the dialog. So if you want to have the\n"
+ " tests in the subpackage test of the current\n"
+ " package, enter \"test\" there.\n"
+ " If you prefer a parallel hierarchy within the\n"
+ " top-level package test for example, also enter\n"
+ " \"test\" in the following field of the dialog.\n"
+ " In that case a production class in the package\n"
+ " foo will be supposed to have a test class in\n"
+ " the package test.foo.\n"
+ "\n"
+ " 7. Test package name\n"
+ " See 6. for explanation.\n"
+ "\n"
+ " 8. Default GUI\n"
+ " This setting controls the UI being started if\n"
+ " main() methods are generated within TestPackage\n"
+ " classes. If you execute tests within Together\n"
+ " this settings controls the UI to be started\n"
+ " too.\n"
+ "\n"
+ " The settings will be stored in a properties file\n"
+ " named XPTest.properties located in your project path.\n");
_text.setEditable (false);
_contentPane.add (_scrollPane, BorderLayout.CENTER);
_helpDialog.setSize (450, 400);
}
}
PK
Ïhí*˜·ï=: : 0 com/togethersoft/modules/xp/IXPTestCommands.java/**
* Title: IXPTestCommand
* Description: Constant list for XPTest commands.
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: IXPTestCommands.java,v 1.3 2001/07/13 11:06:31 aheilwag Exp $
*
* $Log: IXPTestCommands.java,v $
* Revision 1.3 2001/07/13 11:06:31 aheilwag
* reformatted class.
*
* Revision 1.2 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
/**
* Constants for XPTest commands.
*/
public interface IXPTestCommands
{
public String CONFIGURE = "Configure";
public String CONFIGURE_TEXT = "Configure";
public String CREATE_TEST_CASE = "CreateTestCase";
public String CREATE_TEST_CASE_TEXT = "Create Test Case";
public String CREATE_TEST_PACKAGE = "CreateTestPackage";
public String CREATE_TEST_PACKAGE_TEXT = "Create Test Package";
public String CREATE_TEST_PROXY = "CreateTestProxy";
public String CREATE_TEST_PROXY_TEXT = "Create Test Proxy";
public String GROUP = "XPTest";
public String GROUP_TEXT = "XP Test";
public String TEST = "Test";
public String TEST_TEXT = "Test";
}
PK
ií*Ô;Ý
¿ ¿ 1 com/togethersoft/modules/xp/IXPTestConstants.java/**
* Title: IXPTestConstants
* Description: Constant strings for XPTest.
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: IXPTestConstants.java,v 1.5 2001/07/13 11:08:14 aheilwag Exp $
*
* $Log: IXPTestConstants.java,v $
* Revision 1.5 2001/07/13 11:08:14 aheilwag
* reformatted class
*
* Revision 1.4 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
public interface IXPTestConstants
{
// packages
String FRAMEWORK = "framework";
String JUNIT = "junit";
String JUNIT_FRAMEWORK = JUNIT + "." + FRAMEWORK;
String JUNIT_SWINGUI = JUNIT + "." + IXPTestConstants.SWINGUI;
String JUNIT_TEXTUI = JUNIT + "." + IXPTestConstants.TEXTUI;
String JUNITX = "junitx";
String JUNITX_FRAMEWORK = JUNITX + "." + FRAMEWORK;
String SWINGUI = "swingui";
String TEXTUI = "textui";
// objects
String PRIVATETESTCASE = "PrivateTestCase";
String TEST = "Test";
String TESTACCESSEXCEPTION = "TestAccessException";
String TESTCASE = "TestCase";
String TESTPACKAGE = "TestPackage";
String TESTPROXY = "TestProxy";
String TESTRUNNER = "TestRunner";
String TESTSUITE = "TestSuite";
}
PK
.ií*\‡æó ó - com/togethersoft/modules/xp/IXPTestEvent.java/**
* Title: IXPTestEvent
* Description: Interface for an XPTest event
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: IXPTestEvent.java,v 1.5 2001/07/13 11:09:29 aheilwag Exp $
*
* $Log: IXPTestEvent.java,v $
* Revision 1.5 2001/07/13 11:09:29 aheilwag
* reformatting & documentation
*
* Revision 1.4 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
/**
* Interface for an XPTest event.
*/
public interface IXPTestEvent
{
String getTestQualifiedName ();
XPTestType getTestType ();
XPTestEventType getType ();
}
PK
Dií*òIS 0 com/togethersoft/modules/xp/IXPTestListener.java/**
* Title: IXPTestListener
* Description: An interface for listeners for XPTest events.
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: IXPTestListener.java,v 1.5 2001/07/13 11:10:09 aheilwag Exp $
*
* $Log: IXPTestListener.java,v $
* Revision 1.5 2001/07/13 11:10:09 aheilwag
* reformatting
*
* Revision 1.4 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
/**
* XPTest listener.
*/
public interface IXPTestListener
{
/**
* Notification that a test (test case, test package or test proxy) was
* created.
*/
void testCreated (IXPTestEvent event);
}
PK
qsô*yZ‘\¶ ¶ 2 com/togethersoft/modules/xp/IXPTestProperties.java/**
* Title: IXPTestProperties
* Description: Properties for XPTest.
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: IXPTestProperties.java,v 1.8 2001/07/20 12:27:34 aheilwag Exp $
*
* $Log: IXPTestProperties.java,v $
* Revision 1.8 2001/07/20 12:27:34 aheilwag
* reviewed code
*
* Revision 1.7 2001/07/19 08:39:09 tpinos
* new option for "not implemented" assertions;
* bugfixing
*
* Revision 1.6 2001/07/19 04:04:26 tpinos
* testcase and testedclass tags added to the modified sources;
* options for junit.jar and junitx.jar location created - these two jars will
* be add now to the project;
* test command invoked on tested class will try to find the test case
* (via the new tags)
*
* Revision 1.5 2001/07/18 08:49:17 tpinos
* two options added (junitx.jar and junit.jar location) - these two jars are imported to the project
*
* Revision 1.4 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.3 2001/07/13 11:10:39 aheilwag
* reformatting
*
* Revision 1.2 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
public interface IXPTestProperties
{
String FORCE_JUNIT_COMPATIBILITY = "forceJUnitCompatibility";
String JUNIT_JAR = "JUnitJar";
String JUNITX_JAR = "JUnitXJar";
String MODULE = "XPTest";
interface TestCase
{
String NOT_IMPLEMENTED_ASSERTIONS = "TestCase.notImplementedAssertions";
String TEST_TAGS = "TestCase.TestCaseTag";
}
}
PK
MD+4Žäyé é ( com/togethersoft/modules/xp/LogPump.java/**
* Title: LogPump
* Description: This class is used to read the log files of Together's
* exec command and write the results to messages panes.
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: LogPump.java,v 1.4 2001/08/24 06:34:27 tpinos Exp $
*
* $Log: LogPump.java,v $
* Revision 1.4 2001/08/24 06:34:27 tpinos
* bugfixing - properties must be initialized before junitXXX jars will be add to the project
*
* Revision 1.3 2001/08/14 09:24:18 fisakov
* On Windows the log file is always empty if using oistart
*
* Revision 1.2 2001/06/26 03:30:38 tpinos
* modified to be a "safe enum type"
*
* Revision 1.1.1.1 2001/06/08 05:35:19 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.3 2001/06/01 07:46:38 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.7 2001/05/21 19:22:07 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.6 2000/12/02 21:29:48 aheilwag
* add optional filename alternative for stdout log for Together 4.2.
*
* Revision 1.5 2000/11/28 22:56:14 aheilwag
* added support for configuring and catching stdout/stderr for JUnitX on Win32.
*
* Revision 1.4 2000/11/17 13:41:32 aheilwag
* improved documentation and source readability.
*
* Revision 1.3 2000/11/13 12:42:02 aheilwag
* switched from prefix 'm' to '_' for class attributes.
*
* Revision 1.2 2000/11/10 20:06:00 aheilwag
* added cvs tags
*
*/
package com.togethersoft.modules.xp;
import java.io.*;
import java.util.*;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.message.*;
public class LogPump extends Thread
{
private String _logPrefix = null;
private String _stdoutFile = null;
private String _stderrFile = null;
private BufferedReader _stdout = null;
private BufferedReader _stderr = null;
private IdeMessageManager _manager = null;
private IdeMessagePage _stdoutPage = null;
private IdeMessagePage _stderrPage = null;
/**
* create a log pump reading the output from Together's exec method
* and writing it line by line into additional message panes. The
* necessary message panes will be created and removed from the thread.
*
* @return a Thread ready to be started
*/
public void run ()
{
if (!setup ())
{
teardown ();
return;
}
while (!interrupted () && !TestCmd.guiTerminated ())
{
try
{
Thread.sleep (250); // 1/4 second
} catch (InterruptedException e) {};
pump ();
}
teardown ();
}
/**
* transfer new content of the logfiles in the appropriate message panes.
*/
private void pump ()
{
String line;
try
{
if (_stdout.ready ())
while (((line = _stdout.readLine ()) != null) && !interrupted ())
_stdoutPage.printMessage (IdeMessageType.INFORMATION, line);
if (_stderr.ready ())
while (((line = _stderr.readLine ()) != null) && !interrupted ())
_stderrPage.printMessage (IdeMessageType.INFORMATION, line);
}
catch (IOException e) {};
}
/**
* checks if the logfiles can be opened and opens them if possible.
*
* @param aLogPrefix the prefix for the log files
*
* @return true, if the logfiles could be opened.
*/
private boolean openLogFiles (String aLogPrefix)
{
String stdoutAlt = null;
if (XPTestProperties.get ("stdout").equals ("IdeCommandEvent
*/
public void checkStatus (IdeCommandEvent anEvent)
{
RwiElement element = XPTestIDEHelper.getSelectedElement (
XPTestIDEHelper.getActiveDiagram (anEvent));
RwiPackage pkg = XPTestIDEHelper.getSelectedPackage ();
XPTestIDEHelper.setItemVisibility (IXPTestCommands.TEST,
findTest (element, pkg) != null);
}
/**
* creates the class path for the execution of JUnitX. Several parameters
* from the configuration dialog are combined using the correct delimiter.
*
* @param returns a String
*/
private String createClassPath ()
{
StringBuffer finalClassPath = new StringBuffer ("-classpath ");
String path = IdeAccess.getIdeManager ().expandMacros (null, "$CLASSPATH_PROJECT$$PS$$DESTINATION$");
String separator = File.pathSeparator;
if (path.length () > 0)
{
finalClassPath.append ("\"");
finalClassPath.append (separator);
finalClassPath.append (path);
finalClassPath.append ("\"");
}
return finalClassPath.toString ();
}
/**
* selects a JUnitX UI to call if applicable.
*
* @param anElement an instance of RwiElement
*
* @param a empty String or a class to execute as UI
*/
private String selectUIClass (RwiElement anElement)
{
String guiType = XPTestProperties.get ("GuiType");
if (guiType.equals ("Swing UI"))
{
_preserveLog = false;
return IXPTestConstants.JUNIT + "." + IXPTestConstants.SWINGUI + "." + IXPTestConstants.TESTRUNNER;
}
else if (guiType.equals ("Text UI"))
{
_preserveLog = true;
return IXPTestConstants.JUNIT + "." + IXPTestConstants.TEXTUI + "." + IXPTestConstants.TESTRUNNER;
}
return "";
}
/**
* creates a log file.
*
* @return true, if the logfile could be created
*/
private boolean createLogFile ()
{
try
{
_logFile = File.createTempFile ("XPTest", ".log");
}
catch (Exception e)
{
IdeMessageManagerAccess.printMessage (
IdeMessageType.ERROR,
"Could not create temporary file.");
return false;
}
return true;
}
/**
* creates a test GUI for an element by executing JUnitX using the exec()
* method of Together. In the same step a log pump is instantiated to copy
* the stdout- and stderr-Logs from JUnitX to new message panes in Together.
* The log pump does not work on all operation systems and configurations
* since it relies on undocumented features of Together. There will be more
* environment supported as I get access to the necessary configurations.
*
* @param anElement an instance of RwiElement
*/
private void createGUI (RwiElement anElement)
{
Runtime runtime = Runtime.getRuntime ();
if (!createLogFile ())
return;
// exec VM
try
{
StringBuffer cmdLineBuf = new StringBuffer ();
cmdLineBuf.append (XPTestProperties.get ("VM"));
cmdLineBuf.append (" ");
cmdLineBuf.append (XPTestProperties.get ("VMParams"));
cmdLineBuf.append (" ");
cmdLineBuf.append (createClassPath ());
cmdLineBuf.append (" ");
cmdLineBuf.append (selectUIClass (anElement));
cmdLineBuf.append (" ");
cmdLineBuf.append (anElement.getProperty (RwiProperty.FULL_NAME));
String cmdLine = IdeAccess.getIdeManager().expandMacros(null, cmdLineBuf.toString());
IdeMessageManagerAccess.printMessage (
IdeMessageType.INFORMATION,
"Executing " + cmdLine);
_guiProcess = IdeManagerAccess.getManager ().exec (cmdLine, _logFile.getPath ());
if (_guiProcess == null)
throw new IOException ("No process spawned.");
}
catch (Exception e)
{
IdeMessageManagerAccess.printMessage (
IdeMessageType.ERROR_MODAL,
"Could not run TestGUI:\n\n" + e.getMessage ());
return;
}
// setup log pump for non-mac operating systems only (he)
if (System.getProperty ("os.name").toUpperCase ().indexOf ("MAC") < 0)
{
_logPump = new LogPump ();
_logPump.start ();
}
}
/**
* terminates the currently running Test UI and the corresponding log pump.
*/
private void terminateGUI ()
{
_guiProcess.destroy ();
_guiProcess = null;
// terminate log pump
_logPump.interrupt ();
try
{
_logPump.join ();
} catch (InterruptedException e) {};
_logPump = null;
}
/**
* finds the test class for an element using the pattern links if they
* are still present.
*
* @param anElement element whose test class is needed
*/
private RwiElement findTestClassFor (RwiElement anElement)
{
SciModel sciModel = SciModelAccess.getModel ();
RwiModel rwiModel = RwiModelAccess.getModel ();
SciClass tested,
test;
if ((sciModel == null) || (rwiModel == null))
return null;
tested = sciModel.findClass (SciLanguage.JAVA,
anElement.getProperty (RwiProperty.FULL_NAME));
if (tested == null)
return null;
/*
if ((test = SciPatternUtil.findPatternLinkSupplier (tested, "TestCase", "tests")) == null)
return null;
*/
SciTagList tagList;
if ((tagList = tested.getTagList ()) == null)
return null;
String testCaseQName;
if ((testCaseQName = tagList.getTagValue ("testcase")) == null)
return null;
if ((test = sciModel.findClass (SciLanguage.JAVA, testCaseQName)) == null)
return null;
RwiElement result = rwiModel.findElement(test.getUniqueName ());
return result;
// return rwiModel.findElement (test.getUniqueName ());
}
/**
* tests if the GUI process has terminated.
*
* @return true, if the GUI process has terminated
*/
static public boolean guiTerminated ()
{
try
{
if (_guiProcess == null)
return true;
_guiProcess.exitValue ();
return true;
}
catch (IllegalThreadStateException e)
{
return false;
}
}
/**
* checks if an element is a test package.
*
* @param aRwiElement a rwi element
*
* @return true, if the element is test package
*/
private boolean isTestPackage (RwiElement aRwiElement)
{
return (aRwiElement != null)
&& aRwiElement.getProperty (RwiProperty.SHAPE_TYPE).equals (RwiShapeType.CLASS)
&& isTestPackage ((SciClass)aRwiElement.getCodeElement ());
}
/**
* checks if an element is a test package.
*
* @param aSciClass a sci class
*
* @return true, if the element is test package
*/
private boolean isTestPackage (SciClass aSciClass)
{
try
{
SciInheritanceList inheritances = aSciClass.getImplementsList ();
SciInheritanceEnumeration enum = inheritances.inheritances ();
while (enum.hasMoreElements ())
{
SciInheritance inheritance = enum.nextSciInheritance ();
if (inheritance.getName ().equals (IXPTestConstants.JUNITX_FRAMEWORK + "." + IXPTestConstants.TESTPACKAGE))
return true;
}
}
catch (NullPointerException e)
{
}
return false;
}
/**
* finds a test package in a diagram.
*
* @param aRwiDiagram a rwi diagram
*
* @return the test package if found
*/
private RwiElement findTestPackage (RwiDiagram aRwiDiagram)
{
if (aRwiDiagram == null)
return null;
RwiReferenceEnumeration refs = aRwiDiagram.references ();
while (refs.hasMoreElements ())
{
RwiElement element = refs.nextRwiReference ().getElement ();
if (isTestPackage (element))
return element;
}
return null;
}
/**
* finds a test in a given package.
*
* @param anElement a rwi element
* @param aPkg a rwi package
*
* @return the test case if found
*/
private RwiElement findTest (RwiElement anElement, RwiPackage aPkg)
{
RwiElement testElement = null;
if (anElement == null) // checkStatus() ensured pkg != null
{
if (aPkg != null)
testElement = findTestPackage (aPkg.getPhysicalDiagram ());
}
else
{
String shapeName = anElement.getProperty (RwiProperty.SHAPE_TYPE);
if (shapeName.equals (RwiShapeType.CLASS))
{
if (isTestPackage (anElement))
testElement = anElement;
else
{
if (XPTestIDEHelper.doesExtend (anElement, IXPTestConstants.TESTCASE) ||
XPTestIDEHelper.doesExtend (anElement, IXPTestConstants.PRIVATETESTCASE))
testElement = anElement;
else
if ((anElement = findTestClassFor (anElement)) != null)
testElement = anElement;
}
}
else
if (shapeName.equals (RwiShapeType.CLASS_DIAGRAM))
testElement = findTestPackage ((RwiDiagram)anElement);
}
return testElement;
}
/**
* performs the test command. checkStatus() has to ensure that this method is
* never called if getSelectedElement() and getSelectedPackage() both return
* null.
* This method contains code which is not very maintainable to find out the
* kind of the currently selected element. There may still be cases left
* which are not covered.
*
* @param anEvent an instance of IdeCommandEvent
*/
public void actionPerformed (IdeCommandEvent anEvent)
{
RwiElement element = XPTestIDEHelper.getSelectedElement (
XPTestIDEHelper.getActiveDiagram (anEvent));
RwiPackage pkg = XPTestIDEHelper.getSelectedPackage ();
boolean process = false;
String shapeName = null;
element = findTest(element, pkg);
process = element != null;
// ensure singleton
if (!TestCmd.guiTerminated ())
{
int choice = JOptionPane.showConfirmDialog (null,
"Test GUI already active, terminate current GUI?",
"GUI already active",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (choice == JOptionPane.OK_OPTION)
terminateGUI ();
else
return;
}
// process element
if (process) {
if (!XPTestIDEHelper.isClassCompiled (element.getProperty(RwiProperty.FULL_NAME)))
IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR,
"Compiled test not found, please run Make.");
else
createGUI (element);
}
else
IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR,
"Found no appropriate test.");
}
}
PK
‚ƒû*©WÊt(% (% ) com/togethersoft/modules/xp/xptest.config##########
# XPTest
##########
optionsEditor.item.XPTest.condition = isGlobalOptions () && isFeatureEnabledByWorkspace("XPTest")
optionsEditor.item.XPTest.view.UI = treeTableNodeUI
#optionsEditor.item.XPTest.view.expandLevel = 1
#optionsEditor.item.XPTest.condition = !isPlugin()
optionsEditor.item.XPTest.order = 150
optionsEditor.item.XPTest.view.description=This page provides configuration options for the XPTest module.
# Virtual Machine
optionsEditor.item.XPTest.item.VM = FileNameField
optionsEditor.item.XPTest.item.VM.name = Virtual machine
optionsEditor.item.XPTest.item.VM.propertyName = XPTest.VM
optionsEditor.item.XPTest.item.VM.view.description=Defines command to start Java virtual machine that will be used to launch JUnit.
# Virtual Machine Parameters
optionsEditor.item.XPTest.item.VMParams = StringField
optionsEditor.item.XPTest.item.VMParams.name = Virtual machine parameters
optionsEditor.item.XPTest.item.VMParams.propertyName = XPTest.VMParams
optionsEditor.item.XPTest.item.VMParams.view.description=Defines parameters required for the Virtual Machine launching.
# Force JUnit Compatibility
optionsEditor.item.XPTest.item.forceJUnitCompatibility = BooleanField
optionsEditor.item.XPTest.item.forceJUnitCompatibility.name = Force JUnit compatibility
optionsEditor.item.XPTest.item.forceJUnitCompatibility.propertyName = XPTest.forceJUnitCompatibility
optionsEditor.item.XPTest.item.forceJUnitCompatibility.view.description=When checked, the generated Test Cases will require JUnit only, otherwise both JUnit and JUnitX are required to run tests.
# Default Test Location
optionsEditor.item.XPTest.item.TestLocation = ChoiceField
\ (
\ {
\ values := { "Paralell hierarchy", "Same package", "Subpackage" },
\ }
\ )
optionsEditor.item.XPTest.item.TestLocation.name = Default test location
optionsEditor.item.XPTest.item.TestLocation.propertyName = XPTest.TestLocation
optionsEditor.item.XPTest.item.TestLocation.view.description=Defines the default placement of the generated tests:test methods should be created
# Insert "not implemented" assertions
optionsEditor.item.XPTest.item.TestCase.item.notImplementedAssertions = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.notImplementedAssertions.name = Insert "not implemented" assertions
optionsEditor.item.XPTest.item.TestCase.item.notImplementedAssertions.propertyName = XPTest.TestCase.notImplementedAssertions
optionsEditor.item.XPTest.item.TestCase.item.notImplementedAssertions.view.description=Defines whether assertions with "Not implemented" message should be inserted into the generated code.
# Create suite
optionsEditor.item.XPTest.item.TestCase.item.createSuite = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.createSuite.name = Create suite()
optionsEditor.item.XPTest.item.TestCase.item.createSuite.propertyName = XPTest.TestCase.createSuite
optionsEditor.item.XPTest.item.TestCase.item.createSuite.view.description=Defines whether method suite should be created.
# Create setUp
optionsEditor.item.XPTest.item.TestCase.item.createSetUp = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.createSetUp.name = Create setUp()
optionsEditor.item.XPTest.item.TestCase.item.createSetUp.propertyName = XPTest.TestCase.createSetUp
optionsEditor.item.XPTest.item.TestCase.item.createSetUp.view.description=Defines whether setUp method should be created
# Create tearDown
optionsEditor.item.XPTest.item.TestCase.item.createTearDown = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.createTearDown.name = Create tearDown()
optionsEditor.item.XPTest.item.TestCase.item.createTearDown.propertyName = XPTest.TestCase.createTearDown
optionsEditor.item.XPTest.item.TestCase.item.createTearDown.view.description=Defines whether tearDown method should be created
# Access private
optionsEditor.item.XPTest.item.TestCase.item.accessPrivate = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.accessPrivate.name = Access private
optionsEditor.item.XPTest.item.TestCase.item.accessPrivate.propertyName = XPTest.TestCase.accessPrivate
optionsEditor.item.XPTest.item.TestCase.item.accessPrivate.view.description=When checked, the imports and the code to access private methods of the Class being tested are created. Requires JUnitX.
# Create TestCase & TestedClass tags in the tested class javadoc
optionsEditor.item.XPTest.item.TestCase.item.TestTags = BooleanField
optionsEditor.item.XPTest.item.TestCase.item.TestTags.name = Create "testcase" & "testedclass" tags
optionsEditor.item.XPTest.item.TestCase.item.TestTags.propertyName = XPTest.TestCase.TestTags
optionsEditor.item.XPTest.item.TestCase.item.TestTags.view.description=Defines whether @testcase and @testedclass tags should be created
###############
# TestPackage
###############
optionsEditor.item.XPTest.item.TestPackage.name = TestPackage
optionsEditor.item.XPTest.item.TestPackage.view.description=TestPackage specific options
# Default classname
optionsEditor.item.XPTest.item.TestPackage.item.classname = StringField
optionsEditor.item.XPTest.item.TestPackage.item.classname.name = Default classname
optionsEditor.item.XPTest.item.TestPackage.item.classname.propertyName = XPTest.TestPackage.classname
optionsEditor.item.XPTest.item.TestPackage.item.classname.view.description=Defines the default name for the newly created TestPackage
# VisualAge support
optionsEditor.item.XPTest.item.TestPackage.item.VAJSupport = BooleanField
optionsEditor.item.XPTest.item.TestPackage.item.VAJSupport.name = VisualAge support
optionsEditor.item.XPTest.item.TestPackage.item.VAJSupport.propertyName = XPTest.TestPackage.VAJSupport
optionsEditor.item.XPTest.item.TestPackage.item.VAJSupport.view.description=When checked, the method inVAJava is created in the Test Package to check if Visual Age for Java is running
# Collect tests (???)
# Create main()
optionsEditor.item.XPTest.item.TestPackage.item.createMain = ChoiceField
\ (
\ {
\ values := { "Swing UI", "Text UI", "no main()" },
\ }
\ )
optionsEditor.item.XPTest.item.TestPackage.item.createMain.name = Create main()
optionsEditor.item.XPTest.item.TestPackage.item.createMain.propertyName = XPTest.TestPackage.createMain
optionsEditor.item.XPTest.item.TestPackage.item.createMain.view.description=Defines whether main method should be created in the Test Package, and which GUI to use to run JUnit
#############
# TestProxy
#############
PK
MD+!Õ…¶T; T; ' com/togethersoft/modules/xp/XPTest.java/**
* Title: XPTest
* Description: The XP module for Together supports the XP patterns and
* JUnitX by Kent Beck, Erich Gamma and Andreas Heilwagen* Copyright: Copyright (c) 2000 Andreas Heilwagen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Andreas Heilwagen * * $Id: XPTest.java,v 1.11 2001/08/24 06:34:27 tpinos Exp $ * * $Log: XPTest.java,v $ * Revision 1.11 2001/08/24 06:34:27 tpinos * bugfixing - properties must be initialized before junitXXX jars will be add to the project * * Revision 1.10 2001/07/24 11:07:20 tpinos * XPTest enabled only for Java language; * XPTest old-style config dialog dropped; * bugfixing * * Revision 1.9 2001/07/20 12:28:43 aheilwag * reviewed code * * Revision 1.8 2001/07/18 08:49:17 tpinos * two options added (junitx.jar and junit.jar location) - these two jars are imported to the project * * Revision 1.7 2001/07/17 07:24:10 tpinos * page in the standard config dialog created (the old one kept); bigfixing; * * Revision 1.6 2001/07/10 08:08:04 tpinos * produced code modified (de.extremejava.junitx -> junitx); * option "Force JUnit Compatibility" introduced (and behaviour modified); * bugfixing (NullPointerException-s, recreateTestMethod suppressed, * automaticaly generated assertions suppressed, ...); * refactoring (constans for commands (id, text) introduced) * * Revision 1.5 2001/06/20 10:47:27 tpinos * ugly little misspelling corrected * * Revision 1.4 2001/06/20 10:35:12 tpinos * UI modified (config dialog, capitalization, ...) * * Revision 1.3 2001/06/18 11:34:02 fisakov * Listener registration moved to XPTest directly * ListenerRegistry is an internal class, no need make it open * * Revision 1.2 2001/06/15 13:21:32 tpinos * XPTestListenerRegistry and supporting classes created. * ..XP/Test.../Pattern.java now fires the events about new tests. * * Revision 1.1.1.1 2001/06/08 05:35:22 fisakov * Exported from core modules repository (SPb) * * Revision 1.4 2001/06/01 07:46:38 tomas * changes made by Andreas and Peet merged * * Revision 1.8 2001/05/21 19:22:07 aheilwag * moved from GPL to LGPL for TogetherSoft. * * Revision 1.7 2001/05/19 19:55:28 aheilwag * changed activatable module support as suggested by TogetherSoft * * Revision 1.6 2001/05/19 14:51:54 aheilwag * included module activation patch. * * Revision 1.5 2000/11/17 20:10:17 aheilwag * added shortcuts to the important context menu items. * * Revision 1.4 2000/11/17 15:31:43 aheilwag * added the options "Create test case/package/proxy" to the XPTest context menu. * improved the documentation. * * Revision 1.3 2000/11/13 12:44:01 aheilwag * switched from 'm' to '_' as prefix for class attributes. * * Revision 1.2 2000/11/10 20:06:09 aheilwag * added cvs tags * */ package com.togethersoft.modules.xp; import java.awt.Event; import java.awt.event.*; import java.util.*; import javax.swing.*; import com.togethersoft.openapi.ide.*; import com.togethersoft.openapi.ide.command.*; import com.togethersoft.openapi.ide.config.*; import com.togethersoft.openapi.ide.diagram.*; import com.togethersoft.openapi.ide.diagram.enum.*; import com.togethersoft.openapi.ide.project.*; import com.togethersoft.openapi.ide.window.*; import com.togethersoft.openapi.ide.project.IdeProjectManagerAccess; /** * This module runs an XP test in one of the following ways
*
*
*
* The JPDA (Java Platform Debugger Architecture) which is required to
* run code within Together is not required. Instead the classes are
* run on a standard VM.
*/
public class XPTest implements IdeActivatable
{
static private XPTest _instance = null;
static private HashMap _groups = new HashMap ();
static private HashMap _items = new HashMap ();
private XPTestListenerRegistry _listenerRegistry = new XPTestListenerRegistry ();
private boolean _isActivated = false;
private boolean _javaAtAutorun = false;
/**
* adds a menu group.
*
* @param aGroupName the unique name of a group
* @param aGroup an instance of IdeCommandGroup
*/
static public void addGroup (String aGroupName, IdeCommandGroup aGroup)
{
_groups.put (aGroupName, aGroup);
}
/**
* gets a group.
*
* @param aGroupName the unique name of a group
*
* @return an IdeCommandGroup if there is a group with
* the given groupName or null
*/
static public IdeCommandGroup getGroup (String aGroupName)
{
return (IdeCommandGroup)_groups.get (aGroupName);
}
/**
* adds a menu item.
*
* @param anItemName the unique name of an item
* @param anItemText the displayed text
* @param anItem an instance of IdeCommandItem
* @param aKeyStroke a hotkey or null
*/
static public void addItem (String anItemName, String anItemText, IdeCommandItem anItem,
KeyStroke aKeyStroke)
{
if (aKeyStroke != null)
anItem.addShortcut (aKeyStroke);
anItem.setText (anItemText);
_items.put (anItemName, anItem);
}
/**
* gets a menu item.
*
* @param anItemName the unique name of an item
*
* @return an IdeCommandItem if there is a group with then
* given itemName or null
*/
static public IdeCommandItem getItem (String anItemName)
{
return (IdeCommandItem)_items.get (anItemName);
}
/**
* @return the current instance
*/
static public XPTest getInstance ()
{
return _instance;
}
/**
* adds a listener
*
* @param aListener a listener
*/
public void addListener (IXPTestListener aListener)
{
_listenerRegistry.addListener (aListener);
}
/**
* removes a listener
*
* @param aListener a listener
*/
public void removeListener (IXPTestListener aListener)
{
_listenerRegistry.removeListener (aListener);
}
/**
* @return the listener registry
*/
public XPTestListenerRegistry getListenerRegistry ()
{
return _listenerRegistry;
}
/**
* creates the XPTest context menu group.
*/
private void createXPGroup ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
IdeCommandGroup group = cman.createGroup (
IXPTestCommands.GROUP,
new IdeCommandConstraints ("context = element, location=popupMenu"),
new IdeCommandCheckListener ()
{
public void checkStatus (IdeCommandEvent event)
{
if (event.getCommandItem () != null)
event.getCommandItem ().setVisible (isActivated () && XPTestIDEHelper.isProjectLanguageJava ());
}
}
);
group.setText (IXPTestCommands.GROUP_TEXT);
XPTest.addGroup (IXPTestCommands.GROUP, group);
}
/**
* creates the "Test" menu item.
*/
private void createTestItem ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
XPTest.addItem (IXPTestCommands.TEST, IXPTestCommands.TEST_TEXT,
cman.createItem (
IXPTestCommands.TEST,
new IdeCommandConstraints ("context=element, parent="+IXPTestCommands.GROUP+", location=popupMenu"),
new TestCmd ()),
KeyStroke.getKeyStroke (KeyEvent.VK_R,
Event.SHIFT_MASK + Event.CTRL_MASK,
false)
);
}
/**
* creates the "Create test case" menu item.
*/
private void createTestCaseItem ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
XPTest.addItem (IXPTestCommands.CREATE_TEST_CASE, IXPTestCommands.CREATE_TEST_CASE_TEXT,
cman.createItem (
IXPTestCommands.CREATE_TEST_CASE,
new IdeCommandConstraints ("context=element, parent="+IXPTestCommands.GROUP+", location=popupMenu"),
new CreateTestCaseCmd ()),
KeyStroke.getKeyStroke (KeyEvent.VK_E,
Event.SHIFT_MASK + Event.CTRL_MASK,
false)
);
}
/**
* creates the "Create test proxy" menu item.
*/
private void createTestProxyItem ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
XPTest.addItem (IXPTestCommands.CREATE_TEST_PROXY, IXPTestCommands.CREATE_TEST_PROXY_TEXT,
cman.createItem (
IXPTestCommands.CREATE_TEST_PROXY,
new IdeCommandConstraints ("context=element, parent="+IXPTestCommands.GROUP+", location=popupMenu"),
new CreateTestProxyCmd ()),
KeyStroke.getKeyStroke (KeyEvent.VK_X,
Event.SHIFT_MASK + Event.CTRL_MASK,
false)
);
}
/**
* creates the "Create test package" menu item.
*/
private void createTestPackageItem ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
XPTest.addItem (IXPTestCommands.CREATE_TEST_PACKAGE, IXPTestCommands.CREATE_TEST_PACKAGE_TEXT,
cman.createItem (
IXPTestCommands.CREATE_TEST_PACKAGE,
new IdeCommandConstraints ("context=element, parent="+IXPTestCommands.GROUP+", location=popupMenu"),
new CreateTestPackageCmd ()),
KeyStroke.getKeyStroke (KeyEvent.VK_P,
Event.SHIFT_MASK + Event.CTRL_MASK,
false)
);
}
/**
* creates the "Configure" menu item.
*/
private void createConfItem ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
XPTest.addItem (IXPTestCommands.CONFIGURE, IXPTestCommands.CONFIGURE_TEXT,
cman.createItem (
IXPTestCommands.CONFIGURE_TEXT,
new IdeCommandConstraints ("context=element, parent="+IXPTestCommands.GROUP+", location=popupMenu"),
new ConfigureCmd ()),
null
);
}
/**
* creates the XP popup menu for classes and interfaces.
*/
private void createMenu ()
{
IdeCommandManager cman = IdeCommandManagerAccess.getCommandManager ();
createXPGroup ();
createTestItem ();
createTestCaseItem ();
createTestProxyItem ();
createTestPackageItem ();
createConfItem ();
}
/**
* is executed automaGically if "Startup=true" is uncommented in the
* XPTest.def file.
*/
public void autorun ()
{
_instance = this;
// configuration
String configFolder = IdeAccess.getIdeManager().getModuleHomeDirectory(getClass());
IdeModuleConfigAccess.createModuleConfig(getClass(), configFolder);
IdeModuleConfigAccess.loadConfigFile(getClass(), "xptest.config");
// properties
XPTestProperties.initializeProperties();
if (XPTestIDEHelper.isProjectLanguageJava ())
XPTestIDEHelper.updateProjectClasspath (IdeAccess.getProjectManager().getActiveProject());
// project listener
IdeAccess.getProjectManager().addProjectListener(XPTestProjectListener.getInstance());
createMenu ();
_isActivated = true;
}
/**
* shuts the module down.
*/
public void shutdown ()
{
// project listener
IdeAccess.getProjectManager().removeProjectListener(XPTestProjectListener.getInstance());
IdeModuleConfigAccess.unloadConfigFile(getClass(), "xptest.config");
_isActivated = false;
}
/**
* @returns the activation state of this module
*/
private boolean isActivated ()
{
return _isActivated;
}
private static class XPTestProjectListener extends IdeProjectAdapter
{
public static XPTestProjectListener getInstance() {
if (instance == null)
instance = new XPTestProjectListener();
return instance;
}
public void projectOpened(IdeProjectEvent e)
{
IdeProject project = e.getProject();
if (XPTestIDEHelper.isProjectLanguageJava (project)) {
XPTestIDEHelper.updateProjectClasspath (project);
}
}
private static XPTestProjectListener instance;
private XPTestProjectListener() {
}
}
}
PK
«ií*Û†Æ 0 com/togethersoft/modules/xp/XPTestEventType.java/**
* Title: XPTestEventType
* Description: XPTest event
* Copyright: Copyright (c) 2001 TogetherSoft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author TogetherSoft
*
* $Id: XPTestEventType.java,v 1.3 2001/07/13 11:13:23 aheilwag Exp $
*
* $Log: XPTestEventType.java,v $
* Revision 1.3 2001/07/13 11:13:23 aheilwag
* reordering, reformatting & documentation
*
* Revision 1.2 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
*/
package com.togethersoft.modules.xp;
/**
* XPTest event
*/
public class XPTestEventType
{
public final static XPTestEventType TEST_CREATION = new XPTestEventType ("test creation");
private String _type;
/**
* constructor.
*
* @param aType creates an event of a certain type
*/
private XPTestEventType (String type)
{
_type = type;
}
/**
* @return a string representation of this object.
*/
public String toString ()
{
return _type;
}
}
PK
î$+µñE¿1 ¿1 0 com/togethersoft/modules/xp/XPTestIDEHelper.java/**
* Title: XPTestIDHelper
* Description: Helper methods for XPTest concerning the IDE/Sci parts
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: XPTestIDEHelper.java,v 1.11 2001/08/28 02:39:29 tpinos Exp $
*
* $Log: XPTestIDEHelper.java,v $
* Revision 1.11 2001/08/28 02:39:29 tpinos
* console output removed
*
* Revision 1.10 2001/08/24 06:34:27 tpinos
* bugfixing - properties must be initialized before junitXXX jars will be add to the project
*
* Revision 1.9 2001/07/24 11:07:20 tpinos
* XPTest enabled only for Java language;
* XPTest old-style config dialog dropped;
* bugfixing
*
* Revision 1.8 2001/07/19 08:39:09 tpinos
* new option for "not implemented" assertions;
* bugfixing
*
* Revision 1.7 2001/07/18 08:49:17 tpinos
* two options added (junitx.jar and junit.jar location) - these two jars are imported to the project
*
* Revision 1.6 2001/07/12 11:37:44 tpinos
* isClassCompiled method added
*
*
* Revision 1.4 2001/07/12 07:26:08 tpinos
* reformated; a couple of comments added;
*
* Revision 1.3 2001/07/11 10:29:45 tpinos
* name of the created test package now matches the user input;
* property for JUnitX jar dropped from config dialog (it's in the project CP);
* "Test" command works now (checks the selection, recognizes test packages)
*
* Revision 1.2 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.1.1.1 2001/06/08 05:35:23 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.3 2001/06/01 07:46:37 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.5 2001/05/21 19:22:07 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.4 2001/05/19 14:52:09 aheilwag
* added configuration support patch.
*
* Revision 1.3 2000/11/26 11:12:15 aheilwag
* moved from XPTestUtils fo XPTestIDEHelper and XPTestJavaHelper.
*
* Revision 1.2 2000/11/17 17:59:20 aheilwag
* fixed a typo.
*
* Revision 1.1 2000/11/17 17:46:22 aheilwag
* renamed class from XPTestUtils.
* add methods required for CreateTest*Cmd.
*
*/
package com.togethersoft.modules.xp;
import java.io.File;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.config.*;
import com.togethersoft.openapi.ide.command.*;
import com.togethersoft.openapi.ide.diagram.*;
import com.togethersoft.openapi.ide.diagram.enum.*;
import com.togethersoft.openapi.ide.message.*;
import com.togethersoft.openapi.ide.project.*;
import com.togethersoft.openapi.ide.window.*;
import com.togethersoft.openapi.rwi.*;
import com.togethersoft.openapi.rwi.enum.*;
import com.togethersoft.openapi.sci.*;
import com.togethersoft.openapi.sci.enum.*;
/**
* Helper methods for XPTest concerning the *.ide.* and *.sci.* packages
* of the Together API. Some of these methods might be shortened somehow,
* so send me your hints if you like.
*/
public class XPTestIDEHelper
{
/**
* @return true, if a project is opened
*/
private boolean projectOpened ()
{
return IdeProjectManagerAccess.getProjectManager ().getActiveProject () != null;
}
/**
* @return true if default language for the active project is Java
*/
static public boolean isProjectLanguageJava ()
{
return isProjectLanguageJava (IdeProjectManagerAccess.getProjectManager ().getActiveProject ());
}
/**
* @return true if default language for the project is Java
*
* @param aProject
*/
static public boolean isProjectLanguageJava (IdeProject aProject)
{
return (aProject != null && SciLanguage.JAVA.equals (aProject.getDefaultLanguage ()));
}
/**
* gets the main path of the current project.
*
* @return a path or null
*/
static public String getProjectPath ()
{
IdeProject project = IdeProjectManagerAccess.getProjectManager ().getActiveProject ();
String path;
if (project == null)
return null;
path = project.getFileName ();
if (path.lastIndexOf ("/") >= 0)
path = path.substring (0, path.lastIndexOf ("/"));
else
if (path.lastIndexOf ("\\") >= 0)
path = path.substring (0, path.lastIndexOf ("\\"));
return path;
}
/**
* gets the destination for the current projects .class files.
*
* @return a path or null
*/
static public String getBuildDestination ()
{
IdeConfigManager manager = IdeConfigManagerAccess.getConfigManager ();
IdeConfig config = manager.getConfig ("$project");
String build = config.getProperty ("build.destination", "");
return IdeAccess.getIdeManager ().expandMacros (null, build);
}
/**
* sets the visibility of a menu item.
*
* @param anItemName name of an item
* @param visible boolean value
*/
static public void setItemVisibility (String anItemName, boolean visible)
{
IdeCommandItem item = XPTest.getItem (anItemName);
if (item == null)
return;
item.setVisible (true);
item.setEnabled (visible);
}
/**
* gets the currently active diagram.
*
* @param anEvent the current event generated by the user's mouse
* click on the menu item
*
* @return an instance of IdeDiagram or null
*/
static public IdeDiagram getActiveDiagram (IdeCommandEvent anEvent)
{
return anEvent.getElementContext ().getDiagram ();
}
/**
* gets the first selected element of a diagram.
*
* @param aDiagram the currently selected diagram
*
* @return an instance of RwiElement if an element is
* currently selected or null.
*/
static public RwiElement getSelectedElement (IdeDiagram aDiagram)
{
if (aDiagram != null)
{
IdeDiagramElementEnumeration selectedElems = null;
selectedElems = aDiagram.selectedElements ();
if ((selectedElems != null) && (selectedElems.hasMoreElements ()))
return selectedElems.nextIdeDiagramElement ().getRwiElement ();
}
return null;
}
/**
* finds a class using it's string name in a given package
*
* @name aPkg an instance of RwiPackage
* @name aName a string name of a searched class
*
* @return an instance of RwiElement if a class is found or
* null
*/
static public RwiElement findClassInPkg (RwiPackage aPkg,
String aName)
{
RwiDiagram diagram = aPkg.getPhysicalDiagram ();
RwiReferenceEnumeration refs;
RwiElement elem;
if (diagram == null)
return null;
refs = diagram.references ();
while (refs.hasMoreElements ())
{
if ((elem = refs.nextRwiReference ().getElement ()) == null)
return null;
if (elem.getProperty (RwiProperty.NAME).equals (aName))
return elem;
}
return null;
}
/**
* finds a class using it's string name in a given package.
*
* @name anElement an instance of RwiElement
* @name aName a string name of a searched class
*
* @return an instance of RwiElement if a class is found or
* null
*/
static public RwiElement findClassInPkg (RwiElement anElement,
String aName)
{
RwiModel model = RwiModelAccess.getModel ();
RwiPackage pkg = model.findDiagramFor (anElement).getDesignPackage ();
if (pkg == null)
return null;
return XPTestIDEHelper.findClassInPkg (pkg, aName);
}
/**
* gets the currently selected package.
*
* @return an instance of RwiPackage if a package is
* currently selected or null.
*/
static public RwiPackage getSelectedPackage ()
{
IdeDiagramManager manager = IdeDiagramManagerAccess.getDiagramManager ();
IdeDiagram diagram = manager.getActiveDiagram ();
if (diagram != null)
return diagram.getRwiDiagram ().getDesignPackage ();
return null;
}
/**
* gets the selected package's name
*
* @return an instance of RwiPackage if a package is currently
* selected or null.
*/
static public String getSelectedPackageName ()
{
IdeDiagramManager manager = IdeDiagramManagerAccess.getDiagramManager ();
IdeDiagram diagram = manager.getActiveDiagram ();
RwiPackage pkg = diagram.getRwiDiagram ().getDesignPackage ();
return pkg.getContainingPackage ().getProperty (RwiProperty.FULL_NAME);
}
/**
* checks if a class/interface extends a given class/interface.
*
* @param aClass an instance of RwiElement
* @param aName extended class/interface name
*
* @return true if aClass extends aName
*/
static public boolean doesExtend (RwiElement aClass, String aName)
{
String ext = aClass.getProperty (RwiProperty.EXTENDS);
if (ext != null)
if (ext.indexOf (aName) >= 0)
return true;
return false;
}
/**
* checks if a class has a method with the given name.
*
* @param aClass an instance of RwiElement
* @param aMethod name of a method
*
* @return true, if the method could be found
*/
static public boolean hasMethod (RwiElement aClass, String aMethod)
{
SciModel model = SciModelAccess.getModel ();
SciElement elem = model.findElement (aClass.getUniqueName ());
SciOperationEnumeration ops;
SciOperation op;
if (!(elem instanceof SciClass))
return false;
ops = ((SciClass)elem).operations ();
while (ops.hasMoreElements ())
{
op = ops.nextSciOperation ();
if (op.getName ().equals (aMethod))
return true;
}
return false;
}
/**
* check is a given class is compiled.
*
* @param aClassQName qualified class name
*
* @return true, if it is
*
*/
static public boolean isClassCompiled (String aClassQName)
{
if (aClassQName == null)
return false;
String fullpath =
IdeAccess.getIdeManager ().expandMacros (null, "$:destination$") + File.separator +
aClassQName.replace ('.', File.separatorChar) + ".class";
File file = new File (fullpath);
return file.exists ();
}
static public void updateProjectClasspath(IdeProject project)
{
if (project == null)
return;
String junit = IdeAccess.getIdeManager().expandMacros(null, XPTestProperties.get(IXPTestProperties.JUNIT_JAR));
String junitx = IdeAccess.getIdeManager().expandMacros(null, XPTestProperties.get(IXPTestProperties.JUNITX_JAR));
project.addImportPath(junit);
project.addImportPath(junitx);
}
}
PK
g-+yŒá¦` ` 1 com/togethersoft/modules/xp/XPTestJavaHelper.java/**
* Title: XPTestJavaHelper
* Description: elper methods for XPTest concerning Java code
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: XPTestJavaHelper.java,v 1.8 2001/09/13 10:56:50 tpinos Exp $
*
* Revision 1.3 2001/06/22 12:09:27 tpinos
* bugfixing (doesn't crash on creating test cases for classes with constructor, ...)
*
* Revision 1.2 2001/06/19 11:09:21 tpinos
* XPTest modified to produce a "new-style" code
* debug reports deleted (System.out.println...),
* bugfixing (XPTest now generates correct extend statement even when the required libraries are not in the classpath)
*
* Revision 1.1.1.1 2001/06/08 05:35:25 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.5 2001/06/01 07:46:37 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.5 2001/05/21 19:57:39 aheilwag
* fixed syntax errors.
*
* Revision 1.4 2001/05/21 19:22:07 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.3 2001/05/19 19:56:35 aheilwag
* added support for generating assertEquals statements as well as support for
* adding tags. This patch has been submitted by TogetherSoft.
*
* Revision 1.2 2000/11/18 20:19:45 aheilwag
* added hasTag().
* added doesExtend().
*
* Revision 1.1 2000/11/17 18:00:00 aheilwag
* moved and renamed from XPUtil in the pattern package.
*
*/
package com.togethersoft.modules.xp;
import java.util.*;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.message.*;
import com.togethersoft.openapi.sci.*;
import com.togethersoft.openapi.sci.enum.*;
import com.togethersoft.openapi.sci.pattern.*;
import com.togethersoft.openapi.util.propertyMap.*;
/**
* This class contains helper methods for XPTest concerning Java code.
*/
public class XPTestJavaHelper
{
/**
* @return true, if the operating system is Windows
*/
static boolean isWin ()
{
return System.getProperty ("os.name").toUpperCase ().indexOf ("WIN") >= 0;
}
/**
* creates an "assertEquals" statement for SciOperation of SciClass
* @param aTestedClass a reference to an SciClass
* @param aMethod a reference to an SciOperation
* @param isPublic must be true if method has PUBLIC access modifier
*
* @return text for "assertEquals" statement
*/
static public String getAssertForMethod (SciClass aTestedClass, SciOperation aMethod, boolean isPublic)
{
String primitiveTypes = "int,char,long,byte,float,double,short,boolean";
//+ sciRetType could have been null (in case of constructors) ...... crash
SciType sciRetType = aMethod.getReturnType ();
String retType = (sciRetType == null) ? null : sciRetType.getText ().trim ();
//-
if (retType == null)
{
// IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR, "Operation " + aMethod.getQualifiedName () + " is null.");
return new String ("//assertEquals (expected, actual); // return type is null\n");
}
if (retType.equals ("void"))
{
// IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR, "Operation " + aMethod.getQualifiedName () + " is void.");
return new String("//assertEquals (expected, actual); // return type is void\n");
}
if (primitiveTypes.indexOf (retType) >= 0)
return getAssertForMethodPrimitiveRetType (aTestedClass, aMethod, isPublic, retType);
else
return getAssertForMethodNonPrimRetType (aTestedClass, aMethod, isPublic, retType);
}
/**
* creates an "assertEquals" statement for SciOperation of SciClass
* if the method has a primitive return type.
*
* @param aTestedClass a reference to an SciClass
* @param aMethod a reference to an SciOperation
* @param isPublic must be true if method has PUBLIC access modifier
* @param aRetType a return type
*
* @return text for "assertEquals" statement
*/
static protected String getAssertForMethodPrimitiveRetType (SciClass aTestedClass, SciOperation aMethod,
boolean isPublic, String aRetType)
{
StringBuffer buf = new StringBuffer ();
buf.append ("assertEquals (/* change expected result here */ as");
buf.append (aRetType.substring (0, 1).toUpperCase () + aRetType.substring (1));
buf.append ("(new ");
if (aRetType.equals ("char"))
buf.append ("Character('1')), ");
else
if (aRetType.equals ("byte"))
buf.append ("Byte((byte)1)), ");
else
if (aRetType.equals ("boolean"))
buf.append ("Boolean(true)), ");
else
{
if (aRetType.equals ("int"))
buf.append ("Integer");
else
buf.append (aRetType.substring(0, 1).toUpperCase () + aRetType.substring (1));
buf.append ("(1)), ");
}
if (!isPublic)
{
buf.append ("as");
buf.append (aRetType.substring (0, 1).toUpperCase () + aRetType.substring (1));
buf.append ("(invoke (obj, \"");
}
else
buf.append ("(new " + aTestedClass.getQualifiedName () + " ()).");
buf.append (aMethod.getName ());
if (!isPublic)
buf.append ("\", null))");
else
buf.append ("()");
if (aRetType.equals ("float") || aRetType.equals ("Float")
|| aRetType.equals ("double") || aRetType.equals ("Double"))
buf.append (", 0.1 /* change delta here */");
buf.append (");\n");
return buf.toString ();
}
/**
* creates an "assertEquals" statement for SciOperation of SciClass
* if the method has not a primitive return type.
*
* @param aTestedClass a reference to an SciClass
* @param aMethod a reference to an SciOperation
* @param isPublic must be true if method has PUBLIC access modifier
* @param aRetType a return type
*
* @return text for "assertEquals" statement
*/
static protected String getAssertForMethodNonPrimRetType (SciClass aTestedClass, SciOperation aMethod,
boolean isPublic, String aRetType)
{
StringBuffer buf = new StringBuffer ();
buf.append ("assertEquals(/* change expected result here */ ");
buf.append ("new " + aRetType + " (), ");
if (!isPublic)
buf.append ("invoke (obj, \"");
else
buf.append ("(new " + aTestedClass.getQualifiedName () + " ()).");
buf.append (aMethod.getName ());
if (!isPublic)
buf.append ("\", null)");
else
buf.append (" ()");
buf.append (");\n");
return buf.toString ();
}
/**
* checks if a class has a constructor.
*
* @param aClass a reference to an SciClass
*
* @return true if there is already a constructor
*/
static public boolean hasConstructor (SciClass aClass)
{
SciOperationEnumeration ops = aClass.operations ();
if (ops == null)
return false;
SciOperation op;
while (ops.hasMoreElements ())
{
op = ops.nextSciOperation ();
if (op.hasProperty (SciProperty.CONSTRUCTOR))
return true;
}
return false;
}
/**
* checks if a class has a certain method.
*
* @param aClass a reference to an SciClass
* @param aMethod a method name
*
* @return true if there is already a certain method
*/
static public boolean hasMethod (SciClass aClass, String aMethod)
{
SciOperationEnumeration ops = aClass.operations ();
if (ops == null)
return false;
SciOperation op;
while (ops.hasMoreElements ())
{
op = ops.nextSciOperation ();
if (op.getName ().equals (aMethod))
return true;
}
return false;
}
/**
* creates a class tag.
*
* @param aFactory an instance of SciFactory
* @param aClass an instance of SciClass
* @param aTag a String tag name
* @param aValue a String tag value
*/
static public void createTag (SciFactory aFactory, SciClass aClass,
String aTag, String aValue)
{
SciTagList tagList = aClass.getTagList ();
if (tagList == null)
return;
SciTag tag = aFactory.newTag ();
if (aTag != null)
tag.setName (aTag);
if (aValue != null)
tag.setValue (aValue);
tagList.paste (tag, null, false);
}
/**
* checks if a SciElement has a certain tag with a given value.
*
* @param anElement an instance of SciElement
* @param aTagName a tag name
* @param aTagValue a tag value
*
* @return true, if the element has the tag with the value
*/
static public boolean hasTag (SciElement anElement, String aTagName,
String aTagValue)
{
SciTagList tagList = anElement.getTagList ();
if (tagList == null)
return false;
SciTag tag = tagList.getTag (aTagName);
if (tag == null)
return false;
String value = tag.getValue();
return (value != null) && value.equals (aTagValue);
}
/**
* creates an import statement.
*
* @param aFactory an instance of SciFactory
* @param aClass an instance of SciClass
* @param aPkg a String package name
*/
static public void createImport (SciFactory aFactory, SciClass aClass,
String aPkg)
{
SciJavaImportList impList = aClass.getContainingFile ().getJavaImportList ();
SciJavaImport imp = aFactory.newJavaImport ();
imp.setImportText (aPkg);
impList.paste (imp, null, true);
}
/**
* creates extends statement.
*
* @param aFactory an instance of SciFactory
* @param aClass an instance of SciClass
* @param anInheritedClass reference to the inherited class
*/
static public void createExtends (SciFactory aFactory, SciClass aClass,
SciClass anInheritedClass)
{
if (anInheritedClass != null)
{
SciInheritanceList extList = aClass.getExtendsList ();
SciInheritance ext = aFactory.newInheritance ();
ext.setReferencedElement (anInheritedClass);
extList.paste (ext, null, false);
}
}
/**
* creates extends statement.
*
* @param aClass an instance of SciClass
* @param anInheritedClass full qualified class name
*/
static public void createExtends (SciClass aClass, String anInheritedClassName)
{
SciInheritanceList extList = aClass.getExtendsList ();
extList.setText(anInheritedClassName);
}
/**
* checks if a class extends another class.
*
* @param aClassName a class which might be extend another class
* @param anExtClassName a class extended by the first parameter
*
* @return true, if the first class extends the second class
*/
static public boolean doesExtend (String aClassName, String anExtClassName)
{
SciModel model = SciModelAccess.getModel ();
SciClass extendingClass = model.findClass (SciLanguage.JAVA, aClassName);
SciClass extendedClass = model.findClass (SciLanguage.JAVA, anExtClassName);
SciInheritance inheritance;
SciInheritanceEnumeration extEnum;
if ((extendingClass == null) || (extendedClass == null))
return false;
if ((extEnum = extendingClass.getExtendsList ().inheritances ()) == null)
return false;
for ( ; extEnum.hasMoreElements ();)
{
if ((inheritance = extEnum.nextSciInheritance ()) == null)
continue;
if (inheritance.getName ().equals (anExtClassName))
return true;
}
return false;
}
/**
* creates an implements statement.
*
* @param aFactory an instance of SciFactory
* @param aClass an instance of SciClass
* @param anImplClass reference to the inherited class
*/
static public void createImplements (SciFactory aFactory, SciClass aClass,
SciClass anImplClass)
{
if (anImplClass != null)
{
SciInheritanceList implList = aClass.getImplementsList ();
SciInheritance impl = aFactory.newInheritance ();
impl.setReferencedElement (anImplClass);
if (anImplClass.getName().equals(aClass.getName()))
impl.setReferenceText (anImplClass.getQualifiedName ());
implList.paste (impl, null, false);
}
}
/**
* returns the name of the package in the active diagram.
*
* @param aContainer an instance of SciContainer
*
* @return a String or null
*/
static public String getCurrentPackage (SciContainer aContainer)
{
return (aContainer != null) ? ((SciPackage)aContainer).getQualifiedName ()
: "this package";
}
/**
* creates a class member.
*
* @param aSource a piece of source
* @param aClass a reference to an SciClass
* @param aMessage an error message if the source is unusable
* @param aTagValue a value of SciTag of test method
* with "previousTest" name
* @param prevTags a reference to an Vector of values
* of SciTag of test method with "previousTest" name
*/
static public void createMember (String aSource, SciClass aClass,
String aMessage, String aTagValue, Vector prevTags)
{
SciMember member = null;
try
{
member = SciModelAccess.getModel ().getGenericFactory (SciLanguage.JAVA).newMember (
aSource, aClass);
if (prevTags != null)
{
Enumeration tags = prevTags.elements ();
for (; tags.hasMoreElements (); )
{
String prvTagValue = (String)tags.nextElement ();
if ((prvTagValue != null) && (prvTagValue.length() > 0))
addTag (member, "previousTest", prvTagValue);
}
}
if ((aTagValue != null) && (aTagValue.length() > 0))
addTag (member, "previousTest", aTagValue);
}
catch (SciGenericFactoryException e)
{
IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR,
aMessage);
return;
}
aClass.paste (member, null, false);
}
/**
* adds tag (JavaDoc comment) to SciElement.
*
* @param anElement reference to an SciElement
* @param aTagName name of tag
* @param aTagValue value of tag
*/
static public void addTag (SciElement anElement, String aTagName, String aTagValue)
{
SciTagList tagList;
SciTag tag;
if (anElement == null)
{
// IdeAccess.getMessageManager ().getActivePage ().printMessage (IdeMessageType.ERROR, "AddTag: SciElement == null for element " + anElement.getName ());
return;
}
if (aTagName == null)
{
// IdeAccess.getMessageManager ().getActivePage ().printMessage (IdeMessageType.ERROR, "AddTag: tagName == null for element " + anElement.getName ());
return;
}
if (aTagValue == null)
{
// IdeAccess.getMessageManager ().getActivePage ().printMessage (IdeMessageType.ERROR, "AddTag: tagValue == null for element " + anElement.getName ());
return;
}
if ((tagList = anElement.getTagList ()) == null)
{
// IdeAccess.getMessageManager ().getActivePage ().printMessage (IdeMessageType.ERROR, "AddTag: tagList == null for element " + anElement.getName ());
return;
}
if (tagList.canSetTagValue (aTagValue) == false)
{
// IdeAccess.getMessageManager ().getActivePage ().printMessage (IdeMessageType.ERROR, "Unable to set tag value " + aTagValue + " to " + anElement.getName ());
return;
}
tag = SciModelAccess.getModel ().getFactory (SciLanguage.JAVA).newTag ();
tag.setName (aTagName);
tag.setValue (aTagValue);
tagList.paste (tag, null, false);
}
static public SciPackage createTestPackage (String aTestLocationProperty, String aTestPackageProperty, SciClass aTestedClass)
{
if ((aTestedClass == null) || (aTestLocationProperty == null) || (aTestPackageProperty == null))
return null;
SciModel model = SciModelAccess.getModel();
SciPackage testPackage = null;
if ("Parallel hierarchy".equals(aTestLocationProperty)) {
testPackage = model.findPackage(aTestPackageProperty + "." + aTestedClass.getContainingPackage().getQualifiedName(), SciModelPart.MODEL);
if (testPackage == null) {
SciPackageEnumeration rootPackages = model.rootPackages(SciModelPart.MODEL);
// we're trying to find the default root package (it doesn't have to exist when Package Prefix is set)
while (rootPackages.hasMoreElements()) {
SciPackage rootPackage = rootPackages.nextSciPackage();
if ("".equals(rootPackage.getQualifiedName())) {
// now we have found it
testPackage = createPackageStructure(aTestPackageProperty + "." + aTestedClass.getContainingPackage().getQualifiedName(), rootPackage);
return testPackage;
}
}
}
}
else
if ("Subpackage".equals(aTestLocationProperty)) {
testPackage = model.findPackage(aTestedClass.getContainingPackage().getQualifiedName() + "." + aTestPackageProperty, SciModelPart.MODEL);
if (testPackage == null) {
testPackage = model.getFactory(SciLanguage.JAVA).newPackage();
testPackage.setName(aTestPackageProperty);
testPackage = (SciPackage) aTestedClass.getContainingPackage().paste(testPackage, null, false);
}
}
else {
testPackage = aTestedClass.getContainingPackage();
}
return testPackage;
}
static public SciPackage createPackage(String aPackageName) {
if (aPackageName == null)
return null;
SciModel model = SciModelAccess.getModel();
SciPackage resultPackage = null;
SciPackageEnumeration rootPackages = model.rootPackages(SciModelPart.MODEL);
// we're trying to find the default root package (it doesn't have to exist when Package Prefix is set)
while (rootPackages.hasMoreElements()) {
SciPackage rootPackage = rootPackages.nextSciPackage();
if ("".equals(rootPackage.getQualifiedName())) {
// now we have found it
resultPackage = createPackageStructure(aPackageName, rootPackage);
break;
}
}
return resultPackage;
}
/**
* creates a package structure if it does not exist..
*
* @param aPkgName a package name
* @param aRootPackage
*/
static public SciPackage createPackageStructure (String aPkgName, SciPackage aRootPackage)
{
if ((aPkgName == null) || (aRootPackage == null))
return null;
SciModel model = SciModelAccess.getModel ();
SciPackage resultPackage = null;
resultPackage = model.findPackage(aRootPackage.getQualifiedName() + "." + aPkgName, SciModelPart.MODEL);
if (resultPackage != null)
return resultPackage;
StringTokenizer pkg = new StringTokenizer (aPkgName, ".");
String newPkgName = null;
String newPkgFQPN = aRootPackage.getQualifiedName();
SciPackage curPkg = aRootPackage;
SciPackage newPkg = null;
while (pkg.hasMoreTokens ())
{
if (newPkgFQPN.length () > 0)
newPkgFQPN += ".";
newPkgName = pkg.nextToken ();
newPkgFQPN += newPkgName;
// does the required subpackage exist?
if (model.findPackage (newPkgFQPN) != null)
{
curPkg = model.findPackage (newPkgFQPN);
continue;
}
// create new subpackage
newPkg = model.getFactory (SciLanguage.JAVA).newPackage ();
if (newPkg.canSetName (newPkgName))
newPkg.setName (newPkgName);
else
{
IdeMessageManagerAccess.printMessage (IdeMessageType.ERROR, "Cannot create package " + newPkgName);
return null;
}
curPkg = (SciPackage) curPkg.paste (newPkg, null, false);
//curPkg = model.findPackage (newPkgFQPN);
}
return curPkg;
}
/**
* converts the package name to something useful.
*
* @param aPkgName a package name
*
* @return cleaned package name
*/
static public String getJavaPackageName (String aPkgName)
{
int pos;
if (aPkgName == null)
return "";
if (aPkgName.length () == 0)
return "";
if (aPkgName.equals ("XPTest class
* (XPTest.getInstance().getListenerRegistry()).
*/
public class XPTestListenerRegistry
{
private Vector _listeners = new Vector ();
/**
* adds a listener.
*
* @param aListener an event listener
*/
public void addListener (IXPTestListener aListener)
{
_listeners.add (aListener);
}
/**
* removes a listener.
*
* @param aListener an event listener
*/
public void removeListener (IXPTestListener aListener)
{
_listeners.remove (aListener);
}
/**
* notifies listeners about event of a specified type
*
* @param aType an event type
* @param anEvent an event
*/
public void notifyListeners (XPTestEventType aType, IXPTestEvent anEvent)
{
Enumeration enum = _listeners.elements ();
while (enum.hasMoreElements ())
{
IXPTestListener listener = (IXPTestListener)enum.nextElement ();
if (aType == XPTestEventType.TEST_CREATION)
listener.testCreated (anEvent);
}
}
/**
* notifies listeners about the event
*
* @param anEvent an XPTest event
*/
static public void fireEvent (IXPTestEvent anEvent)
{
if (XPTest.getInstance () != null)
XPTest.getInstance ().getListenerRegistry ().notifyListeners (
anEvent.getType (), anEvent);
}
}
PK
g-+ÛAªðì* ì* 1 com/togethersoft/modules/xp/XPTestProperties.java/**
* Title: XPTestProperties
* Description: The XPTest configuration class.
* Copyright: Copyright (c) 2000 Andreas Heilwagen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Andreas Heilwagen
*
* $Id: XPTestProperties.java,v 1.14 2001/09/13 10:56:50 tpinos Exp $
*
* $Log: XPTestProperties.java,v $
* Revision 1.14 2001/09/13 10:56:50 tpinos
* bugfixing (invokation from choose pattern dialog)
*
* Revision 1.13 2001/09/08 10:34:46 aheilwag
* reintroduced Unix support: use java instead of javaw
*
* Revision 1.12 2001/08/24 06:34:27 tpinos
* bugfixing - properties must be initialized before junitXXX jars will be add to the project
*
* Revision 1.11 2001/07/26 10:43:03 tpinos
* bugfixing
*
* Revision 1.10 2001/07/24 11:07:20 tpinos
* XPTest enabled only for Java language;
* XPTest old-style config dialog dropped;
* bugfixing
*
* Revision 1.9 2001/07/20 12:28:22 aheilwag
* reviewed code
*
* Revision 1.8 2001/07/19 08:39:09 tpinos
* new option for "not implemented" assertions;
* bugfixing
*
* Revision 1.7 2001/07/19 04:04:26 tpinos
* testcase and testedclass tags added to the modified sources;
* options for junit.jar and junitx.jar location created - these two jars will
* be add now to the project;
* test command invoked on tested class will try to find the test case
* (via the new tags)
*
* Revision 1.6 2001/07/18 08:49:17 tpinos
* two options added (junitx.jar and junit.jar location) - these two jars are imported to the project
*
* Revision 1.5 2001/07/17 07:24:10 tpinos
* page in the standard config dialog created (the old one kept); bigfixing;
*
* Revision 1.4 2001/07/11 10:29:45 tpinos
* name of the created test package now matches the user input;
* property for JUnitX jar dropped from config dialog (it's in the project CP);
* "Test" command works now (checks the selection, recognizes test packages)
*
* Revision 1.3 2001/07/10 08:08:04 tpinos
* produced code modified (de.extremejava.junitx -> junitx);
* option "Force JUnit Compatibility" introduced (and behaviour modified);
* bugfixing (NullPointerException-s, recreateTestMethod suppressed,
* automaticaly generated assertions suppressed, ...);
* refactoring (constans for commands (id, text) introduced)
*
* Revision 1.2 2001/06/21 11:11:16 tpinos
* new style-code modifications; bugfixing (run test action, ...);
* refactoring (not all constants are hardcoded now)
*
* Revision 1.1.1.1 2001/06/08 05:35:25 fisakov
* Exported from core modules repository (SPb)
*
* Revision 1.4 2001/06/01 07:46:37 tomas
* changes made by Andreas and Peet merged
*
* Revision 1.12 2001/05/21 19:57:39 aheilwag
* fixed syntax errors.
*
* Revision 1.11 2001/05/21 19:22:07 aheilwag
* moved from GPL to LGPL for TogetherSoft.
*
* Revision 1.10 2001/05/19 19:57:10 aheilwag
* removed ClassPath support for a separate path and added support for
* default stdout and stderr files as implemented by TogetherSoft.
*
* Revision 1.9 2001/05/19 14:52:30 aheilwag
* included build destination patch.
*
* Revision 1.8 2000/11/30 18:28:43 aheilwag
* fixed a bug which generated the wrong oistart.exe on Windows.
*
* Revision 1.7 2000/11/28 22:56:49 aheilwag
* added support for configuring and catching stdout/stderr of JUnitX on Win32.
*
* Revision 1.6 2000/11/26 11:17:38 aheilwag
* changed default configuration name to XPTools.properties.
*
* Revision 1.5 2000/11/26 11:12:15 aheilwag
* moved from XPTestUtils fo XPTestIDEHelper and XPTestJavaHelper.
*
* Revision 1.4 2000/11/18 21:31:04 aheilwag
* fixed javadoc concerning non-thrown IOExceptions.
*
* Revision 1.3 2000/11/17 18:06:38 aheilwag
* added load() and store() without parameters.
* refactored the source.
*
* Revision 1.2 2000/11/13 14:04:18 aheilwag
* fixed some typos in the property names.
* changed the way the default property values are assigned.
*
* Revision 1.1 2000/11/13 12:50:54 aheilwag
* added class to repository.
*
*/
package com.togethersoft.modules.xp;
import java.io.*;
import java.util.*;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.config.*;
/**
* This class holds the global parameter for the XPTest for Together patterns
* and module.
*/
public class XPTestProperties implements IXPTestProperties
{
static private Hashtable _defaultProperties = new Properties();
/**
* hides the constructor.
*/
protected XPTestProperties ()
{
}
static public void initializeProperties ()
{
initializeDefaultProperties ();
IdeConfig defaultConfig = IdeConfigManagerAccess.getConfigManager ().getConfig (IdeConfigLevel.DEFAULT);
Enumeration propertyNames = _defaultProperties.keys();
while (propertyNames.hasMoreElements()) {
String propertyName = (String)propertyNames.nextElement();
if (defaultConfig.getProperty(IXPTestProperties.MODULE + "." + propertyName, null) == null)
defaultConfig.putProperty(IXPTestProperties.MODULE + "." + propertyName, getDefaultValue(propertyName));
}
}
/**
* gets a property.
*
* @param aKey a property key
*
* @return an String or null
*/
static public String get (String aKey)
{
return IdeConfigManagerAccess.getConfigManager ().getConfig (IdeConfigLevel.PROJECT).getProperty (IXPTestProperties.MODULE + "." + aKey, getDefaultValue (aKey));
}
/**
* sets a property.
*
* @param aKey a property key
* @param aValue a property value
*/
static public void put (String aKey, String aValue)
{
IdeConfigManagerAccess.getConfigManager ().getConfig (IdeConfigLevel.PROJECT).putProperty (IXPTestProperties.MODULE + "." + aKey, aValue);
}
static private void initializeDefaultProperties ()
{
boolean isWin = (System.getProperty ("os.name").toUpperCase ().indexOf ("WIN") >= 0);
String stdout = "