You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by fu...@apache.org on 2006/07/17 23:15:14 UTC
svn commit: r422876 - in /db/derby/code/trunk/java:
testing/org/apache/derbyTesting/functionTests/suites/
testing/org/apache/derbyTesting/functionTests/tests/tools/
tools/org/apache/derby/tools/
Author: fuzzylogic
Date: Mon Jul 17 14:15:13 2006
New Revision: 422876
URL: http://svn.apache.org/viewvc?rev=422876&view=rev
Log:
DERBY-982: Add genus names for network server and client to sysinfo api. Update
published api javadoc for sysinfo. Add a test of the sysinfo public api.
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java (with props)
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml
db/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall?rev=422876&r1=422875&r2=422876&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall Mon Jul 17 14:15:13 2006
@@ -11,4 +11,5 @@
tools/ij5.sql
tools/ij6.sql
tools/ijConnName.sql
+tools/sysinfo_api.junit
tools/URLCheck.sql
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml?rev=422876&r1=422875&r2=422876&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/build.xml Mon Jul 17 14:15:13 2006
@@ -65,7 +65,7 @@
destdir="${out.dir}">
<classpath>
<!--pathelement location="${oro}"/-->
- <pathelement path="${compile.classpath}"/>
+ <pathelement path="${compile.classpath};${junit}"/>
</classpath>
<include name="${this.dir}/*.java"/>
<!--exclude name=""/-->
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java?rev=422876&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java Mon Jul 17 14:15:13 2006
@@ -0,0 +1,170 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.tools.sysinfo_api
+
+ Copyright 1999, 2005 The Apache Software Foundation or its licensors, as appl
+icable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.tools;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.PipedReader;
+import java.io.PipedWriter;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import org.apache.derby.tools.sysinfo;
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+
+/**
+ * Test all the static public methods of the sysinfo class.
+ */
+
+public class sysinfo_api extends BaseJDBCTestCase {
+
+ Connection c;
+ DatabaseMetaData dm;
+
+ public sysinfo_api(String name) {
+ super(name);
+ }
+
+ /*
+ * getMajorVersion()
+ */
+ public void testMajorVersion() {
+ int dmMajor = dm.getDriverMajorVersion();
+ assertEquals(dmMajor, sysinfo.getMajorVersion());
+ assertEquals(dmMajor, sysinfo.getMajorVersion(sysinfo.DBMS));
+ assertEquals(dmMajor, sysinfo.getMajorVersion(sysinfo.TOOLS));
+ assertEquals(dmMajor, sysinfo.getMajorVersion(sysinfo.NET));
+ assertEquals(dmMajor, sysinfo.getMajorVersion(sysinfo.CLIENT));
+ // bad usage
+ assertEquals(-1, sysinfo.getMajorVersion("foo"));
+ assertEquals(-1, sysinfo.getMajorVersion(null));
+ }
+
+ /*
+ * getMinorVersion()
+ */
+ public void testMinorVersion() {
+ int dmMinor = dm.getDriverMinorVersion();
+ assertEquals(dmMinor, sysinfo.getMinorVersion());
+ assertEquals(dmMinor, sysinfo.getMinorVersion(sysinfo.DBMS));
+ assertEquals(dmMinor, sysinfo.getMinorVersion(sysinfo.TOOLS));
+ assertEquals(dmMinor, sysinfo.getMinorVersion(sysinfo.NET));
+ assertEquals(dmMinor, sysinfo.getMinorVersion(sysinfo.CLIENT));
+ // bad usage
+ assertEquals(-1, sysinfo.getMinorVersion("foo"));
+ assertEquals(-1, sysinfo.getMinorVersion(null));
+ }
+
+ /*
+ * getProductName()
+ */
+ public void testProductName() {
+ assertEquals("Apache Derby", sysinfo.getProductName());
+ assertEquals("Apache Derby", sysinfo.getProductName(sysinfo.DBMS));
+ assertEquals("Apache Derby", sysinfo.getProductName(sysinfo.TOOLS));
+ assertEquals("Apache Derby", sysinfo.getProductName(sysinfo.NET));
+ assertEquals("Apache Derby", sysinfo.getProductName(sysinfo.CLIENT));
+ // bad usage
+ assertEquals("<no name found>", sysinfo.getProductName("foo"));
+ assertEquals("<no name found>", sysinfo.getProductName(null));
+ }
+
+ /*
+ * getVersionString()
+ */
+ public void testVersionString() throws SQLException {
+ String dmPv = dm.getDatabaseProductVersion();
+ assertEquals(dmPv, sysinfo.getVersionString());
+ assertEquals(dmPv, sysinfo.getVersionString(sysinfo.DBMS));
+ assertEquals(dmPv, sysinfo.getVersionString(sysinfo.TOOLS));
+ assertEquals(dmPv, sysinfo.getVersionString(sysinfo.NET));
+ assertEquals(dmPv, sysinfo.getVersionString(sysinfo.CLIENT));
+ // bad usage
+ assertEquals("<no name found>", sysinfo.getVersionString("foo"));
+ assertEquals("<no name found>", sysinfo.getVersionString(null));
+ }
+
+ /*
+ * getBuildNumber()
+ *
+ * Currently no test for sysinfo.getBuildNumber().
+ * There is not currently a way to get this information from another
+ * different public interface.
+ */
+
+ /*
+ * getInfo()
+ *
+ * Currently only tests getInfo() by comparing the first line with the
+ * expected first line in English. Because so much of sysinfo changes from
+ * machine-to-machine, writing a better test may be difficult.
+ *
+ * Test spawns a separate thread in which to call sysinfo and feed the
+ * PipedWriter. Using PipedWriter and PipedReader from the same thread
+ * can cause a deadlock.
+ */
+ public void testGetInfo() throws IOException {
+ sysinfo_api_helper sah = new sysinfo_api_helper();
+ sah.start();
+ PipedReader pipeR = new PipedReader(sah.getPipedWriter());
+ BufferedReader br = new BufferedReader(pipeR);
+ assertEquals("------------------ Java Information ------------------",
+ br.readLine());
+ br.close();
+ pipeR.close();
+ }
+
+ /*
+ * testSetup - get a DatabaseMetadata object with which to compare info
+ * with sysinfo
+ */
+ public void setUp() throws SQLException {
+ c = getConnection();
+ dm = c.getMetaData();
+ }
+
+ public void tearDown() throws SQLException {
+ c.close();
+ }
+
+}
+
+class sysinfo_api_helper extends Thread {
+
+ private static PipedWriter pipeW = new PipedWriter();
+
+ public void run() {
+ PrintWriter pw = new PrintWriter(pipeW, true);
+ sysinfo.getInfo(pw);
+ try {
+ pw.close();
+ pipeW.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public PipedWriter getPipedWriter() {
+ return pipeW;
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java?rev=422876&r1=422875&r2=422876&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java Mon Jul 17 14:15:13 2006
@@ -57,16 +57,28 @@
/**
The genus name for the Apache Derby code. Use this to determine the version of the
- Apache Derby embedded code in cs.jar.
+ Apache Derby embedded code in derby.jar.
*/
public static final String DBMS="DBMS";
/**
* The genus name for the tools code. Use this to determine the version of
- code in cstools.jar
+ code in derbytools.jar
*/
public static final String TOOLS="tools";
+ /**
+ * The genus name for the network server code. Use this to determine the version of
+ code in derbynet.jar
+ */
+ public static final String NET="net";
+
+ /**
+ * The genus name for the client code. Use this to determine the version of
+ code in derbyclient.jar
+ */
+ public static final String CLIENT="dnc";
+
/**
gets the major version of the Apache Derby embedded code.
@@ -81,7 +93,7 @@
/**
gets the major version of the specified code library.
@param genus which library to get the version of. Valid inputs include
- DBMS, TOOLS
+ DBMS, TOOLS, NET, CLIENT
@return the major version. Return -1 if the information is not found.
*/
static public int getMajorVersion(String genus)
@@ -108,7 +120,7 @@
/**
gets the minor version of the specified code library.
@param genus which library to get the version of. Valid inputs include
- DBMS, TOOLS.
+ DBMS, TOOLS, NET, CLIENT.
@return the minor version. Return -1 if the information is not found.
*/
static public int getMinorVersion(String genus)
@@ -134,7 +146,7 @@
/**
gets the build number for the specified library
@param genus which library to get the build number for. Valid inputs are
- DBMS, TOOLS
+ DBMS, TOOLS, NET, CLIENT.
@return the build number, or ???? if the information is not found.
*/
static public String getBuildNumber(String genus)