You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by dw...@apache.org on 2009/06/10 22:44:40 UTC

svn commit: r783503 - in /openjpa/trunk/openjpa-integration/validation: ./ src/ src/main/ src/main/ant/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/openjpa/ src/test/java/org/apache/openjpa/integration...

Author: dwoods
Date: Wed Jun 10 20:44:39 2009
New Revision: 783503

URL: http://svn.apache.org/viewvc?rev=783503&view=rev
Log:
OPENJPA-1106 Integration tests for Bean Validation providers - Part 1 (not hooked into the builds yet)

Added:
    openjpa/trunk/openjpa-integration/validation/
    openjpa/trunk/openjpa-integration/validation/pom.xml   (with props)
    openjpa/trunk/openjpa-integration/validation/src/
    openjpa/trunk/openjpa-integration/validation/src/main/
    openjpa/trunk/openjpa-integration/validation/src/main/ant/
    openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml   (with props)
    openjpa/trunk/openjpa-integration/validation/src/test/
    openjpa/trunk/openjpa-integration/validation/src/test/java/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java   (with props)
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java   (with props)
    openjpa/trunk/openjpa-integration/validation/src/test/resources/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml   (with props)

Added: openjpa/trunk/openjpa-integration/validation/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/pom.xml?rev=783503&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/pom.xml (added)
+++ openjpa/trunk/openjpa-integration/validation/pom.xml Wed Jun 10 20:44:39 2009
@@ -0,0 +1,281 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.   
+-->
+<!-- 
+    Maven release plugin requires the project tag to be on a single line. 
+-->
+<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>
+
+    <parent>
+        <groupId>org.apache.openjpa</groupId>
+        <artifactId>openjpa-integration</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>openjpa-integration-validation</artifactId>
+    <packaging>jar</packaging>
+    <name>OpenJPA Integration Tests - Bean Validation</name>
+    <description>OpenJPA Integration Tests - Bean Validation</description>
+
+    <properties>
+        <openjpa.loglevel>INFO</openjpa.loglevel>
+        <!-- to set debug arguments, you might set the following at the command line:
+            -Dtest.jvm.arguments="-Xmx500m -agentlib:jdwp=transport=dt_socket,server=y,address=8000"
+        -->
+        <test.jvm.arguments>-Xmx500m</test.jvm.arguments>
+        <dbcp.maxActive>10</dbcp.maxActive>
+        <dbcp.maxIdle>5</dbcp.maxIdle>
+        <dbcp.minIdle>2</dbcp.minIdle>
+        <dbcp.maxWait>10000</dbcp.maxWait>
+        <dbcp.args>MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}</dbcp.args>
+        <connection.driver.name>org.apache.derby.jdbc.EmbeddedDriver</connection.driver.name>
+        <connection.url>jdbc:derby:target/database/openjpa-derby-database;create=true</connection.url>
+        <connection.username />
+        <connection.password />
+    </properties>
+
+    <profiles>
+        <!-- Default profile for testing with Agimatec validation provider -->
+        <profile>
+            <id>agimatec</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+                <property>
+                    <name>agimatec</name>
+                </property>
+            </activation>
+            <dependencies>
+                <!-- See http://code.google.com/p/agimatec-validation/wiki/GettingStarted -->
+                <dependency>
+                    <groupId>javax.validation</groupId>
+                    <artifactId>validation-api</artifactId>
+                    <version>1.0.Beta4</version>
+                    <!-- <version>1.0.CR2</version> -->
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>com.agimatec</groupId>
+                    <artifactId>agimatec-jsr303</artifactId>
+                    <version>0.9.0-SNAPSHOT</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>com.agimatec</groupId>
+                    <artifactId>agimatec-validation</artifactId>
+                    <version>0.9.0-SNAPSHOT</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>commons-beanutils</groupId>
+                    <artifactId>commons-beanutils</artifactId>
+                    <version>1.8.0</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+            <repositories>
+                <repository>
+                    <!-- have to use a commiters home dir until released -->
+                    <id>dwoods.people.apache.org</id>
+                    <name>dwoods Staging Repo</name>
+                    <url>http://people.apache.org/~dwoods/staging-repo</url>
+                    <layout>default</layout>
+                    <snapshots>
+                        <enabled>true</enabled>
+                        <updatePolicy>daily</updatePolicy>
+                        <checksumPolicy>ignore</checksumPolicy>
+                    </snapshots>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                </repository>
+            </repositories>
+        </profile>
+
+        <!-- Default profile for testing with Derby and Bean Validation RI -->
+        <profile>
+            <id>hibernate</id>
+            <activation>
+                <property>
+                    <name>hibernate</name>
+                </property>
+            </activation>
+            <dependencies>
+                <!-- Latest matching BV RI versions from 20090427 -->
+                <dependency>
+                    <groupId>javax.validation</groupId>
+                    <artifactId>validation-api</artifactId>
+                    <version>1.0.CR2</version>
+                    <!-- <version>1.0.CR3-SNAPSHOT</version> -->
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.hibernate</groupId>
+                    <artifactId>hibernate-validator</artifactId>
+                    <version>4.0.0.Beta1</version>
+                    <!-- <version>4.0.0.Beta2-SNAPSHOT</version> -->
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                    <version>1.5.6</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                    <version>1.5.6</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+            <repositories>
+                <repository>
+                    <id>repository.jboss.org</id>
+                    <name>JBoss Repository</name>
+                    <url>http://repository.jboss.org/maven2</url>
+                    <layout>default</layout>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                </repository>
+                <!--
+                <repository>
+                    <id>snapshots.jboss.org</id>
+                    <name>JBoss Repository</name>
+                    <url>http://snapshots.jboss.org/maven2</url>
+                    <layout>default</layout>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                </repository>
+                -->
+            </repositories>
+        </profile>
+    </profiles>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-persistence-jdbc</artifactId>
+            <version>${pom.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>jakarta-regexp</groupId>
+            <artifactId>jakarta-regexp</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>test-compile</phase>
+                        <configuration>
+                            <tasks>                           
+                                <ant antfile="src/main/ant/enhancer.xml" target="enhance" inheritRefs="true">
+                                    <property name="maven.test.skip" value="${maven.test.skip}" />
+                                    <property name="test" value="${test}" />
+                                    <property name="outdir" value="${project.build.outputDirectory}" />
+                                    <property name="project.build.testOutputDirectory" value="${project.build.testOutputDirectory}" />
+                                    <property name="openjpa.loglevel" value="${openjpa.loglevel}" />
+                                    <property name="build.enhance" value="${build.enhance}" />
+                                </ant>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <argLine>${test.jvm.arguments}</argLine>
+                    <excludes>
+                        <!-- exclude classes that end with 'Test'; these 
+                             are not test cases per OpenJPA standards -->
+                        <exclude>org/apache/openjpa/**/*Test.java</exclude>
+
+                        <!-- exclude classes that include a $; inner classes
+                             are not test cases per OpenJPA standards -->
+                        <exclude>org/apache/openjpa/**/*$*.class</exclude>
+                        <exclude>org/apache/openjpa/**/*.*.class</exclude>
+                    </excludes>
+                    <systemProperties>
+                        <property>
+                            <name>openjpa.Log</name>
+                            <value>DefaultLevel=${openjpa.loglevel}</value>
+                        </property>
+                        <property>
+                            <name>openjpa.ConnectionDriverName</name>
+                            <value>org.apache.commons.dbcp.BasicDataSource</value>
+                        </property>
+                        <property>
+                            <name>derby.stream.error.file</name>
+                            <value>target/derby.log</value>
+                        </property>
+                        <property>
+                            <name>derby.locks.deadlockTimeout</name>
+                            <value>5</value>
+                        </property>
+                        <property>
+                            <name>derby.locks.waitTimeout</name>
+                            <value>6</value>
+                        </property>
+                        <property>
+                            <name>openjpa.ConnectionProperties</name>
+                            <value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: openjpa/trunk/openjpa-integration/validation/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml?rev=783503&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml (added)
+++ openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml Wed Jun 10 20:44:39 2009
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you 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.   
+-->
+<project name="enhance" basedir=".">
+    <!--
+        This build file executes the PCEnhancer on the test entities. It's in a
+        separate file instead of nested in pom.xml to make some conditional 
+        processing easier.
+        
+        Test classes will not be compiled if maven is invoked with 
+        -Dmaven.test.skip=true. 
+    -->
+
+    <condition property="maven.test.skip.istrue">
+        <istrue value="${maven.test.skip}" />
+    </condition>
+
+	<condition property="skip.enhance">
+		<or>
+        <equals arg1="${test}" arg2="false" />
+			<equals arg1="${build.enhance}" arg2="false" />
+			<istrue value="${maven.test.skip}" />
+			<istrue value="${skipTests}" />
+        </or>
+    </condition>
+
+    <!-- ================================= 
+          target: enhance              
+         ================================= -->
+    <target name="enhance"
+            description="--> run the enhancer unless test=false"
+            unless="skip.enhance">
+        <antcall target="enhance.all.entities"
+                 inheritall="true"
+                 inheritrefs="true" />
+    </target>
+
+    <!-- ================================= 
+          target: enhance.all.entities              
+         ================================= -->
+    <target name="enhance.all.entities"
+            description="--> enhance the test entities"
+            unless="skip.enhance">
+        <echo> running enhancer</echo>
+        <!-- 
+            Inherited references won't be present until the task is called. 
+            Therefore the path definition needs to stay inside the task.
+          -->
+        <path id="cp">
+            <path refid="maven.test.classpath" />
+        </path>
+
+        <taskdef name="openjpac"
+                 classname="org.apache.openjpa.ant.PCEnhancerTask">
+            <classpath refid="cp" />
+        </taskdef>
+
+        <fileset id="enhance.path.ref"
+                 dir="${project.build.testOutputDirectory}">
+            <include name="**/integration/validation/*.class" />
+            <exclude name="**/Test*.class" />
+            <exclude name="**/persistence/**/*.class" />
+            <exclude name="**/inheritance/serializable/*.class" />
+            <exclude name="**/xml/*.class" />
+            <exclude name="**/Unenhanced*.class" />
+            <exclude name="**/AbstractUnenhanced*.class" />
+            <exclude name="**/unenhanced/*.class" />
+        </fileset>
+        <openjpac>
+            <classpath refid="cp" />
+            <fileset refid="enhance.path.ref" />
+            <config log="DefaultLevel=${openjpa.loglevel}" />
+        </openjpac>
+    </target>
+</project>

Propchange: openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java?rev=783503&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java (added)
+++ openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java Wed Jun 10 20:44:39 2009
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.integration.validation;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.FieldResult;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedNativeQueries;
+import javax.persistence.NamedNativeQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+
+@NamedQueries( {
+    @NamedQuery(name="FindOne",
+            query="select s from simple s where s.name = ?1"),
+    @NamedQuery(name="FindAll", query="select s from simple s")
+})
+
+@NamedNativeQueries( { 
+    @NamedNativeQuery(name = "findSimpleEntitites",
+        query = "SELECT ID, NAME, VALUE FROM SIMPLE_ENTITY", 
+        resultSetMapping = "simpleEntitiesResult") })
+
+@SqlResultSetMapping(name = "simpleEntitiesResult",
+    entities = @EntityResult(
+    entityClass = org.apache.openjpa.integration.validation.SimpleEntity.class, 
+    fields = {@FieldResult(name = "id", column = "ID"),
+        @FieldResult(name = "name", column = "NAME"),
+        @FieldResult(name = "value", column = "VALUE") }))
+
+@Entity(name = "simple")
+@Table(name = "SIMPLE_ENTITY")
+public class SimpleEntity implements Serializable {
+
+    @Id
+    @GeneratedValue
+    @Column(name = "ID")
+    private long id;
+
+    @Basic
+    @Column(name = "NAME")
+    private String name;
+
+    @Basic
+    @Column(name = "VALUE")
+    private String value;
+
+    public SimpleEntity() {
+    }
+
+    public SimpleEntity(String name, String value) {
+        this();
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}
+

Propchange: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java?rev=783503&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java (added)
+++ openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java Wed Jun 10 20:44:39 2009
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you 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.integration.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.ValidationMode;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.integration.validation.SimpleEntity;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.test.AllowFailure;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * Tests the new Bean Validation Factory support in the JPA 2.0 spec.
+ * Basic (no provider) Validation scenarios being tested:
+ *   1) Mode of NONE will create a LifecycleEventManager
+ *   2) Mode of AUTO will create a ValidatingLifecycleEventManager
+ *   3) Mode of CALLBACK will create a ValidatingLifecycleEventManager
+ *   4) Verify passed in ValidatorFactory is used
+ * 
+ * @version $Rev$ $Date$
+ */
+public class TestValidationFactory extends SingleEMFTestCase {
+
+    @Override
+    public void setUp() {
+        super.setUp(CLEAR_TABLES, SimpleEntity.class);
+    }
+
+    /**
+     * Scenario being tested:
+     *   1) By default, ValidationFactory is null
+     */
+    public void testValidationFactory1() {
+        getLog().trace("testValidationFactory1() - Default is null");
+        OpenJPAEntityManagerFactory emf = null;
+
+        // create our EMF
+        emf = OpenJPAPersistence.createEntityManagerFactory(
+            "simple-none-mode",
+            "org/apache/openjpa/integration/validation/persistence.xml");
+        assertNotNull(emf);
+        // verify default validation mode
+        OpenJPAConfiguration conf = emf.getConfiguration();
+        assertNotNull(conf);
+        assertEquals("Default ValidationFactory", 
+            null,
+            conf.getValidationFactoryInstance());
+    }
+
+    /**
+     * Scenario being tested:
+     *   2) An invalid ValidationFactory with a mode of NONE will not
+     *      cause an exception
+     */
+    public void testValidationFactory2() {
+        getLog().trace("testValidationFactory2() - ignored invalid factory");
+        OpenJPAEntityManagerFactory emf = null;
+
+        // create the Map to test overrides
+        //   Just use current class object, as we have no provider to test with
+        Map<String,Object> props = new HashMap<String,Object>();
+        props.put("javax.persistence.validation.factory",
+            this.getClass());
+
+        // create our EMF
+        emf = OpenJPAPersistence.createEntityManagerFactory(
+            "simple-none-mode",
+            "org/apache/openjpa/integration/validation/persistence.xml",
+            props);
+        assertNotNull(emf);
+        // verify same "validation factory" object is returned
+        OpenJPAConfiguration conf = emf.getConfiguration();
+        assertNotNull(conf);
+        assertEquals("ValidationFactory", 
+            this.getClass(),
+            conf.getValidationFactoryInstance());
+    }
+
+    /**
+     * Scenario being tested:
+     *   3) An invalid ValidationFactory with a mode of AUTO will not
+     *      cause an exception
+     */
+    public void testValidationFactory3() {
+        getLog().trace("testValidationFactory3() - optional invalid factory");
+        OpenJPAEntityManagerFactory emf = null;
+
+        // create the Map to test overrides
+        //   Just use current class object, as we have no provider to test with
+        Map<String,Object> props = new HashMap<String,Object>();
+        props.put("javax.persistence.validation.factory",
+            this.getClass());
+
+        // create our EMF
+        emf = OpenJPAPersistence.createEntityManagerFactory(
+            "simple-auto-mode",
+            "org/apache/openjpa/integration/validation/persistence.xml",
+            props);
+        assertNotNull(emf);
+        // verify same "validation factory" object is returned
+        OpenJPAConfiguration conf = emf.getConfiguration();
+        assertNotNull(conf);
+        assertEquals("ValidationFactory", 
+            this.getClass(),
+            conf.getValidationFactoryInstance());
+    }
+
+    /**
+     * Scenario being tested:
+     *   4) An invalid ValidationFactory with a mode of CALLBACK will
+     *      cause an exception
+     */
+    @AllowFailure(message="This will fail until OPENJPA-1111 is resolved.")
+    public void testValidationFactory4() {
+        getLog().trace("testValidationFactory4() - required invalid factory");
+        OpenJPAEntityManagerFactory emf = null;
+
+        // create the Map to test overrides
+        //   Just use current class object, as we have no provider to test with
+        Map<String,Object> props = new HashMap<String,Object>();
+        props.put("javax.persistence.validation.factory",
+            this.getClass());
+        props.put("javax.persistence.validation.mode",
+            String.valueOf(ValidationMode.CALLBACK));
+
+        try {
+            // create our EMF
+            emf = OpenJPAPersistence.createEntityManagerFactory(
+                "simple-callback-mode",
+                "org/apache/openjpa/integration/validation/persistence.xml",
+                props);
+            assertNotNull(emf);
+            // verify validation mode
+            OpenJPAConfiguration conf = emf.getConfiguration();
+            assertNotNull(conf);
+            assertEquals("Validation mode", 
+                String.valueOf(ValidationMode.CALLBACK),
+                conf.getValidationMode());
+            fail("Expected an exception when ValidationMode=CALLBACK and " +
+                "an invalid ValidatorFactory is provided.");
+        } catch (Exception e) {
+            // expected
+            getLog().trace("testValidationFactory4() - caught expected " +
+                "exception", e);
+        }
+    }
+
+
+    /**
+     * Internal convenience method for getting the OpenJPA logger
+     * 
+     * @return
+     */
+    private Log getLog() {
+        return emf.getConfiguration().getLog("Tests");
+    }
+}

Propchange: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml?rev=783503&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml (added)
+++ openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml Wed Jun 10 20:44:39 2009
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.   
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    version="2.0">
+    
+    <persistence-unit name="simple">
+    	<class>org.apache.openjpa.integration.validation.SimpleEntity</class>
+    </persistence-unit>
+
+    <persistence-unit name="simple-auto-mode">
+    	<class>org.apache.openjpa.integration.validation.SimpleEntity</class>
+        <validation-mode>AUTO</validation-mode>
+    </persistence-unit>
+
+    <persistence-unit name="simple-callback-mode">
+    	<class>org.apache.openjpa.integration.validation.SimpleEntity</class>
+        <validation-mode>CALLBACK</validation-mode>
+    </persistence-unit>
+
+    <persistence-unit name="simple-none-mode">
+    	<class>org.apache.openjpa.integration.validation.SimpleEntity</class>
+        <validation-mode>NONE</validation-mode>
+    </persistence-unit>
+    
+</persistence>

Propchange: openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
------------------------------------------------------------------------------
    svn:eol-style = native