KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > derbynet > sysinfo


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.sysinfo
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21 package org.apache.derbyTesting.functionTests.tests.derbynet;
22
23 import java.sql.*;
24 import java.util.Vector JavaDoc;
25 import java.util.Properties JavaDoc;
26 import java.io.File JavaDoc;
27 import java.io.FileOutputStream JavaDoc;
28 import java.io.BufferedOutputStream JavaDoc;
29 import java.net.InetAddress JavaDoc;
30
31 import org.apache.derbyTesting.functionTests.harness.jvm;
32 import org.apache.derbyTesting.functionTests.util.ExecProcUtil;
33 import org.apache.derby.drda.NetworkServerControl;
34 import org.apache.derby.tools.ij;
35
36 /**
37     This tests the sysinfo command
38 */

39
40 public class sysinfo
41 {
42
43     private static Properties JavaDoc properties = new java.util.Properties JavaDoc();
44     private static jvm jvm;
45     private static Vector JavaDoc vCmd;
46     private static BufferedOutputStream JavaDoc bos;
47     private static String JavaDoc[] SysInfoCmd = new String JavaDoc[] {"org.apache.derby.drda.NetworkServerControl",
48         "sysinfo"};
49     private static String JavaDoc[] SysInfoLocaleCmd = new String JavaDoc[] {"-Duser.language=err",
50         "-Duser.country=DE", "org.apache.derby.drda.NetworkServerControl", "sysinfo"};
51
52     /*
53      * Test calling server's sysinfo
54      *
55      */

56     public static void test (String JavaDoc args[])
57         throws Exception JavaDoc
58     {
59         if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9"))
60             jvm = jvm.getJvm("j9_13");
61         else
62             jvm = jvm.getJvm("currentjvm"); // ensure compatibility
63
vCmd = jvm.getCommandLine();
64         try
65         {
66             Connection conn1 = ij.startJBMS();
67             bos = new BufferedOutputStream JavaDoc(System.out, 1024);
68
69             /************************************************************
70              * Test sysinfo
71              ************************************************************/

72             System.out.println("Testing Sysinfo");
73             ExecProcUtil.execCmdDumpResults(SysInfoCmd,vCmd,bos);
74             System.out.println("End test");
75             
76             /************************************************************
77              * Test sysinfo by calling NetworkServerControl.getSysinfo()
78              ************************************************************/

79             System.out.println("Testing Sysinfo (method)");
80             NetworkServerControl derbyServer =
81                 new NetworkServerControl( InetAddress.getByName("localhost"),
82                                         NetworkServerControl.DEFAULT_PORTNUMBER);
83             System.out.println(derbyServer.getSysinfo());
84             System.out.println("End test (method)");
85             
86             /************************************************************
87              * Test sysinfo w/ foreign (non-English) locale
88              ************************************************************/

89             System.out.println("Testing Sysinfo (locale)");
90             ExecProcUtil.execCmdDumpResults(SysInfoLocaleCmd,vCmd,bos);
91             System.out.println("End test (locale)");
92
93             bos.close();
94         }
95         catch (Exception JavaDoc e)
96         {
97             e.printStackTrace();
98         }
99     }
100     
101     public static void main(String JavaDoc[] args)
102         throws Exception JavaDoc
103     {
104        test(args);
105     }
106
107 }
108
Popular Tags