Skip to content

Commit

Permalink
Removed use of Junit4 in core and any use of asciidoctorj-arquillian-…
Browse files Browse the repository at this point in the history
…extension
  • Loading branch information
abelsromero committed Apr 26, 2023
1 parent 232f8b5 commit ecc710f
Show file tree
Hide file tree
Showing 45 changed files with 1,608 additions and 1,550 deletions.
1 change: 1 addition & 0 deletions asciidoctorj-arquillian-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
api "org.jboss.arquillian.container:arquillian-container-test-spi:$arquillianVersion"
api "org.jboss.arquillian.container:arquillian-container-impl-base:$arquillianVersion"
api "org.jboss.arquillian.container:arquillian-container-test-impl-base:$arquillianVersion"
api "junit:junit:$junit4Version"
}

def javaApiUrl = "https://docs.oracle.com/javase/8/docs/api/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.asciidoctor.arquillian.api.Shared;
import org.asciidoctor.arquillian.api.Unshared;
import org.asciidoctor.jruby.AsciidoctorJRuby;
import org.asciidoctor.util.ClasspathResources;
import org.asciidoctor.junit.ClasspathResources;
import org.jboss.arquillian.core.api.InstanceProducer;
import org.jboss.arquillian.core.api.annotation.ApplicationScoped;
import org.jboss.arquillian.core.api.annotation.Inject;
Expand Down Expand Up @@ -122,7 +122,7 @@ public void afterTestClassShutdownSharedTemporaryFolderInstance(@Observes AfterC
}

private boolean isSharedInstanceRequired(Class<?> testClass, Class<?> resourceClass) {
for (Field f: SecurityActions.getFieldsWithAnnotation(testClass, ArquillianResource.class)) {
for (Field f : SecurityActions.getFieldsWithAnnotation(testClass, ArquillianResource.class)) {
ArquillianResource arquillianResource = SecurityActions.getAnnotation(f, ArquillianResource.class);
if (f.getType() == resourceClass && arquillianResource.value() == Shared.class) {
return true;
Expand All @@ -132,7 +132,7 @@ private boolean isSharedInstanceRequired(Class<?> testClass, Class<?> resourceCl
}

private boolean isUnsharedInstanceRequired(Class<?> testClass, Class<?> resourceClass) {
for (Field f: SecurityActions.getFieldsWithAnnotation(testClass, ArquillianResource.class)) {
for (Field f : SecurityActions.getFieldsWithAnnotation(testClass, ArquillianResource.class)) {
ArquillianResource arquillianResource = SecurityActions.getAnnotation(f, ArquillianResource.class);
if (f.getType() == resourceClass &&
(arquillianResource.value() == ArquillianResource.class || arquillianResource.value() == Unshared.class)) {
Expand Down Expand Up @@ -171,4 +171,4 @@ private boolean isUnsharedInstanceRequired(Method testMethod, Class<?> resourceC
}
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.asciidoctor.arquillian;

import org.asciidoctor.util.ClasspathResources;
import org.asciidoctor.junit.ClasspathResources;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.ApplicationScoped;
import org.jboss.arquillian.core.api.annotation.Inject;
Expand All @@ -24,4 +24,4 @@ public boolean canProvide(Class<?> type) {
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
return classpathResourcesInstance.get();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.asciidoctor.junit;

import org.asciidoctor.test.extension.ClasspathHelper;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

/**
* JUnit TestRule to handle classpath files.
* <p>
* Delegates to {@link ClasspathHelper}.
*/
public class ClasspathResources implements TestRule {

private ClasspathHelper classpathHelper;

public ClasspathResources() {
}

public ClasspathResources(Class<?> clazz) {
classpathHelper = new ClasspathHelper(clazz);
}

protected void before(Class<?> clazz) {
classpathHelper = new ClasspathHelper(clazz);
}

@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
before(description.getTestClass());
base.evaluate();
}
};
}
}
5 changes: 1 addition & 4 deletions asciidoctorj-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
testImplementation "com.google.guava:guava:$guavaVersion"
testImplementation "org.jsoup:jsoup:$jsoupVersion"
testImplementation "io.netty:netty-all:$nettyVersion"
testImplementation project(':asciidoctorj-arquillian-extension')
testImplementation project(':asciidoctorj-test-support')
compileOnly "org.osgi:osgi.annotation:$osgiVersion"
}

Expand Down Expand Up @@ -138,6 +138,3 @@ task pollutedTest(type: Test) {
}

test.dependsOn pollutedTest



Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ import spock.lang.Specification

class WhenSlimTemplatesAreUsed extends Specification {

ClasspathHelper classpath = new ClasspathHelper()

def setup() {
classpath = new ClasspathHelper()
classpath.classloader = WhenSlimTemplatesAreUsed
}

Asciidoctor asciidoctor = JRubyAsciidoctor.create()

ClasspathHelper classpath = new ClasspathHelper(WhenSlimTemplatesAreUsed)

def 'the slim paragraph template should be used when rendering a document inline'() {
given:
Options options = Options.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ githubcontributors::asciidoctor/asciidoctorj[]

def setup() {
asciidoctor = Asciidoctor.Factory.create()
classpathResources = new ClasspathHelper()
classpathResources.classloader = WhenABlockMacroProcessorCreatesATable
classpathResources = new ClasspathHelper(WhenABlockMacroProcessorCreatesATable)
TestHttpServer.start(['http://api.github.com/repos/asciidoctor/asciidoctorj/contributors': classpathResources.getResource('githubcontributors.json')])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class WhenExtensionsAreRegisteredAsService extends Specification {

def setup() {
asciidoctor = Asciidoctor.Factory.create()
classpath = new ClasspathHelper()
classpath.classloader = WhenExtensionsAreRegisteredAsService
classpath = new ClasspathHelper(WhenExtensionsAreRegisteredAsService)
originalTCCL = Thread.currentThread().contextClassLoader
}

Expand Down
Loading

0 comments on commit ecc710f

Please sign in to comment.