KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > db > derby > CreateDatabaseTest


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.db.derby;
21
22 import junit.extensions.TestSetup;
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25 import org.netbeans.jellytools.actions.ActionNoBlock;
26 import org.netbeans.jellytools.modules.db.nodes.ConnectionNode;
27 import org.netbeans.jellytools.modules.db.nodes.DatabasesNode;
28 import org.netbeans.modules.db.explorer.nodes.DatabaseNode;
29 import org.netbeans.modules.derby.DerbyOptions;
30 import org.netbeans.test.db.derby.lib.CreateDerbyDatabaseOperator;
31
32 /**
33  *
34  * @author lg198683
35  */

36 public class CreateDatabaseTest extends DbJellyTestCase {
37     private static String JavaDoc location="";
38     
39     private static String JavaDoc USER="czesiu";
40     
41     private static String JavaDoc PASSWORD="czesiu";
42     
43     private static String JavaDoc DB="newdatabase";
44     
45     private static String JavaDoc URL="jdbc:derby://localhost:1527/newdatabase";
46
47     public CreateDatabaseTest(String JavaDoc s) {
48         super(s);
49     }
50     
51     public void testCreateDatabase(){
52         debug("Creating Java DB Database");
53         new ActionNoBlock("Tools|Java DB Database|Create Java DB Database...", null).perform();
54         CreateDerbyDatabaseOperator operator=new CreateDerbyDatabaseOperator();
55         operator.typeDatabaseName(DB);
56         operator.typeUserName(USER);
57         operator.typePassword(PASSWORD);
58         operator.ok();
59         debug("Database created");
60         sleep(2000);
61         
62     }
63     
64     public void testConnect() throws Exception JavaDoc {
65         debug("Connection to Java DB server");
66         ConnectionNode connection=ConnectionNode.invoke(URL,USER,PASSWORD);
67         connection.connect();
68         debug("Disconecting");
69         sleep(2000);
70         connection.disconnect();
71         sleep(1000);
72     }
73     
74     
75     public void testStopServer(){
76          debug("Stopping database derver");
77          new ActionNoBlock("Tools|Java DB Database|Stop Java DB Server", null).perform();
78     }
79     
80     public static Test suite() {
81         TestSuite suite=new TestSuite();
82         suite.addTest(new CreateDatabaseTest("testCreateDatabase"));
83         suite.addTest(new CreateDatabaseTest("testConnect"));
84         suite.addTest(new CreateDatabaseTest("testStopServer"));
85         TestSetup setup=new TestSetup(suite){
86            public void setUp() throws Exception JavaDoc {
87                init();
88            }
89            
90         };
91         return setup;
92         
93     }
94     
95     public static void init() throws Exception JavaDoc {
96        // location=System.getProperty("derby.path");
97
String JavaDoc systemHome=System.getProperty("xtest.tmpdir");
98       // DerbyOptions.getDefault().setLocation(location);
99
DerbyOptions.getDefault().setSystemHome(systemHome);
100     }
101     
102     
103     
104    
105     
106 }
107
Popular Tags