diff options
author | aclement <aclement> | 2008-02-20 19:58:49 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-02-20 19:58:49 +0000 |
commit | c75c9f9937291849957802ec14c5c565a776c859 (patch) | |
tree | 72021efc47a4342910c33e60aa0e66038da55293 /tests/bugs160 | |
parent | a22ad46047e2ddfa124c08621dd4bf567c8f23f1 (diff) | |
download | aspectj-c75c9f9937291849957802ec14c5c565a776c859.tar.gz aspectj-c75c9f9937291849957802ec14c5c565a776c859.zip |
216311: testcode
Diffstat (limited to 'tests/bugs160')
-rw-r--r-- | tests/bugs160/pr216311/IPersistable.java | 9 | ||||
-rw-r--r-- | tests/bugs160/pr216311/Persistability.java | 44 | ||||
-rw-r--r-- | tests/bugs160/pr216311/PersistabilityTest.java | 29 |
3 files changed, 82 insertions, 0 deletions
diff --git a/tests/bugs160/pr216311/IPersistable.java b/tests/bugs160/pr216311/IPersistable.java new file mode 100644 index 000000000..82bc63304 --- /dev/null +++ b/tests/bugs160/pr216311/IPersistable.java @@ -0,0 +1,9 @@ +import java.io.Serializable;
+
+public interface IPersistable extends Serializable {
+
+ int getId();
+
+ void setId(int id);
+
+}
diff --git a/tests/bugs160/pr216311/Persistability.java b/tests/bugs160/pr216311/Persistability.java new file mode 100644 index 000000000..4bd76aeca --- /dev/null +++ b/tests/bugs160/pr216311/Persistability.java @@ -0,0 +1,44 @@ +
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.DeclareParents;
+import org.aspectj.lang.annotation.Pointcut;
+
+
+@Aspect
+public class Persistability {
+
+ static class Persistable implements IPersistable {
+
+ private static final long serialVersionUID = 7120491865883787353L;
+
+ private int id;
+
+ public Persistable() {
+ super();
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ }
+
+ @DeclareParents(value = "PersistabilityTest", defaultImpl = Persistable.class)
+ private IPersistable observable;
+
+ @Pointcut("initialization(IPersistable.new(..)) && this(bean) && !this(Persistable)")
+ void init(IPersistable bean) {
+ }
+
+ @Before("init(bean)")
+ public void beforeInit(IPersistable bean) {
+ bean.setId(System.identityHashCode(bean));
+ }
+
+}
diff --git a/tests/bugs160/pr216311/PersistabilityTest.java b/tests/bugs160/pr216311/PersistabilityTest.java new file mode 100644 index 000000000..a977c9a8d --- /dev/null +++ b/tests/bugs160/pr216311/PersistabilityTest.java @@ -0,0 +1,29 @@ +
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+public class PersistabilityTest {
+
+ public static void main(String []argv) throws Exception {
+
+ PersistabilityTest persistabilityTest1 = new PersistabilityTest();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+
+ oos.writeObject(persistabilityTest1);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bis);
+
+ PersistabilityTest persistabilityTest2 = (PersistabilityTest) ois.readObject();
+
+ if (!(persistabilityTest1 instanceof IPersistable)) throw new RuntimeException("pTest1 not IPersistable");
+ if (!(persistabilityTest2 instanceof IPersistable)) throw new RuntimeException("pTest2 not IPersistable");
+ int o = ((IPersistable)persistabilityTest1).getId();
+ int o2 = ((IPersistable)persistabilityTest2).getId();
+ if (o!=o2) throw new RuntimeException(o+" != "+o2);
+ }
+}
|