Author: jharting
Date: 2009-11-09 04:36:37 -0500 (Mon, 09 Nov 2009)
New Revision: 4848
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/CargoShip.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor1.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor2.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor3.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor4.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/InvocationOrderTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/LakeCargoShip.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Ship.java
Log:
Tests for lifecycle callback interceptor methods.
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/CargoShip.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/CargoShip.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/CargoShip.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.Interceptors;
+
+@Interceptors( { Interceptor3.class, Interceptor4.class })
+class CargoShip extends Ship
+{
+ @PostConstruct
+ void postConstruct2()
+ {
+ assert LakeCargoShip.getSequence() == 5;
+ LakeCargoShip.setSequence(6);
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor1.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor1.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor1.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class Interceptor1
+{
+ @PostConstruct
+ void postConstruct1(InvocationContext ctx)
+ {
+ assert LakeCargoShip.getSequence() == 0;
+ LakeCargoShip.setSequence(1);
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor2.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor2.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor2.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class Interceptor2
+{
+ @PostConstruct
+ void postConstruct2(InvocationContext ctx)
+ {
+ assert LakeCargoShip.getSequence() == 1;
+ LakeCargoShip.setSequence(2);
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor3.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor3.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor3.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class Interceptor3
+{
+ @PostConstruct
+ void postConstruct3(InvocationContext ctx)
+ {
+ assert LakeCargoShip.getSequence() == 2;
+ LakeCargoShip.setSequence(3);
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor4.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor4.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Interceptor4.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class Interceptor4
+{
+ @PostConstruct
+ void postConstruct(InvocationContext ctx)
+ {
+ assert LakeCargoShip.getSequence() == 3;
+ LakeCargoShip.setSequence(4);
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/InvocationOrderTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/InvocationOrderTest.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/InvocationOrderTest.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 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 org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+@SpecVersion(spec = "int", version = "3.1.PFD")
+public class InvocationOrderTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "c"),
+ @SpecAssertion(section = "5.1", id = "d"),
+ @SpecAssertion(section = "5.1", id = "e"),
+ @SpecAssertion(section = "5.1", id = "f")
+ })
+ // WELD-280
+ public void testInvocationOrder() {
+ getInstanceByType(LakeCargoShip.class);
+ assert LakeCargoShip.getSequence() == 7;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/LakeCargoShip.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/LakeCargoShip.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/LakeCargoShip.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+
+class LakeCargoShip extends CargoShip
+{
+ // Every interceptor sets this property to a certain value.
+ // The following interceptor verifies the correct order of the chain by
+ // inspecting this value.
+ private static int sequence = 0;
+
+ static int getSequence()
+ {
+ return sequence;
+ }
+
+ static void setSequence(int value)
+ {
+ sequence = value;
+ }
+
+ @PostConstruct
+ void postConstruct3()
+ {
+ assert LakeCargoShip.getSequence() == 6;
+ LakeCargoShip.setSequence(7);
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Ship.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Ship.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/order/Ship.java 2009-11-09
09:36:37 UTC (rev 4848)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.order;
+
+import javax.annotation.PostConstruct;
+
+class Ship
+{
+ @PostConstruct
+ void postConstruct1()
+ {
+ assert LakeCargoShip.getSequence() == 4;
+ LakeCargoShip.setSequence(5);
+ }
+}