1 21 package org.apache.derbyTesting.functionTests.tests.derbynet; 22 23 import java.sql.*; 24 import java.util.Vector ; 25 import java.util.Properties ; 26 import java.io.File ; 27 import java.io.FileOutputStream ; 28 import java.io.BufferedOutputStream ; 29 30 import org.apache.derby.iapi.reference.Property; 31 import org.apache.derby.drda.NetworkServerControl; 32 import org.apache.derbyTesting.functionTests.harness.jvm; 33 import org.apache.derbyTesting.functionTests.util.TestUtil; 34 import org.apache.derbyTesting.functionTests.util.ExecProcUtil; 35 import org.apache.derby.tools.ij; 36 37 40 41 public class maxthreads 42 { 43 private static Properties properties = new java.util.Properties (); 44 private static jvm jvm; 45 private static Vector vCmd; 46 private static String [] maxthreadsCmd1 = new String [] {"org.apache.derby.drda.NetworkServerControl", 47 "maxthreads", "0"}; 48 private static String [] maxthreadsCmd2 = new String [] {"org.apache.derby.drda.NetworkServerControl", 49 "maxthreads","-1", "-h", "localhost", "-p", "1527"}; 50 private static String [] maxthreadsCmd3 = new String [] {"org.apache.derby.drda.NetworkServerControl", 51 "maxthreads", "-12"}; 52 private static String [] maxthreadsCmd4 = new String [] {"org.apache.derby.drda.NetworkServerControl", 53 "maxthreads", "2147483647"}; 54 private static String [] maxthreadsCmd5 = new String [] {"org.apache.derby.drda.NetworkServerControl", 55 "maxthreads", "9000"}; 56 private static String [] maxthreadsCmd6 = new String [] {"org.apache.derby.drda.NetworkServerControl", 57 "maxthreads", "a"}; 58 private static BufferedOutputStream bos = null; 59 private static NetworkServerControl server; 60 private static String host; 61 private static int port = 1527; 62 63 private static void checkMaxThreads( int value) 64 throws Exception 65 { 66 int maxValue = server.getMaxThreads(); 67 if (maxValue == value) 68 System.out.println("PASS - max threads value, "+ value +" is correct"); 69 else 70 System.out.println("FAIL - max threads value is " + maxValue + " should be " 71 + value); 72 } 73 74 75 public static void main (String args[]) throws Exception 76 { 77 host = TestUtil.getHostName(); 78 maxthreadsCmd2[4] = host; 79 80 if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) 81 jvm = jvm.getJvm("j9_13"); 82 else 83 jvm = jvm.getJvm("currentjvm"); vCmd = jvm.getCommandLine(); 85 try 86 { 87 ij.getPropertyArg(args); 88 Connection conn1 = ij.startJBMS(); 89 90 bos = new BufferedOutputStream (System.out, 1024); 91 92 server = new NetworkServerControl(); 93 96 System.out.println("Testing maxthreads"); 97 ExecProcUtil.execCmdDumpResults(maxthreadsCmd1,vCmd,bos); 99 checkMaxThreads(0); 100 ExecProcUtil.execCmdDumpResults(maxthreadsCmd2,vCmd,bos); 102 checkMaxThreads(0); ExecProcUtil.execCmdDumpResults(maxthreadsCmd3,vCmd,bos); 105 checkMaxThreads(0); 106 ExecProcUtil.execCmdDumpResults(maxthreadsCmd4,vCmd,bos); 108 checkMaxThreads(2147483647); 109 ExecProcUtil.execCmdDumpResults(maxthreadsCmd5,vCmd,bos); 111 checkMaxThreads(9000); 112 ExecProcUtil.execCmdDumpResults(maxthreadsCmd6,vCmd,bos); 114 server.setMaxThreads(0); 117 checkMaxThreads(0); 118 server.setMaxThreads(-1); 120 checkMaxThreads(0); 121 try { 123 server.setMaxThreads(-2); 124 } catch (Exception e) { 125 System.out.println (e.getMessage()); 126 } 127 server.setMaxThreads(2147483647); 129 checkMaxThreads(2147483647); 130 server.setMaxThreads(9000); 132 checkMaxThreads(9000); 133 System.out.println("End test"); 134 bos.close(); 135 } 136 catch (Exception e) 137 { 138 e.printStackTrace(); 139 } 140 } 141 } 142 | Popular Tags |