1 19 20 package org.netbeans.test.db.derby; 21 22 23 24 25 import java.sql.Connection ; 26 import java.sql.Driver ; 27 import java.util.Properties ; 28 import junit.extensions.TestSetup; 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import org.netbeans.jellytools.JellyTestCase; 32 import org.netbeans.modules.derby.StartAction; 33 import org.netbeans.junit.NbTestSuite; 34 import org.netbeans.modules.derby.DerbyOptions; 35 import org.netbeans.modules.derby.StopAction; 36 import org.netbeans.test.db.util.DbUtil; 37 import org.openide.util.actions.SystemAction; 38 39 40 41 49 50 54 public class DerbyDatabaseTest extends DbJellyTestCase { 55 56 public static final String DERBY_CLASS_NAME = "org.apache.derby.jdbc.ClientDriver"; 57 public static final String PORT="1527"; 58 public static String location=""; 59 60 public DerbyDatabaseTest(String s) { 61 62 super(s); 63 debug("derby location:"+location); 64 } 65 66 67 68 public void testStartAction() { 69 debug("Starting Java DB server"); 70 StartAction start=(StartAction)SystemAction.get(StartAction.class); 71 start.performAction(); 72 sleep(2000); 73 74 } 75 76 public void testStopAction() throws Exception { 77 debug("Stoping Java DB server"); 78 79 StopAction stop=(StopAction)SystemAction.get(StopAction.class); 80 stop.performAction(); 81 82 } 83 84 85 public void testConnect() throws Exception { 86 debug("Connection to Java DB server"); 87 DbUtil util=new DbUtil(location); 88 String s="jdbc:derby://localhost:1527/db;create=true"; 89 Connection con=util.createConnection(s); 90 con.close(); 91 92 } 93 94 95 96 97 98 public static Test suite() { 99 100 NbTestSuite suite = new NbTestSuite(); 101 suite.addTest(new DerbyDatabaseTest("testStartAction")); 102 suite.addTest(new DerbyDatabaseTest("testConnect")); 103 suite.addTest(new DerbyDatabaseTest("testStopAction")); 104 TestSetup setup=new TestSetup(suite){ 105 106 protected void setUp() throws Exception { 107 init(); 108 } 109 110 protected void tearDown() throws Exception { 111 112 } 113 }; 114 115 return setup; 116 } 117 118 private static void init() throws Exception { 119 location=DerbyOptions.getDefault().getLocation(); 120 String systemHome=System.getProperty("xtest.tmpdir"); 121 DerbyOptions.getDefault().setSystemHome(systemHome); 123 124 } 125 126 127 128 129 130 131 132 } 133 | Popular Tags |