[Joafip-svn] SF.net SVN: joafip:[2978] trunk
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2011-11-22 06:53:37
|
Revision: 2978
http://joafip.svn.sourceforge.net/joafip/?rev=2978&view=rev
Author: luc_peuvrier
Date: 2011-11-22 06:53:30 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
added test for auto save
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java
Removed Paths:
-------------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -292,6 +292,8 @@
.toString();
assert objectAndPersistInfo.isLoaded() : objectAndPersistInfo
.toString();
+ assert persisted;
+ assert dataRecordIdentifier == null;
objectAndPersistInfo.setStorageInfo(storageInfo);
// objectIOManager.objectIsAccessed(objectAndPersistInfo);
// objectAndPersistInfo.setNewObject(true);
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -0,0 +1,38 @@
+package net.sf.joafip.entity.rel400;
+
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+public class BobForAutoSaveInMethodTest {
+
+ private final BobASHeld held;
+
+ private int value;
+
+ public BobForAutoSaveInMethodTest(final IInstanceFactory instanceFactory) {
+ super();
+ held = BobASHeld.newInstance(instanceFactory);
+ }
+
+ public static BobForAutoSaveInMethodTest newInstance(
+ final IInstanceFactory instanceFactory) {
+ final BobForAutoSaveInMethodTest newInstance;
+ if (instanceFactory == null) {
+ newInstance = new BobForAutoSaveInMethodTest(instanceFactory);
+ } else {
+ newInstance = (BobForAutoSaveInMethodTest) instanceFactory
+ .newInstance(BobForAutoSaveInMethodTest.class,
+ new Class<?>[] { IInstanceFactory.class },
+ new Object[] { instanceFactory });
+ }
+ return newInstance;
+ }
+
+ public void incrementValue() {
+ held.setOpened(true);
+ value++;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Deleted: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -1,44 +0,0 @@
-/*
- * Copyright 2010 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * 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 net.sf.joafip.entity.rel400;
-
-import net.sf.joafip.store.service.objectfortest.Bob1;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class BobForAutoSaveTest {
-
- private final int val;
-
- public BobForAutoSaveTest(final Bob1 bob1) {
- super();
- this.val = bob1.getVal();
- }
-
- public int getVal() {
- return val;
- }
-}
Copied: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java (from rev 2977, trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.entity.rel400;
+
+import net.sf.joafip.store.service.objectfortest.Bob1;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class BobForAutoSaveWhenConstructTest {
+
+ private final int val;
+
+ public BobForAutoSaveWhenConstructTest(final Bob1 bob1) {
+ super();
+ this.val = bob1.getVal();
+ }
+
+ public int getVal() {
+ return val;
+ }
+}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -34,7 +34,8 @@
import net.sf.joafip.entity.rel400.BobASDelegatingListenDelegate;
import net.sf.joafip.entity.rel400.BobASWithTransientCaller;
import net.sf.joafip.entity.rel400.BobAsDelegateNotifyDelegating;
-import net.sf.joafip.entity.rel400.BobForAutoSaveTest;
+import net.sf.joafip.entity.rel400.BobForAutoSaveInMethodTest;
+import net.sf.joafip.entity.rel400.BobForAutoSaveWhenConstructTest;
import net.sf.joafip.entity.rel400.KeyDef;
import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.service.FilePersistence;
@@ -115,6 +116,7 @@
filePersistence.maintainInMemorySetup(0);// zero to save at each access,
// needed by the test
filePersistence.setMaintainedInMemoryEnabled(true);
+ filePersistence.addToNotCheckMethod(Bob1.class);
session = filePersistence.createExclusiveDataAccessSession();
}
@@ -264,8 +266,8 @@
assertFalse("must not be loaded",
ProxyManager2.proxiedObjectIsLoaded(bob1));
saveDoneFlag = false;
- final BobForAutoSaveTest bobForAutoSaveTest = (BobForAutoSaveTest) instanceFactory
- .newInstance(BobForAutoSaveTest.class,
+ final BobForAutoSaveWhenConstructTest bobForAutoSaveTest = (BobForAutoSaveWhenConstructTest) instanceFactory
+ .newInstance(BobForAutoSaveWhenConstructTest.class,
new Class[] { Bob1.class }, new Object[] { bob1 });
assertTrue(MUST_SAVE, saveDoneFlag);
session.setObject(KEY, bobForAutoSaveTest);
@@ -503,6 +505,36 @@
assertFalse("must not has next", iterator.hasNext());
}
+ public void testAutoSaveInMethod() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException, ProxyException {
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+ session.open();
+ BobForAutoSaveInMethodTest bob = BobForAutoSaveInMethodTest
+ .newInstance(instanceFactory);
+ assertEquals("bad initial state", 0, bob.getValue());
+ saveDoneFlag = false;
+ int expectedIncrement = 1;
+ for (int count = 0; count < 5; count++) {
+ bob.incrementValue();
+ assertTrue(MUST_SAVE, saveDoneFlag);
+ assertTrue("must be unloaded", ProxyManager2.isUnloaded(bob));
+ assertEquals("bad state", expectedIncrement, bob.getValue());
+ expectedIncrement++;
+ }
+ session.setObject(KEY, bob);
+ session.close();
+
+ session.open();
+ bob = (BobForAutoSaveInMethodTest) session.getObject(KEY);
+ assertEquals("bad state", expectedIncrement - 1, bob.getValue());
+ session.close();
+
+ }
+
@Override
public boolean doSave() {
return true;
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -24,13 +24,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import net.sf.joafip.service.TestExportImport;
-import net.sf.joafip.service.TestExportObject;
-import net.sf.joafip.service.rel300.TestImport222;
-import net.sf.joafip.service.rel300.TestImport222NotLazy;
-import net.sf.joafip.service.rel301.TestImport300;
-import net.sf.joafip.service.rel310.TestImport301ConversionA;
-import net.sf.joafip.service.rel310.TestImport301ConversionB;
+import net.sf.joafip.store.service.TestGarbageForegroundFile;
+import net.sf.joafip.store.service.proxy.TestProxyCreationConstructed;
/**
*
@@ -47,13 +42,8 @@
public static Test suite() {
final TestSuite suite = new TestSuite("in error Tests");
// $JUnit-BEGIN$
- suite.addTestSuite(TestExportImport.class);
- suite.addTestSuite(TestExportObject.class);
- suite.addTestSuite(TestImport222.class);
- suite.addTestSuite(TestImport222NotLazy.class);
- suite.addTestSuite(TestImport300.class);
- suite.addTestSuite(TestImport301ConversionA.class);
- suite.addTestSuite(TestImport301ConversionB.class);
+ suite.addTestSuite(TestGarbageForegroundFile.class);
+ suite.addTestSuite(TestProxyCreationConstructed.class);
// suite.addTest(xxxx.suite());
// $JUnit-END$
return suite;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|