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 my...@apache.org on 2014/03/26 23:15:09 UTC

svn commit: r1582087 - in /db/derby/code/branches/10.10: ./ build.xml java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Author: myrnavl
Date: Wed Mar 26 22:15:09 2014
New Revision: 1582087

URL: http://svn.apache.org/r1582087
Log:
DERBY-6468; Add a version number to derbyTesting.jar
   backport of revision 1581885 from trunk to 10.10

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/build.xml
    db/derby/code/branches/10.10/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1581885

Modified: db/derby/code/branches/10.10/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/build.xml?rev=1582087&r1=1582086&r2=1582087&view=diff
==============================================================================
--- db/derby/code/branches/10.10/build.xml (original)
+++ db/derby/code/branches/10.10/build.xml Wed Mar 26 22:15:09 2014
@@ -273,6 +273,7 @@
     <delete file="${out.dir}/org/apache/derby/info/tools.properties"/>
     <delete file="${out.dir}/org/apache/derby/info/net.properties"/>
     <delete file="${out.dir}/org/apache/derby/info/dnc.properties"/>
+    <delete file="${out.dir}/org/apache/derby/info/tsting.properties"/>
   </target>
 
   <!-- Set the ant variables which identify the compiler classpaths. -->
@@ -665,7 +666,7 @@
     <ant dir="${derby.demo.src.dir}" target="compile-vtidemo"/>
   </target>
 
-  <target name="testing" depends="buildsource,demo">
+  <target name="testing" depends="buildsource,demo,buildtestinginfo">
     <ant dir="${derby.testing.src.dir}"/>
   </target>
 	
@@ -1965,8 +1966,16 @@
 <!-- - - - - - - - - - - - derby testing jar target - - - - - - - - - - -->
 
   <target name="derbytestingjar" depends="initjars,ckderbytesting" if="derbyTesting.available">
+    <!-- generate tsting info property file -->
+    <antcall target="tstinginfowriter">
+      <param name="info.buildnumber" value="${changenumber}"/>
+      <param name="info.iname" value="tsting"/>
+      <param name="info.productfile" value="derbyTesting.jar"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/tsting.properties"/>
+    </antcall>
+
     <zip destfile="${derby.jar.dir}/derbyTesting.jar" filesonly="true" compress="true">
-      <fileset dir="${out.dir}" includes="org/apache/derbyTesting/**,SimpleApp*,org/apache/derby/impl/tools/ij/mt*.class,org/apache/derby/impl/tools/ij/SimpleCharStream.class,org/apache/derby/impl/drda/TestProto.class,org/apache/derby/impl/store/access/conglomerate/QualifierUtil.class,org/apache/derby/loc/m*_qq_PP_testOnly*,toursdb/*"/>
+      <fileset dir="${out.dir}" includes="org/apache/derbyTesting/**,SimpleApp*,org/apache/derby/impl/tools/ij/mt*.class,org/apache/derby/impl/tools/ij/SimpleCharStream.class,org/apache/derby/impl/drda/TestProto.class,org/apache/derby/impl/store/access/conglomerate/QualifierUtil.class,org/apache/derby/loc/m*_qq_PP_testOnly*,toursdb/*,org/apache/derby/info/tsting.properties"/>
     </zip>
   </target>
 
@@ -1975,6 +1984,29 @@
                property="derbyTesting.available"/>
   </target>
 
+  <target name="buildtestinginfo">
+    <antcall target="tstinginfowriter">
+      <param name="info.buildnumber" value="1"/>
+      <param name="info.iname" value="tsting"/>
+      <param name="info.productfile" value="derbyTesting.jar"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/tsting.properties"/>
+    </antcall>
+  </target>
+
+  <target name="tstinginfowriter">
+    <propertyfile file="${info.file}" comment="${copyright.comment}">
+      <entry key="derby.tsting.version.major" value="${major}"/>
+      <entry key="derby.tsting.version.minor" value="${minor}"/>
+      <entry key="derby.tsting.version.maint" value="${maint}"/>
+      <entry key="derby.tsting.build.number" value="${info.buildnumber}"/>
+      <entry key="derby.tsting.technology.name" value="${info.iname}"/>
+      <entry key="derby.tsting.external.name" value="${info.iname}"/>
+      <entry key="derby.version.beta" value="${beta}"/>
+      <entry key="derby.tsting.vendor" value="${vendor}"/>
+      <entry key="derby.product.file" value="${info.productfile}"/>
+    </propertyfile>
+  </target>
+
 <!-- - - - - - - - - - - -  jar build helper targets  - - - - - - - - - -->
 
   <target name="setsanityname" depends="init,setissane,sanitynamesane,sanitynameinsane"/>

