Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 7585af0

Browse files
committed
Upgraded all tests to JUnit 5, and removed the vintage platform. Problem though, since no tests are started by Gradle.
1 parent 346a852 commit 7585af0

143 files changed

Lines changed: 1014 additions & 1110 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

artwork/logo-flag.svg

Lines changed: 0 additions & 1 deletion
Loading

artwork/logo.svg

Lines changed: 0 additions & 1 deletion
Loading

artwork/pb-polygene.svg

Lines changed: 0 additions & 1 deletion
Loading

buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import org.gradle.api.tasks.bundling.Zip
4747
import org.gradle.language.base.plugins.LifecycleBasePlugin
4848
import org.gradle.maven.MavenModule
4949
import org.gradle.maven.MavenPomArtifact
50-
import org.gradle.plugins.ide.internal.IdeDependenciesExtractor
51-
import org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency
50+
//import org.gradle.plugins.ide.internal.IdeDependenciesExtractor
51+
//import org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency
5252
import org.gradle.plugins.signing.Sign
5353
import org.gradle.plugins.signing.SigningExtension
5454
import org.gradle.process.ExecSpec
@@ -553,6 +553,7 @@ class DistributionsPlugin implements Plugin<Project>
553553
}
554554
// Copy Maven artifacts using the Gradle IDE Model
555555
// Include sources if available, otherwise include javadoc if available
556+
/* TODO: Paul!!! These internal classes disappeared in Gradle between 4.2 and 4.6
556557
IdeDependenciesExtractor dependenciesExtractor = new IdeDependenciesExtractor()
557558
def ideDependencies = dependenciesExtractor.extractRepoFileDependencies project.dependencies,
558559
[ configuration ], [ ],
@@ -575,6 +576,7 @@ class DistributionsPlugin implements Plugin<Project>
575576
Files.exists( javadocDestination ) ?: Files.copy( ideDependency.javadocFile.toPath(), javadocDestination )
576577
}
577578
}
579+
*/
578580
}
579581
}
580582
project.tasks.create( TaskNames.ZIP_DEPENDENCIES_DIST, Zip ) { Zip task ->

buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.gradle.api.Project
3434
import org.gradle.api.Task
3535
import org.gradle.api.file.CopySpec
3636
import org.gradle.api.logging.LogLevel
37+
import org.gradle.api.logging.Logger
3738

3839
@CompileStatic
3940
class InternalDockerPlugin implements Plugin<Project>
@@ -84,7 +85,9 @@ class InternalDockerPlugin implements Plugin<Project>
8485
}
8586
else
8687
{
87-
project.logger.lifecycle "Unable to connect to Docker, all Docker tasks will be SKIPPED\n ${ ( ( Exception ) ex ).message }"
88+
def logger = project.logger
89+
def mess = ex == null ? "" : ((Exception) ex).message
90+
logger.lifecycle "Unable to connect to Docker, all Docker tasks will be SKIPPED\n ${ mess }"
8891
}
8992
}
9093
task.onComplete = {

core/testsupport/src/main/java/org/apache/polygene/test/PolygeneUnitExtension.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*
19+
*/
120
package org.apache.polygene.test;
221

322
import org.apache.polygene.api.structure.Application;
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*
19+
*/
20+
package org.apache.polygene.test;
21+
22+
import java.io.File;
23+
import java.io.IOException;
24+
import java.lang.reflect.UndeclaredThrowableException;
25+
import java.nio.file.FileVisitResult;
26+
import java.nio.file.Files;
27+
import java.nio.file.Path;
28+
import java.nio.file.SimpleFileVisitor;
29+
import java.nio.file.attribute.BasicFileAttributes;
30+
import org.junit.jupiter.api.extension.AfterEachCallback;
31+
import org.junit.jupiter.api.extension.BeforeEachCallback;
32+
import org.junit.jupiter.api.extension.Extension;
33+
import org.junit.jupiter.api.extension.ExtensionContext;
34+
35+
import static java.nio.file.FileVisitResult.CONTINUE;
36+
import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.BOTTOM_UP;
37+
import static org.junit.platform.commons.util.ReflectionUtils.findFields;
38+
39+
public class TemporaryFolder
40+
implements Extension, BeforeEachCallback, AfterEachCallback
41+
{
42+
private File root;
43+
44+
public TemporaryFolder()
45+
{
46+
}
47+
48+
@Override
49+
public void beforeEach( ExtensionContext context )
50+
throws Exception
51+
{
52+
try
53+
{
54+
root = File.createTempFile( "junit5-", ".tmp" );
55+
}
56+
catch( IOException ioe )
57+
{
58+
throw new RuntimeException( ioe );
59+
}
60+
root.delete(); // Remove if already exists
61+
root.mkdir();
62+
63+
findFields( context.getRequiredTestClass(),
64+
f -> f.getType().equals( TemporaryFolder.class ), BOTTOM_UP )
65+
.forEach( f -> {
66+
try
67+
{
68+
f.setAccessible( true );
69+
f.set( context.getRequiredTestInstance(), this );
70+
}
71+
catch( IllegalAccessException e )
72+
{
73+
throw new UndeclaredThrowableException( e );
74+
}
75+
} );
76+
}
77+
78+
@Override
79+
public void afterEach( ExtensionContext context )
80+
throws Exception
81+
{
82+
try
83+
{
84+
Files.walkFileTree( root.toPath(), new DeleteAllVisitor() );
85+
}
86+
catch( IOException ioe )
87+
{
88+
throw new RuntimeException( ioe );
89+
}
90+
}
91+
92+
public File file( String name )
93+
throws IOException
94+
{
95+
return new File( root, name );
96+
}
97+
98+
public File getRoot()
99+
{
100+
return root;
101+
}
102+
103+
private static class DeleteAllVisitor extends SimpleFileVisitor<Path>
104+
{
105+
@Override
106+
public FileVisitResult visitFile( Path file, BasicFileAttributes attributes )
107+
throws IOException
108+
{
109+
Files.delete( file );
110+
return CONTINUE;
111+
}
112+
113+
@Override
114+
public FileVisitResult postVisitDirectory( Path directory, IOException exception )
115+
throws IOException
116+
{
117+
Files.delete( directory );
118+
return CONTINUE;
119+
}
120+
}
121+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.apache.polygene.test;
2+
3+
import java.lang.reflect.UndeclaredThrowableException;
4+
import java.util.Optional;
5+
import org.junit.jupiter.api.extension.BeforeAllCallback;
6+
import org.junit.jupiter.api.extension.BeforeEachCallback;
7+
import org.junit.jupiter.api.extension.ExtensionContext;
8+
9+
import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.BOTTOM_UP;
10+
import static org.junit.platform.commons.util.ReflectionUtils.findFields;
11+
12+
public class TestName
13+
implements BeforeAllCallback, BeforeEachCallback
14+
{
15+
private String testName;
16+
private String methodName;
17+
18+
@Override
19+
public void beforeAll( ExtensionContext context )
20+
throws Exception
21+
{
22+
Optional<Class<?>> testClass = context.getTestClass();
23+
testClass.ifPresent( cls -> testName = cls.getName() );
24+
context.getTestMethod().ifPresent( m -> methodName = m.getName() );
25+
inject( context );
26+
}
27+
28+
@Override
29+
public void beforeEach( ExtensionContext context )
30+
throws Exception
31+
{
32+
Optional<Class<?>> testClass = context.getTestClass();
33+
testClass.ifPresent( cls -> testName = cls.getName() );
34+
context.getTestMethod().ifPresent( m -> methodName = m.getName() );
35+
inject( context );
36+
}
37+
38+
private void inject( ExtensionContext context )
39+
{
40+
findFields( context.getRequiredTestClass(),
41+
f -> f.getType().equals( TestName.class ), BOTTOM_UP )
42+
.forEach( f -> {
43+
try
44+
{
45+
f.setAccessible( true );
46+
f.set( context.getRequiredTestInstance(), this );
47+
}
48+
catch( IllegalAccessException e )
49+
{
50+
throw new UndeclaredThrowableException( e );
51+
}
52+
} );
53+
}
54+
55+
public String getTestName()
56+
{
57+
return testName;
58+
}
59+
60+
public String getMethodName()
61+
{
62+
return methodName;
63+
}
64+
}

core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractAnyQueryTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.polygene.test.model.Protocol;
3838
import org.apache.polygene.test.model.QueryParam;
3939
import org.apache.polygene.test.model.URL;
40+
import org.junit.jupiter.api.AfterEach;
4041
import org.junit.jupiter.api.BeforeEach;
4142

4243
/**
@@ -89,6 +90,7 @@ public void setUp()
8990

9091

9192
@Override
93+
@AfterEach
9294
public void tearDown()
9395
{
9496
if( this.unitOfWork != null )

dependencies.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import org.apache.polygene.gradle.dependencies.DependenciesDeclarationExtension
2020
def dependencies = extensions.getByType(DependenciesDeclarationExtension)
2121

2222
// Gradle version
23-
dependencies.gradleVersion = '4.2.1'
23+
dependencies.gradleVersion = '4.6'
2424

2525
// Remote repositories
2626
dependencies.repositoriesUrls << [
@@ -79,7 +79,7 @@ def servletVersion = '3.1.0'
7979
def shiroVersion = '1.4.0'
8080
def slf4jVersion = '1.7.25'
8181
def solrVersion = "1.4.1" // 4.x Fails to compile!
82-
def springVersion = '4.3.9.RELEASE'
82+
def springVersion = '5.0.5.RELEASE'
8383
def spymemcachedVersion = '2.12.3'
8484
def velocityVersion = '1.7'
8585
dependencies.libraries << [
@@ -184,7 +184,8 @@ dependencies.libraries << [
184184
// Runtime, Test and Samples dependencies
185185
def awaitilityVersion = '3.0.0'
186186
def dnsJavaVersion = '2.1.8'
187-
def dockerJUnitVersion = '0.3'
187+
def dockerJUnit5Version = '1.0.0-RC5'
188+
188189
def easyMockVersion = '3.4'
189190
def h2Version = '1.4.196'
190191
def hamcrestVersion = '1.3'
@@ -200,15 +201,15 @@ dependencies.libraries << [
200201
awaitility : "org.awaitility:awaitility:$awaitilityVersion",
201202
derby : "org.apache.derby:derby:$derbyVersion",
202203
dnsjava : "dnsjava:dnsjava:$dnsJavaVersion",
203-
docker_junit : "com.github.tdomzal:junit-docker-rule:$dockerJUnitVersion",
204+
docker_junit : "com.github.faustxvi:junit5-docker:$dockerJUnit5Version",
205+
204206
easymock : "org.easymock:easymock:$easyMockVersion",
205207
h2 : "com.h2database:h2:$h2Version",
206208
hamcrest : ["org.hamcrest:hamcrest-core:$hamcrestVersion",
207209
"org.hamcrest:hamcrest-library:$hamcrestVersion"],
208210
junit : ["org.junit.jupiter:junit-jupiter-api:$junitVersion",
209211
"org.junit.jupiter:junit-jupiter-params:$junitVersion"
210212
],
211-
junit_vintage : "org.junit.vintage:junit-vintage-engine:$junitVersion",
212213

213214
logback : "ch.qos.logback:logback-classic:$logbackVersion",
214215
mockito : "org.mockito:mockito-core:$mockitoVersion",

0 commit comments

Comments
 (0)