Author: marius.bogoevici
Date: 2009-12-11 11:17:50 -0500 (Fri, 11 Dec 2009)
New Revision: 5272
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBean.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericInterface.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/TestBean.java
Log:
Adding unit test for generic beans.
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBean.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBean.java 2009-12-11
16:17:50 UTC (rev 5272)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, 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.generic;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class GenericBean<T> implements GenericInterface<T>
+{
+
+ public T echo(T parameter)
+ {
+ return parameter;
+ }
+
+}
Copied: core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java
(from rev 5268,
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/generic/PartialDecoratorTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java 2009-12-11
16:17:50 UTC (rev 5272)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, 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.generic;
+
+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.Test;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Artifact
+public class GenericBeanTest extends AbstractWeldTest
+{
+
+ @Test(groups = "broken")
+ public void testGenericBean()
+ {
+ TestBean testBean = getCurrentManager().getInstanceByType(TestBean.class);
+ assert "Hello".equals(testBean.echo("Hello"));
+ assert Integer.valueOf(1).equals(testBean.echo(1));
+ }
+}
\ No newline at end of file
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericInterface.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericInterface.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericInterface.java 2009-12-11
16:17:50 UTC (rev 5272)
@@ -0,0 +1,9 @@
+package org.jboss.weld.tests.generic;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface GenericInterface<T>
+{
+ T echo(T parameter);
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/TestBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/TestBean.java
(rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/TestBean.java 2009-12-11
16:17:50 UTC (rev 5272)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, 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.generic;
+
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class TestBean
+{
+ @Inject GenericInterface<String> genericStringField;
+
+ @Inject GenericInterface<Integer> genericIntegerField;
+
+ public String echo(String param)
+ {
+ return genericStringField.echo(param);
+ }
+
+ public Integer echo(Integer param)
+ {
+ return genericIntegerField.echo(param);
+ }
+
+}