diff options
author | tle | 2009-08-25 22:28:36 +0000 |
---|---|---|
committer | tle | 2009-08-25 22:28:36 +0000 |
commit | 74ce2f15e24f056f792d0e23f12f57132dec9a3d (patch) | |
tree | 8057caae26758aaa62860a92a52ea0343860f310 /jpa/tests | |
parent | 6022827ad3b38c5a3a89541d238f84441be67ee6 (diff) | |
download | webtools.dali-74ce2f15e24f056f792d0e23f12f57132dec9a3d.tar.gz webtools.dali-74ce2f15e24f056f792d0e23f12f57132dec9a3d.tar.xz webtools.dali-74ce2f15e24f056f792d0e23f12f57132dec9a3d.zip |
Added convenience methods for testing Persistence Unit properties
Diffstat (limited to 'jpa/tests')
-rw-r--r-- | jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTestCase.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTestCase.java index 07d722d4f5..4e2e837544 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTestCase.java @@ -138,6 +138,17 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase }; } + /** + * Verify if the property exists in the pesistence.xml + */ + protected boolean propertyExists(String puPropertyName) { + return this.getPersistenceUnit().getProperty(puPropertyName) != null; + } + + protected boolean propertyValueEquals(String puPropertyName, String propertyValue) { + return this.getPersistenceUnit().getProperty(puPropertyName).getValue().equals(propertyValue); + } + // ****** verify PersistenceUnit properties ******* /** * Performs three value tests:<br> @@ -149,7 +160,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase assertEquals(expectedValue, subjectValue); assertEquals(expectedValue, aa.getValue()); if (expectedValue != null) { - assertEquals(expectedValue.toString(), this.getPersistenceUnit().getProperty(persistenceXmlKey).getValue()); + assertTrue("PersistenceUnit property value not equals", this.propertyValueEquals(persistenceXmlKey, expectedValue.toString())); } } @@ -163,7 +174,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase assertEquals(expectedValue, subjectValue); assertEquals(expectedValue, aa.getValue()); if (expectedValue != null) { - assertEquals(this.getPropertyStringValueOf(expectedValue), this.getPersistenceUnit().getProperty(puKey).getValue()); + assertTrue("PersistenceUnit property value not equals", this.propertyValueEquals(puKey, this.getPropertyStringValueOf(expectedValue))); } } @@ -195,7 +206,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(puKey); assertTrue("model.itemIsProperty() is false: ", getModel().itemIsProperty(property)); - assertEquals("PersistenceUnit not populated - populatedPu()", this.getPropertyStringValueOf(expectedValue), property.getValue()); + assertTrue("PersistenceUnit not populated - populatedPu()", this.propertyValueEquals(puKey, this.getPropertyStringValueOf(expectedValue))); String propertyName = this.getModel().propertyIdOf(property); Object modelValue = this.getProperty(propertyName); assertEquals( @@ -238,7 +249,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase this.clearEvent(); --this.propertiesTotal; --this.modelPropertiesSize; - assertNotNull("persistenceUnit.properties doesn't contains: " + puKey, this.getPersistenceUnit().getProperty(puKey)); + this.verifyPuHasProperty(puKey, "persistenceUnit.properties doesn't contains: "); this.getPersistenceUnit().removeProperty(puKey); assertNull(this.getPersistenceUnit().getProperty(puKey)); assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1); @@ -330,11 +341,11 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase } protected void verifyPuHasProperty(String puPropertyName, String msg) { - assertNotNull(msg + " - " + puPropertyName, this.getPersistenceUnit().getProperty(puPropertyName)); + assertTrue(msg + " - " + puPropertyName, this.propertyExists(puPropertyName)); } protected void verifyPuHasNotProperty(String puPropertyName, String msg) { - assertNull(msg + " - " + puPropertyName, this.getPersistenceUnit().getProperty(puPropertyName)); + assertFalse(msg + " - " + puPropertyName, this.propertyExists(puPropertyName)); } } |