0001: package salomeTMF_plug.clif.ui;
0002:
0003: import java.awt.BorderLayout;
0004: import java.awt.Dimension;
0005: import java.awt.FlowLayout;
0006: import java.awt.Frame;
0007: import java.awt.event.ActionEvent;
0008: import java.awt.event.ActionListener;
0009: import java.awt.event.MouseEvent;
0010: import java.awt.event.MouseListener;
0011: import java.awt.event.WindowEvent;
0012: import java.awt.event.WindowListener;
0013: import java.io.BufferedReader;
0014: import java.io.File;
0015: import java.io.FileInputStream;
0016: import java.io.FileNotFoundException;
0017: import java.io.IOException;
0018: import java.io.InputStreamReader;
0019: import java.net.MalformedURLException;
0020: import java.net.URL;
0021: import java.util.ArrayList;
0022: import java.util.HashMap;
0023: import java.util.Iterator;
0024: import java.util.Map;
0025: import java.util.Observable;
0026: import java.util.Observer;
0027: import java.util.Vector;
0028:
0029: import javax.swing.BorderFactory;
0030: import javax.swing.ImageIcon;
0031: import javax.swing.JButton;
0032: import javax.swing.JDialog;
0033: import javax.swing.JLabel;
0034: import javax.swing.JPanel;
0035: import javax.swing.JScrollPane;
0036: import javax.swing.JSplitPane;
0037: import javax.swing.JTable;
0038: import javax.swing.JTextArea;
0039: import javax.swing.JToggleButton;
0040: import javax.swing.border.TitledBorder;
0041: import javax.swing.table.DefaultTableModel;
0042: import javax.swing.JOptionPane;
0043:
0044: import org.objectweb.clif.console.lib.ClifDeployDefinition;
0045: import org.objectweb.clif.console.lib.TestPlanReader;
0046: import org.objectweb.clif.console.lib.batch.BatchUtil;
0047: import org.objectweb.clif.console.lib.gui.GuiMonitorPanel;
0048: import org.objectweb.clif.console.lib.gui.GuiPanelBladeState;
0049: import org.objectweb.clif.deploy.ClifAppFacade;
0050: import org.objectweb.clif.deploy.ClifRegistry;
0051: import org.objectweb.clif.deploy.DeployObservation;
0052: import org.objectweb.clif.storage.api.AlarmEvent;
0053: import org.objectweb.clif.supervisor.api.BladeState;
0054: import org.objectweb.clif.supervisor.lib.BladeObservation;
0055: import org.objectweb.clif.util.ExecutionContext;
0056: import org.objectweb.clif.util.ThrowableHelper;
0057: import org.objectweb.fractal.util.Fractal;
0058: import org.objectweb.salome_tmf.data.AutomaticTest;
0059: import org.objectweb.salome_tmf.data.Execution;
0060: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
0061: import org.objectweb.salome_tmf.ihm.main.plugins.PluginsTools;
0062:
0063: import salomeTMF_plug.clif.ClifAutomaticExecution;
0064: import salomeTMF_plug.clif.ClifPlugin;
0065:
0066: public class GuiTestControl extends JDialog implements Observer,
0067: ActionListener {
0068:
0069: private static final String CLIF_APPLICATION = "salomeTMF_plug.clif.ClifApp";
0070:
0071: private static final int TEST_SUCCESS = 0;
0072: private static final int TEST_FAILED = 1;
0073: private static final int TEST_INCONCLUSIF = 2;
0074:
0075: /*GUI*/
0076: private JSplitPane jspTop;
0077: private JSplitPane jspBottom;
0078: private JSplitPane jspMiddle;
0079:
0080: private GuiPanelBladeState jpTestPlanPanel;
0081: private JPanel jpManualAction;
0082: private JPanel jContentPane = null;
0083:
0084: private JButton jbInit;
0085: private JButton jbStart;
0086: private JButton jbStop;
0087: private JButton jbCollect;
0088: private JButton jbDeploy;
0089: private JButton jbRun;
0090: private JToggleButton jtbSuspendResume;
0091:
0092: private JTable jtAction;
0093: private DefaultTableModel actionModel;
0094:
0095: private JButton jbInconclusive;
0096: private JButton jbFailure;
0097: private JLabel jlTitleComment;
0098: private JScrollPane jspComment;
0099: private JTextArea jtaComment;
0100: private JButton jbOk;
0101:
0102: private Frame parent;
0103: /****/
0104:
0105: private ClifAppFacade clifApp = null;
0106: private ClifRegistry reg = null;
0107:
0108: private String testPlan = "";
0109: private GuiLaunchTest uiLaunchTest = null;
0110:
0111: private AutomaticTest autoTest;
0112:
0113: private BladeState globalState = BladeState.UNDEPLOYED;
0114:
0115: private Thread threadRun = null;
0116:
0117: private String testId = "";
0118: private String tmpLog = null;
0119: private String reportUrl = null;
0120:
0121: private String url_txt = null;
0122:
0123: private int executionResult = TEST_INCONCLUSIF;
0124:
0125: public GuiTestControl(Frame _parent, String _testPlan,
0126: AutomaticTest pTest) {
0127:
0128: super (_parent, true);
0129: this .testPlan = _testPlan;
0130: this .parent = _parent;
0131: this .autoTest = pTest;
0132:
0133: // Init url-txt
0134: String _urlSalome = SalomeTMFContext.getInstance().getUrlBase()
0135: .toString();
0136: url_txt = _urlSalome.substring(0, _urlSalome.lastIndexOf("/"));
0137:
0138: /* GuiLaunchTest */
0139: uiLaunchTest = new GuiLaunchTest(_parent);
0140: // if GuiLaunchTest window is not close by the cross
0141: if (!uiLaunchTest.isClose()) {
0142: String campName = PluginsTools.getCurrentCampaign()
0143: .getNameFromModel();
0144: Execution exec = PluginsTools.getCurrentCampExecution();
0145: testId = campName + "." + exec.getNameFromModel() + "_"
0146: + exec.getExecutionResultListFromModel().size()
0147: + ".";
0148:
0149: initialize();
0150:
0151: if (reg != null) {
0152: this .setAlwaysOnTop(true);
0153:
0154: this .pack();
0155:
0156: // if it's an automatic execution, it's launch imediately
0157: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.AUTOMATIC_TEST) {
0158: threadRun = new Thread(new ClifAutomaticExecution(
0159: this ));
0160: threadRun.start();
0161: }
0162:
0163: this .setVisible(true);
0164: }
0165: }
0166: }
0167:
0168: /**
0169: *
0170: */
0171: private void initialize() {
0172:
0173: switch (uiLaunchTest.getKindOfTest()) {
0174: case GuiLaunchTest.NO_TEST:
0175: initRegistry();
0176: initializeManual();
0177: this .setPreferredSize(new Dimension(700, 700));
0178:
0179: tmpLog = "NO_TEST\n";
0180: break;
0181: case GuiLaunchTest.MANUAL_TEST:
0182: initRegistry();
0183: initializeManual();
0184: this .setPreferredSize(new Dimension(700, 700));
0185:
0186: tmpLog = "MANUAL_TEST\n";
0187: break;
0188: case GuiLaunchTest.SEMIAUTOMATIC_TEST:
0189: initRegistry();
0190: initializeSemiautomatic();
0191: this .setPreferredSize(new Dimension(700, 700));
0192:
0193: tmpLog = "SEMIAUTOMATIC_TEST\n";
0194: break;
0195: case GuiLaunchTest.AUTOMATIC_TEST:
0196: findRegistry();
0197: initializeAutomatic();
0198: this .setPreferredSize(new Dimension(700, 500));
0199:
0200: tmpLog = "AUTOMATIC_TEST\n";
0201: break;
0202: default:
0203: break;
0204: }
0205:
0206: try {
0207: jpTestPlanPanel.setTestPlan(TestPlanReader
0208: .readFromProp(new FileInputStream(new File(
0209: this .testPlan))));
0210:
0211: // Update table actions
0212: updateActionTable();
0213: } catch (Exception ex) {
0214: tmpLog += "Error: Can't open test plan " + this .testPlan
0215: + "\n";
0216: String message = "Can't open test plan" + this .testPlan;
0217: System.out.println(message);
0218: }
0219:
0220: // set dialog title
0221: this .setTitle("CLIF is a Load Injector Framework");
0222:
0223: // window close listener
0224: this .addWindowListener(new WindowListener() {
0225: public void windowActivated(WindowEvent e) {
0226: }
0227:
0228: public void windowClosed(WindowEvent e) {
0229: }
0230:
0231: public void windowClosing(WindowEvent e) {
0232: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST
0233: || uiLaunchTest.getKindOfTest() == GuiLaunchTest.AUTOMATIC_TEST) {
0234: threadRun.stop();
0235: }
0236: executionResult = GuiTestControl.TEST_INCONCLUSIF;
0237: tmpLog = tmpLog + "=> TEST_INCONCLUSIF : \n";
0238: }
0239:
0240: public void windowDeactivated(WindowEvent e) {
0241: }
0242:
0243: public void windowDeiconified(WindowEvent e) {
0244: }
0245:
0246: public void windowIconified(WindowEvent e) {
0247: }
0248:
0249: public void windowOpened(WindowEvent e) {
0250: }
0251: });
0252: }
0253:
0254: /**
0255: *
0256: */
0257: private void initRegistry() {
0258: /*if (System.getSecurityManager() == null)
0259: {
0260: System.setSecurityManager(new SecurityManager());
0261: }*/
0262: if (reg == null) {
0263: try {
0264: initSystemProperties();
0265: ExecutionContext.init("./");
0266: reg = new ClifRegistry();
0267: } catch (Error e) {
0268: reg = new ClifRegistry(false);
0269: }
0270:
0271: }
0272: }
0273:
0274: /**
0275: *
0276: */
0277: private void findRegistry() {
0278: try {
0279: initSystemProperties();
0280: ExecutionContext.init("./");
0281: reg = new ClifRegistry(false);
0282:
0283: } catch (Error e) {
0284: tmpLog += "Error: can't find a registry\n";
0285: //tmpLog = tmpLog + "/!\\ A registry is needed to launch an automatic test\n";
0286: System.err
0287: .println("[CLIF:Registry] Error: can't find a registry. Please check if registry is launch.");
0288: }
0289: }
0290:
0291: private void initSystemProperties() {
0292:
0293: BufferedReader br = null;
0294: try {
0295: //flux de lecture en UTF-8
0296: URL url = new URL(url_txt
0297: + "/plugins/clif/resources/clif.props");
0298: br = new BufferedReader(new InputStreamReader(url
0299: .openStream()));
0300:
0301: //flux d'écriture en ISO (valeur par défaut)
0302: String line;
0303: String[] splitLine;
0304: while ((line = br.readLine()) != null) {
0305: splitLine = line.split(" ", 2);
0306: System.setProperty(splitLine[0], splitLine[1]);
0307: }
0308: } catch (Exception ex) {
0309: ex.getMessage();
0310: ex.printStackTrace();
0311: tmpLog += "Error: can't load system properties\n";
0312: System.out.println("Error: can't load system properties");
0313: }
0314: }
0315:
0316: /**
0317: * Do actions when Finish button push.
0318: */
0319: private void finishButtonAction() {
0320: // Text area comment
0321: String comment = jtaComment.getText();
0322: if (!comment.trim().equals("")) {
0323: switch (this .executionResult) {
0324: case GuiTestControl.TEST_SUCCESS:
0325: tmpLog = tmpLog + "=> TEST_SUCCESS : \n";
0326: break;
0327: case GuiTestControl.TEST_INCONCLUSIF:
0328: tmpLog = tmpLog + "=> TEST_INCONCLUSIF : \n";
0329: break;
0330: case GuiTestControl.TEST_FAILED:
0331: tmpLog = tmpLog + "=> TEST_FAILED : \n";
0332: break;
0333: default:
0334: }
0335:
0336: tmpLog = tmpLog + comment;
0337: }
0338:
0339: this .dispose();
0340: }
0341:
0342: /**
0343: * Do actions when Inconclusive button push.
0344: */
0345: private void inconclusiveButtonAction() {
0346: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST
0347: || uiLaunchTest.getKindOfTest() == GuiLaunchTest.AUTOMATIC_TEST) {
0348: threadRun.stop();
0349: }
0350:
0351: this .executionResult = GuiTestControl.TEST_INCONCLUSIF;
0352:
0353: jspMiddle.setVisible(false);
0354: jbInconclusive.setVisible(false);
0355: jbFailure.setVisible(false);
0356:
0357: jlTitleComment.setVisible(true);
0358: jspComment.setVisible(true);
0359: jbOk.setVisible(true);
0360:
0361: this .setPreferredSize(new Dimension(250, 256));
0362: this .pack();
0363:
0364: }
0365:
0366: /**
0367: * Do actions when Fail button push.
0368: */
0369: private void failButtonAction() {
0370: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST
0371: || uiLaunchTest.getKindOfTest() == GuiLaunchTest.AUTOMATIC_TEST) {
0372: threadRun.stop();
0373: }
0374:
0375: this .executionResult = GuiTestControl.TEST_FAILED;
0376:
0377: jspMiddle.setVisible(false);
0378: jbInconclusive.setVisible(false);
0379: jbFailure.setVisible(false);
0380:
0381: jlTitleComment.setVisible(true);
0382: jspComment.setVisible(true);
0383: jbOk.setVisible(true);
0384:
0385: this .setPreferredSize(new Dimension(250, 256));
0386: this .pack();
0387: }
0388:
0389: /**
0390: *
0391: * @return a String with the log.
0392: */
0393: public String getTestLog() {
0394: return tmpLog;
0395: }
0396:
0397: /**
0398: *
0399: * @return a String with collect data folder url
0400: */
0401: public String getReportUrl() {
0402: return reportUrl;
0403: }
0404:
0405: /**
0406: * Launch an automatic execution
0407: */
0408: public void launchAutomaticExecution() {
0409: jbRunActionPerformed();
0410: }
0411:
0412: /**
0413: * Initialize GUI for automatic test control.
0414: */
0415: private void initializeAutomatic() {
0416: jspMiddle = new JSplitPane();
0417: jspMiddle.setOrientation(JSplitPane.VERTICAL_SPLIT);
0418:
0419: jspMiddle.setLeftComponent(getTestPlanPanel());
0420:
0421: jspMiddle.setRightComponent(getMonitoringPanel());
0422:
0423: jContentPane = new JPanel();
0424: jContentPane.setLayout(new BorderLayout());
0425: jContentPane.add(jspMiddle, BorderLayout.CENTER);
0426:
0427: this .setContentPane(jContentPane);
0428: }
0429:
0430: /**
0431: * Initialize GUI for semi-automatic test control.
0432: */
0433: private void initializeSemiautomatic() {
0434: jspTop = new JSplitPane();
0435: jspTop.setOrientation(JSplitPane.VERTICAL_SPLIT);
0436:
0437: jspTop.setLeftComponent(getManualActionsPanel());
0438:
0439: jspTop.setRightComponent(getTestPlanPanel());
0440:
0441: jspBottom = new JSplitPane();
0442: jspBottom.setOrientation(JSplitPane.VERTICAL_SPLIT);
0443:
0444: jspBottom.setLeftComponent(getRunButtonPanel());
0445:
0446: jspBottom.setRightComponent(getMonitoringPanel());
0447:
0448: jspMiddle = new JSplitPane();
0449: jspMiddle.setOrientation(JSplitPane.VERTICAL_SPLIT);
0450:
0451: jspMiddle.setLeftComponent(jspTop);
0452: jspMiddle.setRightComponent(jspBottom);
0453:
0454: jContentPane = new JPanel();
0455: jContentPane.setLayout(new BorderLayout());
0456: jContentPane.add(jspMiddle, BorderLayout.CENTER);
0457: jContentPane.add(getEchecInconclusivePanel(),
0458: BorderLayout.SOUTH);
0459:
0460: this .setContentPane(jContentPane);
0461: checkActionsStates();
0462: }
0463:
0464: /**
0465: * Initialize GUI for manual test control.
0466: */
0467: private void initializeManual() {
0468: jspTop = new JSplitPane();
0469: jspTop.setOrientation(JSplitPane.VERTICAL_SPLIT);
0470:
0471: jspTop.setLeftComponent(getManualActionsPanel());
0472:
0473: jspTop.setRightComponent(getTestPlanPanel());
0474:
0475: jspBottom = new JSplitPane();
0476: jspBottom.setOrientation(JSplitPane.VERTICAL_SPLIT);
0477:
0478: jspBottom.setLeftComponent(getActionsButtonsPanel());
0479:
0480: jspBottom.setRightComponent(getMonitoringPanel());
0481:
0482: jspMiddle = new JSplitPane();
0483: jspMiddle.setOrientation(JSplitPane.VERTICAL_SPLIT);
0484:
0485: jspMiddle.setLeftComponent(jspTop);
0486: jspMiddle.setRightComponent(jspBottom);
0487:
0488: jContentPane = new JPanel();
0489: jContentPane.setLayout(new BorderLayout());
0490: jContentPane.add(jspMiddle, BorderLayout.CENTER);
0491: jContentPane.add(getEchecInconclusivePanel(),
0492: BorderLayout.SOUTH);
0493:
0494: this .setContentPane(jContentPane);
0495: checkActionsStates();
0496: }
0497:
0498: private JPanel getEchecInconclusivePanel() {
0499: JPanel jpButtonsText = new JPanel();
0500: jpButtonsText.setLayout(new BorderLayout());
0501: JPanel jpComment = new JPanel();
0502: jpComment.setLayout(new BorderLayout());
0503: jpComment.setBorder(BorderFactory.createTitledBorder(null, "",
0504: TitledBorder.DEFAULT_JUSTIFICATION,
0505: TitledBorder.DEFAULT_POSITION, null, null));
0506:
0507: jspComment = new JScrollPane();
0508: jspComment.setPreferredSize(new Dimension(300, 150));
0509: jtaComment = new JTextArea();
0510: jspComment.setViewportView(jtaComment);
0511: jspComment.setVisible(false);
0512: jlTitleComment = new JLabel("Comments:");
0513: jlTitleComment.setVisible(false);
0514:
0515: jpComment.add(jlTitleComment, BorderLayout.NORTH);
0516: jpComment.add(jspComment, BorderLayout.CENTER);
0517:
0518: JPanel jpFinishButton = new JPanel();
0519: jpFinishButton.setLayout(new FlowLayout());
0520: jbOk = new JButton();
0521: jbOk.setText("Finish");
0522: jbOk.addActionListener(new ActionListener() {
0523: public void actionPerformed(ActionEvent e) {
0524: finishButtonAction();
0525: }
0526: });
0527: try {
0528: jbOk.setIcon(new ImageIcon(new URL(url_txt
0529: + "/plugins/clif/resources/stop.gif")));
0530: } catch (MalformedURLException e1) {
0531: e1.printStackTrace();
0532: }
0533: jbOk.setVisible(false);
0534: jpFinishButton.add(jbOk);
0535:
0536: jpButtonsText.add(jpComment, BorderLayout.CENTER);
0537: jpButtonsText.add(jpFinishButton, BorderLayout.SOUTH);
0538: jpButtonsText.add(getButtonsStateTestPanel(),
0539: BorderLayout.NORTH);
0540:
0541: return jpButtonsText;
0542: }
0543:
0544: private JPanel getButtonsStateTestPanel() {
0545: JPanel jpButtons = new JPanel();
0546: jpButtons.setLayout(new FlowLayout());
0547:
0548: jbInconclusive = new JButton();
0549: jbInconclusive.setText("Finish (Inconclusive)");
0550: try {
0551: jbInconclusive.setIcon(new ImageIcon(new URL(url_txt
0552: + "/plugins/clif/resources/inconclusive.gif")));
0553: } catch (MalformedURLException e1) {
0554: e1.printStackTrace();
0555: }
0556: jbInconclusive.addActionListener(new ActionListener() {
0557: public void actionPerformed(ActionEvent e) {
0558: inconclusiveButtonAction();
0559: }
0560: });
0561:
0562: jbFailure = new JButton();
0563: jbFailure.setText("Finish (Failure)");
0564: try {
0565: jbFailure.setIcon(new ImageIcon(new URL(url_txt
0566: + "/plugins/clif/resources/fail.gif")));
0567: } catch (MalformedURLException e1) {
0568: e1.printStackTrace();
0569: }
0570: jbFailure.addActionListener(new ActionListener() {
0571: public void actionPerformed(ActionEvent e) {
0572: failButtonAction();
0573: }
0574: });
0575:
0576: jpButtons.add(jbInconclusive);
0577: jpButtons.add(jbFailure);
0578:
0579: return jpButtons;
0580: }
0581:
0582: /**
0583: * Get JPanel for a view of test plan.
0584: * @return Test plan panel
0585: */
0586: private JPanel getTestPlanPanel() {
0587: JPanel jpTitleTestPlan = new JPanel();
0588: jpTitleTestPlan.setLayout(new BorderLayout());
0589:
0590: JLabel jlTitleTestPlan = new JLabel();
0591: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.NO_TEST
0592: || uiLaunchTest.getKindOfTest() == GuiLaunchTest.MANUAL_TEST
0593: || uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST) {
0594: jlTitleTestPlan.setText("2. Check the test plan:");
0595: } else if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.AUTOMATIC_TEST) {
0596: jlTitleTestPlan.setText("1. Check the test plan:");
0597: }
0598:
0599: jpTitleTestPlan.add(jlTitleTestPlan, BorderLayout.NORTH);
0600:
0601: ArrayList<String> servers = new ArrayList<String>();
0602: try {
0603: Map tp = TestPlanReader.readFromProp(new FileInputStream(
0604: new File(this .testPlan)));
0605: Iterator iter = tp.entrySet().iterator();
0606: while (iter.hasNext()) {
0607: Map.Entry entry = (Map.Entry) iter.next();
0608: ClifDeployDefinition def = (ClifDeployDefinition) entry
0609: .getValue();
0610: servers.add(def.getServerName());
0611: }
0612: } catch (Exception e) {
0613:
0614: }
0615:
0616: jpTestPlanPanel = new GuiPanelBladeState(null);
0617: jpTestPlanPanel.setEditable(false);
0618: jpTestPlanPanel.setAvailableServers((String[]) servers
0619: .toArray(new String[0]));
0620: jpTestPlanPanel.setMinimumSize(new Dimension(0, 200));
0621: jpTestPlanPanel.setPreferredSize(new Dimension(0, 200));
0622: jpTitleTestPlan.add(jpTestPlanPanel, BorderLayout.CENTER);
0623:
0624: return jpTitleTestPlan;
0625: }
0626:
0627: /**
0628: * Get JPanel for manual actions.
0629: * @return manual actions panel
0630: */
0631: private JPanel getManualActionsPanel() {
0632: JPanel jpTitleActions = new JPanel();
0633: jpTitleActions.setLayout(new BorderLayout());
0634:
0635: JLabel jlTitleActionTable = new JLabel(
0636: "1. Do the action and put his state once do:");
0637: jpTitleActions.add(jlTitleActionTable, BorderLayout.NORTH);
0638:
0639: jtAction = new JTable();
0640: addJtActionModel();
0641: jtAction.addMouseListener(new MouseListener() {
0642: public void mouseClicked(MouseEvent e) {
0643: if (e.getClickCount() == 1) {
0644: checkActionsStates();
0645: }
0646: }
0647:
0648: public void mouseEntered(MouseEvent e) {
0649: }
0650:
0651: public void mouseExited(MouseEvent e) {
0652: }
0653:
0654: public void mousePressed(MouseEvent e) {
0655: }
0656:
0657: public void mouseReleased(MouseEvent e) {
0658: }
0659: });
0660:
0661: JScrollPane jspActionTable = new JScrollPane();
0662: jspActionTable.setViewportView(jtAction);
0663: jspActionTable.setPreferredSize(new Dimension(0, 100));
0664:
0665: jpTitleActions.add(jspActionTable, BorderLayout.CENTER);
0666:
0667: jpManualAction = new JPanel();
0668: jpManualAction.setLayout(new BorderLayout());
0669: jpManualAction.add(jpTitleActions, BorderLayout.CENTER);
0670:
0671: return jpManualAction;
0672: }
0673:
0674: /**
0675: * Get JPanel for all actions buttons.
0676: * @return actions buttons panel
0677: */
0678: private JPanel getActionsButtonsPanel() {
0679: jbCollect = new JButton("Collect");
0680: jbCollect.setEnabled(false);
0681: jbCollect.setActionCommand("Collect");
0682: jbCollect.addActionListener(this );
0683:
0684: jbDeploy = new JButton("Deploy");
0685: jbDeploy.setEnabled(false);
0686: jbDeploy.setActionCommand("Deploy");
0687: jbDeploy.addActionListener(this );
0688:
0689: jbInit = new JButton("Init");
0690: jbInit.setEnabled(false);
0691: jbInit.setActionCommand("Init");
0692: jbInit.addActionListener(this );
0693:
0694: jbStart = new JButton("Start");
0695: jbStart.setEnabled(false);
0696: jbStart.setActionCommand("Start");
0697: jbStart.addActionListener(this );
0698:
0699: jbStop = new JButton("Stop");
0700: jbStop.setEnabled(false);
0701: jbStop.setActionCommand("Stop");
0702: jbStop.addActionListener(this );
0703:
0704: jtbSuspendResume = new JToggleButton("Suspend");
0705: jtbSuspendResume.setEnabled(false);
0706: jtbSuspendResume.setActionCommand("Suspend");
0707: jtbSuspendResume.addActionListener(this );
0708:
0709: JPanel jpAction = new JPanel();
0710:
0711: JPanel jpTitleButtons = new JPanel();
0712: jpTitleButtons.setLayout(new BorderLayout());
0713:
0714: JLabel jlTitleButtons = new JLabel("3. Launch action:");
0715: jpTitleButtons.add(jlTitleButtons, BorderLayout.NORTH);
0716:
0717: jpAction.setLayout(new FlowLayout());
0718: jpAction.add(jbDeploy);
0719: jpAction.add(jbInit);
0720: jpAction.add(jbStart);
0721: jpAction.add(jtbSuspendResume);
0722: jpAction.add(jbStop);
0723: jpAction.add(jbCollect);
0724:
0725: jpTitleButtons.add(jpAction, BorderLayout.CENTER);
0726:
0727: return jpTitleButtons;
0728: }
0729:
0730: /**
0731: * Get JPanel for run button.
0732: * @return run button panel
0733: */
0734: private JPanel getRunButtonPanel() {
0735: jbRun = new JButton("Run");
0736: jbRun.setEnabled(false);
0737: jbRun.setActionCommand("Run");
0738: jbRun.addActionListener(this );
0739:
0740: JPanel jpAction = new JPanel();
0741:
0742: JPanel jpTitleButtons = new JPanel();
0743: jpTitleButtons.setLayout(new BorderLayout());
0744:
0745: JLabel jlTitleButtons = new JLabel("3. Launch run:");
0746: jpTitleButtons.add(jlTitleButtons, BorderLayout.NORTH);
0747:
0748: jpAction.setLayout(new FlowLayout());
0749: jpAction.add(jbRun);
0750:
0751: jpTitleButtons.add(jpAction, BorderLayout.CENTER);
0752:
0753: return jpTitleButtons;
0754: }
0755:
0756: /**
0757: * Get JPanel for the monitoring.
0758: * @return monitoring panel
0759: */
0760: private JPanel getMonitoringPanel() {
0761: JPanel jpTitleMonitoring = new JPanel();
0762: jpTitleMonitoring.setLayout(new BorderLayout());
0763:
0764: JLabel jlTitleMonitoring = new JLabel();
0765: jlTitleMonitoring.setText("Monitoring:");
0766:
0767: jpTitleMonitoring.add(jlTitleMonitoring, BorderLayout.NORTH);
0768:
0769: return jpTitleMonitoring;
0770: }
0771:
0772: private JPanel getMonitoringPanelAfterInit() {
0773:
0774: JPanel jpMonitoring = getMonitoringPanel();
0775:
0776: GuiMonitorPanel monitoring = new GuiMonitorPanel(
0777: jpTestPlanPanel.getTestPlan(), clifApp);
0778:
0779: jpMonitoring.add(monitoring, BorderLayout.CENTER);
0780:
0781: return jpMonitoring;
0782: }
0783:
0784: /**
0785: * Add a JTable Model to Actions JTable.
0786: */
0787: private void addJtActionModel() {
0788: jtAction.setModel(actionModel = new DefaultTableModel(
0789: new Object[][] {}, new String[] { "#", "Action(s)",
0790: "State" }) {
0791: Class[] types = new Class[] { java.lang.Integer.class,
0792: java.lang.String.class, java.lang.Boolean.class };
0793:
0794: boolean[] canEdit = new boolean[] { false, false, true };
0795:
0796: public Class getColumnClass(int columnIndex) {
0797: return types[columnIndex];
0798: }
0799:
0800: public boolean isCellEditable(int rowIndex, int columnIndex) {
0801: return canEdit[columnIndex];
0802: }
0803: });
0804:
0805: jtAction.getColumnModel().getColumn(0).setPreferredWidth(0);
0806: jtAction.getColumnModel().getColumn(1).setPreferredWidth(400);
0807: jtAction.getColumnModel().getColumn(2).setPreferredWidth(30);
0808: }
0809:
0810: /**
0811: * Update Actions JTable with server list without "local host" server.
0812: */
0813: private void updateActionTable() {
0814: Vector aRow = new Vector();
0815: Vector serverLst = new Vector();
0816: HashMap bladeLst = new HashMap();
0817: try {
0818: bladeLst = (HashMap) TestPlanReader
0819: .readFromProp(new FileInputStream(new File(
0820: this .testPlan)));
0821: } catch (IOException e) {
0822: e.printStackTrace();
0823: }
0824:
0825: Iterator it = bladeLst.entrySet().iterator();
0826: Map.Entry entry;
0827: String serverName;
0828: int num = 1;
0829:
0830: while (it.hasNext()) {
0831: entry = (Map.Entry) it.next();
0832: serverName = ((ClifDeployDefinition) entry.getValue())
0833: .getServerName();
0834: if (!serverName.equals(ExecutionContext.DEFAULT_SERVER)
0835: && !serverLst.contains("Launch a server named: "
0836: + serverName)) {
0837: aRow.add(num);
0838: aRow.add("Launch a server named: " + serverName);
0839: aRow.add(false);
0840:
0841: actionModel.addRow(aRow);
0842: serverLst.add("Launch a server named: " + serverName);
0843: aRow = new Vector();
0844: num++;
0845: }
0846: }
0847:
0848: if (actionModel.getRowCount() == 0
0849: && uiLaunchTest.getKindOfTest() == GuiLaunchTest.MANUAL_TEST) {
0850: jbDeploy.setEnabled(true);
0851: } else if (actionModel.getRowCount() == 0
0852: && uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST) {
0853: jbRun.setEnabled(true);
0854: }
0855: }
0856:
0857: /**
0858: * Check if all actions in the action table are true.
0859: * If it's true the action table set disable and deploy button set enable.
0860: */
0861: private void checkActionsStates() {
0862: if (jtAction.isEnabled()) {
0863: Vector data = actionModel.getDataVector();
0864: int i = 0;
0865:
0866: for (i = 0; i < data.size(); i++) {
0867: if (!((Boolean) ((Vector) data.elementAt(i))
0868: .elementAt(2)).booleanValue()) {
0869: break;
0870: }
0871: }
0872:
0873: if (data.size() != 0 && i == data.size()) {
0874: // all actions are check, go to next step
0875: switch (uiLaunchTest.getKindOfTest()) {
0876: case GuiLaunchTest.NO_TEST:
0877: jbDeploy.setEnabled(true);
0878: break;
0879: case GuiLaunchTest.MANUAL_TEST:
0880: jbDeploy.setEnabled(true);
0881: break;
0882: case GuiLaunchTest.SEMIAUTOMATIC_TEST:
0883: jbRun.setEnabled(true);
0884: break;
0885: case GuiLaunchTest.AUTOMATIC_TEST:
0886:
0887: break;
0888: default:
0889: break;
0890: }
0891: } else {
0892: // all actions are not check
0893: switch (uiLaunchTest.getKindOfTest()) {
0894: case GuiLaunchTest.NO_TEST:
0895: jbDeploy.setEnabled(false);
0896: break;
0897: case GuiLaunchTest.MANUAL_TEST:
0898: jbDeploy.setEnabled(false);
0899: break;
0900: case GuiLaunchTest.SEMIAUTOMATIC_TEST:
0901: jbRun.setEnabled(false);
0902: break;
0903: case GuiLaunchTest.AUTOMATIC_TEST:
0904:
0905: break;
0906: default:
0907: break;
0908: }
0909: }
0910: }
0911: }
0912:
0913: /* (non-Javadoc)
0914: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
0915: */
0916: public void actionPerformed(ActionEvent e) {
0917:
0918: if (e.getActionCommand().equals("Deploy")) {
0919: jtAction.setEnabled(false);
0920: globalState = BladeState.DEPLOYING;
0921: jbDeployActionPerformed();
0922:
0923: } else if (e.getActionCommand().equals("Init")) {
0924: jbInitActionPerformed();
0925: jspBottom.setRightComponent(getMonitoringPanelAfterInit());
0926: } else if (e.getActionCommand().equals("Start")) {
0927: jbStartActionPerformed();
0928: } else if (e.getActionCommand().equals("Stop")) {
0929: jbStopActionPerformed();
0930: } else if (e.getActionCommand().equals("Collect")) {
0931: jbCollectActionPerformed();
0932: String dir = ExecutionContext.getBaseDir();
0933: dir = dir.replaceAll("[.]", "report");
0934: if (globalState.equals(BladeState.COMPLETED)) {
0935: if (ClifPlugin.AUTOMATIC_ADD_URL) {
0936: JOptionPane.showMessageDialog(this ,
0937: "The test ended with success and the data were collected\n"
0938: + "in \"" + dir + "\" folder.",
0939: "Data collect",
0940: JOptionPane.INFORMATION_MESSAGE);
0941: reportUrl = dir;
0942: } else {
0943: JOptionPane
0944: .showMessageDialog(
0945: this ,
0946: "The test ended with success and the data were collected.",
0947: "Data collect",
0948: JOptionPane.INFORMATION_MESSAGE);
0949: }
0950: } else if (globalState.equals(BladeState.STOPPED)) {
0951: if (ClifPlugin.AUTOMATIC_ADD_URL) {
0952: JOptionPane
0953: .showMessageDialog(this ,
0954: "The test was stopped by the user and the data were collected\n"
0955: + "in \"" + dir
0956: + "\" folder.",
0957: "Data collect",
0958: JOptionPane.WARNING_MESSAGE);
0959: reportUrl = dir;
0960: } else {
0961: JOptionPane
0962: .showMessageDialog(
0963: this ,
0964: "The test was stopped by the user and the data were collected.",
0965: "Data collect",
0966: JOptionPane.WARNING_MESSAGE);
0967: }
0968: }
0969:
0970: switch (this .executionResult) {
0971: case GuiTestControl.TEST_SUCCESS:
0972: tmpLog = tmpLog + "=> TEST_SUCCESS\n";
0973: break;
0974: case GuiTestControl.TEST_INCONCLUSIF:
0975: tmpLog = tmpLog + "=> TEST_INCONCLUSIF\n";
0976: break;
0977: case GuiTestControl.TEST_FAILED:
0978: tmpLog = tmpLog + "=> TEST_FAILED\n";
0979: break;
0980: default:
0981: }
0982:
0983: this .dispose();
0984: } else if (e.getActionCommand().equals("Suspend")) {
0985: if (jtbSuspendResume.isSelected()) {
0986: jtbSuspendActionPerformed();
0987: jtbSuspendResume.setText("Resume");
0988: } else {
0989: jtbResumeActionPerformed();
0990: jtbSuspendResume.setText("Suspend");
0991: }
0992: } else if (e.getActionCommand().equals("Run")) {
0993: jtAction.setEnabled(false);
0994: jbRun.setEnabled(false);
0995: threadRun = new Thread(new ClifAutomaticExecution(this ));
0996: threadRun.start();
0997: } else if (e.getActionCommand().equals("Quit")) {
0998: this .dispose();
0999: }
1000:
1001: if (globalState.equals(BladeState.ABORTED)) {
1002: executionResult = TEST_FAILED;
1003: JOptionPane.showMessageDialog(this , "The test failed",
1004: "Test Failure", JOptionPane.ERROR_MESSAGE);
1005: executionResult = TEST_FAILED;
1006: this .dispose();
1007: }
1008:
1009: updateButtons();
1010: }
1011:
1012: public int getExecutionResult() {
1013: return this .executionResult;
1014: }
1015:
1016: ////////////////////////
1017: // interface Observer //
1018: ////////////////////////
1019:
1020: /**
1021: * Receive alarms and blade state changes from the supervisor
1022: */
1023: public void update(Observable super visor, Object observation) {
1024: if (observation instanceof BladeObservation) {
1025: String id = ((BladeObservation) observation).getBladeId();
1026: BladeState state = ((BladeObservation) observation)
1027: .getState();
1028: if (!state.equals(BladeState.DEPLOYED)) {
1029: globalState = clifApp.getGlobalState(null);
1030: }
1031: if (globalState.equals(BladeState.STOPPED)
1032: || globalState.equals(BladeState.SUSPENDED)) {
1033: // if (lastStartTime != 0)
1034: // {
1035: // ellapsedTime += System.currentTimeMillis() - lastStartTime;
1036: // lastStartTime = 0;
1037: // ellapsedTimeTimer.stop();
1038: // }
1039: // jpTestPlanPanel.setStatusLine(globalState, ellapsedTime);
1040: }
1041:
1042: jpTestPlanPanel.setBladeState(id, state);
1043: } else if (observation instanceof DeployObservation) {
1044: DeployObservation obs = (DeployObservation) observation;
1045: if (obs.isSuccessful()) {
1046: //clifApp = obs.getTestControl();
1047: clifApp.addObserver(this );
1048: globalState = BladeState.DEPLOYED;
1049: } else {
1050: String message = "Deployment failure";
1051: // new GuiAlert(
1052: // desktop,
1053: // message,
1054: // ThrowableHelper.toString(obs.getException())).alert();
1055: // log.log(BasicLevel.ERROR, message, obs.getException());
1056: testPlan = null;
1057: tmpLog += "Error: Deployment failure\n";
1058: System.err
1059: .println("[CLIF: Deploy] Error: Deployment fail");
1060: if (uiLaunchTest.getKindOfTest() != GuiLaunchTest.AUTOMATIC_TEST) {
1061: JOptionPane
1062: .showMessageDialog(
1063: this ,
1064: "An error occured during the deployment."
1065: + "\nCheck if all servers are launch."
1066: + "\nThe test will be quit in Inconclusive state",
1067: "Deployment Failure",
1068: JOptionPane.WARNING_MESSAGE);
1069:
1070: }
1071: this .dispose();
1072: }
1073: } else if (observation instanceof AlarmEvent) {
1074: AlarmEvent alarm = (AlarmEvent) observation;
1075: String argument = null;
1076: if (alarm.argument != null) {
1077: if (alarm.argument instanceof Throwable) {
1078: argument = ThrowableHelper
1079: .toString((Throwable) alarm.argument);
1080: } else {
1081: argument = alarm.argument.toString();
1082: }
1083: }
1084: // new GuiAlert(
1085: // desktop,
1086: // "Alarm",
1087: // argument).alert();
1088: }
1089: updateButtons();
1090: }
1091:
1092: private void updateButtons() {
1093: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.MANUAL_TEST) {
1094: jbDeploy.setEnabled(false);
1095: jbInit.setEnabled(false);
1096: jbStart.setEnabled(false);
1097: jbStop.setEnabled(false);
1098: jtbSuspendResume.setEnabled(false);
1099: jbCollect.setEnabled(false);
1100:
1101: if (globalState.equals(BladeState.DEPLOYED)) {
1102: jbInit.setEnabled(testPlan != null);
1103: } else if (globalState.equals(BladeState.INITIALIZED)) {
1104: jbStart.setEnabled(true);
1105: jbStop.setEnabled(true);
1106: } else if (globalState.equals(BladeState.RUNNING)) {
1107: jbStop.setEnabled(true);
1108: jtbSuspendResume.setEnabled(true);
1109: } else if (globalState.equals(BladeState.SUSPENDED)) {
1110: jtbSuspendResume.setEnabled(true);
1111: jbStop.setEnabled(true);
1112: } else if (globalState.equals(BladeState.STOPPED)
1113: || globalState.equals(BladeState.COMPLETED)) {
1114: jbInit.setEnabled(testPlan != null);
1115: jbCollect.setEnabled(testPlan != null);
1116: } else {
1117:
1118: }
1119: }
1120: }
1121:
1122: private void jbDeployActionPerformed() {
1123: try {
1124: /*Bind bootstrap component for this clifApp*/
1125: reg.bindServer(ExecutionContext.DEFAULT_SERVER, Fractal
1126: .getBootstrapComponent());
1127:
1128: System.out.println("[CLIF:Deploy] Deploying from "
1129: + testPlan + " test plan definition...");
1130:
1131: File ctpFile = new File(testPlan);
1132: Map definitions = TestPlanReader
1133: .readFromProp(new FileInputStream(ctpFile));
1134: clifApp = new ClifAppFacade("ClifSalome", CLIF_APPLICATION);
1135: clifApp.addObserver(this );
1136: clifApp.syncDeploy(definitions, reg);
1137: reg.bindClifApp("ClifSalome", clifApp.getClifApp());
1138: System.out.println("[CLIF:Deploy] Test plan "
1139: + "ClifSalome" + " is deployed.");
1140:
1141: tmpLog = tmpLog + "> Deploy Action Performed\n";
1142: } catch (FileNotFoundException fileEx) {
1143: tmpLog += "Error: Test plan file " + testPlan
1144: + " not found\n";
1145: System.err.println("[CLIF:Deploy] Error: Test plan file "
1146: + testPlan + " not found");
1147: fileEx.printStackTrace(System.err);
1148: executionResult = TEST_INCONCLUSIF;
1149: return;
1150: } catch (IOException ioEx) {
1151: tmpLog += "Error: Invalid test plan file " + testPlan
1152: + "\n";
1153: System.err
1154: .println("[CLIF:Deploy] Error: Invalid test plan file "
1155: + testPlan);
1156: ioEx.printStackTrace(System.err);
1157: executionResult = TEST_INCONCLUSIF;
1158: return;
1159: } catch (Exception ex) {
1160: tmpLog += "Error: Execution problem while deploying\n";
1161: System.err
1162: .println("[CLIF:Deploy] Error: Execution problem while deploying");
1163: ex.printStackTrace(System.err);
1164: executionResult = TEST_INCONCLUSIF;
1165: }
1166: }
1167:
1168: private void jbInitActionPerformed() {
1169: try {
1170: if (clifApp == null) {
1171: tmpLog += "Error: unable to find such deployed test plan";
1172: System.err
1173: .println("[CLIF:Init] Error: unable to find such deployed test plan");
1174: executionResult = TEST_INCONCLUSIF;
1175: return;
1176: }
1177: System.out.println("[CLIF:Init] Initializing");
1178: int res = clifApp
1179: .init(testId + autoTest.getNameFromModel());
1180: if (res == BatchUtil.SUCCESS) {
1181: res = clifApp
1182: .waitForState(null, BladeState.INITIALIZED);
1183: if (res == BatchUtil.SUCCESS) {
1184: System.out.println("[CLIF:Init] Initialized");
1185: tmpLog = tmpLog + "> Init Action Performed\n";
1186: return;
1187: }
1188: }
1189: tmpLog += "Error: blades are not in the deployed state\n";
1190: System.err
1191: .println("[CLIF:Init] Error: blades are not in the deployed state");
1192: executionResult = TEST_INCONCLUSIF;
1193: } catch (Exception ex) {
1194: tmpLog += "Error: execution problem while initializing blades\n";
1195: System.err
1196: .println("[CLIF:Init] Error: execution problem while initializing blades");
1197: ex.printStackTrace();
1198: executionResult = TEST_INCONCLUSIF;
1199: }
1200: }
1201:
1202: private void jbStartActionPerformed() {
1203: try {
1204: if (clifApp == null) {
1205: tmpLog += "Error: no such deployed test plan\n";
1206: System.err
1207: .println("[CLIF:Start] Error: no such deployed test plan");
1208: executionResult = TEST_INCONCLUSIF;
1209: return;
1210: }
1211: System.out.println("[CLIF:Start] Starting " + "ClifSalome"
1212: + " test plan...");
1213: int res = clifApp.start(null);
1214: if (res == BatchUtil.SUCCESS) {
1215: // res = clifApp.waitForState(null, BladeState.RUNNING);
1216: if (res == BatchUtil.SUCCESS) {
1217: System.out.println("[CLIF:Start] Started");
1218: tmpLog = tmpLog + "> Start Action Performed\n";
1219: return;
1220: }
1221: }
1222: tmpLog += "Error: blades are not in the initialized state\n";
1223: System.err
1224: .println("[CLIF:Start] Error: blades are not in the initialized state");
1225: executionResult = TEST_INCONCLUSIF;
1226: } catch (Exception ex) {
1227: tmpLog += "Error: Execution problem while deploying\n";
1228: System.err
1229: .println("[CLIF:Start] Error: execution problem while starting blades");
1230: ex.printStackTrace(System.err);
1231: executionResult = TEST_FAILED;
1232: }
1233: }
1234:
1235: private void jbStopActionPerformed() {
1236: try {
1237: if (clifApp == null) {
1238: tmpLog += "Error: Unknown test plan\n";
1239: System.err
1240: .println("[CLIF:Stop] Error: Unknown test plan");
1241: executionResult = TEST_INCONCLUSIF;
1242: return;
1243: }
1244: int res = clifApp.stop(null);
1245: if (res == BatchUtil.SUCCESS) {
1246: res = clifApp.waitForState(null, BladeState.STOPPED);
1247: if (res == BatchUtil.SUCCESS) {
1248: System.out.println("[CLIF:Stop] Stopped");
1249: executionResult = TEST_INCONCLUSIF;
1250: tmpLog = tmpLog + "> Stop Action Performed\n";
1251: return;
1252: }
1253: }
1254: tmpLog += "Error: Blades are not in a stoppable state\n";
1255: System.err
1256: .println("[CLIF:Stop] Error: Blades are not in a stoppable state");
1257: } catch (Exception ex) {
1258: tmpLog += "Error: Execution problem while stopping\n";
1259: System.err
1260: .println("[CLIF:Stop] Error: Execution problem while stopping");
1261: ex.printStackTrace(System.err);
1262: }
1263: }
1264:
1265: private void jtbSuspendActionPerformed() {
1266: try {
1267: if (clifApp == null) {
1268: tmpLog += "Error: Test undeployed\n";
1269: System.err
1270: .println("[CLIF:Suspend] Error: Test undeployed");
1271: //System.exit(BatchUtil.ERR_DEPLOY);
1272: }
1273: int res = clifApp.suspend(null);
1274: if (res == BatchUtil.ERR_LIFECYCLE) {
1275: tmpLog += "Error: Blades are not running\n";
1276: System.err
1277: .println("[CLIF:Suspend] Error: Blades are not running");
1278: return;
1279: }
1280: System.out.println("[CLIF:Suspend] Suspended");
1281:
1282: tmpLog = tmpLog + "> Suspend Action Performed\n";
1283: } catch (Exception ex) {
1284: tmpLog += "Error: Execution problem while suspending\n";
1285: System.err
1286: .println("[CLIF:Suspend] Error: Execution problem while suspending");
1287: ex.printStackTrace(System.err);
1288: }
1289: }
1290:
1291: private void jtbResumeActionPerformed() {
1292: try {
1293: if (clifApp == null) {
1294: tmpLog += "Error: Unknown test plan\n";
1295: System.err
1296: .println("[CLIF:Resume] Error: Unknown test plan");
1297: return;
1298: }
1299: int res = clifApp.resume(null);
1300: if (res == BatchUtil.SUCCESS) {
1301: res = clifApp.waitForState(null, BladeState.RUNNING);
1302: if (res == BatchUtil.SUCCESS) {
1303: System.out.println("[CLIF:Resume] Resumed");
1304: tmpLog = tmpLog + "> Resume Action Performed\n";
1305: return;
1306: }
1307: }
1308: tmpLog += "Error: Blades are not in the suspended state\n";
1309: System.err
1310: .println("[CLIF:Resume] Error: Blades are not in the suspended state");
1311: } catch (Exception ex) {
1312: ex.printStackTrace(System.err);
1313: }
1314: }
1315:
1316: private void jbCollectActionPerformed() {
1317: try {
1318: System.out
1319: .println("[CLIF:Collect] Collecting data from test plan "
1320: + "ClifSalome" + "...");
1321: int res = clifApp.collect(null, null);
1322: if (res == BatchUtil.ERR_LIFECYCLE) {
1323: tmpLog += "Error: blades are not stopped nor completed\n";
1324: System.err
1325: .println("[CLIF:Collect] Error: blades are not stopped nor completed");
1326: //System.exit(BatchUtil.ERR_LIFECYCLE);
1327: }
1328: System.out.println("[CLIF:Collect] Collection done");
1329:
1330: if (globalState.equals(BladeState.COMPLETED)) {
1331: executionResult = TEST_SUCCESS;
1332: }
1333: tmpLog = tmpLog + "> Collect Action Performed\n";
1334: } catch (Exception ex) {
1335: tmpLog += "Error: execution problem while collecting data from blades\n";
1336: System.err
1337: .println("[CLIF:Collect] Error: execution problem while collecting data from blades");
1338: ex.printStackTrace(System.err);
1339: } catch (Error er) {
1340:
1341: }
1342: }
1343:
1344: private void jbRunActionPerformed() {
1345: tmpLog = tmpLog + "> Run Action Performed\n";
1346:
1347: globalState = BladeState.DEPLOYING;
1348: jbDeployActionPerformed();
1349: clifApp.waitForState(null, BladeState.DEPLOYED);
1350: jbInitActionPerformed();
1351: clifApp.waitForState(null, BladeState.INITIALIZED);
1352: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST) {
1353: jspBottom.setRightComponent(getMonitoringPanelAfterInit());
1354: } else {
1355: jspMiddle.setRightComponent(getMonitoringPanelAfterInit());
1356: }
1357:
1358: this .pack();
1359: this .setVisible(true);
1360: if (clifApp.getGlobalState(null).equals(BladeState.INITIALIZED)) {
1361: jbStartActionPerformed();
1362: clifApp.join(null);
1363: jbCollectActionPerformed();
1364:
1365: String dir = ExecutionContext.getBaseDir();
1366: dir = dir.replaceAll("[.]", "report");
1367:
1368: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST) {
1369: if (ClifPlugin.AUTOMATIC_ADD_URL) {
1370: JOptionPane.showMessageDialog(this ,
1371: "The test ended with success and the data were collected\n"
1372: + "in \"" + dir + "\" folder.",
1373: "Data collect",
1374: JOptionPane.INFORMATION_MESSAGE);
1375: } else {
1376: JOptionPane
1377: .showMessageDialog(
1378: this ,
1379: "The test ended with success and the data were collected.",
1380: "Data collect",
1381: JOptionPane.INFORMATION_MESSAGE);
1382: }
1383: }
1384:
1385: if (ClifPlugin.AUTOMATIC_ADD_URL) {
1386: reportUrl = dir;
1387: }
1388:
1389: } else {
1390: if (uiLaunchTest.getKindOfTest() == GuiLaunchTest.SEMIAUTOMATIC_TEST) {
1391: JOptionPane.showMessageDialog(this ,
1392: "Impossible to initialize the blades", "Error",
1393: JOptionPane.ERROR_MESSAGE);
1394: }
1395: }
1396: this.dispose();
1397: }
1398: }
|