Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
a test demonstrating that VerifyError is raised when binding and inte…
…rceptor to a method in a class with final equals method
  • Loading branch information
sgraca authored and stuartwdouglas committed Mar 7, 2012
1 parent 256b5f8 commit 84f5035
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 0 deletions.
@@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, 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.finalEquals;


import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.BeanArchive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Test;
import org.junit.runner.RunWith;

import static junit.framework.Assert.assertEquals;


/**
* @author Sebastian Graca, ISPiK S.A.
*/
@RunWith(Arquillian.class)
public class InterceptedBeanWithFinalEqualsTest {
@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(BeanArchive.class).intercept(QuotingInterceptor.class).addPackage(InterceptedBeanWithFinalEqualsTest.class.getPackage());
}

@Test
public void interceptionWorksOnClassWithFinalEquals(Quoter quoter) {
assertEquals("\"unquoted\"", quoter.returnUnquoted("unquoted"));
}
}
@@ -0,0 +1,37 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, 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.finalEquals;

import javax.interceptor.InterceptorBinding;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

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


/**
* @author Sebastian Graca, ISPiK S.A.
*/
@InterceptorBinding
@Retention(RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
public @interface Quoted {

}
@@ -0,0 +1,33 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, 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.finalEquals;


/**
* @author Sebastian Graca, ISPiK S.A.
*/
public class Quoter {
@Quoted
public String returnUnquoted(String value) {
return value;
}

@Override
public final boolean equals(Object obj) {
return super.equals(obj);
}
}
@@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, 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.finalEquals;

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


/**
* @author Sebastian Graca, ISPiK S.A.
*/
@Quoted
@Interceptor
public class QuotingInterceptor {
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
return "\"" + context.proceed() + "\"";
}
}

0 comments on commit 84f5035

Please sign in to comment.