aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSabine Heider2013-04-19 05:47:44 (EDT)
committertware2013-05-16 10:18:40 (EDT)
commit16d3cc4ebace0f8b999955533451d18307765853 (patch)
tree04d11fb6743f29e7b4e3ad298dcf2814a7626115
parent22c92c358c864f3b79d1cc762f20c13137fb36ce (diff)
downloadeclipselink.runtime-16d3cc4ebace0f8b999955533451d18307765853.zip
eclipselink.runtime-16d3cc4ebace0f8b999955533451d18307765853.tar.gz
eclipselink.runtime-16d3cc4ebace0f8b999955533451d18307765853.tar.bz2
Bug 406193 - Unused object-type-converter in XML mapping for JPA test
entity Mafioso Signed-off-by: Sabine Heider <sabine.heider@sap.com>
-rw-r--r--jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/advanced-multitenant-entity-mappings.xml1
-rw-r--r--jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/advanced-multitenant-entity-mappings.xml1
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/advanced/EntityMappingsMultitenantJUnitTestCase.java28
3 files changed, 18 insertions, 12 deletions
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/advanced-multitenant-entity-mappings.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/advanced-multitenant-entity-mappings.xml
index f6ee575..d802845 100644
--- a/jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/advanced-multitenant-entity-mappings.xml
+++ b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/advanced-multitenant-entity-mappings.xml
@@ -50,6 +50,7 @@
<basic name="firstName"/>
<basic name="lastName"/>
<basic name="gender">
+ <convert>gender</convert>
<object-type-converter name="gender" data-type="String" object-type="Mafioso$Gender">
<conversion-value data-value="F" object-value="Female"/>
<conversion-value data-value="M" object-value="Male"/>
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/advanced-multitenant-entity-mappings.xml b/jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/advanced-multitenant-entity-mappings.xml
index f6ee575..d802845 100644
--- a/jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/advanced-multitenant-entity-mappings.xml
+++ b/jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/advanced-multitenant-entity-mappings.xml
@@ -50,6 +50,7 @@
<basic name="firstName"/>
<basic name="lastName"/>
<basic name="gender">
+ <convert>gender</convert>
<object-type-converter name="gender" data-type="String" object-type="Mafioso$Gender">
<conversion-value data-value="F" object-value="Female"/>
<conversion-value data-value="M" object-value="Male"/>
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/advanced/EntityMappingsMultitenantJUnitTestCase.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/advanced/EntityMappingsMultitenantJUnitTestCase.java
index 0c094e2..c0038bb 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/advanced/EntityMappingsMultitenantJUnitTestCase.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/advanced/EntityMappingsMultitenantJUnitTestCase.java
@@ -21,38 +21,36 @@
******************************************************************************/
package org.eclipse.persistence.testing.tests.jpa.xml.advanced;
+import static org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Mafioso.Gender.Female;
+
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.NamedQuery;
-import javax.persistence.Persistence;
import javax.persistence.Query;
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.persistence.config.EntityManagerProperties;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.internal.helper.Helper;
-
import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
import org.eclipse.persistence.testing.framework.junit.JUnitTestCaseHelper;
-
-import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Candidate;
-import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Mason;
-import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Party;
-import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Riding;
-import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Supporter;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.AdvancedMultiTenantTableCreator;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Boss;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Candidate;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Capo;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Contract;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.MafiaFamily;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Mafioso;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Mafioso.Gender;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Mason;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Party;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Riding;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Soldier;
+import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Supporter;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Trowel;
import org.eclipse.persistence.testing.models.jpa.xml.advanced.multitenant.Underboss;
@@ -641,6 +639,12 @@ public class EntityMappingsMultitenantJUnitTestCase extends JUnitTestCase {
// Find our boss and make sure his name has not been compromised from the 707 family.
Boss boss = em.find(Boss.class, family007Mafiosos.get(0));
assertFalse("The Boss name has been compromised", boss.getFirstName().equals("Compromised"));
+
+ // Check if the conversion of the Gender enum values works
+ List result = em.createNativeQuery("SELECT GENDER FROM XML_MAFIOSO WHERE ID = " + boss.getId()).getResultList();
+ assertTrue("Boss with id = " + boss.getId() + " not found", result.size() == 1);
+ String genderFieldExpected = (boss.getGender() == Female) ? "F" : "M";
+ assertTrue("Gender value conversion failed, expected [" + genderFieldExpected + "] but got [" + result.get(0) + "]", genderFieldExpected.equals(result.get(0)) );
commitTransaction(em);
}