Skip to content

Commit

Permalink
Tests for WELD-568
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogoevici committed Jul 22, 2010
1 parent 03ecaf5 commit df4e0eb
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 0 deletions.
@@ -0,0 +1,36 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.weld.tests.interceptors.hierarchical;

/**
* @author Marius Bogoevici
*/
@Play
public class Attacker extends Player
{

public void playBall()
{
// do nothing
}


public Attacker cloneMe()
{
return this;
}
}
@@ -0,0 +1,37 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.weld.tests.interceptors.hierarchical;

import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

/**
* @author Marius Bogoevici
*/
@Interceptor @Play
public class Defender
{
static int invocationsCount = 0;

@AroundInvoke
public Object tackle(InvocationContext invocationContext) throws Exception
{
invocationsCount ++;
return invocationContext.proceed();
}
}
@@ -0,0 +1,30 @@
package org.jboss.weld.tests.interceptors.hierarchical;

import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.jboss.weld.test.AbstractWeldTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
* @author Marius Bogoevici
*/
@Artifact
@BeansXml("beans.xml")
public class InterceptorsWithHierarchyTest extends AbstractWeldTest
{
@BeforeClass
public static void initialize()
{
Defender.invocationsCount = 0;
}

@Test(groups = "broken")
public void testInterceptorsWithHierarchy()
{
Attacker player = this.getReference(Attacker.class);
player.cloneMe();
assert Defender.invocationsCount == 1;
}

}
@@ -0,0 +1,38 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.weld.tests.interceptors.hierarchical;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.interceptor.InterceptorBinding;

/**
* @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a>
*/
@InterceptorBinding
@Retention(RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
public @interface Play
{
}
@@ -0,0 +1,33 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.weld.tests.interceptors.hierarchical;

/**
* @author Marius Bogoevici
*/
public class Player
{
public void playBall()
{

}

public Player cloneMe()
{
return this;
}
}
@@ -0,0 +1,5 @@
<beans>
<interceptors>
<class>org.jboss.weld.tests.interceptors.hierarchical.Defender</class>
</interceptors>
</beans>

0 comments on commit df4e0eb

Please sign in to comment.