Skip to content

Commit

Permalink
WELD-2010 Testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed Aug 18, 2015
1 parent bf3d133 commit b87b904
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 0 deletions.
@@ -0,0 +1,53 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, 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.extensions.custombeans.types;

import javax.enterprise.inject.spi.Extension;
import javax.inject.Inject;

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;

/**
* Testcase for https://issues.jboss.org/browse/WELD-2010
*
* @author Jozef Hartinger
* @author Arjan Tijms
*
*/
@RunWith(Arquillian.class)
public class CustomBeanWithAbstractBeanTypeTest {

@Inject
private MyMap map;

@Deployment
public static Archive<?> getDeployment() {
return ShrinkWrap.create(BeanArchive.class).addPackage(CustomBeanWithAbstractBeanTypeTest.class.getPackage())
.addAsServiceProvider(Extension.class, MyMapExtension.class);
}

@Test
public void test() {
map.clear();
}
}
@@ -0,0 +1,22 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, 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.extensions.custombeans.types;

import java.util.Map;

public abstract class MyMap implements Map<String, Object> {
}
@@ -0,0 +1,94 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, 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.extensions.custombeans.types;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.PassivationCapable;

import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.literal.DefaultLiteral;
import org.jboss.weld.util.collections.Arrays2;

public class MyMapBean implements Bean<MyMap>, PassivationCapable {

@Override
public void destroy(MyMap instance, CreationalContext<MyMap> creationalContext) {
}

@Override
public Set<Type> getTypes() {
return Collections.singleton(MyMap.class);
}

@Override
public Set<Annotation> getQualifiers() {
return Arrays2.asSet(DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE);
}

@Override
public Class<? extends Annotation> getScope() {
return RequestScoped.class;
}

@Override
public String getName() {
return null;
}

@Override
public Set<Class<? extends Annotation>> getStereotypes() {
return Collections.emptySet();
}

@Override
public boolean isAlternative() {
return false;
}

@Override
public Class<?> getBeanClass() {
return MyMap.class;
}

@Override
public Set<InjectionPoint> getInjectionPoints() {
return Collections.emptySet();
}

@Override
public boolean isNullable() {
return false;
}

@Override
public MyMap create(CreationalContext<MyMap> creationalContext) {
return new MyMapImpl();
}

@Override
public String getId() {
return MyMap.class.getName();
}
}
@@ -0,0 +1,28 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, 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.extensions.custombeans.types;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.Extension;

public class MyMapExtension implements Extension {

public void registerBean(@Observes AfterBeanDiscovery event) {
event.addBean(new MyMapBean());
}
}
@@ -0,0 +1,85 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, 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.extensions.custombeans.types;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.enterprise.inject.Vetoed;

@Vetoed
public class MyMapImpl extends MyMap {

@Override
public Collection<Object> values() {
return null;
}

@Override
public int size() {
return 0;
}

@Override
public Object remove(Object key) {
return null;
}

@Override
public void putAll(Map<? extends String, ? extends Object> m) {
}

@Override
public Object put(String key, Object value) {
return null;
}

@Override
public Set<String> keySet() {
return null;
}

@Override
public boolean isEmpty() {
return false;
}

@Override
public Object get(Object key) {
return null;
}

@Override
public Set<Entry<String, Object>> entrySet() {
return null;
}

@Override
public boolean containsValue(Object value) {
return false;
}

@Override
public boolean containsKey(Object key) {
return false;
}

@Override
public void clear() {
}
}

0 comments on commit b87b904

Please sign in to comment.