Modified: db/derby/code/branches/10.10/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1582087&r1=1582086&r2=1582087&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/branches/10.10/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Wed Mar 26 22:15:09 2014
@@ -152,6 +152,16 @@ public static void getMainInfo (java.io.
       aw.println (Main.getTextMessage ("SIF01.Q"));
       aw.println (Main.getTextMessage ("SIF01.B"));
     }
+    
+    // derbyTesting info
+    try {
+        reportTesting(aw);
+    }
+    catch (Exception e) {
+        // ignore locales for the testing jar
+        aw.println("Exception in reporting version of derbyTesting.jar");
+        e.printStackTrace();
+    }
 
 
     if (pause) {
@@ -519,6 +529,82 @@ public static void getMainInfo (java.io.
 
   } // end of reportLocales
 
+  /**
+  Writes out information about the derbyTesting classes with the product.
+
+  @param localAW the AppStreamWriter to which the info is written. If this
+  value is null, the info is written to System.out
+
+   */
+  private static void reportTesting (java.io.PrintWriter localAW) {
+
+      String hdr="org.apache.derbyTesting.*:";
+      Properties p = new Properties ();
+      String tstingResource ="/org/apache/derby/info/tsting.properties";
+
+      final Properties finalp = p;
+      final String finalTstingResource = tstingResource;
+      try {
+          InputStream is = (InputStream) AccessController.doPrivileged
+                  (new PrivilegedAction() {
+                      public Object run() {
+                          InputStream is =
+                                  finalp.getClass().getResourceAsStream (finalTstingResource);
+                          return is;
+                      }
+                  });
+          if (is == null) {
+              //localAW.println("resource is null: " + tstingResource);
+          }
+          else {
+              try {
+                  p.clear();
+                  p.load (is);
+                  //Displaying Testing info
+                  //String tstingName = p.getProperty("derby.tsting.external.name");
+
+                  StringBuffer successes = new StringBuffer(Main.getTextMessage(crLf()));
+                  StringBuffer failures = new StringBuffer(crLf() + Main.getTextMessage("SIF08.E") + crLf());
+                  tryTstingClasspath(successes, failures);
+                  String successString = successes.toString();
+
+                  if (successString == null || successString.length()<=2)
+                  {
+                      // if we don't have the BaseTestCase class, assume we don't have any of the
+                      // testing classes, and just print nothing
+                      // this would be the situation that end-users would likely see.
+                      return;
+                  }
+
+                  // show the path and add brackets like we do for the core classes
+                  localAW.println(hdr);
+                  localAW.print("\t ");
+                  localAW.print("[");
+                  localAW.print(formatURL(new URL(successString)));
+                  localAW.println("]");
+                  // show the version info
+                  int major = Integer.parseInt(p.getProperty ("derby.tsting.version.major"));
+                  int minor = Integer.parseInt(p.getProperty ("derby.tsting.version.minor"));
+                  int maint = Integer.parseInt(p.getProperty ("derby.tsting.version.maint"));
+                  String build = p.getProperty ("derby.tsting.build.number");
+                  String lv = ProductVersionHolder.fullVersionString(major, minor, maint, false, build);
+                  localAW.println (Main.getTextMessage ("SIF01.S", lv));
+              } catch (IOException ioe) {
+                  //This case is a bit ugly. If we get an IOException, we return
+                  //null. Though this correctly reflects that the product is not
+                  //available for use, it may be confusing to users that we swallow
+                  //the IO error here.
+                  localAW.println("Could not get testing properties from : " + is);
+              }
+          }
+          localAW.println (sep);
+      }
+      catch (Throwable t) {
+          localAW.println ("Could not load resource: " + tstingResource);
+          localAW.println ("Exception: " + t);
+      }
+  } // end of reportTesting
+  
 	/* for arguments, choose from one of:*/
 	private static final String EMBEDDED = "embedded";
 
@@ -665,6 +751,10 @@ public static void getMainInfo (java.io.
 	private static void tryUtilsClasspath(StringBuffer successes, StringBuffer failures) {
 		tryMyClasspath("org.apache.derby.tools.ij", Main.getTextMessage("SIF08.Q", "derbytools.jar"), successes, failures);
 	}
+	
+	private static void tryTstingClasspath(StringBuffer successes, StringBuffer failures) {
+        tryMyClasspath("org.apache.derbyTesting.junit.BaseTestCase", "", successes, failures);
+    }
 
 	private static void tryMyClasspath(String cn, String library, StringBuffer successes, StringBuffer failures) {