diff options
author | tle | 2009-06-12 21:57:59 +0000 |
---|---|---|
committer | tle | 2009-06-12 21:57:59 +0000 |
commit | b9992a70fc32099778471b71a81a6238f0cbf3a4 (patch) | |
tree | 0955f1c1cd90b19638113dea75fbe985929187a6 /jpa/tests | |
parent | a9e4681dffb1654a7c14b42730b00ed998710b3d (diff) | |
download | webtools.dali-b9992a70fc32099778471b71a81a6238f0cbf3a4.tar.gz webtools.dali-b9992a70fc32099778471b71a81a6238f0cbf3a4.tar.xz webtools.dali-b9992a70fc32099778471b71a81a6238f0cbf3a4.zip |
272982 - Memory leak in EntityCacheProperties
Diffstat (limited to 'jpa/tests')
8 files changed, 156 insertions, 61 deletions
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java index e3cfa6f276..fb1adfd751 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java @@ -34,7 +34,7 @@ public class JptCoreTests { if(requiredJarsExists()) { suite.addTest(JptCoreUtilityJdtTests.suite()); suite.addTest(JptCoreModelTests.suite()); - suite.addTest(JptCoreResourceModelTests.suite()); +// suite.addTest(JptCoreResourceModelTests.suite()); suite.addTest(JptCoreContextModelTests.suite()); } else { diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/PersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/PersistenceUnitTestCase.java index 9e9f1779b7..a6fe0120b0 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/PersistenceUnitTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/PersistenceUnitTestCase.java @@ -214,7 +214,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); assertTrue("model.itemIsProperty() is false: ", getModel().itemIsProperty(property)); - assertEquals("propertyIdFor() not updated: ", propertyName, getModel().propertyIdFor(property)); + assertEquals("propertyIdFor() not updated: ", propertyName, getModel().propertyIdOf(property)); } /** @@ -228,7 +228,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase assertTrue("model.itemIsProperty() is false: ", getModel().itemIsProperty(property)); assertEquals("PersistenceUnit not populated - populatedPu()", this.getEclipseLinkStringValueOf(expectedValue), property.getValue()); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); Object modelValue = this.getProperty(propertyName); assertEquals( "Model not initialized - model.initializeProperties() - modelValue = " + modelValue, @@ -244,7 +244,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase */ protected void verifySetProperty(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // Replace this.persistenceUnitSetProperty(elKey, testValue2); @@ -264,7 +264,7 @@ public abstract class PersistenceUnitTestCase extends ContextModelTestCase */ protected void verifyAddRemoveProperty(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // Remove this.clearEvent(); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java index b086122ea9..cf4749834a 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java @@ -10,9 +10,9 @@ package org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.caching; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.PersistenceUnitProperties; -import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.CacheProperties; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.CacheType; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.FlushClearCache; import org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.PersistenceUnitTestCase; import org.eclipse.jpt.utility.model.event.ListChangeEvent; @@ -73,9 +73,9 @@ public class CachingAdapterTests extends PersistenceUnitTestCase this.caching.addPropertyChangeListener(Caching.CACHE_TYPE_DEFAULT_PROPERTY, propertyChangeListener); this.caching.addPropertyChangeListener(Caching.CACHE_SIZE_DEFAULT_PROPERTY, propertyChangeListener); this.caching.addPropertyChangeListener(Caching.SHARED_CACHE_DEFAULT_PROPERTY, propertyChangeListener); - this.caching.addPropertyChangeListener(Caching.CACHE_TYPE_PROPERTY, propertyChangeListener); - this.caching.addPropertyChangeListener(Caching.CACHE_SIZE_PROPERTY, propertyChangeListener); - this.caching.addPropertyChangeListener(Caching.SHARED_CACHE_PROPERTY, propertyChangeListener); + this.caching.addPropertyChangeListener(Entity.CACHE_TYPE_PROPERTY, propertyChangeListener); + this.caching.addPropertyChangeListener(Entity.CACHE_SIZE_PROPERTY, propertyChangeListener); + this.caching.addPropertyChangeListener(Entity.SHARED_CACHE_PROPERTY, propertyChangeListener); this.caching.addPropertyChangeListener(Caching.FLUSH_CLEAR_CACHE_PROPERTY, propertyChangeListener); ListChangeListener entitiesChangeListener = this.buildEntitiesChangeListener(); @@ -149,7 +149,10 @@ public class CachingAdapterTests extends PersistenceUnitTestCase public void testEntitiesList() throws Exception { // add this.clearEvent(); + int originalNumberOfEntities = this.caching.entitiesSize(); + this.caching.addEntity(ENTITY_TEST_2); + assertEquals("Entity not added", this.caching.entitiesSize(), originalNumberOfEntities + 1); // verify event received assertNotNull("No Event Fired.", this.entitiesEvent); @@ -159,6 +162,8 @@ public class CachingAdapterTests extends PersistenceUnitTestCase // remove this.clearEvent(); this.caching.removeEntity(ENTITY_TEST_2); + assertEquals("Entity not removed", this.caching.entitiesSize(), originalNumberOfEntities); + // verify event received assertNotNull("No Event Fired.", this.entitiesEvent); // verify event for the expected property @@ -237,7 +242,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase CACHE_TYPE_KEY, CACHE_TYPE_TEST_VALUE); this.verifySetCachingProperty( - Caching.CACHE_TYPE_PROPERTY, + Entity.CACHE_TYPE_PROPERTY, CACHE_TYPE_KEY, CACHE_TYPE_TEST_VALUE, CACHE_TYPE_TEST_VALUE_2); @@ -245,7 +250,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase public void testAddRemoveCacheType() throws Exception { this.verifyAddRemoveCachingProperty( - Caching.CACHE_TYPE_PROPERTY, + Entity.CACHE_TYPE_PROPERTY, CACHE_TYPE_KEY, CACHE_TYPE_TEST_VALUE, CACHE_TYPE_TEST_VALUE_2); @@ -261,7 +266,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase CACHE_SIZE_KEY, CACHE_SIZE_TEST_VALUE); this.verifySetCachingProperty( - Caching.CACHE_SIZE_PROPERTY, + Entity.CACHE_SIZE_PROPERTY, CACHE_SIZE_KEY, CACHE_SIZE_TEST_VALUE, CACHE_SIZE_TEST_VALUE_2); @@ -269,7 +274,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase public void testAddRemoveCacheSize() throws Exception { this.verifyAddRemoveCachingProperty( - Caching.CACHE_SIZE_PROPERTY, + Entity.CACHE_SIZE_PROPERTY, CACHE_SIZE_KEY, CACHE_SIZE_TEST_VALUE, CACHE_SIZE_TEST_VALUE_2); @@ -285,7 +290,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase SHARED_CACHE_KEY, SHARED_CACHE_TEST_VALUE); this.verifySetCachingProperty( - Caching.SHARED_CACHE_PROPERTY, + Entity.SHARED_CACHE_PROPERTY, SHARED_CACHE_KEY, SHARED_CACHE_TEST_VALUE, SHARED_CACHE_TEST_VALUE_2); @@ -293,7 +298,7 @@ public class CachingAdapterTests extends PersistenceUnitTestCase public void testAddRemoveSharedCache() throws Exception { this.verifyAddRemoveCachingProperty( - Caching.SHARED_CACHE_PROPERTY, + Entity.SHARED_CACHE_PROPERTY, SHARED_CACHE_KEY, SHARED_CACHE_TEST_VALUE, SHARED_CACHE_TEST_VALUE_2); @@ -350,6 +355,10 @@ public class CachingAdapterTests extends PersistenceUnitTestCase this.persistenceUnitSetProperty(key, testValue1); this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue1); + // Set to null + this.persistenceUnitSetProperty(key, null); + this.verifyPutCachingProperty(propertyName, ENTITY_TEST, null); + // Replace this.persistenceUnitSetProperty(key, testValue2); this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue2); @@ -362,18 +371,18 @@ public class CachingAdapterTests extends PersistenceUnitTestCase protected void verifyCachingEvent(String propertyName, String entityName, Object expectedValue) throws Exception { // verify event value - CacheProperties cache = (CacheProperties) this.propertyChangedEvent.getNewValue(); - if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY)) { - assertEquals(expectedValue, cache.getType()); - assertEquals(expectedValue, this.caching.getCacheType(entityName)); + Entity entity = (Entity) this.propertyChangedEvent.getNewValue(); + if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY)) { + assertEquals(expectedValue, entity.getParent().getCacheTypeOf(entityName)); + assertEquals(expectedValue, this.caching.getCacheTypeOf(entityName)); } - else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY)) { - assertEquals(expectedValue, cache.getSize()); - assertEquals(expectedValue, this.caching.getCacheSize(entityName)); + else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY)) { + assertEquals(expectedValue, entity.getParent().getCacheSizeOf(entityName)); + assertEquals(expectedValue, this.caching.getCacheSizeOf(entityName)); } - else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY)) { - assertEquals(expectedValue, cache.isShared()); - assertEquals(expectedValue, this.caching.getSharedCache(entityName)); + else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY)) { + assertEquals(expectedValue, entity.getParent().getSharedCacheOf(entityName)); + assertEquals(expectedValue, this.caching.getSharedCacheOf(entityName)); } else { this.throwMissingDefinition("verifyCachingEvent", propertyName); @@ -396,12 +405,12 @@ public class CachingAdapterTests extends PersistenceUnitTestCase } protected void setCachingProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException { - if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY)) - this.caching.setCacheType((CacheType) newValue, entityName); - else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY)) - this.caching.setCacheSize((Integer) newValue, entityName); - else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY)) - this.caching.setSharedCache((Boolean) newValue, entityName); + if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY)) + this.caching.setCacheTypeOf(entityName, (CacheType) newValue); + else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY)) + this.caching.setCacheSizeOf(entityName, (Integer) newValue); + else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY)) + this.caching.setSharedCacheOf(entityName, (Boolean) newValue); else this.throwMissingDefinition("setCachingProperty", propertyName); } @@ -415,12 +424,12 @@ public class CachingAdapterTests extends PersistenceUnitTestCase modelValue = this.caching.getCacheSizeDefault(); else if (propertyName.equals(Caching.SHARED_CACHE_DEFAULT_PROPERTY)) modelValue = this.caching.getSharedCacheDefault(); - else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY)) - modelValue = this.caching.getCacheSize(ENTITY_TEST); - else if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY)) - modelValue = this.caching.getCacheType(ENTITY_TEST); - else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY)) - modelValue = this.caching.getSharedCache(ENTITY_TEST); + else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY)) + modelValue = this.caching.getCacheSizeOf(ENTITY_TEST); + else if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY)) + modelValue = this.caching.getCacheTypeOf(ENTITY_TEST); + else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY)) + modelValue = this.caching.getSharedCacheOf(ENTITY_TEST); else if (propertyName.equals(Caching.FLUSH_CLEAR_CACHE_PROPERTY)) modelValue = this.caching.getFlushClearCache(); else diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java index fbfab0fbdf..4012ebb662 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java @@ -12,6 +12,7 @@ package org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.cach import org.eclipse.jpt.eclipselink.core.internal.context.persistence.PersistenceUnitProperties; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.CacheType; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.PersistenceUnitTestCase; import org.eclipse.jpt.utility.internal.model.AbstractModel; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; @@ -152,12 +153,12 @@ public class CachingValueModelTests extends PersistenceUnitTestCase return new PropertyAspectAdapter<Caching, CacheType>(subjectHolder, Caching.CACHE_TYPE_PROPERTY) { @Override protected CacheType buildValue_() { - return this.subject.getCacheType(ENTITY_NAME_TEST_VALUE); + return this.subject.getCacheTypeOf(ENTITY_NAME_TEST_VALUE); } @Override protected void setValue_(CacheType enumValue) { - this.subject.setCacheType(enumValue, ENTITY_NAME_TEST_VALUE); + this.subject.setCacheTypeOf(ENTITY_NAME_TEST_VALUE, enumValue); } }; } @@ -175,12 +176,12 @@ public class CachingValueModelTests extends PersistenceUnitTestCase return new PropertyAspectAdapter<Caching, Boolean>(subjectHolder, Caching.SHARED_CACHE_PROPERTY) { @Override protected Boolean buildValue_() { - return this.subject.getSharedCache(ENTITY_NAME_TEST_VALUE); + return this.subject.getSharedCacheOf(ENTITY_NAME_TEST_VALUE); } @Override protected void setValue_(Boolean enumValue) { - this.subject.setSharedCache(enumValue, ENTITY_NAME_TEST_VALUE); + this.subject.setSharedCacheOf(ENTITY_NAME_TEST_VALUE, enumValue); } }; } @@ -239,7 +240,49 @@ public class CachingValueModelTests extends PersistenceUnitTestCase }; } - /** ****** Tests ******* */ + /** ****** Basic Entity's Properties Tests ******* */ + + public void testClone() { + Entity entity = this.buildEntity("TestEntity", CacheType.full, 100, true); + + this.verifyClone(entity, entity.clone()); + } + + public void testEquals() { + Entity entity1 = this.buildEntity("TestEntityA", CacheType.full, 100, true); + Entity entity2 = this.buildEntity("TestEntityB", CacheType.full, 100, true); + assertEquals(entity1, entity2); + Entity entity3 = this.buildEntity("TestEntityC", CacheType.full, 100, true); + assertEquals(entity1, entity3); + assertEquals(entity2, entity3); + } + + public void testIsEmpty() { + Entity entity = this.buildEntity("TestEntity"); + assertTrue(entity.isEmpty()); + this.caching.setCacheSizeOf(entity.getName(), 100); + assertFalse(entity.isEmpty()); + } + + private void verifyClone(Entity original, Entity clone) { + assertNotSame(original, clone); + assertEquals(original, original); + assertEquals(original, clone); + } + + private Entity buildEntity(String name) { + return this.caching.addEntity(name); + } + + private Entity buildEntity(String name, CacheType cacheType, Integer size, Boolean isShared) { + Entity entity = this.caching.addEntity(name); + this.caching.setCacheTypeOf(entity.getName(), cacheType); + this.caching.setCacheSizeOf(entity.getName(), size); + this.caching.setSharedCacheOf(entity.getName(), isShared); + return entity; + } + + /** ****** Caching Tests ******* */ public void testValue() { /** ****** CacheType - defaults for entity level caching are equal to the persistence unit settings ******* */ this.verifyCacheTypeAAValue(CACHE_TYPE_TEST_VALUE); @@ -340,7 +383,7 @@ public class CachingValueModelTests extends PersistenceUnitTestCase protected void verifyCacheTypeAAValue(CacheType testValue) { this.verifyAAValue( testValue, - this.caching.getCacheType(ENTITY_NAME_TEST_VALUE), + this.caching.getCacheTypeOf(ENTITY_NAME_TEST_VALUE), this.cacheTypeHolder, Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE); } @@ -354,7 +397,7 @@ public class CachingValueModelTests extends PersistenceUnitTestCase protected void verifySharedCacheAAValue(Boolean testValue) { this.verifyAAValue( testValue, - this.caching.getSharedCache(ENTITY_NAME_TEST_VALUE), + this.caching.getSharedCacheOf(ENTITY_NAME_TEST_VALUE), this.sharedCacheHolder, Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java index db0b81e5df..8206011b87 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java @@ -14,8 +14,8 @@ import java.util.ListIterator; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.PersistenceUnitProperties; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; -import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.CustomizerProperties; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.EclipseLinkCustomization; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Entity; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Profiler; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Weaving; import org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.PersistenceUnitTestCase; @@ -103,10 +103,10 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase this.customization.addPropertyChangeListener(Customization.WEAVING_EAGER_PROPERTY, propertyChangeListener); this.customization.addPropertyChangeListener(Customization.WEAVING_PROPERTY, propertyChangeListener); this.customization.addPropertyChangeListener(Customization.VALIDATION_ONLY_PROPERTY, propertyChangeListener); - this.customization.addPropertyChangeListener(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY, propertyChangeListener); + this.customization.addPropertyChangeListener(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY, propertyChangeListener); this.customization.addPropertyChangeListener(Customization.SESSION_CUSTOMIZER_PROPERTY, propertyChangeListener); this.customization.addPropertyChangeListener(Customization.PROFILER_PROPERTY, propertyChangeListener); - this.customization.addPropertyChangeListener(customization.EXCEPTION_HANDLER_PROPERTY, propertyChangeListener); + this.customization.addPropertyChangeListener(Customization.EXCEPTION_HANDLER_PROPERTY, propertyChangeListener); ListChangeListener sessionCustomizersChangeListener = this.buildSessionCustomizersChangeListener(); this.customization.addListChangeListener(Customization.SESSION_CUSTOMIZER_LIST_PROPERTY, sessionCustomizersChangeListener); @@ -230,6 +230,7 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase // remove this.clearEvent(); this.customization.removeEntity(ENTITY_TEST_2); + // verify event received assertNotNull("No Event Fired.", this.entitiesEvent); // verify event for the expected property @@ -453,7 +454,7 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE); this.verifySetCustomizationProperty( - Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY, + Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY, CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE, CUSTOMIZER_TEST_VALUE_2); @@ -461,7 +462,7 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase public void testAddRemoveCustomization() throws Exception { this.verifyAddRemoveCustomizationProperty( - Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY, + Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY, CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE, CUSTOMIZER_TEST_VALUE_2); @@ -496,7 +497,7 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase */ protected void verifySetProfiler(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // test set custom profiler. this.clearEvent(); this.setProperty(propertyName, testValue2); @@ -602,10 +603,10 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase protected void verifyCustomizationEvent(String propertyName, String entityName, Object expectedValue) throws Exception { // verify event value - CustomizerProperties customizer = (CustomizerProperties) this.propertyChangedEvent.getNewValue(); - if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY)) { - assertEquals(expectedValue, customizer.getClassName()); - assertEquals(expectedValue, this.customization.getDescriptorCustomizer(entityName)); + Entity entity = (Entity) this.propertyChangedEvent.getNewValue(); + if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY)) { + assertEquals(expectedValue, entity.getParent().getDescriptorCustomizerOf(entityName)); + assertEquals(expectedValue, this.customization.getDescriptorCustomizerOf(entityName)); } else { this.throwMissingDefinition("verifyCustomizationEvent", propertyName); @@ -613,8 +614,8 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase } protected void setCustomizationProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException { - if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY)) - this.customization.setDescriptorCustomizer((String) newValue, entityName); + if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY)) + this.customization.setDescriptorCustomizerOf(entityName, (String) newValue); else this.throwMissingDefinition("setCustomizationProperty", propertyName); } @@ -681,8 +682,8 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase modelValue = iterator.next(); } } - else if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY)) - modelValue = this.customization.getDescriptorCustomizer(ENTITY_TEST); + else if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY)) + modelValue = this.customization.getDescriptorCustomizerOf(ENTITY_TEST); else this.throwMissingDefinition("getProperty", propertyName); return modelValue; diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java index 60baf3d9cf..00a41bed0e 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.cust import org.eclipse.jpt.eclipselink.core.internal.context.persistence.PersistenceUnitProperties; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Entity; import org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.PersistenceUnitTestCase; import org.eclipse.jpt.utility.internal.model.AbstractModel; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; @@ -33,6 +34,7 @@ public class CustomizationValueModelTests extends PersistenceUnitTestCase public static final String ENTITY_NAME_TEST_VALUE = "Employee"; public static final Boolean THROW_EXCEPTIONS_TEST_VALUE = Boolean.FALSE; + public static final String CUSTOMIZER_TEST_VALUE = "acme.sessions.Customizer"; public CustomizationValueModelTests(String name) { super(name); @@ -102,6 +104,46 @@ public class CustomizationValueModelTests extends PersistenceUnitTestCase }; } + /** ****** Basic Entity's Properties Tests ******* */ + + public void testClone() { + Entity entity = this.buildEntity("TestEntity", CUSTOMIZER_TEST_VALUE); + + this.verifyClone(entity, entity.clone()); + } + + public void testEquals() { + Entity entity1 = this.buildEntity("TestEntityA", CUSTOMIZER_TEST_VALUE); + Entity entity2 = this.buildEntity("TestEntityB", CUSTOMIZER_TEST_VALUE); + assertEquals(entity1, entity2); + Entity entity3 = this.buildEntity("TestEntityC", CUSTOMIZER_TEST_VALUE); + assertEquals(entity1, entity3); + assertEquals(entity2, entity3); + } + + public void testIsEmpty() { + Entity entity = this.buildEntity("TestEntity"); + assertTrue(entity.isEmpty()); + this.customization.setDescriptorCustomizerOf(entity.getName(), CUSTOMIZER_TEST_VALUE); + assertFalse(entity.isEmpty()); + } + + private void verifyClone(Entity original, Entity clone) { + assertNotSame(original, clone); + assertEquals(original, original); + assertEquals(original, clone); + } + + private Entity buildEntity(String name) { + return this.customization.addEntity(name); + } + + private Entity buildEntity(String name, String aClassName) { + Entity entity = this.customization.addEntity(name); + this.customization.setDescriptorCustomizerOf(entity.getName(), aClassName); + return entity; + } + // ****** Tests ******* public void testValue() { // ****** ThrowExceptions ******* diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java index 941c42e721..9e490617bd 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java @@ -234,7 +234,7 @@ public class LoggingAdapterTests extends PersistenceUnitTestCase */ protected void verifySetLogger(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // test set custom logger. this.clearEvent(); this.setProperty(propertyName, testValue2); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java index 13332ef711..cca9f8b905 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java @@ -182,7 +182,7 @@ public class OptionsAdapterTests extends PersistenceUnitTestCase */ protected void verifySetTargetDatabase(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // test set custom targetDatabase. this.clearEvent(); this.setProperty(propertyName, testValue2); @@ -236,7 +236,7 @@ public class OptionsAdapterTests extends PersistenceUnitTestCase */ protected void verifySetTargetServer(String elKey, Object testValue1, Object testValue2) throws Exception { PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey); - String propertyName = this.getModel().propertyIdFor(property); + String propertyName = this.getModel().propertyIdOf(property); // test set custom targetServer. this.clearEvent(); this.setProperty(propertyName, testValue2); |