Search in sources :

Example 1 with ExecutionContextImpl

use of org.datanucleus.ExecutionContextImpl in project datanucleus-core by datanucleus.

the class FrequentlyAccessedPropertiesTest method testConfiguration.

@Test
public void testConfiguration() {
    Map<String, Object> props = new HashMap<String, Object>();
    props.put(PropertyNames.PROPERTY_DETACH_ON_CLOSE, "true");
    props.put(PropertyNames.PROPERTY_OPTIMISTIC, "true");
    props.put("datanucleus.storeManagerType", StoreManagerStub.class.getName());
    PersistenceNucleusContextImpl ctx = new PersistenceNucleusContextImpl(null, props) {

        private static final long serialVersionUID = 6287389368679465707L;

        @Override
        public synchronized void initialise() {
        }
    };
    Configuration conf = ctx.getConfiguration();
    Assert.assertFalse(conf.getFrequentProperties().getDetachAllOnCommit());
    Assert.assertTrue(conf.getFrequentProperties().getDetachOnClose());
    ExecutionContextImpl ec = new ExecutionContextImpl(ctx, null, new HashMap<String, Object>());
    Assert.assertTrue(ec.getTransaction().getOptimistic());
    ec.setProperty(PropertyNames.PROPERTY_OPTIMISTIC, "false");
    Assert.assertFalse(ec.getTransaction().getOptimistic());
    Assert.assertTrue(conf.getFrequentProperties().getOptimisticTransaction());
}
Also used : Configuration(org.datanucleus.Configuration) HashMap(java.util.HashMap) ExecutionContextImpl(org.datanucleus.ExecutionContextImpl) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Configuration (org.datanucleus.Configuration)1 ExecutionContextImpl (org.datanucleus.ExecutionContextImpl)1 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)1 Test (org.junit.Test)1