-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the example TCK runner to work with Weld 5 after the remvoval …
…of @New, #19 Signed-off-by: Scott M Stark <starksm64@gmail.com>
- Loading branch information
Showing
7 changed files
with
141 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2021, 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 weld; | ||
|
||
import org.atinject.tck.auto.Convertible; | ||
import org.atinject.tck.auto.Drivers; | ||
import org.atinject.tck.auto.DriversSeat; | ||
import org.atinject.tck.auto.accessories.SpareTire; | ||
import org.jboss.weld.literal.NamedLiteral; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
import jakarta.enterprise.inject.spi.Extension; | ||
import jakarta.enterprise.inject.spi.ProcessAnnotatedType; | ||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
public class AtInjectTCKExtension implements Extension { | ||
public void convertible(@Observes ProcessAnnotatedType<Convertible> pat) { | ||
pat.configureAnnotatedType() | ||
.filterFields(field -> "spareTire".equals(field.getJavaMember().getName())) | ||
// add @Spare to the injection point, because the bean doesn't have @Default; see also below | ||
.forEach(field -> {field.add(SpareLiteral.INSTANCE); System.out.printf("Added @Spare to %s\n", field.getAnnotated());}); | ||
} | ||
|
||
public void driversSeat(@Observes ProcessAnnotatedType<DriversSeat> pat) { | ||
pat.configureAnnotatedType() | ||
.add(DriversLiteral.INSTANCE); | ||
System.out.printf("Added @Drivers to: %s\n", pat.getAnnotatedType()); | ||
} | ||
|
||
public void spareTire(@Observes ProcessAnnotatedType<SpareTire> pat) { | ||
pat.configureAnnotatedType() | ||
.add(new NamedLiteral("spare")) | ||
// add @Spare to prevent adding @Default, otherwise there would be 2 beans for the Tire type | ||
.add(SpareLiteral.INSTANCE); | ||
System.out.printf("Added @Named('spare') to: %s\n", pat.getAnnotatedType()); | ||
} | ||
|
||
static final class DriversLiteral extends AnnotationLiteral<Drivers> implements Drivers { | ||
static final DriversLiteral INSTANCE = new DriversLiteral(); | ||
|
||
private DriversLiteral() { | ||
} | ||
} | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@interface Spare { | ||
} | ||
|
||
static final class SpareLiteral extends AnnotationLiteral<Spare> implements Spare { | ||
static final SpareLiteral INSTANCE = new SpareLiteral(); | ||
|
||
private SpareLiteral() { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2021, 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 weld; | ||
|
||
import junit.framework.Test; | ||
import org.atinject.tck.Tck; | ||
import org.atinject.tck.auto.Car; | ||
|
||
import jakarta.enterprise.inject.se.SeContainer; | ||
import jakarta.enterprise.inject.se.SeContainerInitializer; | ||
|
||
public class SampleBootstrapTCK { | ||
|
||
public static Test suite() { | ||
|
||
SeContainer container = SeContainerInitializer | ||
.newInstance() | ||
.addExtensions(AtInjectTCKExtension.class) | ||
.addPackages(true, Tck.class) | ||
.initialize(); | ||
Car tckCar = container.select(Car.class).get(); | ||
return Tck.testsFor(tckCar, false, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
<beans version="2.0" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation=" | ||
http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee | ||
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd" | ||
version="4.0" | ||
bean-discovery-mode="all" > | ||
<scan> | ||
<exclude name="org.jboss.weld.**" /> | ||
<exclude name="org.atinject.tck.auto.DriversSeat" /> | ||
<exclude name="org.atinject.tck.auto.accessories.SpareTire" /> | ||
</scan> | ||
|
||
</beans> |