Skip to content

Commit

Permalink
Adding more tests for WELD-339
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogoevici committed Dec 15, 2009
1 parent af7aff7 commit f629f4d
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
25 changes: 25 additions & 0 deletions tests/src/test/java/org/jboss/weld/tests/generic/BaseClass.java
@@ -0,0 +1,25 @@
/*
* 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 BaseClass
{
}
@@ -0,0 +1,28 @@
/*
* 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 BoundedGenericBean<T extends BaseClass>
{
public T echo (T param) {
return param;
}
}
Expand Up @@ -18,7 +18,6 @@
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;

Expand All @@ -35,5 +34,11 @@ public void testGenericBean()
TestBean testBean = getCurrentManager().getInstanceByType(TestBean.class);
assert "Hello".equals(testBean.echo("Hello"));
assert Integer.valueOf(1).equals(testBean.echo(1));
Subclass subclassInstance = new Subclass();
assert subclassInstance == testBean.echo(subclassInstance);
assert subclassInstance == testBean.echo((BaseClass)subclassInstance);
BaseClass baseInstance = new BaseClass();
assert baseInstance == testBean.echo(baseInstance);
}

}
26 changes: 26 additions & 0 deletions tests/src/test/java/org/jboss/weld/tests/generic/Subclass.java
@@ -0,0 +1,26 @@
/*
* 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 Subclass extends BaseClass
{

}
15 changes: 15 additions & 0 deletions tests/src/test/java/org/jboss/weld/tests/generic/TestBean.java
Expand Up @@ -28,6 +28,11 @@ public class TestBean

@Inject GenericInterface<Integer> genericIntegerField;

@Inject BoundedGenericBean<Subclass> boundedGenericSubclassField;

@Inject BoundedGenericBean<BaseClass> boundedGenericBaseField;


public String echo(String param)
{
return genericStringField.echo(param);
Expand All @@ -37,5 +42,15 @@ public Integer echo(Integer param)
{
return genericIntegerField.echo(param);
}

public Subclass echo (Subclass param)
{
return boundedGenericSubclassField.echo(param);
}

public BaseClass echo (BaseClass param)
{
return boundedGenericBaseField.echo(param);
}

}

0 comments on commit f629f4d

Please sign in to comment.