1 21 package org.apache.derbyTesting.functionTests.tests.derbynet; 22 23 import java.net.InetAddress ; 24 import java.sql.*; 25 import java.util.Vector ; 26 import java.util.Properties ; 27 import java.io.File ; 28 import java.io.FileOutputStream ; 29 import java.io.BufferedOutputStream ; 30 31 import org.apache.derbyTesting.functionTests.harness.jvm; 32 import org.apache.derby.drda.NetworkServerControl; 33 import org.apache.derby.tools.ij; 34 import org.apache.derbyTesting.functionTests.util.TestUtil; 35 import org.apache.derbyTesting.functionTests.util.ExecProcUtil; 36 import org.apache.derby.tools.JDBCDisplayUtil; 37 38 41 42 public class runtimeinfo 43 { 44 45 private static Properties properties = new java.util.Properties (); 46 private static jvm jvm; 47 private static Vector vCmd; 48 private static BufferedOutputStream bos; 49 private static String [] RuntimeinfoCmd = new String [] {"org.apache.derby.drda.NetworkServerControl", 50 "runtimeinfo"}; 51 private static String [] RuntimeinfoLocaleCmd = new String [] {"-Duser.language=err", 52 "-Duser.country=DE", "org.apache.derby.drda.NetworkServerControl", "runtimeinfo"}; 53 54 55 56 public static void main (String args[]) throws Exception 57 { 58 if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) 59 jvm = jvm.getJvm("j9_13"); 60 else 61 jvm = jvm.getJvm("currentjvm"); vCmd = jvm.getCommandLine(); 63 try 64 { 65 ij.getPropertyArg(args); 66 Connection conn1 = ij.startJBMS(); 67 bos = new BufferedOutputStream (System.out, 1024); 68 69 70 73 System.out.println("Testing Runtimeinfo"); 74 ExecProcUtil.execCmdDumpResults(RuntimeinfoCmd,vCmd,bos); 75 System.out.println("End test"); 76 77 Connection conn2 = ij.startJBMS(); 79 PreparedStatement ps = prepareAndExecuteQuery(conn1,"SELECT count(*) from sys.systables"); 80 PreparedStatement ps2 = prepareAndExecuteQuery(conn1,"VALUES(1)"); 81 82 Connection conn3 = ij.startJBMS(); 83 PreparedStatement ps3 = prepareAndExecuteQuery(conn2,"SELECT count(*) from sys.systables"); 84 PreparedStatement ps4 = prepareAndExecuteQuery(conn2,"VALUES(2)"); 85 86 87 90 System.out.println("Testing Runtimeinfo (locale)"); 91 ExecProcUtil.execCmdDumpResults(RuntimeinfoLocaleCmd,vCmd,bos); 92 System.out.println("End test (locale)"); 93 ps.close(); 94 ps2.close(); 95 ps3.close(); 96 ps4.close(); 97 conn1.close(); 98 conn2.close(); 99 conn3.close(); 100 103 System.out.println("Testing Runtimeinfo after closing connectiosn"); 104 Thread.sleep(1000); 106 NetworkServerControl derbyServer = 107 new NetworkServerControl( InetAddress.getByName("localhost"), 108 NetworkServerControl.DEFAULT_PORTNUMBER); 109 System.out.println(derbyServer.getRuntimeInfo()); 110 System.out.println("End test"); 111 112 bos.close(); 113 } 114 catch (Exception e) 115 { 116 e.printStackTrace(); 117 } 118 } 119 120 121 public static PreparedStatement prepareAndExecuteQuery(Connection conn, 122 String sql) 123 throws SQLException 124 { 125 PreparedStatement ps = conn.prepareStatement(sql); 126 ResultSet rs = ps.executeQuery(); 127 rs.next(); 128 return ps; 129 } 130 } 131 132 133 134 135 136 137 138 139 140 141 | Popular Tags |