[CVS nanning] Added failing test-case for rollback, NAN-11
Jon Tirsen <[email protected]> Wed, 13 Aug 2003 05:46:05 -0500
| Newsgroups | gmane.comp.java.nanning.devel |
|---|---|
| Message-ID | <200308131046.h7DAk5K02794__22330.7487824515$1060771209@codehaus.org> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler</tt></b> on <span id="info">MAIN</span></td></tr>
<tr><td><tt><a href="#file1">MyObjectImpl.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr class="alt"><td><tt><a href="#file2">MySystem.java</a></tt></td><td align="right" id="added">+7</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">1.3 -> 1.4</td></tr>
<tr><td><tt><a href="#file3">MySystemImpl.java</a></tt></td><td align="right" id="added">+7</td><td></td><td nowrap="nowrap" align="center">1.3 -> 1.4</td></tr>
<tr class="alt"><td><tt><a href="#file4">PrevaylerTest.java</a></tt></td><td align="right" id="added">+58</td><td align="right" id="removed">-18</td><td nowrap="nowrap" align="center">1.5 -> 1.6</td></tr>
<tr><td></td><td align="right" id="added">+73</td><td align="right" id="removed">-21</td><td></td></tr>
</table>
<small id="info">4 modified files</small><br />
<pre class="comment">
Added failing test-case for rollback, NAN-11
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>MyObjectImpl.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- MyObjectImpl.java 4 Jul 2003 10:53:58 -0000 1.1
+++ MyObjectImpl.java 13 Aug 2003 10:46:05 -0000 1.2
@@ -3,7 +3,7 @@
</small></pre><pre class="diff" id="context"> import org.codehaus.nanning.prevayler.MyObject;
public class MyObjectImpl implements MyObject {
</pre><pre class="diff" id="removed">- private String value;
</pre><pre class="diff" id="added">+ private String value = "initialValue";
</pre><pre class="diff" id="context"> private MyObject myObject;
private boolean wasFinalized;
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>MySystem.java</b></big> <small id="info">1.3 -> 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- MySystem.java 11 Aug 2003 14:52:41 -0000 1.3
+++ MySystem.java 13 Aug 2003 10:46:05 -0000 1.4
@@ -23,13 +23,18 @@
</small></pre><pre class="diff" id="context">
/**
* @transaction
</pre><pre class="diff" id="removed">- */<span id="removedchars"> </span>
</pre><pre class="diff" id="added">+ */
</pre><pre class="diff" id="context"> void setSimpleString(String string);
String getSimpleString();
/**
* @transaction
</pre><pre class="diff" id="removed">- */<span id="removedchars"> </span>
</pre><pre class="diff" id="added">+ */
+ String changeAndReturnPreviousValue(PrevaylerTest.ObjectWithValue objectWithValue, String newValue);
+
+ /**
+ * @transaction
+ */
</pre><pre class="diff" id="context"> void add(Object o);
}
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>MySystemImpl.java</b></big> <small id="info">1.3 -> 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- MySystemImpl.java 11 Aug 2003 14:52:41 -0000 1.3
+++ MySystemImpl.java 13 Aug 2003 10:46:05 -0000 1.4
@@ -6,6 +6,7 @@
</small></pre><pre class="diff" id="context"> import java.util.List;
import org.codehaus.nanning.Aspects;
</pre><pre class="diff" id="added">+import org.codehaus.nanning.locking.SimpleMixinAspect;
</pre><pre class="diff" id="context"> import org.codehaus.nanning.prevayler.MyObject;
import org.codehaus.nanning.prevayler.MySystem;
</pre><pre class="diff"><small id="info">@@ -50,5 +51,11 @@
</small></pre><pre class="diff" id="context">
public void setSimpleString(String simpleString) {
this.simpleString = simpleString;
</pre><pre class="diff" id="added">+ }
+
+ public String changeAndReturnPreviousValue(PrevaylerTest.ObjectWithValue objectWithValue, String newValue) {
+ String retval = objectWithValue.getValue();
+ objectWithValue.setValue(newValue);
+ return retval;
</pre><pre class="diff" id="context"> }
}
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>PrevaylerTest.java</b></big> <small id="info">1.5 -> 1.6</small></div>
<pre class="diff"><small id="info">diff -u -r1.5 -r1.6
--- PrevaylerTest.java 11 Aug 2003 14:52:41 -0000 1.5
+++ PrevaylerTest.java 13 Aug 2003 10:46:05 -0000 1.6
@@ -13,14 +13,17 @@
</small></pre><pre class="diff" id="context"> import org.codehaus.nanning.Mixin;
import org.codehaus.nanning.attribute.AbstractAttributesTest;
import org.codehaus.nanning.attribute.Attributes;
</pre><pre class="diff" id="removed">-import org.codehaus.nanning.config.AspectSystem;
-import org.codehaus.nanning.config.FindTargetMixinAspect;
</pre><pre class="diff" id="added">+import org.codehaus.nanning.config.*;
</pre><pre class="diff" id="context"> import org.prevayler.PrevaylerFactory;
import org.prevayler.Prevayler;
public class PrevaylerTest extends AbstractAttributesTest {
</pre><pre class="diff" id="removed">- private AspectFactory aspectFactory;
</pre><pre class="diff" id="added">+
+
+
+
+ private AspectSystem aspectSystem;
</pre><pre class="diff" id="context">
private File prevaylerDir;
</pre><pre class="diff"><small id="info">@@ -36,8 +39,8 @@
</small></pre><pre class="diff" id="context"> aspectSystem.addAspect(new FindTargetMixinAspect());
aspectSystem.addAspect(new PrevaylerAspect());
</pre><pre class="diff" id="removed">- aspectFactory = aspectSystem;
- Aspects.setContextAspectFactory(aspectFactory);
</pre><pre class="diff" id="added">+ this.aspectSystem = aspectSystem;
+ Aspects.setContextAspectFactory(this.aspectSystem);
</pre><pre class="diff" id="context">
prevaylerDir = File.createTempFile("test", "");
prevaylerDir.delete();
</pre><pre class="diff"><small id="info">@@ -132,8 +135,8 @@
</small></pre><pre class="diff" id="context">
public void testMethodCallingBackOnArgumentIsMadePersistent() throws Exception {
Prevayler prevayler = newPrevayler();
</pre><pre class="diff" id="removed">- final CallingBack callingBack = (CallingBack) aspectFactory.newInstance(CallingBack.class);
- final CalledBack calledBack = (CalledBack) aspectFactory.newInstance(CalledBack.class);
</pre><pre class="diff" id="added">+ final CallingBack callingBack = (CallingBack) aspectSystem.newInstance(CallingBack.class);
+ final CalledBack calledBack = (CalledBack) aspectSystem.newInstance(CalledBack.class);
</pre><pre class="diff" id="context">
CurrentPrevayler.withPrevayler(prevayler, new PrevaylerAction() {
public Object run() throws Exception {
</pre><pre class="diff"><small id="info">@@ -161,7 +164,44 @@
</small></pre><pre class="diff" id="context"> });
}
</pre><pre class="diff" id="added">+ /**
+ * @entity
+ */
+ public interface ObjectWithValue
+ {
+ String getValue();
+
+ /**
+ * @transaction
+ */
+ void setValue(String freddl);
+ }
+
+ public static class ObjectWithValueImpl implements ObjectWithValue, Serializable
+ {
+ String value = "initialValue";
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+// public void testChangeAndReturnPreviousValue() throws Exception {
+// // JIRA: NAN-11
+// final CountingPrevayler prevayler = newPrevayler();
+// CurrentPrevayler.withPrevayler(prevayler, new PrevaylerAction() {
+// public Object run() throws Exception {
+// ObjectWithValue o = (ObjectWithValue) aspectSystem.newInstance(ObjectWithValue.class);
+// assertEquals("initialValue", o.getValue());
+// assertEquals("initialValue", currentMySystem().changeAndReturnPreviousValue(o, "FREDDL"));
+// return null;
+// }
+// });
+// }
</pre><pre class="diff" id="context">
/**
* Big badass functional test. I hate it, I want to kill it...
</pre><pre class="diff"><small id="info">@@ -181,10 +221,10 @@
</small></pre><pre class="diff" id="context"> insideObject.setValue("newValue");
prevayler.assertNumberOfCommands(3);
</pre><pre class="diff" id="removed">- MyObject outsideObject = (MyObject) aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="added">+ MyObject outsideObject = (MyObject) aspect<span id="addedchars">System</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="context"> prevayler.assertNumberOfCommands("no command when object created outside prevayler", 3);
</pre><pre class="diff" id="removed">- MyObject outsideNestedObject = (MyObject) aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="added">+ MyObject outsideNestedObject = (MyObject) aspect<span id="addedchars">System</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="context"> prevayler.assertNumberOfCommands("no command when object created outside prevayler", 3);
outsideObject.setMyObject(outsideNestedObject);
</pre><pre class="diff"><small id="info">@@ -244,7 +284,7 @@
</small></pre><pre class="diff" id="context"> }
public void testABC() throws ClassNotFoundException, IOException, NoSuchMethodException {
</pre><pre class="diff" id="removed">- AspectInstance aspectInstance = Aspects.getAspectInstance(aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class));
</pre><pre class="diff" id="added">+ AspectInstance aspectInstance = Aspects.getAspectInstance(aspect<span id="addedchars">System</span>.newInstance(MyObject.class));
</pre><pre class="diff" id="context"> Mixin mixinInstance = (Mixin) aspectInstance.getMixins().iterator().next();
Method setValue = MyObject.class.getDeclaredMethod("setValue", new Class[]{String.class});
</pre><pre class="diff"><small id="info">@@ -270,9 +310,9 @@
</small></pre><pre class="diff" id="context"> CountingPrevayler prevayler = newPrevayler();
CurrentPrevayler.withPrevayler(prevayler, new Runnable() {
public void run() {
</pre><pre class="diff" id="removed">- MyObject myObject = (MyObject) aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="added">+ MyObject myObject = (MyObject) aspect<span id="addedchars">System</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="context"> currentMySystem().setMyObject(myObject);
</pre><pre class="diff" id="removed">- myObject.setMyObject((MyObject) aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class));
</pre><pre class="diff" id="added">+ myObject.setMyObject((MyObject) aspect<span id="addedchars">System</span>.newInstance(MyObject.class));
</pre><pre class="diff" id="context"> assertEquals("two MyObjects should have been created", 2, currentMySystem().getAllObjects().size());
}
});
</pre><pre class="diff"><small id="info">@@ -301,7 +341,7 @@
</small></pre><pre class="diff" id="context"> }
public void testSerialization() throws IOException, ClassNotFoundException {
</pre><pre class="diff" id="removed">- MyObject myObject = (MyObject) aspect<span id="removedchars">Factory</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="added">+ MyObject myObject = (MyObject) aspect<span id="addedchars">System</span>.newInstance(MyObject.class);
</pre><pre class="diff" id="context"> myObject.setValue("value");
IdentityHashMap identityHashMap = new IdentityHashMap();
identityHashMap.put(myObject, new Long(1));
</pre><pre class="diff"><small id="info">@@ -318,8 +358,8 @@
</small></pre><pre class="diff" id="context"> }
// public void testOptionalDataException() throws IOException, ClassNotFoundException {
</pre><pre class="diff" id="removed">-// MySystem mySystem = (MySystem) aspectFactory.newInstance(MySystem.class);
-// mySystem.registerObjectID(aspectFactory.newInstance(MyObject.class));
</pre><pre class="diff" id="added">+// MySystem mySystem = (MySystem) aspectSystem.newInstance(MySystem.class);
+// mySystem.registerObjectID(aspectSystem.newInstance(MyObject.class));
</pre><pre class="diff" id="context"> // assertEquals(1, mySystem.getObjectID(mySystem.getAllRegisteredObjects().iterator().next()));
// mySystem = (MySystem) serialize(mySystem);
// mySystem = (MySystem) serialize(mySystem);
</pre><pre class="diff"><small id="info">@@ -340,7 +380,7 @@
</small></pre><pre class="diff" id="context">
private CountingPrevayler newPrevayler() throws IOException, ClassNotFoundException {
CountingPrevayler prevayler = new CountingPrevayler(
</pre><pre class="diff" id="removed">- PrevaylerFactory.createPrevayler(aspect<span id="removedchars">Factory</span>.newInstance(MySystem.class),
</pre><pre class="diff" id="added">+ PrevaylerFactory.createPrevayler(aspect<span id="addedchars">System</span>.newInstance(MySystem.class),
</pre><pre class="diff" id="context"> prevaylerDir.getAbsolutePath()));
return prevayler;
}
</pre><pre class="diff"><small id="info">@@ -348,7 +388,7 @@
</small></pre><pre class="diff" id="context"> public void testUnsupportedTransaction() {
assertTrue(CheckTransactionUnsupportedInterceptor.isTransactionsSupported());
TestUnsupportedTransaction testUnsupportedTransaction =
</pre><pre class="diff" id="removed">- (TestUnsupportedTransaction) aspect<span id="removedchars">Factory</span>.newInstance(TestUnsupportedTransaction.class);
</pre><pre class="diff" id="added">+ (TestUnsupportedTransaction) aspect<span id="addedchars">System</span>.newInstance(TestUnsupportedTransaction.class);
</pre><pre class="diff" id="context"> try {
testUnsupportedTransaction.callWithUnsupportedTransaction();
fail();
</pre><pre class="diff"><small id="info">@@ -365,4 +405,4 @@
</small></pre><pre class="diff" id="context"> MySystem.class.getMethod("setMyObject", new Class[]{MyObject.class})));
assertTrue(PrevaylerInterceptor.transactionalReturnValue(MySystem.class.getMethod("createMyObject", null)));
}
</pre><pre class="diff" id="removed">-}
</pre><pre class="diff" id="added">+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
</body></html>