diff --git a/openjpa-integration/validation/pom.xml b/openjpa-integration/validation/pom.xml
new file mode 100644
index 000000000..8d2edae9d
--- /dev/null
+++ b/openjpa-integration/validation/pom.xml
@@ -0,0 +1,281 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.openjpa
+ openjpa-integration
+ 2.0.0-SNAPSHOT
+
+
+ openjpa-integration-validation
+ jar
+ OpenJPA Integration Tests - Bean Validation
+ OpenJPA Integration Tests - Bean Validation
+
+
+ INFO
+
+ -Xmx500m
+ 10
+ 5
+ 2
+ 10000
+ MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}
+ org.apache.derby.jdbc.EmbeddedDriver
+ jdbc:derby:target/database/openjpa-derby-database;create=true
+
+
+
+
+
+
+
+ agimatec
+
+ true
+
+ agimatec
+
+
+
+
+
+ javax.validation
+ validation-api
+ 1.0.Beta4
+
+ test
+
+
+ com.agimatec
+ agimatec-jsr303
+ 0.9.0-SNAPSHOT
+ test
+
+
+ com.agimatec
+ agimatec-validation
+ 0.9.0-SNAPSHOT
+ test
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.8.0
+ test
+
+
+
+
+
+ dwoods.people.apache.org
+ dwoods Staging Repo
+ http://people.apache.org/~dwoods/staging-repo
+ default
+
+ true
+ daily
+ ignore
+
+
+ false
+
+
+
+
+
+
+
+ hibernate
+
+
+ hibernate
+
+
+
+
+
+ javax.validation
+ validation-api
+ 1.0.CR2
+
+ test
+
+
+ org.hibernate
+ hibernate-validator
+ 4.0.0.Beta1
+
+ test
+
+
+ org.slf4j
+ slf4j-api
+ 1.5.6
+ test
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.5.6
+ test
+
+
+
+
+ repository.jboss.org
+ JBoss Repository
+ http://repository.jboss.org/maven2
+ default
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+ org.apache.openjpa
+ openjpa
+ ${pom.version}
+
+
+ org.apache.openjpa
+ openjpa-persistence-jdbc
+ ${pom.version}
+ tests
+ test
+
+
+ commons-dbcp
+ commons-dbcp
+ test
+
+
+ org.apache.derby
+ derby
+ test
+
+
+ jakarta-regexp
+ jakarta-regexp
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ test-compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ ${test.jvm.arguments}
+
+
+ org/apache/openjpa/**/*Test.java
+
+
+ org/apache/openjpa/**/*$*.class
+ org/apache/openjpa/**/*.*.class
+
+
+
+ openjpa.Log
+ DefaultLevel=${openjpa.loglevel}
+
+
+ openjpa.ConnectionDriverName
+ org.apache.commons.dbcp.BasicDataSource
+
+
+ derby.stream.error.file
+ target/derby.log
+
+
+ derby.locks.deadlockTimeout
+ 5
+
+
+ derby.locks.waitTimeout
+ 6
+
+
+ openjpa.ConnectionProperties
+ DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}
+
+
+
+
+
+
+
diff --git a/openjpa-integration/validation/src/main/ant/enhancer.xml b/openjpa-integration/validation/src/main/ant/enhancer.xml
new file mode 100644
index 000000000..ac003bb1b
--- /dev/null
+++ b/openjpa-integration/validation/src/main/ant/enhancer.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ running enhancer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
new file mode 100644
index 000000000..069cb2479
--- /dev/null
+++ b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
@@ -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;
+ }
+}
+
diff --git a/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java
new file mode 100644
index 000000000..972f748d9
--- /dev/null
+++ b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationFactory.java
@@ -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 props = new HashMap();
+ 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 props = new HashMap();
+ 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 props = new HashMap();
+ 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");
+ }
+}
diff --git a/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml b/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
new file mode 100644
index 000000000..9385e8c78
--- /dev/null
+++ b/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ org.apache.openjpa.integration.validation.SimpleEntity
+
+
+
+ org.apache.openjpa.integration.validation.SimpleEntity
+ AUTO
+
+
+
+ org.apache.openjpa.integration.validation.SimpleEntity
+ CALLBACK
+
+
+
+ org.apache.openjpa.integration.validation.SimpleEntity
+ NONE
+
+
+