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 km...@apache.org on 2005/06/02 14:26:19 UTC

svn commit: r179584 - in /incubator/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/iapi/services/stream/ engine/org/apache/derby/impl/services/stream/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: kmarsden
Date: Thu Jun  2 05:26:18 2005
New Revision: 179584

URL: http://svn.apache.org/viewcvs?rev=179584&view=rev
Log:
DERBY-205 spin off - clean up handling of derby.stream.error properties
 
- Removed the (redundant) reading of these stream name properties from 
  NetworkServerControlImpl.java: 

            derby.stream.error.file 
derby.stream.error.method 
derby.stream.error.field 

- Modified DRDAConnThread.java to get the stream name via 
  Monitor.getStream().getName (a new method). DRDAConnThread was the 
  sole client and reason for the redundancy Kathey spotted. 
- Augmented HeaderPrintWriter interface with a new method, getName. 
- Augmented BasicHeaderPrintWriter to hold the stream name of the 
  error log. 
- Moved hard coded constants for the stream name attributes from 
  SingleStream.java to the Property interface and documented them there. 
- Removed the errorLogLocation field and the getErrorLogLocation from 
  NetworkServerControlImpl.java 
- Cleaned up some Javadoc for the items I touched. 

I have run derbyall with JDK1.4.2 on Solaris/x86. derbyall runs with 
errors, but the same errors are present on a clean checkout as well 

There are some additional changes to the sed file for the new 
errorstream test. Checking in all but the addition to the suite.

			contributed by Dag H. Wanvik


Added:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties   (with props)
Modified:
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Thu Jun  2 05:26:18 2005
@@ -5173,7 +5173,7 @@
 				if (severeExceptionInfo != null)
 				{
 					severeExceptionInfo += "(" + "server log:" +
-						server.getErrorLogLocation() + ")" ;
+                                           Monitor.getStream().getName() + ")" ;
 					sqlerrmc += separator + severeExceptionInfo;
 				}
 			}

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Thu Jun  2 05:26:18 2005
@@ -121,14 +121,6 @@
 	private final static int SQLERROR = 3;
 	private final static int SQLWARNING = 4;
 
-	private final static String
-		NETWORKSERVER_PROP_STREAM_ERROR_FIELD="derby.stream.error.field";
-
-	private final static String
-		NETWORKSERVER_PROP_STREAM_ERROR_METHOD="derby.stream.error.method";
-	private final static String
-		NETWORKSERVER_PROP_STREAM_ERROR_FILE="derby.stream.error.file";
-
 	private final static String DRDA_PROP_MESSAGES = "org.apache.derby.loc.drda.messages";
 	private final static String DRDA_PROP_DEBUG = "derby.drda.debug";
 	private final static String CLOUDSCAPE_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
@@ -253,8 +245,6 @@
 	private boolean cleanupOnStart = false;	// Should we clean up when starting the server?
 	private boolean restartFlag = false;
 
-	private String errorLogLocation = null;
-
 	//
 	// variables for a client command session
 	//
@@ -2506,28 +2496,6 @@
 		if (propval != null  && StringUtil.SQLEqualsIgnoreCase(propval, "true"))
 			debugOutput = true;
 
-		//RESOLVE: Need to clean this up. There should be just a
-		// server API call to get the log location
-		// Determine errror log location
-		propval = PropertyUtil.getSystemProperty(
-                      NetworkServerControlImpl.NETWORKSERVER_PROP_STREAM_ERROR_FIELD);
-		if (propval == null)
-			propval = PropertyUtil.getSystemProperty( 
-                          NetworkServerControlImpl.NETWORKSERVER_PROP_STREAM_ERROR_METHOD);
-		if (propval == null)
-		{
-			propval = PropertyUtil.getSystemProperty( 
-                          NetworkServerControlImpl.NETWORKSERVER_PROP_STREAM_ERROR_FILE);
-			if (propval == null)
-				propval = "derby.log";
-		}
-		File errorFile = new File(propval);
-		if (errorFile.isAbsolute())
-			errorLogLocation = errorFile.getPath();
-		else
-			errorLogLocation = (new File
-				(directory,propval)).getPath();
-		
 	}
 
 	/**
@@ -3269,11 +3237,6 @@
 			}
 		}
 		return retval;
-	}
-
-	public String getErrorLogLocation ()
-	{
-		return errorLogLocation;
 	}
 
 

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java Thu Jun  2 05:26:18 2005
@@ -74,6 +74,29 @@
 	*/
 	String LOG_SEVERITY_LEVEL = "derby.stream.error.logSeverityLevel";
 
