Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add negative tests for build compatible extensions with invalid metho… #329

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.shrinkwrap.impl.BeansXml;
import org.testng.annotations.Test;

public abstract class AbstractInvalidExtensionParamTest extends AbstractTest {

/**
* Prepared archive builder minus the extension being tested
*/
static WebArchiveBuilder prepareArchiveBuilder() {
return new WebArchiveBuilder()
// add some class that will be type-discovered
.withClasses(SomeBean.class)
.withTestClass(AbstractInvalidExtensionParamTest.class)
// annotated discovery mode
.withBeansXml(new BeansXml());
}


@Test()
//@SpecAssertion(section = TODO, id = "TODO")
public void test() {
// deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementMultipleParams2Test extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(EnhancementMultipleParamsExtension2.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.ClassConfig;
import jakarta.enterprise.inject.build.compatible.spi.Enhancement;
import jakarta.enterprise.inject.build.compatible.spi.Messages;
import jakarta.enterprise.lang.model.declarations.ClassInfo;

public class EnhancementMultipleParamsExtension implements BuildCompatibleExtension {

@Enhancement(types = SomeBean.class)
public void enhance(ClassConfig cc, ClassInfo ci, Messages msg) {
// no-op deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.ClassConfig;
import jakarta.enterprise.inject.build.compatible.spi.Enhancement;
import jakarta.enterprise.inject.build.compatible.spi.MethodConfig;
import jakarta.enterprise.lang.model.declarations.FieldInfo;

public class EnhancementMultipleParamsExtension2 implements BuildCompatibleExtension {

@Enhancement(types = SomeBean.class)
public void enhance(ClassConfig cc, MethodConfig mc, FieldInfo fi) {
// no-op deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementMultipleParamsTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(EnhancementMultipleParamsExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Enhancement;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementNoParamExtension implements BuildCompatibleExtension {

@Enhancement(types = SomeBean.class)
public void enhance() {
// no-op deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementNoParamTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(EnhancementNoParamExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Enhancement;
import jakarta.enterprise.inject.build.compatible.spi.Messages;

public class EnhancementOnlyMessagesExtension implements BuildCompatibleExtension {

@Enhancement(types = SomeBean.class)
public void enhance(Messages msg) {
// no-op deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementOnlyMessagesTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(EnhancementOnlyMessagesExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Enhancement;
import jakarta.enterprise.inject.build.compatible.spi.Types;

public class EnhancementOnlyTypesExtension implements BuildCompatibleExtension {

@Enhancement(types = SomeBean.class)
public void enhance(Types types) {
// no-op deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class EnhancementOnlyTypesTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(EnhancementOnlyTypesExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class RegistrationMultipleParams2Test extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(RegistrationMultipleParamsExtension2.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BeanInfo;
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.InterceptorInfo;
import jakarta.enterprise.inject.build.compatible.spi.Registration;

public class RegistrationMultipleParamsExtension implements BuildCompatibleExtension {

@Registration(types = {SomeBean.class})
public void register(BeanInfo bi, InterceptorInfo ii) {
// no-op, deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BeanInfo;
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.ObserverInfo;
import jakarta.enterprise.inject.build.compatible.spi.Registration;
import jakarta.enterprise.inject.build.compatible.spi.Types;

public class RegistrationMultipleParamsExtension2 implements BuildCompatibleExtension {

@Registration(types = {SomeBean.class})
public void register(ObserverInfo oi, Types t, BeanInfo bi) {
// no-op, deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class RegistrationMultipleParamsTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(RegistrationMultipleParamsExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Registration;

public class RegistrationNoParamExtension implements BuildCompatibleExtension {

@Registration(types = {SomeBean.class})
public void register() {
// no-op, deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class RegistrationNoParamTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(RegistrationNoParamExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Messages;
import jakarta.enterprise.inject.build.compatible.spi.Registration;

public class RegistrationOnlyMessagesExtension implements BuildCompatibleExtension {

@Registration(types = {SomeBean.class})
public void register(Messages m) {
// no-op, deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class RegistrationOnlyMessagesTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(RegistrationOnlyMessagesExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.Registration;
import jakarta.enterprise.inject.build.compatible.spi.Types;

public class RegistrationOnlyTypesExtension implements BuildCompatibleExtension {

@Registration(types = {SomeBean.class})
public void register(Types t) {
// no-op, deployment should fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.inject.spi.DefinitionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecVersion;

@SpecVersion(spec = "cdi", version = "4.0")
public class RegistrationOnlyTypesTest extends AbstractInvalidExtensionParamTest {

@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return prepareArchiveBuilder().withBuildCompatibleExtension(RegistrationOnlyTypesExtension.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.invalid;

import jakarta.enterprise.context.Dependent;

// Dummy bean class just to have some in the bean archive
@Dependent
public class SomeBean {
}