001: /*
002:
003: Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.sysinfo
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021: package org.apache.derbyTesting.functionTests.tests.derbynet;
022:
023: import java.sql.*;
024: import java.util.Vector;
025: import java.util.Properties;
026: import java.io.File;
027: import java.io.FileOutputStream;
028: import java.io.BufferedOutputStream;
029: import java.net.InetAddress;
030:
031: import org.apache.derbyTesting.functionTests.harness.jvm;
032: import org.apache.derbyTesting.functionTests.util.ExecProcUtil;
033: import org.apache.derby.drda.NetworkServerControl;
034: import org.apache.derby.tools.ij;
035:
036: /**
037: This tests the sysinfo command
038: */
039:
040: public class sysinfo {
041:
042: private static Properties properties = new java.util.Properties();
043: private static jvm jvm;
044: private static Vector vCmd;
045: private static BufferedOutputStream bos;
046: private static String[] SysInfoCmd = new String[] {
047: "org.apache.derby.drda.NetworkServerControl", "sysinfo" };
048: private static String[] SysInfoLocaleCmd = new String[] {
049: "-Duser.language=err", "-Duser.country=DE",
050: "org.apache.derby.drda.NetworkServerControl", "sysinfo" };
051:
052: /*
053: * Test calling server's sysinfo
054: *
055: */
056: public static void test(String args[]) throws Exception {
057: if ((System.getProperty("java.vm.name") != null)
058: && System.getProperty("java.vm.name").equals("J9"))
059: jvm = jvm.getJvm("j9_13");
060: else
061: jvm = jvm.getJvm("currentjvm"); // ensure compatibility
062: vCmd = jvm.getCommandLine();
063: try {
064: Connection conn1 = ij.startJBMS();
065: bos = new BufferedOutputStream(System.out, 1024);
066:
067: /************************************************************
068: * Test sysinfo
069: ************************************************************/
070: System.out.println("Testing Sysinfo");
071: ExecProcUtil.execCmdDumpResults(SysInfoCmd, vCmd, bos);
072: System.out.println("End test");
073:
074: /************************************************************
075: * Test sysinfo by calling NetworkServerControl.getSysinfo()
076: ************************************************************/
077: System.out.println("Testing Sysinfo (method)");
078: NetworkServerControl derbyServer = new NetworkServerControl(
079: InetAddress.getByName("localhost"),
080: NetworkServerControl.DEFAULT_PORTNUMBER);
081: System.out.println(derbyServer.getSysinfo());
082: System.out.println("End test (method)");
083:
084: /************************************************************
085: * Test sysinfo w/ foreign (non-English) locale
086: ************************************************************/
087: System.out.println("Testing Sysinfo (locale)");
088: ExecProcUtil
089: .execCmdDumpResults(SysInfoLocaleCmd, vCmd, bos);
090: System.out.println("End test (locale)");
091:
092: bos.close();
093: } catch (Exception e) {
094: e.printStackTrace();
095: }
096: }
097:
098: public static void main(String[] args) throws Exception {
099: test(args);
100: }
101:
102: }
|