[jboss-cvs] JBossAS SVN: r59251 - in projects/aop/branches/arrays/aop/src: main/org/jboss/aop/array test/org/jboss/test/aop/array
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Dec 31 10:13:53 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-12-31 10:13:49 -0500 (Sun, 31 Dec 2006)
New Revision: 59251
Modified:
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/TestArrayElementInterceptor.java
Log:
Test that the primitive and object values stored in the arrayelementwriteinvocations match
Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java 2006-12-30 21:52:49 UTC (rev 59250)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java 2006-12-31 15:13:49 UTC (rev 59251)
@@ -54,7 +54,7 @@
return new Short(value);
}
- public float getShortValue()
+ public short getShortValue()
{
return value;
}
Modified: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/TestArrayElementInterceptor.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/TestArrayElementInterceptor.java 2006-12-30 21:52:49 UTC (rev 59250)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/TestArrayElementInterceptor.java 2006-12-31 15:13:49 UTC (rev 59251)
@@ -23,11 +23,23 @@
import java.util.List;
+import junit.framework.Assert;
+
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.array.ArrayElementReadInvocation;
import org.jboss.aop.array.ArrayElementWriteInvocation;
import org.jboss.aop.array.ArrayReference;
import org.jboss.aop.array.ArrayRegistry;
+import org.jboss.aop.array.BooleanArrayElementWriteInvocation;
+import org.jboss.aop.array.ByteArrayElementWriteInvocation;
+import org.jboss.aop.array.CharArrayElementWriteInvocation;
+import org.jboss.aop.array.DoubleArrayElementWriteInvocation;
+import org.jboss.aop.array.FloatArrayElementWriteInvocation;
+import org.jboss.aop.array.IntArrayElementReadInvocation;
+import org.jboss.aop.array.IntArrayElementWriteInvocation;
+import org.jboss.aop.array.LongArrayElementWriteInvocation;
+import org.jboss.aop.array.ObjectArrayElementWriteInvocation;
+import org.jboss.aop.array.ShortArrayElementWriteInvocation;
import org.jboss.aop.joinpoint.Invocation;
/**
@@ -64,10 +76,67 @@
{
index = ((ArrayElementWriteInvocation)invocation).getIndex();
value = ((ArrayElementWriteInvocation)invocation).getValue();
+ checkType((ArrayElementWriteInvocation)invocation);
}
owners = ArrayRegistry.getInstance().getArrayOwners(invocation.getTargetObject());
invocation.getMetaData().addMetaData("test", "invoked", "TestArrayElementInterceptor");
return invocation.invokeNext();
}
+ public static class Value
+ {
+ public Object value;
+ }
+
+ private void checkType(ArrayElementWriteInvocation invocation)
+ {
+ if (invocation instanceof ObjectArrayElementWriteInvocation)
+ {
+
+ }
+ else if (invocation instanceof ByteArrayElementWriteInvocation)
+ {
+ byte b = ((ByteArrayElementWriteInvocation)invocation).getByteValue();
+ Assert.assertEquals(b, ((Byte)invocation.getValue()).byteValue());
+ }
+ else if (invocation instanceof BooleanArrayElementWriteInvocation)
+ {
+ boolean b = ((BooleanArrayElementWriteInvocation)invocation).getBooleanValue();
+ Assert.assertEquals(b, ((Boolean)invocation.getValue()).booleanValue());
+ }
+ else if (invocation instanceof CharArrayElementWriteInvocation)
+ {
+ char c = ((CharArrayElementWriteInvocation)invocation).getCharValue();
+ Assert.assertEquals(c, ((Character)invocation.getValue()).charValue());
+ }
+ else if (invocation instanceof DoubleArrayElementWriteInvocation)
+ {
+ double d = ((DoubleArrayElementWriteInvocation)invocation).getDoubleValue();
+ Assert.assertEquals(d, ((Double)invocation.getValue()).doubleValue());
+ }
+ else if (invocation instanceof FloatArrayElementWriteInvocation)
+ {
+ float f = ((FloatArrayElementWriteInvocation)invocation).getFloatValue();
+ Assert.assertEquals(f, ((Float)invocation.getValue()).floatValue());
+ }
+ else if (invocation instanceof IntArrayElementWriteInvocation)
+ {
+ int i = ((IntArrayElementWriteInvocation)invocation).getIntValue();
+ Assert.assertEquals(i, ((Integer)invocation.getValue()).intValue());
+ }
+ else if (invocation instanceof LongArrayElementWriteInvocation)
+ {
+ long l = ((LongArrayElementWriteInvocation)invocation).getLongValue();
+ Assert.assertEquals(l, ((Long)invocation.getValue()).longValue());
+ }
+ else if (invocation instanceof ShortArrayElementWriteInvocation)
+ {
+ short s = ((ShortArrayElementWriteInvocation)invocation).getShortValue();
+ Assert.assertEquals(s, ((Short)invocation.getValue()).shortValue());
+ }
+ else
+ {
+ throw new RuntimeException("Dodgy invocation type " + invocation.getClass().getName());
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list