+        /**
+		derby.stream.error.file=<absolute or relative error log filename>
+		Takes precendence over derby.stream.error.method.
+		Takes precendence over derby.stream.error.field
+	*/
+	
+	String ERRORLOG_FILE_PROPERTY = "derby.stream.error.file";
+
+        /**
+		derby.stream.error.method=
+			<className>.<methodName> returning an OutputStream or Writer object
+		Takes precendence over derby.stream.error.field
+	*/
+	
+	String ERRORLOG_METHOD_PROPERTY = "derby.stream.error.method";
+
+        /**
+		derby.stream.error.field=
+			<className>.<fieldName> returning an OutputStream or Writer object>
+	*/
+	
+	String ERRORLOG_FIELD_PROPERTY = "derby.stream.error.field";
+
 	/** 
 	derby.infolog.append={true,false}
 	<BR>

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java Thu Jun  2 05:26:18 2005
@@ -58,6 +58,11 @@
 	 */
 	public PrintWriter getPrintWriter();
 
+	/**
+	 * Gets the name of the wrapped writer or stream
+	 */
+	public String getName ();
+
 	/*
 	 * The routines that mimic java.io.PrintWriter...
 	 */

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java Thu Jun  2 05:26:18 2005
@@ -42,28 +42,44 @@
 
 	private final PrintWriterGetHeader headerGetter;
 	private final boolean canClose;
+	private final String name;
 
 	// constructors
 
 	/**
 	 * the constructor sets up the HeaderPrintWriter. 
 	 * <p>
-	 * @param writeTo		Where to write to.
+	 * @param writeTo       Where to write to.
 	 * @param headerGetter	Object to get headers for output lines.
+	 * @param canClose      If true, {@link #complete} will also close writeTo
+	 * @param streamName    Name of writeTo, e.g. a file name
 	 *
 	 * @see	PrintWriterGetHeader
 	 */
 	BasicHeaderPrintWriter(OutputStream writeTo,
-			PrintWriterGetHeader headerGetter,  boolean canClose){
+			PrintWriterGetHeader headerGetter,  boolean canClose, String streamName){
 		super(writeTo, true);
 		this.headerGetter = headerGetter;
 		this.canClose = canClose;
+		this.name = streamName;
 	}
