openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r417860 [1/12] - in /incubator/openjpa/trunk: ./ openjpa-lib/ openjpa-lib/main/ openjpa-lib/src/ openjpa-lib/src/main/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/test/ openjpa-lib/src/test/java/ openjpa-lib/src/t...
Date Wed, 28 Jun 2006 19:46:19 GMT
Author: pcl
Date: Wed Jun 28 12:46:13 2006
New Revision: 417860

URL: http://svn.apache.org/viewvc?rev=417860&view=rev
Log:
added some openjpa-lib test, pom files, and serp fork. We may move the changes in serp back into the serp source tree and add a maven layout to serp, but for now, let's just get things rolling here.

Added:
    incubator/openjpa/trunk/openjpa-lib/pom.xml   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/
    incubator/openjpa/trunk/openjpa-lib/src/main/
      - copied from r417858, incubator/openjpa/trunk/openjpa-lib/main/
    incubator/openjpa/trunk/openjpa-lib/src/test/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties   (with props)
    incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties   (with props)
    incubator/openjpa/trunk/pom.xml   (with props)
    incubator/openjpa/trunk/serp/
    incubator/openjpa/trunk/serp/pom.xml   (with props)
    incubator/openjpa/trunk/serp/src/
    incubator/openjpa/trunk/serp/src/main/
    incubator/openjpa/trunk/serp/src/main/java/
    incubator/openjpa/trunk/serp/src/main/java/serp/
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCClass.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCClassLoader.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCEntity.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCField.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCMember.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/BCMethod.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ClassConstantInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ClassInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/CmpInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Code.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/CodeEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ConstantInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ConstantValue.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Constants.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ConvertInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Deprecated.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ExceptionHandler.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Exceptions.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/FieldInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/GetFieldInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IIncInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IfInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClass.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClasses.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Instruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtr.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtrStrategy.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/JumpInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumber.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumberTable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LoadInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Local.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalTable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalVariable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalVariableInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalVariableTable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalVariableType.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LocalVariableTypeTable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LookupSwitchInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MathInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MethodInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorEnterInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorExitInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MultiANewArrayInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NameCache.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NewArrayInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ObjectState.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PrimitiveState.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Project.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PutFieldInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/RetInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ReturnInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/SourceFile.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/StackInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/State.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/StoreInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/SwitchInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Synthetic.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/TableSwitchInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/TypedInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/UnknownAttribute.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/WideInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ClassEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ComplexEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPool.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPoolTable.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/DoubleEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/Entry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FieldEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FloatEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/IntEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/InterfaceMethodEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/LongEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/MethodEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/NameAndTypeEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/StringEntry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/UTF8Entry.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/package.html   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/package.html   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/BCVisitor.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/PrettyPrintVisitor.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/VisitAcceptor.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/package.html   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/util/
    incubator/openjpa/trunk/serp/src/main/java/serp/util/Numbers.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/util/Strings.java   (with props)
    incubator/openjpa/trunk/serp/src/main/java/serp/util/package.html   (with props)
    incubator/openjpa/trunk/serp/src/main/resources/
    incubator/openjpa/trunk/serp/src/test/
    incubator/openjpa/trunk/serp/src/test/java/
    incubator/openjpa/trunk/serp/src/test/java/serp/
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/AbstractStateTest.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestArray.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestArrayLoadInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestArrayStoreInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestAttributes.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestBCClass.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestCode.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestConstantInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestConvertInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestLoadInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestMathInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestNameCache.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestPrimitive.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestProject.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/TestStoreInstruction.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/lowlevel/
    incubator/openjpa/trunk/serp/src/test/java/serp/bytecode/lowlevel/TestConstantPool.java   (with props)
    incubator/openjpa/trunk/serp/src/test/java/serp/util/
    incubator/openjpa/trunk/serp/src/test/java/serp/util/TestStrings.java   (with props)
Removed:
    incubator/openjpa/trunk/openjpa-lib/main/
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/NoneConfigurationProvider.java

Added: incubator/openjpa/trunk/openjpa-lib/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/pom.xml?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/pom.xml (added)
+++ incubator/openjpa/trunk/openjpa-lib/pom.xml Wed Jun 28 12:46:13 2006
@@ -0,0 +1,113 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+		<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.openjpa</groupId>
+	<artifactId>openjpa-lib</artifactId>
+	<packaging>jar</packaging>
+
+	<name>Utilities</name>
+	<description>Utilities</description>
+	<url>http://incubator.apache.org/projects/openjpa</url>
+<parent>
+	
+		<groupId>org.apache.openjpa</groupId>
+		<artifactId>openjpa</artifactId>
+		<version>0.0.1</version>
+		
+	</parent>
+	<dependencies>
+	
+		<dependency>
+		
+			<groupId>org.apache.openjpa</groupId>
+			<artifactId>serp</artifactId>
+			<version>0.0.1</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.0.4</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.13</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.5</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.1</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>ant</groupId>
+			<artifactId>ant</artifactId>
+			<version>1.6.5</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>commons-collections</groupId>
+			<artifactId>commons-collections</artifactId>
+			<version>3.1</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>commons-pool</groupId>
+			<artifactId>commons-pool</artifactId>
+			<version>1.2</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		<dependency>
+		
+			<groupId>backport-util-concurrent</groupId>
+			<artifactId>backport-util-concurrent</artifactId>
+			<version>2.1</version>
+			<scope>compile</scope>
+			
+		</dependency>
+		
+	</dependencies>
+	<build>
+	
+		<plugins>
+		
+			<plugin>
+			
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+				<source>1.3</source>
+				<target>1.3</target>
+				</configuration>
+				
+			</plugin>
+			
+		</plugins>
+		
+	</build>
+	
+
+</project>

