Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 67c391d

Browse files
committed
#135: Upgraded tests to JUnit 5
Removed jcenter dependency as well
1 parent 6566ce1 commit 67c391d

25 files changed

+162
-276
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ out
1313
target
1414
gradle-local.properties
1515
snyk
16-
16+
.vscode

build.gradle

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,65 @@ plugins {
33
id "maven-publish"
44
id "eclipse"
55
id "idea"
6-
id "com.jfrog.bintray" version "1.8.4"
76
id "com.github.jk1.dependency-license-report" version "1.3"
8-
9-
id "net.saliman.properties" version "1.5.1"
107
id "io.snyk.gradle.plugin.snykplugin" version "0.4"
118
}
129

10+
group = "com.marklogic"
11+
archivesBaseName = "ml-javaclient-util"
12+
version = "4.1-SNAPSHOT"
13+
1314
sourceCompatibility = "8"
1415
targetCompatibility = "8"
1516

1617
repositories {
17-
jcenter()
1818
mavenCentral()
19-
maven { url "http://developer.marklogic.com/maven2/" }
2019
}
2120

2221
dependencies {
23-
api 'com.marklogic:marklogic-client-api:5.3.2'
24-
api 'com.marklogic:marklogic-xcc:10.0.5'
25-
api 'org.jdom:jdom2:2.0.6'
26-
api 'org.springframework:spring-context:5.2.9.RELEASE'
22+
api ('com.marklogic:marklogic-client-api:5.4.0') {
23+
// This isn't available via mavenCentral with its 2.3 coordinates, so it's excluded
24+
// and then depended on below via its 2.5 coordinates
25+
exclude module: "okhttp-digest"
26+
}
27+
implementation 'io.github.rburgst:okhttp-digest:2.5'
28+
29+
api 'com.marklogic:marklogic-xcc:10.0.6.2'
30+
api 'org.springframework:spring-context:5.3.7'
2731

28-
testImplementation 'junit:junit:4+'
29-
testImplementation 'org.springframework:spring-test:5.2.9.RELEASE'
32+
implementation 'org.jdom:jdom2:2.0.6'
33+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.1'
34+
implementation 'org.slf4j:slf4j-api:1.7.30'
35+
36+
testImplementation "org.junit.jupiter:junit-jupiter:5.7.1"
37+
testImplementation 'org.springframework:spring-test:5.3.7'
3038

3139
// Used for testing loading modules from the classpath
32-
testRuntime files("lib/modules.jar")
40+
testImplementation files("lib/modules.jar")
3341

3442
// Forcing Spring to use logback instead of commons-logging
35-
testRuntime "ch.qos.logback:logback-classic:1.2.3"
36-
testRuntime group: "org.slf4j", name: "jcl-over-slf4j", version: "1.7.30"
37-
testRuntime group: "org.slf4j", name: "slf4j-api", version: "1.7.30"
43+
testImplementation "ch.qos.logback:logback-classic:1.2.3"
44+
testImplementation "org.slf4j:jcl-over-slf4j:1.7.30"
45+
testImplementation "org.slf4j:slf4j-api:1.7.30"
46+
}
47+
48+
test {
49+
useJUnitPlatform()
50+
testLogging {
51+
events 'started','passed', 'skipped', 'failed'
52+
exceptionFormat 'full'
53+
}
3854
}
3955

4056
task sourcesJar(type: Jar, dependsOn: classes) {
4157
classifier 'sources'
42-
from sourceSets.main.allJava
58+
from sourceSets.main.allSource
4359
}
4460

4561
task javadocJar(type: Jar, dependsOn: javadoc) {
4662
classifier "javadoc"
47-
from file(javadocsDir + "/" + project.name)
63+
from javadoc
4864
}
49-
50-
javadoc.destinationDir = file(javadocsDir + "/" + project.name)
5165
javadoc.failOnError = false
5266

5367
publishing {
@@ -65,31 +79,6 @@ publishing {
6579
}
6680
}
6781