+
+	/**
+	 * the constructor sets up the HeaderPrintWriter. 
+	 * <p>
+	 * @param writeTo       Where to write to.
+	 * @param headerGetter	Object to get headers for output lines.
+	 * @param canClose      If true, {@link #complete} will also close writeTo
+	 * @param writerName    Name of writeTo, e.g. a file name
+	 *
+	 * @see	PrintWriterGetHeader
+	 */
 	BasicHeaderPrintWriter(Writer writeTo,
-			PrintWriterGetHeader headerGetter, boolean canClose){
+			PrintWriterGetHeader headerGetter, boolean canClose, String writerName){
 		super(writeTo, true);
 		this.headerGetter = headerGetter;
 		this.canClose = canClose;
+		this.name = writerName;
 	}
 
 	/*
@@ -84,6 +100,15 @@
 	public PrintWriter getPrintWriter(){
 		return this;
 	}
+
+	public String getName(){
+		return name;
+	}
+
+	/**
+	 * Flushes stream, and optionally also closes it if constructed
+	 * with canClose equal to true.
+	 */
 
 	void complete() {
 		flush();

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java Thu Jun  2 05:26:18 2005
@@ -121,17 +121,9 @@
 	 */
 	private HeaderPrintWriter makeStream() {
 
-		StringBuffer propName = new StringBuffer("derby.stream.error.");
-
-		int prefixLength = propName.length();
-
 		// get the header
 		PrintWriterGetHeader header = makeHeader();
-
-		// get the stream
-		propName.setLength(prefixLength);
-		
-		HeaderPrintWriter hpw = makeHPW(propName, header);
+		HeaderPrintWriter hpw = makeHPW(header);
 
 		// If hpw == null then no properties were specified for the stream
 		// so use/create the default stream.
@@ -152,31 +144,23 @@
 		create a HeaderPrintWriter based on the header.
 		Will still need to determine the target type.
 	 */
-	private HeaderPrintWriter makeHPW(StringBuffer propPrefix,
-		PrintWriterGetHeader header) {
+	private HeaderPrintWriter makeHPW(PrintWriterGetHeader header) {
 
 		// the type of target is based on which property is used
 		// to set it. choices are file, method, field, stream
 
-		int prefixLength = propPrefix.length();
-
-		// looking for derby.stream.<name>.file=<path to file>
-		propPrefix.append("file");
-		String target = PropertyUtil.getSystemProperty(propPrefix.toString());
+		String target = PropertyUtil.
+                   getSystemProperty(Property.ERRORLOG_FILE_PROPERTY);
 		if (target!=null)
 			return makeFileHPW(target, header);
 
-		// looking for derby.stream.<name>.method=<className>.<methodName>
-		propPrefix.setLength(prefixLength);
-		propPrefix.append("method");
-		target = PropertyUtil.getSystemProperty(propPrefix.toString());
+		target = PropertyUtil.
+                   getSystemProperty(Property.ERRORLOG_METHOD_PROPERTY);
 		if (target!=null) 
 			return makeMethodHPW(target, header);
 
-		// looking for derby.stream.<name>.field=<className>.<fieldName>
-		propPrefix.setLength(prefixLength);
-		propPrefix.append("field");
-		target = PropertyUtil.getSystemProperty(propPrefix.toString());
+		target = PropertyUtil.
+                   getSystemProperty(Property.ERRORLOG_FIELD_PROPERTY);
 		if (target!=null) 
 			return makeFieldHPW(target, header);
 
@@ -217,7 +201,8 @@
 			return useDefaultStream(header, se);
 		}
 
-		return new BasicHeaderPrintWriter(new BufferedOutputStream(fos), header, true);
+		return new BasicHeaderPrintWriter(new BufferedOutputStream(fos), header,
+			true, streamFile.getPath());
 	}
 
 	private HeaderPrintWriter makeMethodHPW(String methodInvocation,
@@ -241,7 +226,8 @@
 				}
 
 				try {
-					return makeValueHPW(theMethod, theMethod.invoke((Object) null, new Object[0]), header);
+					return makeValueHPW(theMethod, theMethod.invoke((Object) null, 
+						new Object[0]), header, methodInvocation);
 				} catch (IllegalAccessException iae) {
 					t = iae;
 				} catch (IllegalArgumentException iarge) {
@@ -286,7 +272,8 @@
 				}
 
 				try {
-					return makeValueHPW(theField, theField.get((Object) null), header);
+					return makeValueHPW(theField, theField.get((Object) null), 
+						header, fieldAccess);
 				} catch (IllegalAccessException iae) {
 					t = iae;
 				} catch (IllegalArgumentException iarge) {
@@ -317,12 +304,12 @@
 	}
 
 	private HeaderPrintWriter makeValueHPW(Member whereFrom, Object value,
-		PrintWriterGetHeader header) {
+		PrintWriterGetHeader header, String name) {
 
 		if (value instanceof OutputStream)
-			 return new BasicHeaderPrintWriter((OutputStream) value, header, false);
+			 return new BasicHeaderPrintWriter((OutputStream) value, header, false, name);
 		else if (value instanceof Writer)
-			 return new BasicHeaderPrintWriter((Writer) value, header, false);
+			 return new BasicHeaderPrintWriter((Writer) value, header, false, name);
 		
 		HeaderPrintWriter hpw = useDefaultStream(header);
 
@@ -347,7 +334,7 @@
 	*/
 	private HeaderPrintWriter useDefaultStream(PrintWriterGetHeader header) {
 
-		return new BasicHeaderPrintWriter(System.err, header, false);
+		return new BasicHeaderPrintWriter(System.err, header, false, "System.err");
 	}
 
 	private HeaderPrintWriter useDefaultStream(PrintWriterGetHeader header, Throwable t) {

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out?rev=179584&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out Thu Jun  2 05:26:18 2005
@@ -0,0 +1,39 @@
+Test errorStream starting
+shutdown ok: XJ015:Derby system shutdown.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT Thread[main,5,main] java.io.FileNotFoundException: xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus-file-2.log (No such file or directory)
+----------------------------------------------------------------
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+ Booting Derby: xxxFILTERED_VERSIONxxx
+on database directory xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus-2 
+Database Class Loader started - derby.database.classpath=''
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+Shutting down instance xxxxFILTERED-UUIDxxxx
+----------------------------------------------------------------
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT Thread[main,5,main] java.lang.NoSuchMethodException: org.apache.derbyTesting.functionTests.tests.lang.errorStream.nonExistingGetStream()
+----------------------------------------------------------------
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+ Booting Derby: xxxFILTERED_VERSIONxxx
+on database directory xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus-4 
+Database Class Loader started - derby.database.classpath=''
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+Shutting down instance xxxxFILTERED-UUIDxxxx
+----------------------------------------------------------------
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT Thread[main,5,main] java.lang.NoSuchFieldException: nonExistingFieldStream
+----------------------------------------------------------------
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+ Booting Derby: xxxFILTERED_VERSIONxxx
+on database directory xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus-6 
+Database Class Loader started - derby.database.classpath=''
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT:
+Shutting down instance xxxxFILTERED-UUIDxxxx
+----------------------------------------------------------------
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+shutdown ok: XJ015:Derby system shutdown.
+Test errorStream finished successfully

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/errorStream.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude Thu Jun  2 05:26:18 2005
@@ -1,4 +1,5 @@
 # excluding resultsetStream.java because this test uses java.io.FileInputStream throughout the test
+# excluding TestErrorStreamTarget.java since it's not relevant for clients
 # excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported
 # excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561)
 # excluding statementJdbc20.java because this tests fetch_reverse throughout the test
@@ -6,6 +7,7 @@
 # excluding lang/updatableResultSet.java because changes are required in JCC Driver for this test to run correctly
 # excluding jdbcapi/rsgetXXXcolumnNames.java as it fails incorrectly, according to JDBC spec. Forwarding test case to JCC team.
 jdbcapi/resultsetStream.java
+lang/errorStream.java
 lang/scrollCursors2.java
 jdbcapi/batchUpdate.java
 jdbcapi/statementJdbc20.java

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude Thu Jun  2 05:26:18 2005
@@ -1,9 +1,11 @@
 # excluding resultsetStream.java because this test uses java.io.FileInputStream throughout the test
+# excluding TestErrorStreamTarget.java since it's not relevant for clients
 # excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported
 # excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561)
 # excluding statementJdbc20.java because this tests fetch_reverse throughout the test
 # excluding jdbcapi/testRelative.java because it is a new test that requires debugging with the IBM Driver
 jdbcapi/resultsetStream.java
+lang/errorStream.java
 lang/scrollCursors2.java
 jdbcapi/batchUpdate.java
 jdbcapi/statementJdbc20.java

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant?rev=179584&r1=179583&r2=179584&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant Thu Jun  2 05:26:18 2005
@@ -76,6 +76,7 @@
 emptyStatistics.sql
 errorCode.sql
 errorCode_app.properties
+errorStream_sed.properties
 fk_nonSPS.sql
 fk_nonSPS_derby.properties
 floattypes.sql

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java?rev=179584&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java Thu Jun  2 05:26:18 2005
@@ -0,0 +1,456 @@
+/*
+  Derby - Class org.apache.derbyTesting.functionTests.tests.lang.errorStream
+
+  Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+  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.lang;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+
+import org.apache.derby.tools.ij;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
+
+/*
+ * Partial test of semantics for the three derby.stream.error.* flags.
+ * See their description in the Tuning Guide. 
+ * Limitations:
+ *       - The test uses only OutputStream values for .field and .method
+ *         (not Writer, which is also allowed)
+ *       - Negative test don't exercise all ways to fail; the test uses
+ *         non-existence, but not non-accessability
+ *       - Tests precedence, but only for valid values (e.g. missing: "what if
+ *         non-existing file is specified AND also a method or field": 
+ *         Fallback should be System.err )
+ * 
+ */
+
+
+final class AssertException extends Exception 
+{
+   AssertException (String e) {
+      super(e);
+   };
+}
+
+public class errorStream
+{
+   private static String derbyHome;
+
+   private static Properties sysProps;
+   private static final String FILE_PROP   = "derby.stream.error.file";
+   private static final String METHOD_PROP = "derby.stream.error.method";
+   private static final String FIELD_PROP  = "derby.stream.error.field";
+
+   /*
+    * database names are constructed as <database>-<runNo>
+    */
+   private static final String database = "VombatusUrsinusHirsutus";
+
+   /* runNo keeps track of which run we are in: Derby is booted
+    * several times; once for each combination of properties we want
+    * to test the behavior of.
+    */ 
+   private static int runNo = 0;
+
+   /*
+    * File used when FILE_PROP is set, it maps to file
+    * <database>-file-<runNo>.log
+    */
+   private static File fileStreamFile;
+
+   /* see doc for getStream below */
+   private static OutputStream methodStream;
+   private static File methodStreamFile;
+
+   /*
+    * Field fieldStream used by Derby when FIELD_PROP is set, 
+    * so it needs to be public.  Maps to file <database>-field-<runNo>.log
+    */
+   public static OutputStream fieldStream;
+   private static File fieldStreamFile;
+
+
+   /*
+    * Method getStream used by Derby when METHOD_PROP
+    * is set.  Maps to file <database>-method-<runNo>.log
+    */
+   public static OutputStream getStream() {
+      return methodStream;
+   }
+
+   private static String makeStreamFilename(String type) {
+      return database + "-" + type + "-" + runNo + ".log";
+   }
+
+   private static String makeDatabaseName() {
+      return database + "-" + runNo;
+   }
+
+   private static void openStreams() throws IOException{
+
+      runNo += 1;
+
+      try {
+         fileStreamFile = new File(derbyHome, makeStreamFilename("file"));
+
+         methodStreamFile = new File(derbyHome, makeStreamFilename("method"));
+         methodStream = new FileOutputStream(methodStreamFile);
+
+         fieldStreamFile = new File(derbyHome, makeStreamFilename("field"));
+         fieldStream = new FileOutputStream(fieldStreamFile);
+
+      }
+      catch (IOException e) {
+         System.out.println("Could not open stream files");
+         throw e;
+      }
+   }
+
+
+   private static void closeStreams() throws IOException {
+      try {
+         methodStream.close();
+         fieldStream.close();
+      }
+      catch (IOException e) {
+         System.out.println("Could not close stream files");
+         throw e;
+      }
+   }
+
+
+   private static void assertEmpty(File f) throws AssertException, 
+                                                  IOException {
+      if ( ! (f.exists() && (f.length() == 0)) ) {
+         AssertException e = new AssertException("assertEmpty failed: : " + 
+                                                 f.getCanonicalPath());
+         throw e;
+      }
+   }
+
+
+   private static void assertNonEmpty(File f) throws AssertException, 
+                                                     IOException {
+      if ( ! f.exists() || (f.length() == 0) ) {
+         AssertException e = new AssertException("assertNonEmpty failed:" + 
+                                                 f.getCanonicalPath());
+         throw e;
+      }
+   }
+
+
+   private static void assertNonExisting(File f) throws AssertException, 
+                                                        IOException {
+      if ( f.exists() ) {
+         AssertException e = new AssertException("assertNonExisting failed: " + 
+                                                 f.getCanonicalPath());
+         throw e;
+      }
+   }
+
+
+   private static void resetProps () {
+      sysProps.remove(FILE_PROP);
+      sysProps.remove(METHOD_PROP);
+      sysProps.remove(FIELD_PROP);
+   }
+
+
+   private static void bootDerby () throws SQLException {
+      Properties attrs = new Properties();
+      attrs.setProperty("databaseName", makeDatabaseName());
+      attrs.setProperty("createDatabase", "create");
+      DataSource ds = TestUtil.getDataSource(attrs);
+      try {
+         Connection conn = ds.getConnection();
+         conn.close();
+      }
+      catch (SQLException e) {
+         System.out.println("Derby boot failed: " + ":" + 
+                            attrs.getProperty("databaseName"));
+         throw e;
+      }
+   }
+
+
+   private static void shutdownDerby () throws AssertException, SQLException {
+      Properties attrs = new Properties();
+      attrs.setProperty("databaseName", "");
+      attrs.setProperty("shutdownDatabase", "shutdown");
+      DataSource ds = TestUtil.getDataSource(attrs);
+      try {
+         Connection conn = ds.getConnection();
+         AssertException e = new AssertException("shutdown failed: " + 
+                                                 makeDatabaseName());
+         throw e;
+      }
+      catch (SQLException e) {
+         System.out.println("shutdown ok: " + e.getSQLState() + ":" + 
+                            e.getMessage());
+      }
+   }
+
+
+   private static void checkFile() throws AssertException, IOException, 
+                                          SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FILE_PROP, fileStreamFile.getCanonicalPath());
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonEmpty(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkWrongFile() throws AssertException, IOException, 
+                                               SQLException {
+      openStreams();
+
+      sysProps.put(FILE_PROP, 
+                   new File(derbyHome+"foo", // erroneous path
+                            makeStreamFilename("file")).getCanonicalPath());
+
+      bootDerby();
+      shutdownDerby();
+      
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkMethod() throws AssertException, IOException, 
+                                            SQLException  {
+      openStreams();
+
+      resetProps();
+      sysProps.put(METHOD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.getStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertNonEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkWrongMethod() throws AssertException, IOException, 
+                                                 SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(METHOD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.nonExistingGetStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkField() throws AssertException, IOException, 
+                                           SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FIELD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.fieldStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertNonEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkWrongField() throws AssertException, IOException, 
+                                                SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FIELD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.nonExistingFieldStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+   
+   private static void checkFileOverMethod() throws AssertException, IOException, 
+                                                    SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FILE_PROP, fileStreamFile.getCanonicalPath());
+      sysProps.put(METHOD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.getStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonEmpty(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkFileOverField() throws AssertException, IOException, 
+                                                   SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FILE_PROP, fileStreamFile.getCanonicalPath());
+      sysProps.put(FIELD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.fieldStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonEmpty(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkFileOverMethodAndField() throws AssertException, 
+                                                            IOException, 
+                                                            SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(FILE_PROP, fileStreamFile.getCanonicalPath());
+      sysProps.put(METHOD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.getStream");
+      sysProps.put(FIELD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.fieldStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonEmpty(fileStreamFile);
+      assertEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   private static void checkMethodOverField() throws AssertException, IOException, 
+                                                     SQLException {
+      openStreams();
+
+      resetProps();
+      sysProps.put(METHOD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.getStream");
+      sysProps.put(FIELD_PROP, 
+                   "org.apache.derbyTesting.functionTests.tests.lang."+
+                   "errorStream.fieldStream");
+
+      bootDerby();
+      shutdownDerby();
+
+      closeStreams();
+
+      assertNonExisting(fileStreamFile);
+      assertNonEmpty(methodStreamFile);
+      assertEmpty(fieldStreamFile);
+   }
+
+
+   public static void main(String[] args)
+   {
+      try {
+         ij.getPropertyArg(args);
+         sysProps  = System.getProperties();
+         derbyHome = sysProps.getProperty("derby.system.home");
+
+         System.out.println("Test errorStream starting");
+
+         checkFile();
+         checkWrongFile();
+
+         checkMethod();
+         checkWrongMethod();
+
+         checkField();
+         checkWrongField();
+
+         checkFileOverMethod();
+         checkFileOverField();
+         checkFileOverMethodAndField();
+         
+         checkMethodOverField();
+
+         System.out.println("Test errorStream finished successfully");
+      }
+      catch (Exception e) {
+         System.out.println("Test errorStream failed: " + e.getMessage());
+         e.printStackTrace();
+      };
+   }
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties?rev=179584&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties Thu Jun  2 05:26:18 2005
@@ -0,0 +1,10 @@
+# Filters and substitutes for SED
+# Multiple patterns for DELETE: comma separated
+#   delete=pattern1,pattern2,...,patternn
+# No commas can be allowed in the patterns.
+#
+# Multiple patterns for SUBSTITUTE: comma separated <pattern;substitute> pair
+#   substitute=pattern1;substitute1,pattern2;substitute2,...,patternn;substituten
+# No commas or semicolons can be allowed in the patterns/subsitutes.
+---------------------------------------------------------------------------------
+substitute=Booting Derby.*;Booting Derby: xxxFILTERED_VERSIONxxx,FileNotFoundException: .*VombatusUrsinusHirsutus-file-2.log;FileNotFoundException: xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus-file-2.log,on database directory .*/VombatusUrsinusHirsutus;on database directory xxxFILTERED_PATHxxx/VombatusUrsinusHirsutus

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream_sed.properties
------------------------------------------------------------------------------
    svn:eol-style = native