-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
187 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus.arc</groupId> | ||
<artifactId>arc-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>arc-atinject-tck-runner</artifactId> | ||
<name>ArC - AtInject TCK Runner</name> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.arquillian</groupId> | ||
<artifactId>arquillian-bom</artifactId> | ||
<version>${version.arquillian}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus.arc</groupId> | ||
<artifactId>arc-arquillian</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-tck</artifactId> | ||
<version>${version.atinject-tck}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${version.junit4}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
...ojects/arc/atinject-tck-runner/src/test/java/io/quarkus/arc/tck/AtInjectTckExtension.java
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,53 @@ | ||
package io.quarkus.arc.tck; | ||
|
||
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; | ||
import jakarta.enterprise.inject.build.compatible.spi.ClassConfig; | ||
import jakarta.enterprise.inject.build.compatible.spi.Discovery; | ||
import jakarta.enterprise.inject.build.compatible.spi.Enhancement; | ||
import jakarta.enterprise.inject.build.compatible.spi.MetaAnnotations; | ||
import jakarta.enterprise.inject.build.compatible.spi.ScannedClasses; | ||
import jakarta.enterprise.inject.literal.NamedLiteral; | ||
|
||
import org.atinject.tck.auto.Convertible; | ||
import org.atinject.tck.auto.Drivers; | ||
import org.atinject.tck.auto.DriversSeat; | ||
import org.atinject.tck.auto.FuelTank; | ||
import org.atinject.tck.auto.Seat; | ||
import org.atinject.tck.auto.Tire; | ||
import org.atinject.tck.auto.V8Engine; | ||
import org.atinject.tck.auto.accessories.Cupholder; | ||
import org.atinject.tck.auto.accessories.SpareTire; | ||
|
||
public class AtInjectTckExtension implements BuildCompatibleExtension { | ||
@Discovery | ||
public void discovery(ScannedClasses scan, MetaAnnotations meta) { | ||
scan.add(Convertible.class.getName()); | ||
scan.add(DriversSeat.class.getName()); | ||
scan.add(FuelTank.class.getName()); | ||
scan.add(Seat.class.getName()); | ||
scan.add(Tire.class.getName()); | ||
scan.add(V8Engine.class.getName()); | ||
|
||
scan.add(Cupholder.class.getName()); | ||
scan.add(SpareTire.class.getName()); | ||
} | ||
|
||
@Enhancement(types = Convertible.class) | ||
public void convertible(ClassConfig clazz) { | ||
clazz.fields() | ||
.stream() | ||
.filter(it -> "spareTire".equals(it.info().name())) | ||
.forEach(it -> it.addAnnotation(Spare.class)); | ||
} | ||
|
||
@Enhancement(types = DriversSeat.class) | ||
public void driversSeat(ClassConfig clazz) { | ||
clazz.addAnnotation(Drivers.class); | ||
} | ||
|
||
@Enhancement(types = SpareTire.class) | ||
public void spareTire(ClassConfig clazz) { | ||
clazz.addAnnotation(NamedLiteral.of("spare")) | ||
.addAnnotation(Spare.class); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...ndent-projects/arc/atinject-tck-runner/src/test/java/io/quarkus/arc/tck/AtInjectTest.java
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,61 @@ | ||
package io.quarkus.arc.tck; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.Enumeration; | ||
|
||
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; | ||
|
||
import org.atinject.tck.Tck; | ||
import org.atinject.tck.auto.Car; | ||
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.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import io.quarkus.arc.Arc; | ||
|
||
@RunWith(Arquillian.class) | ||
public class AtInjectTest { | ||
@Deployment | ||
public static Archive<?> deployment() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addPackages(true, Tck.class.getPackage()) | ||
.addClasses(AtInjectTest.class, AtInjectTckExtension.class, Spare.class) | ||
.addAsServiceProvider(BuildCompatibleExtension.class, AtInjectTckExtension.class) | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
Car instance = Arc.container().instance(Car.class).get(); | ||
|
||
junit.framework.Test test = Tck.testsFor(instance, /* supportsStatic */ false, /* supportsPrivate */ true); | ||
junit.framework.TestResult result = new junit.framework.TestResult(); | ||
test.run(result); | ||
|
||
// this is ugly and doesn't report failures properly, but I don't see a better way | ||
if (!result.wasSuccessful()) { | ||
int failuresCount = 0; | ||
Enumeration<junit.framework.TestFailure> failures = result.failures(); | ||
while (failures.hasMoreElements()) { | ||
System.out.println(failures.nextElement()); | ||
failuresCount++; | ||
} | ||
|
||
int errorsCount = 0; | ||
Enumeration<junit.framework.TestFailure> errors = result.errors(); | ||
while (errors.hasMoreElements()) { | ||
System.out.println(errors.nextElement()); | ||
errorsCount++; | ||
} | ||
System.out.println("Total " + failuresCount + " failures and " + errorsCount + " errors"); | ||
} | ||
|
||
assertTrue(result.wasSuccessful()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
independent-projects/arc/atinject-tck-runner/src/test/java/io/quarkus/arc/tck/Spare.java
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,11 @@ | ||
package io.quarkus.arc.tck; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import jakarta.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Spare { | ||
} |
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