Propchange: incubator/openjpa/trunk/openjpa-lib/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import java.lang.Exception;
+import java.lang.System;
+
+
+/*
+        Millisecond (only) accuracy timer.
+        Java 1.4 supposedly has sun.misc.Perf.
+        Java 1.5 has System.nanoTime (JSR 166)
+*/
+public class Duration implements Cloneable {
+    private String _name;
+    private boolean _started;
+    private boolean _running;
+    private long _startTime; // millis
+    private long _stopTime; // millis
+
+    // NYI clock time of day at start
+    public Duration(String name) {
+        _name = name;
+        _started = false;
+        _running = false;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public synchronized void start() {
+        if (_started) {
+            throw new RuntimeException("Duration was already started.");
+        }
+
+        _startTime = System.currentTimeMillis();
+        _started = true;
+        _running = true;
+    }
+
+    public synchronized void stop() {
+        if (!_started) {
+            throw new RuntimeException("Duration was never started.");
+        }
+
+        if (!_running) {
+            throw new RuntimeException("Duration was already stopped.");
+        }
+
+        _stopTime = System.currentTimeMillis();
+        _running = false;
+    }
+
+    protected Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+    /*
+            Returns a new Duration object from a currently running timer
+            as a snapshot of this object.
+            The returned timer is stopped, while this object continue on.
+    */
+    public synchronized Duration getCurrentDuration() {
+        if (!_started) {
+            throw new RuntimeException("Duration was never started.");
+        }
+
+        if (!_running) {
+            throw new RuntimeException("Duration is not running.");
+        }
+
+        long now = System.currentTimeMillis();
+        Duration currentDuration;
+
+        try {
+            currentDuration = (Duration) this.clone();
+        } catch (Exception e) {
+            currentDuration = new Duration("");
+        }
+
+        currentDuration._stopTime = now;
+        currentDuration._running = false;
+
+        return currentDuration;
+    }
+
+    /* Obtain the duration that this timer has run (in seconds)        */
+    public synchronized double getDurationAsSeconds() {
+        if (!_started) {
+            throw new RuntimeException("Duration was never started.");
+        }
+
+        if (_running) {
+            // snapshot
+            Duration snapshot = getCurrentDuration();
+
+            return (1000.0 * (snapshot._stopTime - snapshot._startTime));
+        }
+
+        // Return a double value. Someday this class may make use of
+        // higher precision timing services (e.g. java 1.5)
+        return ((_stopTime - _startTime) / (double) 1000.0);
+    }
+
+    public synchronized boolean isRunning() {
+        return _running;
+    }
+
+    public synchronized boolean wasStarted() {
+        return _started;
+    }
+
+    public String toString() {
+        double time = 0.0;
+        StringBuffer buf = new StringBuffer(256);
+
+        if (wasStarted()) {
+            if (isRunning()) {
+                Duration snapshot = getCurrentDuration();
+                time = snapshot.getDurationAsSeconds();
+            } else {
+                time = getDurationAsSeconds();
+            }
+
+            buf.append("Duration for '" + _name + "' is " + time + " (s).");
+        } else {
+            buf.append("Duration for '" + _name +
+                "' has not yet been started.");
+        }
+
+        return buf.toString();
+    }
+
+    /* Example usage:
+               public static void main (String[] args)
+                    throws Exception
+            {
+                    Duration test = new Duration ("hello, count to 1 million");
+                    System.out.println (test);
+                    test.start ();
+                    for (int i = 0; i < 1000000000; i++)
+                            {
+                            }
+                    test.stop ();
+                    System.out.println (test);
+            }
+            */
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/Duration.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the {@link AbstractEventManager}.</p>
+ *
+ *  @author Abe White
+ */
+public class TestAbstractEventManager extends TestCase {
+    private EventManager _em = new EventManager();
+
+    public TestAbstractEventManager(String test) {
+        super(test);
+    }
+
+    public void testReentrantAdd() {
+        Listener l1 = new Listener(Listener.ADD);
+        Listener l2 = new Listener(Listener.NONE);
+        _em.addListener(l1);
+        _em.addListener(l2);
+        _em.fireEvent(new Object());
+        assertTrue(l1.fired);
+        assertTrue(l2.fired);
+        assertEquals(3, _em.getListeners().size());
+    }
+
+    public void testReentrantRemove() {
+        Listener l1 = new Listener(Listener.REMOVE);
+        Listener l2 = new Listener(Listener.NONE);
+        _em.addListener(l1);
+        _em.addListener(l2);
+        _em.fireEvent(new Object());
+        assertTrue(l1.fired);
+        assertTrue(l2.fired);
+        assertEquals(1, _em.getListeners().size());
+        assertFalse(_em.getListeners().contains(l1));
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestAbstractEventManager.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    private static class EventManager extends AbstractEventManager {
+        protected void fireEvent(Object event, Object listener) {
+            ((Listener) listener).fire();
+        }
+    }
+
+    private class Listener {
+        public static final int NONE = 0;
+        public static final int ADD = 1;
+        public static final int REMOVE = 2;
+        public boolean fired;
+        private final int _action;
+
+        public Listener(int action) {
+            _action = action;
+        }
+
+        public void fire() {
+            fired = true;
+
+            if (_action == ADD) {
+                _em.addListener(new Listener(NONE));
+            } else if (_action == REMOVE) {
+                assertTrue(_em.removeListener(this));
+            }
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import org.apache.openjpa.lib.util.testlocalizer.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the Localizer.</p>
+ *
+ *  @author Abe White
+ */
+public class TestLocalizer extends TestCase {
+    private Localizer _locals = null;
+
+    public TestLocalizer(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        _locals = Localizer.forPackage(LocalizerTestHelper.class);
+    }
+
+    /**
+     *  Test getting a string for a class.
+     */
+    public void testForClass() {
+        assertEquals("value1", _locals.get("test.local1"));
+    }
+
+    /**
+     *  Test getting a string for a non-default locale.
+     */
+    public void testForLocale() {
+        Localizer locl = Localizer.forPackage(LocalizerTestHelper.class,
+                Locale.GERMANY);
+        assertEquals("value1_de", locl.get("test.local1"));
+    }
+
+    /**
+     *  Tests that if a locale is missing the system falls back to
+     *  the default.
+     */
+    public void testFallbackLocale() {
+        Localizer locl = Localizer.forPackage(LocalizerTestHelper.class,
+                Locale.FRANCE);
+        assertEquals("value1", locl.get("test.local1"));
+    }
+
+    /**
+     *  Tests that a null class accesses the localizer.properties file
+     *  for the top-level (no package).
+     */
+    public void testTopLevel() {
+        Localizer system = Localizer.forPackage(null);
+        assertEquals("systemvalue1", system.get("test.systemlocal"));
+    }
+
+    /**
+     *  Test that the message formatting works correctly.
+     */
+    public void testMessageFormat() {
+        assertEquals("value2 x sep y",
+            _locals.get("test.local2", new String[] { "x", "y" }));
+
+        // test that it treates single objects as single-element arrays
+        assertEquals("value2 x sep {1}", _locals.get("test.local2", "x"));
+    }
+
+    /**
+     *  Test that a {@link MissingResourceException} is thrown for missing
+     *  resource bundles.
+     */
+    public void testMissingBundle() {
+        Localizer missing = Localizer.forPackage(String.class);
+        assertEquals("foo.bar", missing.get("foo.bar"));
+
+        try {
+            missing.getFatal("foo.bar");
+            fail("No exception for fatal get on missing bundle.");
+        } catch (MissingResourceException mre) {
+        }
+    }
+
+    /**
+     *  Test that a {@link MissingResourceException} is thrown for missing
+     *  keys.
+     */
+    public void testMissingKey() {
+        assertEquals("foo.bar", _locals.get("foo.bar"));
+
+        try {
+            _locals.getFatal("foo.bar");
+            fail("No exception for fatal get on missing key.");
+        } catch (MissingResourceException mre) {
+        }
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestLocalizer.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestLocalizer.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import java.net.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the {@link MultiClassLoader}.</p>
+ *
+ *  @author Abe White
+ */
+public class TestMultiClassLoader extends TestCase {
+    private ClassLoader SYSTEM_LOADER = MultiClassLoader.class.getClassLoader();
+    private MultiClassLoader _loader = new MultiClassLoader();
+
+    public TestMultiClassLoader(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        _loader.addClassLoader(MultiClassLoader.THREAD_LOADER);
+        _loader.addClassLoader(SYSTEM_LOADER);
+    }
+
+    /**
+     *  Tests basic add/remove functionality.
+     */
+    public void testBasic() {
+        assertEquals(2, _loader.size());
+        assertTrue(!_loader.isEmpty());
+        assertTrue(_loader.getClassLoaders()[0] == SYSTEM_LOADER);
+        assertEquals(Thread.currentThread().getContextClassLoader(),
+            _loader.getClassLoaders()[1]);
+        assertTrue(_loader.getClassLoader(0) == SYSTEM_LOADER);
+        assertTrue(!_loader.addClassLoader(_loader.THREAD_LOADER));
+
+        FooLoader foo = new FooLoader();
+        assertTrue(_loader.addClassLoader(foo));
+        assertTrue(!_loader.addClassLoader(foo));
+        assertEquals(3, _loader.size());
+        assertEquals(foo, _loader.getClassLoaders()[2]);
+
+        assertTrue(_loader.removeClassLoader(_loader.THREAD_LOADER));
+        assertTrue(!_loader.removeClassLoader(_loader.THREAD_LOADER));
+        assertEquals(2, _loader.size());
+        assertTrue(_loader.getClassLoaders()[0] == SYSTEM_LOADER);
+        assertEquals(foo, _loader.getClassLoaders()[1]);
+
+        assertTrue(_loader.removeClassLoader(foo));
+        assertTrue(_loader.removeClassLoader(SYSTEM_LOADER));
+        assertTrue(_loader.isEmpty());
+
+        MultiClassLoader loader2 = new MultiClassLoader();
+        loader2.addClassLoader(MultiClassLoader.THREAD_LOADER);
+        loader2.addClassLoader(SYSTEM_LOADER);
+        assertTrue(_loader.addClassLoaders(loader2));
+        assertTrue(!_loader.addClassLoaders(loader2));
+
+        FooLoader foo2 = new FooLoader();
+        loader2.addClassLoader(foo);
+        loader2.addClassLoader(foo2);
+        assertTrue(_loader.addClassLoaders(1, loader2));
+
+        ClassLoader[] loaders = _loader.getClassLoaders();
+        assertTrue(loaders[0] == SYSTEM_LOADER);
+        assertEquals(Thread.currentThread().getContextClassLoader(), loaders[3]);
+        assertEquals(foo, loaders[1]);
+        assertEquals(foo2, loaders[2]);
+    }
+
+    /**
+      *  Test finding classes.
+     */
+
+    /*
+            public void testClassForName ()
+                    throws Exception
+            {
+                    assertEquals (MultiClassLoader.class,
+                            Class.forName (MultiClassLoader.class.getName (), true, _loader));
+                    assertTrue (_loader.removeClassLoader (SYSTEM_LOADER));
+                    assertTrue (_loader.removeClassLoader (MultiClassLoader.THREAD_LOADER));
+                    try
+                    {
+                            // have to switch classes here b/c other is now cached
+                            assertEquals (TestMultiClassLoader.class, Class.forName
+                                    (TestMultiClassLoader.class.getName (), true, _loader));
+                            fail ("System class laoder still working.");
+                    }
+                    catch (ClassNotFoundException cnfe)
+                    {
+                    }
+                    try
+                    {
+                            Class.forName ("foo", true, _loader);
+                            fail ("Somehow found 'foo'???");
+                    }
+                    catch (ClassNotFoundException cnfe)
+                    {
+                    }
+                    _loader.addClassLoader (new FooLoader ());
+                    assertEquals (Integer.class, Class.forName ("foo", true, _loader));
+            }
+    */
+
+    /**
+     *  Test finding resources.
+     */
+    public void testGetResource() {
+        assertNull(_loader.getResource("foo"));
+        _loader.addClassLoader(new FooLoader());
+        assertNotNull(_loader.getResource("foo"));
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestMultiClassLoader.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    private static final class FooLoader extends ClassLoader {
+        protected Class findClass(String name) throws ClassNotFoundException {
+            if ("foo".equals(name)) {
+                return Integer.class;
+            }
+
+            throw new ClassNotFoundException(name);
+        }
+
+        protected URL findResource(String name) {
+            try {
+                if ("foo".equals(name)) {
+                    return new URL("file:///dev/null");
+                }
+            } catch (Exception e) {
+            }
+
+            return null;
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestMultiClassLoader.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the {@link Options} type.</p>
+ *
+ *  @author Abe White
+ */
+public class TestOptions extends TestCase {
+    private Options _opts = null;
+    private String[] _args = new String[] {
+            "-int", "10", "-boolean", "-string", "STR,STR2", "-range1", "10,100",
+            "-range2", "10", "-fieldVal", "20", "-FieldVal2", "30",
+            "-inner.nullInner.range1", "10,100", "arg1", "arg2", "arg3"
+        };
+
+    public TestOptions(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        Properties defs = new Properties();
+        defs.setProperty("default", "value");
+        _opts = new Options(defs);
+        _args = _opts.setFromCmdLine(_args);
+    }
+
+    /**
+     *  Test command-line parsing.
+     */
+    public void testCmdLineParsing() {
+        assertEquals(3, _args.length);
+        assertEquals("arg1", _args[0]);
+        assertEquals("arg2", _args[1]);
+        assertEquals("arg3", _args[2]);
+
+        assertEquals("10", _opts.getProperty("int"));
+        assertEquals("true", _opts.getProperty("boolean"));
+        assertEquals("STR,STR2", _opts.getProperty("string"));
+        assertEquals("20", _opts.getProperty("fieldVal"));
+        assertEquals("30", _opts.getProperty("FieldVal2"));
+        assertEquals("10,100", _opts.getProperty("range1"));
+        assertEquals("10", _opts.getProperty("range2"));
+        assertEquals("10,100", _opts.getProperty("inner.nullInner.range1"));
+        assertEquals("value", _opts.getProperty("default"));
+
+        _args = _opts.setFromCmdLine(new String[] { "-default", "newValue" });
+        assertEquals(0, _args.length);
+        assertEquals("newValue", _opts.getProperty("default"));
+    }
+
+    /**
+     *  Tests the setting of option values into bean objects.
+     */
+    public void testSetObject() {
+        Inner inner = new Inner();
+        _opts.setInto(inner);
+
+        assertEquals(10, inner.getInt());
+        assertTrue(inner.getBoolean());
+        assertEquals("STR,STR2", inner.getString());
+        assertEquals(20, inner.fieldVal);
+        assertEquals(30, inner.fieldVal2);
+        assertEquals(10, inner.getRange1()[0]);
+        assertEquals(100, inner.getRange1()[1]);
+        assertEquals(10, inner.getRange2()[0]);
+        assertEquals(0, inner.getRange2()[1]);
+        assertEquals("value", inner.getDefault());
+
+        assertEquals(10, inner.getInner().getNullInner().getRange1()[0]);
+        assertEquals(100, inner.getInner().getNullInner().getRange1()[1]);
+
+        inner = new Inner();
+
+        Options opts = new Options();
+        opts.setProperty("inner", Inner2.class.getName());
+        opts.setInto(inner);
+        assertEquals(Inner2.class, inner.getInner().getClass());
+
+        inner = new Inner();
+        opts = new Options();
+        opts.setProperty("mixed", "STR,1");
+        opts.setInto(inner);
+        assertEquals(1, inner.getInt());
+        assertEquals("STR", inner.getString());
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestOptions.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    /**
+     *  Used internally for testing; must be public so Options can
+     *  construct it.
+     */
+    public static class Inner {
+        public int fieldVal = 0;
+        public int fieldVal2 = 0;
+        private int _int = 0;
+        private boolean _boolean = false;
+        private String _string = null;
+        private String _default = null;
+        private Inner _inner = null;
+        private Inner _nullInner = null;
+        private int[] _range1 = new int[2];
+        private int[] _range2 = new int[2];
+
+        public Inner() {
+        }
+
+        public int getInt() {
+            return _int;
+        }
+
+        public void setInt(int i) {
+            _int = i;
+        }
+
+        public boolean getBoolean() {
+            return _boolean;
+        }
+
+        public void setBoolean(boolean b) {
+            _boolean = b;
+        }
+
+        public String getString() {
+            return _string;
+        }
+
+        public void setString(String s) {
+            _string = s;
+        }
+
+        public String getDefault() {
+            return _default;
+        }
+
+        public void setDefault(String s) {
+            _default = s;
+        }
+
+        public int[] getRange1() {
+            return _range1;
+        }
+
+        public void setRange1(int min, int max) {
+            _range1[0] = min;
+            _range1[1] = max;
+        }
+
+        public int[] getRange2() {
+            return _range2;
+        }
+
+        public void setRange2(int min, int max) {
+            _range2[0] = min;
+            _range2[1] = max;
+        }
+
+        public void setMixed(String s, int i) {
+            _int = i;
+            _string = s;
+        }
+
+        public Inner getInner() {
+            if (_inner == null) {
+                _inner = new Inner();
+            }
+
+            return _inner;
+        }
+
+        public void setInner(Inner in) {
+            _inner = in;
+        }
+
+        public Inner getNullInner() {
+            return _nullInner;
+        }
+
+        public void setNullInner(Inner in) {
+            _nullInner = in;
+        }
+    }
+
+    /**
+     *  Used internally for testing; must be public so Options can
+     *  construct it.
+     */
+    public static class Inner2 extends Inner {
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestOptions.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+
+/**
+ *  <p>Tests the {@link ParameterTemplate} utility class.</p>
+ *
+ *  @author Abe White
+ */
+public class TestParameterTemplate extends TestCase {
+    private ParameterTemplate templ = new ParameterTemplate();
+
+    public TestParameterTemplate(String test) {
+        super(test);
+    }
+
+    public void testParameters() {
+        templ.append("{foo$${foo}bar{${bar}}biz baz$");
+        templ.append("{booz}booz${java.io.tmpdir}{ack}");
+
+        templ.setParameter("foo", "X");
+        templ.setParameter("bar", "Y");
+        templ.setParameter("booz", "Z");
+
+        String tmpdir = System.getProperty("java.io.tmpdir");
+        assertEquals("{foo$Xbar{Y}biz bazZbooz" + tmpdir + "{ack}",
+            templ.toString());
+
+        templ.clearParameters();
+        templ.setParameter("foo", "AA");
+        templ.setParameter("bar", "BB");
+        templ.setParameter("booz", "CC");
+        assertEquals("{foo$AAbar{BB}biz bazCCbooz" + tmpdir + "{ack}",
+            templ.toString());
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestParameterTemplate.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestParameterTemplate.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import org.apache.openjpa.lib.util.FormatPreservingProperties.*;
+
+import java.io.*;
+
+import java.util.*;
+
+
+// things to test:
+// - delimiters in keys
+// - escape chars, including \:, \= in files (as generated by Properties)
+// - unicode
+// - non-String keys / vals
+// - list() method behavior
+public class TestPropertiesParser extends TestCase {
+    public void testSimpleProperties() throws IOException {
+        StringBuffer buf = new StringBuffer();
+        buf.append("key: value\n");
+        buf.append("key2: value2"); // no EOL -- this is intentional
+
+        Properties p = toProperties(buf.toString());
+        assertProperties(new String[][] {
+                { "key", "value" },
+                { "key2", "value2" }
+            }, p);
+    }
+
+    public void testComments() throws IOException {
+        StringBuffer buf = new StringBuffer();
+        buf.append("# this is a comment\n");
+        buf.append(" # another one, with leading whitespace	\n");
+        buf.append(" 	# 	and more with interesting whitespace	\n");
+        buf.append("! and with a ! delimiter\n");
+        buf.append("! and with escape \t chars\n");
+        buf.append("#and a comment with no whitespace\n");
+
+        Properties p = toProperties(buf.toString());
+        assertEquals(0, p.size());
+    }
+
+    public void testMixedContent() throws IOException {
+        StringBuffer buf = new StringBuffer();
+        buf.append("# this is a comment\n");
+        buf.append(" # another one, with leading whitespace	\n");
+        buf.append("foo: bar#baz\n");
+        buf.append("! and with a ! delimiter\n");
+        buf.append("! and with escape \t chars\n");
+
+        Properties p = toProperties(buf.toString());
+        assertProperties(new String[][] {
+                { "foo", "bar#baz" }
+            }, p);
+    }
+
+    public void testMultiLineInput() throws IOException {
+        String s = "foo: bar\\\n" + "more line goes here";
+        Properties p = toProperties(s);
+        assertProperties(new String[][] {
+                { "foo", "barmore line goes here" }
+            }, p);
+    }
+
+    public void testEmptyLines() throws IOException {
+        Properties p = toProperties("\nfoo: bar\n\nbaz: val");
+        assertProperties(new String[][] {
+                { "foo", "bar" },
+                { "baz", "val" }
+            }, p);
+    }
+
+    public void testAddProperties() throws IOException {
+        // intentionally left out the trailing end line
+        String s = "foo: bar\nbaz: val";
+        Properties p = toProperties(s);
+        assertProperties(new String[][] {
+                { "foo", "bar" },
+                { "baz", "val" }
+            }, p);
+
+        p.put("new-key", "val1");
+        p.put("new-key-2", "val2");
+        p.put("another-new-key", "val3");
+        assertRoundTrip(s + "\nnew-key: val1\nnew-key-2: val2\n" +
+            "another-new-key: val3\n", p);
+    }
+
+    public void testAddAndMutateProperties() throws IOException {
+        // intentionally left out the trailing end line
+        Properties p = toProperties("foo: bar\nbaz: val");
+        assertProperties(new String[][] {
+                { "foo", "bar" },
+                { "baz", "val" }
+            }, p);
+
+        p.put("new-key", "new value");
+        p.put("foo", "barbar");
+        assertRoundTrip("foo: barbar\nbaz: val\nnew-key: new value\n", p);
+    }
+
+    public void testEscapedEquals() throws IOException {
+        Properties p = toProperties("foo=bar\\=WARN,baz\\=TRACE");
+        assertProperties(new String[][] {
+                { "foo", "bar=WARN,baz=TRACE" }
+            }, p);
+    }
+
+    public void testLineTypes() throws IOException {
+        StringBuffer buf = new StringBuffer();
+        buf.append("   !comment\n \t  \nname = no\n    " +
+            "#morec\tomm\\\nents\n\n  dog=no\\cat   \nburps    " +
+            ":\ntest=\ndate today\n\n\nlong\\\n   value=tryin \\\n " +
+            "gto\n4:vier\nvier     :4");
+
+        Properties p = toProperties(buf.toString());
+        assertProperties(new String[][] {
+                { "name", "no" },
+                { "ents", "" },
+                { "dog", "nocat   " },
+                { "burps", "" },
+                { "test", "" },
+                { "date", "today" },
+                { "longvalue", "tryin gto" },
+                { "4", "vier" },
+                { "vier", "4" },
+            }, p);
+    }
+
+    public void testSpecialChars() throws Throwable {
+        testSpecialChars(false, true);
+        testSpecialChars(true, true);
+        testSpecialChars(false, false);
+        testSpecialChars(true, false);
+    }
+
+    /**
+     *  Test that special characters work.
+     *
+     *  @param formattingProps  if true, test against the
+     *                           FormatPreservingProperties, otherwise test
+     *                           against a normal Properties instance (for
+     *                           validation of the test case).
+     *  @param value            whether to test the key or the value
+     */
+    public void testSpecialChars(boolean formattingProps, boolean value)
+        throws Throwable {
+        List valueList = new ArrayList(Arrays.asList(
+                    new String[] {
+                        "xxyy", "xx\\yy", "xx\nyy", "xx\\nyy", "xx\tyy",
+                        "xx\\tyy", "xx\ryy", "xx\\ryy", "xx\fyy", "xx\\fyy",
+                        "xx\r\n\\\t\r\t\nyy", "xx\\r\n\\\t\\r\t\\nyy",
+                        "xx\r\n\\\\\\\\\\\\\\\\\\\\\\\\\\\t\r\t\nyy",
+                        "C:\\Program Files\\Some Application\\OpenJPA\\My File.dat",
+                    }));
+
+        // also store every individual character
+        for (char c = 'a'; c < 'Z'; c++) {
+            valueList.add(new String(new char[] { c }));
+            valueList.add(new String(new char[] { c, '\\', c }));
+            valueList.add(new String(new char[] { '\\', c }));
+        }
+
+        String[] values = (String[]) valueList.toArray(new String[0]);
+
+        final String dummy = "XXX";
+
+        for (int i = 0; i < values.length; i++) {
+            // test special characters in either keys or values
+            String val = value ? values[i] : dummy;
+            String key = value ? dummy : values[i];
+
+            Properties p = formattingProps ? new FormatPreservingProperties()
+                                           : new Properties();
+
+            if (p instanceof FormatPreservingProperties) {
+                // set these properties so we behave the same way as
+                // java.util.Properties
+                ((FormatPreservingProperties) p).setDefaultEntryDelimiter('=');
+                ((FormatPreservingProperties) p).setAddWhitespaceAfterDelimiter(false);
+            }
+
+            p.setProperty(key, val);
+
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            p.store(out, null);
+
+            Properties copy = new Properties();
+            copy.setProperty(key, val);
+
+            ByteArrayOutputStream copyOut = new ByteArrayOutputStream();
+            copy.store(copyOut, null);
+
+            p = formattingProps ? new FormatPreservingProperties()
+                                : new Properties();
+
+            InputStream in = new BufferedInputStream(new ByteArrayInputStream(
+                        out.toByteArray()));
+
+            try {
+                // make sure that the 2 properties serialized are the same
+                String copyOutString = stripComments(copyOut.toByteArray());
+                String outString = stripComments(out.toByteArray());
+                assertEquals(copyOutString, outString);
+
+                p.load(in);
+
+                assertNotNull("Property \"" + key + "\" was null",
+                    p.getProperty(key));
+                assertEquals(val.trim(), p.getProperty(key).trim());
+            } catch (Throwable ioe) {
+                if (!formattingProps) {
+                    throw ioe;
+                }
+
+                // bug (1211, ioe,
+                // 	"Cannot store backslash in FormatPreservingProperties");
+                throw ioe;
+            }
+        }
+    }
+
+    static Character randomChar() {
+        char[] TEST_CHAR_ARRAY = new char[] {
+                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+                'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+                '1', '2', '3', '4', '5', '6', '7', '8', '9'
+            };
+
+        return new Character(TEST_CHAR_ARRAY[(int) (Math.random() * TEST_CHAR_ARRAY.length)]);
+    }
+
+    static String randomString(int len) {
+        StringBuffer buf = new StringBuffer();
+
+        for (int i = 0; i < ((int) (Math.random() * len) + 1); i++)
+            buf.append(randomChar());
+
+        return buf.toString();
+    }
+
+    public void testEquivalentStore() throws IOException {
+        Properties p1 = new Properties();
+        FormatPreservingProperties p2 = new FormatPreservingProperties();
+
+        ((FormatPreservingProperties) p2).setDefaultEntryDelimiter('=');
+        ((FormatPreservingProperties) p2).setAddWhitespaceAfterDelimiter(false);
+
+        String[] values = new String[] {
+                "x", "x\ny", "x\\ny", "x\ty", "x\\ty", "x\fy", "x\\fy", "x\ry",
+                "x\\ry", "C:\\Foo Bar\\Baz", randomString(5).replace('a', '\\'),
+                randomString(500).replace('a', '\\'),
+                randomString(5000).replace('a', '\\'),
+            };
+
+        for (int i = 0; i < values.length; i++) {
+            p1.clear();
+            p2.clear();
+
+            p1.setProperty("xxx", values[i]);
+            p2.setProperty("xxx", values[i]);
+
+            ByteArrayOutputStream out1 = new ByteArrayOutputStream();
+            ByteArrayOutputStream out2 = new ByteArrayOutputStream();
+
+            p1.store(out1, null);
+            p2.store(out2, null);
+
+            String s1 = new String(out1.toByteArray());
+            String s2 = new String(out2.toByteArray());
+
+            assertTrue("Expected <" + s1 + "> but was <" + s2 + ">",
+                s1.indexOf(s2) != -1);
+        }
+    }
+
+    static String stripComments(byte[] bytes) throws IOException {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                    new ByteArrayInputStream(bytes)));
+        StringBuffer sbuf = new StringBuffer();
+        String line;
+
+        while ((line = reader.readLine()) != null) {
+            // skip comments
+            if (line.trim().startsWith("#")) {
+                continue;
+            }
+
+            sbuf.append(line);
+            sbuf.append('\n');
+        }
+
+        return sbuf.toString();
+    }
+
+    public void testDuplicateProperties() throws IOException {
+        FormatPreservingProperties p = new FormatPreservingProperties();
+
+        try {
+            toProperties("foo=bar\nfoo=baz", p);
+            fail("expected duplicate keys to cause exception");
+        } catch (DuplicateKeyException e) {
+            // expected
+        }
+
+        // now test the expected behavior when duplicates are allowed.
+        p = new FormatPreservingProperties();
+        p.setAllowDuplicates(true);
+        toProperties("foo=bar\nfoo=baz", p);
+        assertProperties(new String[][] {
+                { "foo", "baz" }
+            }, p);
+    }
+
+    public void testMultipleLoads() throws IOException {
+        String props = "foo=bar\nbaz=quux";
+        String props2 = "a=b\nc=d";
+        Properties vanilla = new Properties();
+        vanilla.load(new BufferedInputStream(new StringBufferInputStream(props)));
+        vanilla.load(new BufferedInputStream(
+                new StringBufferInputStream(props2)));
+
+        Properties p = new FormatPreservingProperties();
+        p.load(new BufferedInputStream(new StringBufferInputStream(props)));
+        p.load(new BufferedInputStream(new StringBufferInputStream(props2)));
+        assertPropertiesSame(vanilla, p);
+    }
+
+    protected FormatPreservingProperties toProperties(String s)
+        throws IOException {
+        return toProperties(s, new FormatPreservingProperties());
+    }
+
+    protected FormatPreservingProperties toProperties(String s,
+        FormatPreservingProperties p) throws IOException {
+        Properties vanilla = new Properties();
+        vanilla.load(new StringBufferInputStream(s));
+
+        p.load(new StringBufferInputStream(s));
+        assertRoundTrip(s, p);
+
+        assertPropertiesSame(vanilla, p);
+
+        return p;
+    }
+
+    private void assertRoundTrip(String s, Properties p)
+        throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        p.store(out, null);
+        assertEquals(s, out.toString());
+
+        // also check serializable
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        new ObjectOutputStream(bout).writeObject(p);
+
+        try {
+            FormatPreservingProperties deserialized = (FormatPreservingProperties) new ObjectInputStream(new ByteArrayInputStream(
+                        bout.toByteArray())).readObject();
+            assertEquals(p, deserialized);
+
+            out = new ByteArrayOutputStream();
+            deserialized.store(out, null);
+            assertEquals(s, out.toString());
+        } catch (ClassNotFoundException cnfe) {
+            fail(cnfe + "");
+        }
+    }
+
+    public static void assertEquals(String expected, String actual) {
+        if (expected == actual) {
+            return;
+        }
+
+        if ((expected == null) || !expected.equals(actual)) {
+            fail("Expected <" + expected + "> but was <" + actual + ">");
+        }
+    }
+
+    private void assertPropertiesSame(Properties vanilla, Properties p) {
+        assertEquals(vanilla, p);
+    }
+
+    protected void assertProperties(String[][] strings, Properties p) {
+        for (int i = 0; i < strings.length; i++)
+            assertEquals(strings[i][1], p.get(strings[i][0]));
+
+        assertEquals(strings.length, p.size());
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestPropertiesParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the {@link ReferenceHashSet}.</p>
+ *
+ *  @author Abe White
+ */
+public class TestReferenceSet extends TestCase {
+    private ReferenceHashSet _coll = new ReferenceHashSet(ReferenceHashSet.WEAK);
+    private Object _heldValue = new Integer(2);
+
+    public TestReferenceSet(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        _coll.add(_heldValue);
+        _coll.add(new Integer(1));
+    }
+
+    /**
+     *  Tests basic add/contains/remove functionality.
+     */
+    public void testBasics() {
+        Collection coll = new ReferenceHashSet(ReferenceHashSet.WEAK);
+        assertEquals(0, coll.size());
+        assertTrue(!coll.contains("foo"));
+
+        assertTrue(coll.add("foo"));
+        assertEquals(1, coll.size());
+        assertTrue(coll.contains("foo"));
+        assertEquals("foo", coll.iterator().next());
+
+        assertTrue(!coll.remove("bar"));
+        assertEquals(1, coll.size());
+        assertTrue(coll.remove("foo"));
+        assertEquals(0, coll.size());
+        assertTrue(coll.isEmpty());
+    }
+
+    /**
+     *  Test that values with strong references are not gc'd.
+     */
+    public void testHeldReference() {
+        if (JavaVersions.VERSION >= 5) {
+            return;
+        }
+
+        System.gc();
+        System.gc();
+        assertTrue(_coll.contains(_heldValue));
+    }
+
+    /**
+     *  Test that weak references are gc'd.
+      */
+    public void testWeakReference() {
+        if (JavaVersions.VERSION >= 5) {
+            return;
+        }
+
+        System.gc();
+        System.gc();
+        assertTrue(!_coll.contains(new Integer(1)));
+        assertEquals(1, _coll.size());
+
+        int size = 0;
+
+        for (Iterator itr = _coll.iterator(); itr.hasNext(); size++)
+            assertEquals(_heldValue, itr.next());
+
+        assertEquals(1, size);
+
+        // run a mutator method to ensure expired elements are removed
+        _coll.add("foo");
+        assertEquals(2, _coll.size());
+        assertTrue(_coll.contains("foo"));
+        assertTrue(_coll.contains(_heldValue));
+        assertTrue(!_coll.contains(new Integer(1)));
+    }
+
+    /**
+     *  Test that values that have been replaced aren't expired.
+     */
+    public void testChangeValue() {
+        if (JavaVersions.VERSION >= 5) {
+            return;
+        }
+
+        Object held = new Integer(1);
+        assertTrue(_coll.remove(held));
+        assertTrue(_coll.add(held));
+        System.gc();
+        System.gc();
+
+        // run a mutator to clear expired references
+        _coll.add("foo");
+        assertTrue(_coll.contains(held));
+    }
+
+    /**
+     *  Used to test inherited functionality.
+     */
+    private static final class Node {
+        public int hashCode() {
+            return 1;
+        }
+
+        public boolean equals(Object other) {
+            return true;
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestReferenceSet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+
+/**
+ *  <p>Tests simple regex for use in in-memory query execution.</p>
+ *
+ *  @author Greg Campbell
+ */
+public class TestSimpleRegex extends TestCase {
+    private boolean matchExpr(String target, String expr, boolean caseInsens) {
+        SimpleRegex re = new SimpleRegex(expr, caseInsens);
+
+        return re.matches(target);
+    }
+
+    public void testWildcards() {
+        assertTrue(matchExpr("Hello", "Hello", false));
+        assertFalse(matchExpr("Hello", "Bye", false));
+        assertFalse(matchExpr("Hello", "ByeBye", false));
+        assertFalse(matchExpr("Hello", "Hellooo", false));
+        assertFalse(matchExpr("Hello", "HHello", false));
+        assertTrue(matchExpr("Hello", "H.llo", false));
+        assertTrue(matchExpr("Hello", "Hell.*", false));
+        assertTrue(matchExpr("Yo Hello", ".*ello", false));
+        assertTrue(matchExpr("Hello", ".*ello", false));
+        assertTrue(matchExpr("Hello", ".*ell.*", false));
+        assertTrue(matchExpr("Hellow", ".*ell.*", false));
+        assertTrue(matchExpr("Hello", "Hel.*lo", false));
+        assertTrue(matchExpr("HelYolo", "Hel.*lo", false));
+        assertTrue(matchExpr("Hello", "H.*lo", false));
+        assertFalse(matchExpr("Hellowe", "H.*lo", false));
+        assertTrue(matchExpr("Hello", "h.*lo", true));
+        assertFalse(matchExpr("Hello", "h.*lo", false));
+        assertTrue(matchExpr("The quick brown fox jumped over the lazy dog",
+                "The .*brown.*dog", false));
+        assertTrue(matchExpr("The quick brown fox jumped over the lazy dog",
+                "The .*br.wn.*d.g", false));
+        assertTrue(matchExpr("the quick BRown fox jumped over the lazy dog",
+                "The .*br.wn.*d.g", true));
+        assertFalse(matchExpr("The quick brown fox jumped over the lazy dog",
+                "The .*brown.*dogg", false));
+        assertFalse(matchExpr("The quick brown fox jumped over the lazy dog",
+                "TThe .*brown.*dogg", false));
+
+        assertFalse(matchExpr("Yo Hellow", ".*ello", false));
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(TestSimpleRegex.class);
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestSimpleRegex.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import java.util.*;
+
+
+public class TestTemporaryClassLoader extends TestCase {
+    public void testTemporaryClassLoader() throws Exception {
+        Set s = new HashSet();
+
+        for (int i = 0; i < 2; i++) {
+            ClassLoader loader = new TemporaryClassLoader(getClass()
+                                                              .getClassLoader());
+            Class cls = Class.forName("org.apache.openjpa.lib.util.TempClass",
+                    true, loader);
+            s.add(cls);
+            assertEquals(loader, cls.getClassLoader());
+            assertEquals(i + 1, s.size());
+        }
+    }
+}
+
+
+class TempClass {
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTemporaryClassLoader.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+
+/**
+ *  <p>Tests the {@link TypedProperties} type.</p>
+ *
+ *  @author Abe White
+ */
+public class TestTypedProperties extends TestCase {
+    private TypedProperties _props = null;
+    private TypedProperties _defs = null;
+
+    public TestTypedProperties(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        _props = new TypedProperties();
+        _props.setProperty("bool", "true");
+        _props.setProperty("int", "1");
+        _props.setProperty("long", "2");
+        _props.setProperty("float", "1.1");
+        _props.setProperty("double", "2.2");
+
+        _defs = new TypedProperties(_props);
+    }
+
+    /**
+     *  Tests basic typed gets.
+     */
+    public void testTypes() {
+        assertTrue(_props.getBooleanProperty("bool"));
+        assertEquals(1, _props.getIntProperty("int"));
+        assertEquals(2L, _props.getLongProperty("long"));
+        assertEquals(1.1F, _props.getFloatProperty("float"), 0.01F);
+        assertEquals(2.2D, _props.getDoubleProperty("double"), 0.01D);
+        assertEquals("2.2", _props.getProperty("double"));
+    }
+
+    /**
+     *  Tests the defaults returned for missing keys.
+     */
+    public void testNoDefaults() {
+        assertTrue(!_props.getBooleanProperty("bool2"));
+        assertEquals(0, _props.getIntProperty("int2"));
+        assertEquals(0L, _props.getLongProperty("long2"));
+        assertEquals(0F, _props.getFloatProperty("float2"), 0F);
+        assertEquals(0D, _props.getDoubleProperty("double2"), 0D);
+        assertEquals(null, _props.getProperty("double2"));
+    }
+
+    /**
+     *  Tests the defaults returned by keys found in the default
+     *  backing properties instance.
+     */
+    public void testDefaults() {
+        assertTrue(_defs.getBooleanProperty("bool"));
+        assertEquals(1, _defs.getIntProperty("int"));
+        assertEquals(2L, _defs.getLongProperty("long"));
+        assertEquals(1.1F, _defs.getFloatProperty("float"), 0.01F);
+        assertEquals(2.2D, _defs.getDoubleProperty("double"), 0.01D);
+        assertEquals("2.2", _defs.getProperty("double"));
+    }
+
+    /**
+     *  Tests that given defaults works.
+     */
+    public void testGivenDefaults() {
+        assertTrue(_props.getBooleanProperty("bool2", true));
+        assertEquals(1, _props.getIntProperty("int2", 1));
+        assertEquals(2L, _props.getLongProperty("long2", 2L));
+        assertEquals(1.1F, _props.getFloatProperty("float2", 1.1F), 0.01F);
+        assertEquals(2.2D, _props.getDoubleProperty("double2", 2.2D), 0.01D);
+        assertEquals("2.2", _props.getProperty("double2", "2.2"));
+
+        assertTrue(_defs.getBooleanProperty("bool", false));
+        assertEquals(1, _defs.getIntProperty("int", 2));
+        assertEquals(2L, _defs.getLongProperty("long", 3L));
+        assertEquals(1.1F, _defs.getFloatProperty("float", 2.2F), 0.01F);
+        assertEquals(2.2D, _defs.getDoubleProperty("double", 3.3D), 0.01D);
+        assertEquals("2.2", _defs.getProperty("double", "3.3"));
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestTypedProperties.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestTypedProperties.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util;
+
+import junit.framework.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Test UUID generation.</p>
+ *
+ *  @author Abe White
+ */
+public class TestUUIDGenerator extends TestCase {
+    public void testUniqueString() {
+        Set seen = new HashSet();
+
+        for (int i = 0; i < 1000; i++)
+            assertTrue(seen.add(UUIDGenerator.nextString()));
+    }
+
+    public void testUniqueHex() {
+        Set seen = new HashSet();
+
+        for (int i = 0; i < 1000; i++)
+            assertTrue(seen.add(UUIDGenerator.nextHex()));
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestUUIDGenerator.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.openjpa.lib.util.concurrent;
+
+import junit.framework.*;
+
+import junit.textui.*;
+
+import org.apache.openjpa.lib.util.*;
+
+import java.util.*;
+
+
+/**
+ *  <p>Tests the methods of {@link ConcurrentMap}.</p>
+ *
+ *  @author Abe White
+ */
+public class TestConcurrentMap extends TestCase {
+    private static final int ENTRIES = 333;
+    private static final int SLEEP = 3;
+    private ConcurrentMap[] _maps = new ConcurrentMap[] {
+            new ConcurrentHashMap(),
+            new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.HARD),
+        };
+
+    public void setUp() {
+        for (int i = 0; i < ENTRIES; i++) {
+            for (int j = 0; j < _maps.length; j++) {
+                int key = (j * ENTRIES) + i;
+                _maps[j].put(new Integer(key), "v" + key);
+            }
+        }
+    }
+
+    public void testRemoveRandom() {
+        Set keys = new TreeSet();
+
+        for (int i = 0; i < ENTRIES; i++)
+            for (int j = 0; j < _maps.length; j++)
+                assertTrue(removeRandom(_maps[j], keys));
+
+        postRemoveTest(keys);
+    }
+
+    private static boolean removeRandom(ConcurrentMap map, Set keys) {
+        Map.Entry rem = map.removeRandom();
+
+        return (rem != null) && rem.getValue().equals("v" + rem.getKey()) &&
+        keys.add(rem.getKey());
+    }
+
+    private void postRemoveTest(Set keys) {
+        for (int i = 0; i < _maps.length; i++) {
+            assertTrue(_maps[i].isEmpty());
+            assertTrue(!_maps[i].containsKey(new Integer((ENTRIES * i) + i)));
+        }
+
+        assertEquals(keys.toString(), ENTRIES * _maps.length, keys.size());
+    }
+
+    public synchronized void testRemoveRandomThreaded()
+        throws InterruptedException {
+        Set keys = Collections.synchronizedSet(new TreeSet());
+        RemoveRandomRunnable[] runs = new RemoveRandomRunnable[ENTRIES * _maps.length];
+
+        for (int i = 0; i < ENTRIES; i++)
+            for (int j = 0; j < _maps.length; j++)
+                runs[(j * ENTRIES) + i] = new RemoveRandomRunnable(_maps[j],
+                        keys);
+
+        for (int i = 0; i < runs.length; i++)
+            new Thread(runs[i]).start();
+
+        Thread.currentThread().sleep(SLEEP * ENTRIES * _maps.length);
+
+        for (int i = 0; i < runs.length; i++) {
+            assertTrue(String.valueOf(i), !runs[i].error);
+
+            if (runs[i].interrupted) {
+                throw new InterruptedException(String.valueOf(i));
+            }
+        }
+
+        postRemoveTest(keys);
+    }
+
+    public void testIterate() {
+        iterationTest(false);
+    }
+
+    private List iterationTest(boolean random) {
+        Set keys = new TreeSet();
+        List ordered = new ArrayList(200);
+
+        for (int i = 0; i < _maps.length; i++) {
+            Iterator itr = (random) ? _maps[i].randomEntryIterator()
+                                    : _maps[i].entrySet().iterator();
+
+            while (itr.hasNext()) {
+                Map.Entry entry = (Map.Entry) itr.next();
+                assertEquals("v" + entry.getKey(), entry.getValue());
+                assertTrue(keys + ":: " + _maps[i].getClass() + "::" +
+                    entry.getKey() + "::" + entry.getValue(),
+                    keys.add(entry.getKey()));
+                ordered.add(entry.getKey());
+            }
+        }
+
+        assertEquals(keys.toString(), ENTRIES * _maps.length, keys.size());
+
+        return ordered;
+    }
+
+    public void testRandomIterate() {
+        List l1 = iterationTest(true);
+        List l2 = iterationTest(true);
+        assertTrue(!l1.equals(l2));
+    }
+
+    private static class RemoveRandomRunnable implements Runnable {
+        public boolean error = false;
+        public boolean interrupted = false;
+        private final ConcurrentMap _map;
+        private final Set _keys;
+
+        public RemoveRandomRunnable(ConcurrentMap map, Set keys) {
+            _map = map;
+            _keys = keys;
+        }
+
+        public synchronized void run() {
+            try {
+                Thread.currentThread().sleep((long) (Math.random() * SLEEP));
+            } catch (InterruptedException ie) {
+                interrupted = true;
+            }
+
+            error = !removeRandom(_map, _keys);
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message