Source Code Cross Referenced for JunitTester.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » simpleJunit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » salomeTMF_plug.simpleJunit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package salomeTMF_plug.simpleJunit;
025:
026:        import java.awt.Color;
027:        import java.awt.FlowLayout;
028:        import java.io.File;
029:        import java.net.URL;
030:        import java.util.Enumeration;
031:        import java.util.Hashtable;
032:        import java.util.Vector;
033:
034:        import javax.swing.BorderFactory;
035:        import javax.swing.ButtonGroup;
036:        import javax.swing.JFileChooser;
037:        import javax.swing.JPanel;
038:        import javax.swing.JRadioButton;
039:
040:        import org.objectweb.salome_tmf.data.Attachment;
041:        import org.objectweb.salome_tmf.data.AutomaticTest;
042:        import org.objectweb.salome_tmf.data.FileAttachment;
043:        import org.objectweb.salome_tmf.data.Project;
044:        import org.objectweb.salome_tmf.data.UrlAttachment;
045:        import org.objectweb.salome_tmf.ihm.admin.AskName;
046:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
047:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
048:        import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
049:
050:        import salomeTMF_plug.simpleJunit.languages.Language;
051:
052:        /**
053:         *
054:         * @author  marchemi
055:         */
056:        public class JunitTester extends javax.swing.JDialog {
057:
058:            boolean okPressed = false;
059:            Attachment pNewAttch = null;
060:            Attachment pSelectedAttch = null;
061:
062:            static final String junitDescAttach = "[JUNIT_CLASSFILE]";
063:            static JFileChooser fileChooser = new JFileChooser();
064:            static ScriptFileFilter pJarFileFilter = new ScriptFileFilter(
065:                    Language.getInstance().getText("Fichier_Jar"), ".jar");
066:            static ScriptFileFilter pZipFileFilter = new ScriptFileFilter(
067:                    Language.getInstance().getText("Fichier_Zip"), ".zip");
068:
069:            static {
070:                fileChooser.addChoosableFileFilter(pZipFileFilter);
071:                fileChooser.addChoosableFileFilter(pJarFileFilter);
072:                fileChooser.setAcceptAllFileFilterUsed(false);
073:            }
074:
075:            /** Creates new form JunitTester */
076:            public JunitTester(java.awt.Frame parent, boolean modal,
077:                    AutomaticTest pTest, boolean newtest, String strID,
078:                    String strAttachment, String strClass, String meth,
079:                    String version) {
080:                super (parent, modal);
081:                initComponents();
082:                //pTest.getTestList();
083:                jTextFieldTestMethod.setEditable(true);
084:                jLabelTestMethod.setEnabled(true);
085:                //initData(pTest.getTestListFromModel(), newtest, strID, strAttachment,  strClass, meth);
086:                initData(DataModel.getCurrentProject(), newtest, strID,
087:                        strAttachment, strClass, meth, version);
088:
089:            }
090:
091:            //public JunitTester(java.awt.Frame parent, boolean modal, TestList pSuite, boolean newtest, String strID, String strAttachment,  String strClass) {
092:            public JunitTester(java.awt.Frame parent, boolean modal,
093:                    Project pProject, boolean newtest, String strID,
094:                    String strAttachment, String strClass, String version) {
095:                super (parent, modal);
096:                initComponents();
097:                //initData(pSuite, newtest, strID, strAttachment,  strClass, "");
098:                initData(pProject, newtest, strID, strAttachment, strClass, "",
099:                        version);
100:
101:            }
102:
103:            //public void initData(TestList pSuite, boolean newtest, String strID, String strAttachment,  String strClass, String meth) {
104:            public void initData(Project pProject, boolean newtest,
105:                    String strID, String strAttachment, String strClass,
106:                    String meth, String version) {
107:                //Hashtable tabAttach = new Hashtable(pSuite.getAttachmentMapFromModel());
108:                Hashtable tabAttach = new Hashtable(pProject
109:                        .getAttachmentMapFromModel());
110:                Enumeration e = tabAttach.elements();
111:                Vector pListJunitClass = new Vector();
112:                Attachment pAtiveAttach = null;
113:                jTextFieldTesterClass.setText(strClass);
114:                jTextFieldTestMethod.setText(meth);
115:                while (e.hasMoreElements()) {
116:                    Attachment pAttach = (Attachment) e.nextElement();
117:                    //System.out.println("Attach desc = " + pAttach.getDescriptionFromModel());
118:                    if (pAttach.getDescriptionFromModel().equals(
119:                            junitDescAttach)) {
120:                        pListJunitClass.add(pAttach);
121:                        jComboBoxAttachList.addItem(pAttach);
122:                    }
123:                    String id = "" + pAttach.getIdBdd();
124:                    //System.out.println("Test if " + id + " == " + strID);
125:                    if (!newtest && pAtiveAttach == null) {
126:                        if (id.trim().equals(strID.trim())) {
127:                            pAtiveAttach = pAttach;
128:                        }
129:                    }
130:                }
131:                if (pAtiveAttach != null) {
132:                    jComboBoxAttachList.setSelectedItem(pAtiveAttach);
133:                }
134:                if (version != null) {
135:                    if (version.equals("3.x")) {
136:                        v3.setSelected(true);
137:                    } else {
138:                        v4.setSelected(true);
139:                    }
140:                } else {
141:                    v3.setSelected(true);
142:                }
143:            }
144:
145:            Attachment getNewAttachment() {
146:                return pNewAttch;
147:            }
148:
149:            Attachment getSelectedAttachment() {
150:                return pSelectedAttch;
151:            }
152:
153:            String getJunitClass() {
154:                return jTextFieldTesterClass.getText();
155:            }
156:
157:            String getJunitMeth() {
158:                return jTextFieldTestMethod.getText();
159:            }
160:
161:            String getJunitVersion() {
162:                if (v4.isSelected()) {
163:                    return "4.x";
164:                }
165:                return "3.x";
166:            }
167:
168:            boolean execute() {
169:                show();
170:                return okPressed;
171:            }
172:
173:            /** This method is called from within the constructor to
174:             * initialize the form.
175:             * WARNING: Do NOT modify this code. The content of this method is
176:             * always regenerated by the Form Editor.
177:             */
178:            private void initComponents() {//GEN-BEGIN:initComponents
179:                jPanelTitle = new javax.swing.JPanel();
180:                jLabelJunit = new javax.swing.JLabel();
181:                jPanelAsk = new javax.swing.JPanel();
182:                jLabelClassPath = new javax.swing.JLabel();
183:                jPanelVide = new javax.swing.JPanel();
184:                jComboBoxAttachList = new javax.swing.JComboBox();
185:                jPanelNewAttach = new javax.swing.JPanel();
186:                jButtonNewFile = new javax.swing.JButton();
187:                jButtonNewUrl = new javax.swing.JButton();
188:                jLabelTesterClass = new javax.swing.JLabel();
189:                jTextFieldTesterClass = new javax.swing.JTextField();
190:                jLabelTestMethod = new javax.swing.JLabel();
191:                jTextFieldTestMethod = new javax.swing.JTextField();
192:                jPanelReturn = new javax.swing.JPanel();
193:                jButtonOK = new javax.swing.JButton();
194:                jButtonCancel = new javax.swing.JButton();
195:
196:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
197:                jLabelJunit
198:                        .setIcon(new javax.swing.ImageIcon(
199:                                getClass()
200:                                        .getResource(
201:                                                "/salomeTMF_plug/simpleJunit/resources/junitlogo.gif")));
202:                jPanelTitle.add(jLabelJunit);
203:
204:                jVersionPanel = new JPanel(new FlowLayout());
205:                jVersionPanel.setBorder(BorderFactory.createTitledBorder(
206:                        BorderFactory.createLineBorder(Color.BLACK),
207:                        "JUnit Version"));
208:                v3 = new JRadioButton("3.x");
209:                v4 = new JRadioButton("4.x");
210:                jVersionPanel.add(v3);
211:                jVersionPanel.add(v4);
212:                ButtonGroup group = new ButtonGroup();
213:                group.add(v3);
214:                group.add(v4);
215:                jPanelTitle.add(jVersionPanel);
216:                getContentPane().add(jPanelTitle, java.awt.BorderLayout.NORTH);
217:
218:                jPanelAsk.setLayout(new java.awt.GridLayout(4, 4, 5, 2));
219:
220:                jLabelClassPath.setText(Language.getInstance().getText(
221:                        "Chemin_d'accès_à_la_classe_(jar)"));
222:                jPanelAsk.add(jLabelClassPath);
223:
224:                jPanelAsk.add(jPanelVide);
225:
226:                jComboBoxAttachList
227:                        .addItemListener(new java.awt.event.ItemListener() {
228:                            public void itemStateChanged(
229:                                    java.awt.event.ItemEvent evt) {
230:                                jComboBoxAttachListItemStateChanged(evt);
231:                            }
232:                        });
233:
234:                jPanelAsk.add(jComboBoxAttachList);
235:
236:                jPanelNewAttach.setLayout(new javax.swing.BoxLayout(
237:                        jPanelNewAttach, javax.swing.BoxLayout.X_AXIS));
238:
239:                jButtonNewFile.setText(Language.getInstance().getText(
240:                        "Nouveau_Fichier"));
241:                jButtonNewFile
242:                        .addActionListener(new java.awt.event.ActionListener() {
243:                            public void actionPerformed(
244:                                    java.awt.event.ActionEvent evt) {
245:                                NewFilePerformed(evt);
246:                            }
247:                        });
248:
249:                jPanelNewAttach.add(jButtonNewFile);
250:
251:                jButtonNewUrl.setText(Language.getInstance().getText(
252:                        "Nouvelle_Url"));
253:                jButtonNewUrl
254:                        .addActionListener(new java.awt.event.ActionListener() {
255:                            public void actionPerformed(
256:                                    java.awt.event.ActionEvent evt) {
257:                                NewUrlPerformed(evt);
258:                            }
259:                        });
260:
261:                jPanelNewAttach.add(jButtonNewUrl);
262:
263:                //jPanelAsk.add(jVersionPanel);
264:                jPanelAsk.add(jPanelNewAttach);
265:
266:                jLabelTesterClass.setText(Language.getInstance().getText(
267:                        "Classe_Tester_(héritant_de_Test)"));
268:                jPanelAsk.add(jLabelTesterClass);
269:
270:                jPanelAsk.add(jTextFieldTesterClass);
271:
272:                jLabelTestMethod.setText(Language.getInstance().getText(
273:                        "Méthode_de_test"));
274:                jLabelTestMethod.setEnabled(false);
275:                jPanelAsk.add(jLabelTestMethod);
276:
277:                jTextFieldTestMethod.setEditable(false);
278:                jPanelAsk.add(jTextFieldTestMethod);
279:
280:                getContentPane().add(jPanelAsk, java.awt.BorderLayout.CENTER);
281:
282:                jPanelReturn.setLayout(new java.awt.GridLayout(1, 2, 5, 5));
283:
284:                jButtonOK.setText(Language.getInstance().getText("OK"));
285:                jButtonOK
286:                        .addActionListener(new java.awt.event.ActionListener() {
287:                            public void actionPerformed(
288:                                    java.awt.event.ActionEvent evt) {
289:                                OkPerfomed(evt);
290:                            }
291:                        });
292:
293:                jPanelReturn.add(jButtonOK);
294:
295:                jButtonCancel
296:                        .setText(Language.getInstance().getText("Annuler"));
297:                jButtonCancel
298:                        .addActionListener(new java.awt.event.ActionListener() {
299:                            public void actionPerformed(
300:                                    java.awt.event.ActionEvent evt) {
301:                                CancelPerformed(evt);
302:                            }
303:                        });
304:
305:                jPanelReturn.add(jButtonCancel);
306:
307:                getContentPane().add(jPanelReturn, java.awt.BorderLayout.SOUTH);
308:
309:                pack();
310:            }//GEN-END:initComponents
311:
312:            private void jComboBoxAttachListItemStateChanged(
313:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxAttachListItemStateChanged
314:                // TODO add your handling code here:
315:                pSelectedAttch = (Attachment) jComboBoxAttachList
316:                        .getSelectedItem();
317:            }//GEN-LAST:event_jComboBoxAttachListItemStateChanged
318:
319:            private void NewUrlPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewUrlPerformed
320:                // TODO add your handling code here:
321:                AskName askName = new AskName(Language.getInstance().getText(
322:                        "Entrez_une_URL_:"), Language.getInstance().getText(
323:                        "Attacher_une_URL"),
324:                        org.objectweb.salome_tmf.ihm.languages.Language
325:                                .getInstance().getText("url"), null,
326:                        SalomeTMFContext.getInstance().getSalomeFrame());
327:                String res = askName.getResult();
328:                //Attachment pOldAttch = null;
329:                Attachment pOldAttch = pNewAttch;
330:                if (res != null) {
331:                    if (pNewAttch != null) {
332:                        jComboBoxAttachList.removeItem(pNewAttch);
333:                    }
334:                    try {
335:                        pNewAttch = new UrlAttachment(res, junitDescAttach);
336:                        URL url = new URL(res);
337:                        //((UrlAttachment)pNewAttch).setName(res);
338:                        ((UrlAttachment) pNewAttch).setUrl(url);
339:                        //pNewAttch.setDescription(junitDescAttach);
340:                        jComboBoxAttachList.addItem(pNewAttch);
341:                        jComboBoxAttachList.setSelectedItem(pNewAttch);
342:                    } catch (Exception e) {
343:                        if (pOldAttch != null) {
344:                            jComboBoxAttachList.addItem(pOldAttch);
345:                        }
346:                        pNewAttch = pOldAttch;
347:                    }
348:                }
349:            }//GEN-LAST:event_NewUrlPerformed
350:
351:            private void NewFilePerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewFilePerformed
352:                // TODO add your handling code here:
353:                int returnVal = fileChooser.showOpenDialog(this );
354:                Attachment pOldAttch = pNewAttch;
355:                if (returnVal == JFileChooser.APPROVE_OPTION) {
356:                    if (pNewAttch != null) {
357:                        jComboBoxAttachList.removeItem(pNewAttch);
358:                    }
359:                    try {
360:                        File file = fileChooser.getSelectedFile();
361:                        if (!file.exists()) {
362:                            if (pOldAttch != null) {
363:                                jComboBoxAttachList.addItem(pOldAttch);
364:                            }
365:                            return;
366:                        }
367:                        //Date dateOfFile = new Date(file.lastModified());
368:                        //pNewAttch = new FileAttachment(file.getName(), junitDescAttach);
369:                        pNewAttch = new FileAttachment(file, junitDescAttach);
370:                        //((FileAttachment)pNewAttch).setName(file.getName());
371:                        //((FileAttachment)pNewAttch).setLocalisation(file.getAbsolutePath());
372:                        //((FileAttachment)pNewAttch).setSize(new Long(file.length()));
373:                        //((FileAttachment)pNewAttch).setDate(new Date(file.lastModified()));
374:                        //pNewAttch.setDescription(junitDescAttach);
375:                        jComboBoxAttachList.addItem(pNewAttch);
376:                        jComboBoxAttachList.setSelectedItem(pNewAttch);
377:                    } catch (Exception e) {
378:                        if (pOldAttch != null) {
379:                            jComboBoxAttachList.addItem(pOldAttch);
380:                        }
381:                        pNewAttch = pOldAttch;
382:                    }
383:                }
384:            }//GEN-LAST:event_NewFilePerformed
385:
386:            private void CancelPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelPerformed
387:                // TODO add your handling code here:
388:                okPressed = false;
389:                dispose();
390:            }//GEN-LAST:event_CancelPerformed
391:
392:            private void OkPerfomed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkPerfomed
393:                // TODO add your handling code here:
394:                okPressed = true;
395:                dispose();
396:            }//GEN-LAST:event_OkPerfomed
397:
398:            /**
399:             * @param args the command line arguments
400:             */
401:            public static void main(String args[]) {
402:                //  new JunitTester(new javax.swing.JFrame(), true, null, true, "", "", "").show();
403:            }
404:
405:            // Variables declaration - do not modify//GEN-BEGIN:variables
406:            private javax.swing.JButton jButtonCancel;
407:            private javax.swing.JButton jButtonNewFile;
408:            private javax.swing.JButton jButtonNewUrl;
409:            private javax.swing.JButton jButtonOK;
410:            private javax.swing.JComboBox jComboBoxAttachList;
411:            private javax.swing.JLabel jLabelClassPath;
412:            private javax.swing.JLabel jLabelJunit;
413:            private javax.swing.JLabel jLabelTestMethod;
414:            private javax.swing.JLabel jLabelTesterClass;
415:            private javax.swing.JPanel jPanelAsk;
416:            private javax.swing.JPanel jPanelNewAttach;
417:            private javax.swing.JPanel jPanelReturn;
418:            private javax.swing.JPanel jPanelTitle;
419:            private javax.swing.JPanel jPanelVide;
420:            private JRadioButton v3;
421:            private JRadioButton v4;
422:            private javax.swing.JPanel jVersionPanel;
423:            private javax.swing.JTextField jTextFieldTestMethod;
424:            private javax.swing.JTextField jTextFieldTesterClass;
425:            // End of variables declaration//GEN-END:variables
426:
427:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.