68-
if (project.hasProperty("myBintrayUser")) {
69-
bintray {
70-
user = myBintrayUser
71-
key = myBintrayKey
72-
publications = ['mainJava', 'sourcesJava']
73-
pkg {
74-
repo = 'maven'
75-
name = project.name
76-
licenses = ['Apache-2.0']
77-
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
78-
version {
79-
name = project.version
80-
released = new Date()
81-
}
82-
}
83-
}
84-
}
85-
86-
test {
87-
testLogging {
88-
events 'started','passed', 'skipped', 'failed'
89-
exceptionFormat 'full'
90-
}
91-
}
92-
9382
// See https://github.com/snyk/gradle-plugin for more information
9483
snyk {
9584
//arguments = '--all-sub-projects'

gradle.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
group=com.marklogic
2-
javadocsDir=../gh-pages-marklogic-java/javadocs
3-
version=4.1.1
4-
5-
# Define this via gradle-local.properties or on the command line when running snyk-test
1+
# Define this on the command line when running snyk-test
62
snykToken=

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip

pom.xml.old

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/test/java/com/marklogic/client/ext/AbstractIntegrationTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.marklogic.client.DatabaseClient;
44
import com.marklogic.client.ext.spring.SpringDatabaseClientConfig;
5-
import org.junit.After;
6-
import org.junit.Assert;
7-
import org.junit.runner.RunWith;
5+
import org.junit.jupiter.api.AfterEach;
6+
import org.junit.jupiter.api.extension.ExtendWith;
87
import org.slf4j.Logger;
98
import org.slf4j.LoggerFactory;
109
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,11 +13,11 @@
1413
import org.springframework.context.annotation.PropertySource;
1514
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
1615
import org.springframework.test.context.ContextConfiguration;
17-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
16+
import org.springframework.test.context.junit.jupiter.SpringExtension;
1817

19-
@RunWith(SpringJUnit4ClassRunner.class)
18+
@ExtendWith(SpringExtension.class)
2019
@ContextConfiguration(classes = {TestConfig.class})
21-
public abstract class AbstractIntegrationTest extends Assert {
20+
public abstract class AbstractIntegrationTest {
2221

2322
protected Logger logger = LoggerFactory.getLogger(getClass());
2423

@@ -33,7 +32,7 @@ protected DatabaseClient newClient() {
3332
return client;
3433
}
3534

36-
@After
35+
@AfterEach
3736
public void releaseClientOnTearDown() {
3837
if (client != null) {
3938
try {

src/test/java/com/marklogic/client/ext/batch/RestBatchWriterTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.marklogic.client.io.FileHandle;
1313
import com.marklogic.client.io.Format;
1414
import com.marklogic.client.io.StringHandle;
15-
import org.junit.Test;
15+
import org.junit.jupiter.api.Test;
1616
import org.springframework.core.io.FileSystemResource;
1717
import org.springframework.core.io.Resource;
1818

@@ -21,6 +21,8 @@
2121
import java.util.Arrays;
2222
import java.util.List;
2323

24+
import static org.junit.jupiter.api.Assertions.*;
25+
2426
public class RestBatchWriterTest extends AbstractIntegrationTest {
2527

2628
@Test
@@ -55,7 +57,7 @@ public void failureTestWithCustomListener() {
5557
writer.waitForCompletion();
5658

5759
Throwable caughtError = testWriteListener.caughtError;
58-
assertNotNull("An error should have been thrown due to the invalid XML", caughtError);
60+
assertNotNull(caughtError, "An error should have been thrown due to the invalid XML");
5961
assertTrue(caughtError instanceof FailedRequestException);
6062
}
6163

src/test/java/com/marklogic/client/ext/es/EntityServicesTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.marklogic.client.ext.es;
22

33
import com.marklogic.client.ext.AbstractIntegrationTest;
4-
import org.junit.Before;
5-
import org.junit.Test;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.*;
68

79
/**
810
* Tests against the default Documents database. Doesn't clear it out before or after.
@@ -33,7 +35,7 @@ public class EntityServicesTest extends AbstractIntegrationTest {
3335
" }\n" +
3436
"}";
3537

36-
@Before
38+
@BeforeEach
3739
public void setup() {
3840
client = newClient("Documents");
3941
}

src/test/java/com/marklogic/client/ext/file/CollectionsFileDocumentFileProcessorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.marklogic.client.ext.file;
22

33
import com.marklogic.client.ext.tokenreplacer.DefaultTokenReplacer;
4-
import org.junit.Assert;
5-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
65

76
import java.io.File;
87
import java.util.Properties;
98

10-
public class CollectionsFileDocumentFileProcessorTest extends Assert {
9+
import static org.junit.jupiter.api.Assertions.*;
10+
11+
public class CollectionsFileDocumentFileProcessorTest {
1112

1213
private CollectionsFileDocumentFileProcessor processor = new CollectionsFileDocumentFileProcessor();
1314

src/test/java/com/marklogic/client/ext/file/DocumentFinderTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.marklogic.client.ext.file;
22

3-
import com.marklogic.client.ext.file.DefaultDocumentFileReader;
4-
import com.marklogic.client.ext.file.DocumentFile;
5-
import com.marklogic.client.ext.file.DocumentFileReader;
6-
import org.junit.Assert;
7-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
84

95
import java.nio.file.Paths;
106
import java.util.ArrayList;
117
import java.util.List;
128

13-
public class DocumentFinderTest extends Assert {
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.assertTrue;
11+
12+
public class DocumentFinderTest {
1413

1514
private DocumentFileReader sut = new DefaultDocumentFileReader();
1615

0 commit comments

Comments
 (0)