KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > CreateCMPBeansFromDB


1 /*
2 The contents of this file are subject to the terms of the Common Development
3 and Distribution License (the License). You may not use this file except in
4 compliance with the License.
5
6 You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7 or http://www.netbeans.org/cddl.txt.
8
9 When distributing Covered Code, include this CDDL Header Notice in each file
10 and include the License file at http://www.netbeans.org/cddl.txt.
11 If applicable, add the following below the CDDL Header, with the fields
12 enclosed by brackets [] replaced by your own identifying information:
13 "Portions Copyrighted [year] [name of copyright owner]"
14
15 The Original Software is NetBeans. The Initial Developer of the Original
16 Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17 Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.j2ee;
21
22 import java.io.File JavaDoc;
23 import java.io.FilenameFilter JavaDoc;
24 import java.io.IOException JavaDoc;
25 import org.netbeans.jellytools.*;
26 import org.netbeans.jellytools.actions.ActionNoBlock;
27 import org.netbeans.jellytools.actions.OpenAction;
28 import org.netbeans.jellytools.nodes.Node;
29 import org.netbeans.jemmy.JemmyException;
30 import org.netbeans.jemmy.Waitable;
31 import org.netbeans.jemmy.Waiter;
32 import org.netbeans.jemmy.operators.*;
33 import org.netbeans.test.j2ee.*;
34 import org.netbeans.test.j2ee.lib.Utils;
35
36 /**
37  *
38  * @author lm97939
39  */

40 public class CreateCMPBeansFromDB extends JellyTestCase {
41     
42     
43     /** Creates a new instance of AddMethodTest */
44     public CreateCMPBeansFromDB(String JavaDoc name) {
45         super(name);
46     }
47     
48     public void setUp() {
49         System.out.println("######## "+getName()+" #######");
50     }
51     
52     public void testCreateCMPBeansFromDB() throws IOException JavaDoc {
53         final String JavaDoc FILE_TYPE = "CMP Entity Beans from Database";
54         
55         NewFileWizardOperator op = NewFileWizardOperator.invoke();
56         op.selectProject(EJBValidation.EAR_PROJECT_NAME+"-ejb");
57         op.selectCategory("Enterprise");
58         op.selectFileType(FILE_TYPE);
59         op.next();
60         WizardOperator wizard = new WizardOperator(FILE_TYPE);
61         new JComboBoxOperator(wizard).selectItem("/sample");
62         //new JComboBoxOperator(wizard,3).getTextField().clearText();
63
new JComboBoxOperator(wizard,3).getTextField().enterText("cmpdb");
64         wizard.next();
65         //NbDialogOperator dialog = new NbDialogOperator("Connect");
66
//new JTextFieldOperator(dialog,0).typeText("pbpublic");
67
//dialog.ok();
68
wizard = new WizardOperator(FILE_TYPE);
69         new JButtonOperator(wizard, "Add All").push();
70         //new JListOperator(wizard,2).selectItem("SALES_REP_DATA_TBL");
71
//new JButtonOperator(wizard, "Remove").push();
72
wizard.finish();
73
74         //JDialogOperator status = new JDialogOperator("Progress");
75
//status.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 300000);
76
//status.waitClosed();
77

78         String JavaDoc beanNames[] = {
79             "Customer", "DiscountCode", "Manufacture", "MicroMarkets",
80             "Order", "ProductCode", "Product"
81             // "Office", "OfficeTypeCode", "SalesRep", "SalesTaxCode", "SalesRepData"
82
};
83         Node beansNode = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
84                              Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node"));
85         beansNode.tree().getTimeouts().setTimeout("JTreeOperator.WaitNextNodeTimeout", 300000);
86         for (int i=0; i<beanNames.length; i++) {
87             new Node(beansNode,beanNames[i]);
88         }
89         new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
90
91         Utils utils = new Utils(this);
92         String JavaDoc ddNames[] = { "ejb-jar.xml", "sun-ejb-jar.xml", "sun-cmp-mappings.xml" /*, "PBPUBLIC_TestingEntApp-EJBModule.dbschema" */};
93         utils.assertFiles(new File JavaDoc(EJBValidation.EJB_PROJECT_PATH + File.separator + "src" + File.separator + "conf"), ddNames, getName()+"_");
94     for (int i=0; i<beanNames.length; i++) {
95             Node openFile = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
96                                  Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node")
97                                  +"|"+beanNames[i]);
98             new OpenAction().performAPI(openFile);
99             EditorOperator editor = new EditorWindowOperator().getEditor(beanNames[i]);
100             editor.deleteLine(7);
101             editor.deleteLine(7);
102             editor.save();
103             editor.close();
104         }
105         File JavaDoc dbBeansDir = new File JavaDoc(EJBValidation.EJB_PROJECT_PATH + File.separator + "src" + File.separator + "java" + File.separator + "cmpdb");
106         String JavaDoc beanFiles[] = dbBeansDir.list(new FilenameFilter JavaDoc () {
107             public boolean accept(File JavaDoc dir, String JavaDoc name) {
108                 return name.endsWith(".java");
109             }
110         });
111         if (beanFiles.length != 28)
112             fail("28 generated db bean files are expected in "+dbBeansDir+" but "+String.valueOf(beanFiles.length)+" was found");
113         utils.assertFiles(dbBeansDir, beanFiles, getName()+"_");
114     }
115
116 }
117
Popular Tags