diff --git a/.gitignore b/.gitignore
index 5c4b0fb..b1adc24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,9 +3,9 @@
.idea/modules
.idea/.gitignore
build
-gradle
.gradle
.gradle.properties
bin
.vscode
+gradle/wrapper/gradle-wrapper.jar
gradle.properties.for-release
diff --git a/.run/Run integration tests.run.xml b/.run/Run integration tests.run.xml
new file mode 100644
index 0000000..981d9a8
--- /dev/null
+++ b/.run/Run integration tests.run.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/.run/Run unit tests.run.xml b/.run/Run unit tests.run.xml
new file mode 100644
index 0000000..446fc9d
--- /dev/null
+++ b/.run/Run unit tests.run.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 24a52fb..d09d6f9 100644
--- a/README.md
+++ b/README.md
@@ -40,4 +40,24 @@ if (response.isSuccessful){
val members = response.body();
}
```
-Please note that in order to create API stub, you have to specify that the response should be converted by gson. And that's how you can easily use r2z.
\ No newline at end of file
+Please note that in order to create API stub, you have to specify that the response should be converted by gson. And that's how you can easily use r2z.
+
+## How to run tests
+
+### Unit tests
+To run unit tests:
+```
+./gradlew test -x signArchives
+```
+### Integration tests
+**NOTE:** integration tests use a specific environment. To test their correctness, you need either create the compliant one, or change the tests
+
+Before running integration tests, you need three variables to be set up:
+- ``ZOSMF_TEST_URL`` - URL of the real mainframe with z/OSMF API to run the tests
+- ``ZOSMF_TEST_USERNAME`` - username with appropriate permissions to run the tests
+- ``ZOSMF_TEST_PASSWORD`` - user password to run the tests
+
+To run integration tests:
+```
+./gradlew intTest
+```
diff --git a/build.gradle b/build.gradle
index a605495..655bafb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,14 +25,14 @@ repositories {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
- implementation "org.jetbrains.kotlin:kotlin-reflect:1.4.21"
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
- testImplementation 'com.squareup.okhttp:mockwebserver:1.2.1'
+ implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.21"
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
implementation 'com.squareup.retrofit2:retrofit:2.9.0',
'com.squareup.retrofit2:converter-gson:2.9.0',
'com.squareup.retrofit2:converter-scalars:2.9.0',
- 'com.google.code.gson:gson:2.9.0',
+ 'com.google.code.gson:gson:2.10',
'com.starxg:java-keytar:1.0.0',
'org.yaml:snakeyaml:1.29',
'org.junit.jupiter:junit-jupiter-api:5.8.2'
@@ -59,6 +59,43 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
+/**
+ * Adds intTest source sets
+ */
+sourceSets {
+ intTest {
+ java {
+ compileClasspath += main.output
+ runtimeClasspath += main.output
+ srcDir 'src/intTest/kotlin'
+ }
+ resources {
+ srcDir 'src/intTest/resources'
+ }
+ }
+}
+
+/**
+ * Configures the integration tests to inherit the testImplementation and testRuntimeOnly in dependencies
+ */
+configurations {
+ intTestImplementation.extendsFrom testImplementation
+ intTestRuntimeOnly.extendsFrom testRuntimeOnly
+}
+
+task intTest(type:Test) {
+ description = "Run integration tests"
+ group = "verification"
+ testClassesDirs = sourceSets.intTest.output.classesDirs
+ classpath = sourceSets.intTest.runtimeClasspath
+ useJUnitPlatform() {
+ excludeTags "FirstTime"
+ }
+ testLogging {
+ events("passed", "skipped", "failed")
+ }
+}
+
artifacts {
archives jar
archives sourceJar
@@ -151,7 +188,6 @@ def customizePom(pom) {
}
}
-
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
diff --git a/gradle.properties b/gradle.properties
index 74b3cbf..27a74f1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -10,4 +10,4 @@ signing.keyId=FADC1195
signing.password=key_pass
signing.secretKeyRingFile=path/to/secret/key
-projectVersion=1.2.2
+projectVersion=1.2.3
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..aa991fc
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/src/intTest/intTest.iml b/src/intTest/intTest.iml
new file mode 100644
index 0000000..0b61efc
--- /dev/null
+++ b/src/intTest/intTest.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/kotlin/eu/ibagroup/r2z/BaseTest.kt b/src/intTest/kotlin/common/BaseTest.kt
similarity index 92%
rename from src/test/kotlin/eu/ibagroup/r2z/BaseTest.kt
rename to src/intTest/kotlin/common/BaseTest.kt
index e25e2cc..ed1d0cb 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/BaseTest.kt
+++ b/src/intTest/kotlin/common/BaseTest.kt
@@ -1,7 +1,8 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.BytesConverterFactory
import okhttp3.Credentials
import okhttp3.OkHttpClient
import retrofit2.Retrofit
@@ -38,7 +39,7 @@ open class BaseTest {
return try {
- val trustAllCerts: Array = arrayOf(
+ val trustAllCerts: Array = arrayOf(
object : X509TrustManager {
@Throws(CertificateException::class)
override fun checkClientTrusted(
@@ -62,7 +63,7 @@ open class BaseTest {
val sslContext: SSLContext = SSLContext.getInstance("TLSv1.2")
sslContext.init(null, trustAllCerts, SecureRandom())
- val sslSocketFactory: SSLSocketFactory = sslContext.getSocketFactory()
+ val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory
val builder = OkHttpClient.Builder()
builder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager)
builder.hostnameVerifier(object : HostnameVerifier {
@@ -75,4 +76,4 @@ open class BaseTest {
throw RuntimeException(e)
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/CancelJobAndPurgeOutputTest.kt b/src/intTest/kotlin/common/CancelJobAndPurgeOutputTest.kt
similarity index 89%
rename from src/test/kotlin/eu/ibagroup/r2z/CancelJobAndPurgeOutputTest.kt
rename to src/intTest/kotlin/common/CancelJobAndPurgeOutputTest.kt
index e1fc466..fce47a0 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/CancelJobAndPurgeOutputTest.kt
+++ b/src/intTest/kotlin/common/CancelJobAndPurgeOutputTest.kt
@@ -1,7 +1,10 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.CancelJobPurgeOutRequest
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.ProcessMethod
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import retrofit2.Call
@@ -43,7 +46,7 @@ class CancelJobAndPurgeOutputTest : BaseTest() {
println(jobStatus.status)
Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner?.toLowerCase(), "hlh")
+ Assertions.assertEquals(jobStatus.owner?.lowercase(), "hlh")
} else
{
println(response.errorBody())
diff --git a/src/intTest/kotlin/common/CancelJobTest.kt b/src/intTest/kotlin/common/CancelJobTest.kt
new file mode 100644
index 0000000..bcec192
--- /dev/null
+++ b/src/intTest/kotlin/common/CancelJobTest.kt
@@ -0,0 +1,58 @@
+// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
+
+package common
+
+import eu.ibagroup.r2z.CancelJobRequest
+import eu.ibagroup.r2z.CancelJobRequestBody
+import eu.ibagroup.r2z.JESApi
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
+import retrofit2.Call
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+class CancelJobTest : BaseTest() {
+ val JOB_ID = "JOB06200"
+ val JOB_NAME = "NOTHINGJ"
+
+ val JOB_CORRELATOR = "J0001561S0W1....D940967F.......:"
+
+ // 0 - request was successful
+ val SUCCESSFUL_REQUEST_RESULT = "0"
+
+ @Test
+ fun cancelJobTest() {
+ val retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .client(getUnsafeOkHttpClient())
+ .build()
+
+ val request = retrofit.create(JESApi::class.java)
+ val call: Call = request
+ .cancelJobRequest(
+ BASIC_AUTH_TOKEN,
+ JOB_NAME,
+ JOB_ID,
+ CancelJobRequestBody()
+ )
+ enqueueCancelJobCallAndCheckResult(call)
+ }
+
+ fun enqueueCancelJobCallAndCheckResult(call: Call) {
+ val response = call.execute()
+
+ if (response.isSuccessful)
+ {
+ val jobStatus: CancelJobRequest = response.body() as CancelJobRequest
+ println(jobStatus.status)
+ Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
+ Assertions.assertNotNull(jobStatus.owner)
+ Assertions.assertEquals(jobStatus.owner?.lowercase(), "hlh")
+ } else
+ {
+ println(response.errorBody())
+ Assertions.assertTrue(false)
+ }
+ }
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/DataAPITest.kt b/src/intTest/kotlin/common/DataAPITest.kt
similarity index 99%
rename from src/test/kotlin/eu/ibagroup/r2z/DataAPITest.kt
rename to src/intTest/kotlin/common/DataAPITest.kt
index ca9fdaf..41ae35e 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/DataAPITest.kt
+++ b/src/intTest/kotlin/common/DataAPITest.kt
@@ -1,7 +1,8 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.*
import org.junit.jupiter.api.Test
diff --git a/src/intTest/kotlin/common/HoldJobFor10sThenReleaseTest.kt b/src/intTest/kotlin/common/HoldJobFor10sThenReleaseTest.kt
new file mode 100644
index 0000000..032a88b
--- /dev/null
+++ b/src/intTest/kotlin/common/HoldJobFor10sThenReleaseTest.kt
@@ -0,0 +1,80 @@
+// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
+package common
+
+import eu.ibagroup.r2z.*
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
+import retrofit2.Call
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.*
+
+class HoldJobFor10sThenReleaseTest : BaseTest() {
+ val JOB_ID = "JOB06152"
+ val JOB_NAME = "NOTHINGJ"
+
+ val JOB_CORRELATOR = "J0001561S0W1....D940967F.......:"
+
+ // 0 - request was successful
+ val SUCCESSFUL_REQUEST_RESULT = 0
+
+ @Test
+ fun holdFor10sThenReleaseJobTest() {
+ val retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .client(getUnsafeOkHttpClient())
+ .build()
+
+ val request = retrofit.create(JESApi::class.java)
+ val firstCall: Call = request
+ .holdJobRequest(
+ BASIC_AUTH_TOKEN,
+ JOB_NAME,
+ JOB_ID,
+ HoldJobRequestBody()
+ )
+
+ enqueueHoldCallAndCheckResult(firstCall)
+
+ Thread.sleep(10000)
+
+ val secondCall: Call = request
+ .releaseJobRequest(
+ BASIC_AUTH_TOKEN,
+ JOB_NAME,
+ JOB_ID,
+ ReleaseJobRequestBody()
+ )
+
+ enqueueReleaseCallAndCheckResult(secondCall)
+ }
+
+ fun enqueueHoldCallAndCheckResult(call: Call) {
+ val response = call.execute()
+ if (response.isSuccessful) {
+ val jobStatus: HoldJobRequest = response.body() as HoldJobRequest
+ println(jobStatus.status)
+ Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
+ Assertions.assertNotNull(jobStatus.owner)
+ Assertions.assertEquals(jobStatus.owner?.lowercase(Locale.getDefault()), "hlh")
+ } else {
+ println(response.errorBody())
+ Assertions.assertTrue(false)
+ }
+ }
+
+ fun enqueueReleaseCallAndCheckResult(call: Call) {
+ val response = call.execute()
+ if (response.isSuccessful) {
+ val jobStatus: ReleaseJobRequest = response.body() as ReleaseJobRequest
+ println(jobStatus.status)
+ Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
+ Assertions.assertNotNull(jobStatus.owner)
+ Assertions.assertEquals(jobStatus.owner?.lowercase(Locale.getDefault()), "hlh")
+ } else {
+ println(response.errorBody())
+ Assertions.assertTrue(false)
+ }
+ }
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/ListFilteredJobsTest.kt b/src/intTest/kotlin/common/ListFilteredJobsTest.kt
similarity index 97%
rename from src/test/kotlin/eu/ibagroup/r2z/ListFilteredJobsTest.kt
rename to src/intTest/kotlin/common/ListFilteredJobsTest.kt
index 4b35823..c7b9156 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/ListFilteredJobsTest.kt
+++ b/src/intTest/kotlin/common/ListFilteredJobsTest.kt
@@ -1,7 +1,9 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.Job
import org.junit.jupiter.api.*
import retrofit2.Call
import java.util.concurrent.TimeUnit
@@ -79,4 +81,4 @@ class ListFilteredJobsTest : BaseTest() {
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/ListSpoolFilesTest.kt b/src/intTest/kotlin/common/ListSpoolFilesTest.kt
similarity index 85%
rename from src/test/kotlin/eu/ibagroup/r2z/ListSpoolFilesTest.kt
rename to src/intTest/kotlin/common/ListSpoolFilesTest.kt
index 3c810a1..51d1e9e 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/ListSpoolFilesTest.kt
+++ b/src/intTest/kotlin/common/ListSpoolFilesTest.kt
@@ -1,7 +1,9 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.SpoolFile
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@@ -30,12 +32,12 @@ class ListSpoolFilesTest : BaseTest(){
}
fun executeCallAndCheckResult(call: Call>){
- var response = call.execute()
- if(response.isSuccessful == true){
- var spoolFiles = response.body()
+ val response = call.execute()
+ if (response.isSuccessful){
+ val spoolFiles = response.body()
spoolFiles?.forEach { el-> println(el) }
} else{
Assertions.assertTrue(false)
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/ObtainJobStatusTest.kt b/src/intTest/kotlin/common/ObtainJobStatusTest.kt
similarity index 85%
rename from src/test/kotlin/eu/ibagroup/r2z/ObtainJobStatusTest.kt
rename to src/intTest/kotlin/common/ObtainJobStatusTest.kt
index 7a804dc..caa0f24 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/ObtainJobStatusTest.kt
+++ b/src/intTest/kotlin/common/ObtainJobStatusTest.kt
@@ -1,7 +1,10 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.Job
+import eu.ibagroup.r2z.UseStepData
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@@ -16,8 +19,6 @@ class ObtainJobStatusTest : BaseTest() {
val JOB_ID = "JOB05569"
val JOB_NAME = "NOTHINGJ"
-
-
@Test
fun obtainStatusByNameAndIdTest() {
val call = jesApi.getJob(BASIC_AUTH_TOKEN, JOB_NAME, JOB_ID, UseStepData.DISABLE)
@@ -35,13 +36,12 @@ class ObtainJobStatusTest : BaseTest() {
val response = call.execute()
if (response.isSuccessful) {
val jobStatus = response.body() as Job
- jobStatus.steps?.forEach { el ->
+ jobStatus.steps.forEach { el ->
println(el)
-
}
Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner.toLowerCase(), "hlh")
+ Assertions.assertEquals(jobStatus.owner.lowercase(), "hlh")
} else {
println(response.errorBody())
diff --git a/src/test/kotlin/eu/ibagroup/r2z/SpoolFileRecordsTest.kt b/src/intTest/kotlin/common/SpoolFileRecordsTest.kt
similarity index 88%
rename from src/test/kotlin/eu/ibagroup/r2z/SpoolFileRecordsTest.kt
rename to src/intTest/kotlin/common/SpoolFileRecordsTest.kt
index 600ffe7..7b7a895 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/SpoolFileRecordsTest.kt
+++ b/src/intTest/kotlin/common/SpoolFileRecordsTest.kt
@@ -1,13 +1,15 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.BinaryMode
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.RecordRange
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import retrofit2.Call
-
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class SpoolFileRecordsTest : BaseTest() {
val jesApi = buildApi(BASE_URL, getUnsafeOkHttpClient())
@@ -44,8 +46,8 @@ class SpoolFileRecordsTest : BaseTest() {
fun executeCallAndCheckResult(call: Call) {
val response = call.execute()
- if (response.isSuccessful == true) {
- var arr = response.body() as ByteArray
+ if (response.isSuccessful) {
+ val arr = response.body() as ByteArray
println(arr.toString(Charsets.UTF_8))
} else {
@@ -54,4 +56,4 @@ class SpoolFileRecordsTest : BaseTest() {
}
-}
\ No newline at end of file
+}
diff --git a/src/intTest/kotlin/common/SubmitJobRequestTest.kt b/src/intTest/kotlin/common/SubmitJobRequestTest.kt
new file mode 100644
index 0000000..8d6e9ed
--- /dev/null
+++ b/src/intTest/kotlin/common/SubmitJobRequestTest.kt
@@ -0,0 +1,72 @@
+// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
+
+package common
+
+import eu.ibagroup.r2z.JESApi
+import eu.ibagroup.r2z.SubmitFileNameBody
+import eu.ibagroup.r2z.SubmitJobRequest
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
+import retrofit2.Call
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+
+class SubmitJobRequestTest : BaseTest() {
+ val JOB_PATH = "//'HHAL.PLUGIN.TEST.JOBS(JOB1)'"
+
+ @Test
+ fun submitJobOnZOS_System() {
+ val retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .client(getUnsafeOkHttpClient())
+ .build()
+
+ val request = retrofit.create(JESApi::class.java)
+ val call: Call = request.submitJobRequest(BASIC_AUTH_TOKEN,
+ body = SubmitFileNameBody(file = JOB_PATH)
+ )
+ enqueueSubmitJob(call)
+ }
+
+ @Test
+ fun submitJobFromInputText() {
+ val retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(ScalarsConverterFactory.create())
+ .addConverterFactory(GsonConverterFactory.create())
+ .client(getUnsafeOkHttpClient())
+ .build()
+
+ val request = retrofit.create(JESApi::class.java)
+ val body = "" +
+ "//NOTHINGJ JOB CLASS=B,MSGLEVEL=(1,1),MSGCLASS=X,\n" +
+ "// NOTIFY=HAL,REGION=6M\n" +
+ "//*********\n" +
+ "//STEP0 EXEC PGM=IEFBR14\n" +
+ "//SYSPRINT DD SYSOUT=*\n" +
+ "//SYSIN DD *\n" +
+ "//STEP1 EXEC PGM=IKJEFT01,PARM='JOB2'\n" +
+ "//SYSPROC DD DSN=HHAL.PLUGIN.TEST.JOBS,DISP=SHR\n" +
+ "//SYSTSPRT DD SYSOUT=*\n" +
+ "//SYSTSIN DD DUMMY,DCB=BLKSIZE=80"
+ val call: Call = request.submitJobRequest(BASIC_AUTH_TOKEN, body = body)
+ enqueueSubmitJob(call)
+ }
+
+ fun enqueueSubmitJob(call: Call) {
+ val response = call.execute()
+ if (response.isSuccessful) {
+ val jobStatus: SubmitJobRequest = response.body() as SubmitJobRequest
+ println(jobStatus.jobid)
+ println(jobStatus.jobname)
+ println(jobStatus.status)
+ Assertions.assertNotNull(jobStatus.owner)
+ Assertions.assertEquals(jobStatus.owner?.lowercase(), "hlh")
+ } else {
+ println(response.errorBody())
+ Assertions.assertTrue(false)
+ }
+ }
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/TestValues.kt b/src/intTest/kotlin/common/TestValues.kt
similarity index 62%
rename from src/test/kotlin/eu/ibagroup/r2z/TestValues.kt
rename to src/intTest/kotlin/common/TestValues.kt
index e6f3dab..0d9ee53 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/TestValues.kt
+++ b/src/intTest/kotlin/common/TestValues.kt
@@ -1,24 +1,16 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
-import com.google.gson.Gson
-import com.google.gson.GsonBuilder
import okhttp3.Credentials
-import okhttp3.OkHttpClient
import okhttp3.ResponseBody
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-import retrofit2.converter.scalars.ScalarsConverterFactory
val zosmfUrl = System.getenv("ZOSMF_TEST_URL") ?: ""
val zosmfUser = System.getenv("ZOSMF_TEST_USERNAME") ?: ""
val zosmfPassword = System.getenv("ZOSMF_TEST_PASSWORD") ?: ""
-val basicCreds = Credentials.basic(zosmfUser, zosmfPassword) ?: ""
-
-
+val basicCreds = Credentials.basic(zosmfUser, zosmfPassword)
fun errorBodyToList(errorBody: ResponseBody) : List {
return errorBody.charStream().readLines()
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/TsoApiTest.kt b/src/intTest/kotlin/common/TsoApiTest.kt
similarity index 98%
rename from src/test/kotlin/eu/ibagroup/r2z/TsoApiTest.kt
rename to src/intTest/kotlin/common/TsoApiTest.kt
index 2681d17..b0ef447 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/TsoApiTest.kt
+++ b/src/intTest/kotlin/common/TsoApiTest.kt
@@ -1,7 +1,8 @@
// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-package eu.ibagroup.r2z
+package common
+import eu.ibagroup.r2z.*
import org.junit.jupiter.api.Test
class TsoApiTest: BaseTest() {
@@ -68,4 +69,4 @@ class TsoApiTest: BaseTest() {
val body = response.body() as TsoResponse
assert(body.servletKey == servletKey)
}
-}
\ No newline at end of file
+}
diff --git a/src/intTest/kotlin/common/ZoweConfigParsingTest.kt b/src/intTest/kotlin/common/ZoweConfigParsingTest.kt
new file mode 100644
index 0000000..b033e3b
--- /dev/null
+++ b/src/intTest/kotlin/common/ZoweConfigParsingTest.kt
@@ -0,0 +1,38 @@
+// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
+
+package common
+
+import okhttp3.mockwebserver.MockWebServer
+import eu.ibagroup.r2z.DataAPI
+import eu.ibagroup.r2z.zowe.config.*
+import okhttp3.OkHttpClient
+import org.junit.jupiter.api.*
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class ZoweConfigParsingTest() {
+
+ lateinit var mockServer: MockWebServer
+ lateinit var proxyClient: OkHttpClient
+ lateinit var keytarWrapper: KeytarWrapper
+ lateinit var zoweConfig: ZoweConfig
+
+ @Test
+ fun readConfigAndListDatasets() {
+ val authToken = zoweConfig.getAuthEncoding().withBasicPrefix()
+
+ val dataApi = buildGsonApi("http://${zoweConfig.host}:${zoweConfig.port}", proxyClient)
+ val response = dataApi
+ .listDataSets(
+ authorizationToken = authToken,
+ dsLevel = "TEST.*"
+ )
+ .execute()
+ if (response.isSuccessful) {
+ val datasetLists = response.body()
+ Assertions.assertEquals(datasetLists?.items?.size, 4)
+ } else {
+ Assertions.fail("response must be successful.")
+ }
+ }
+
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/CancelJobTest.kt b/src/test/kotlin/eu/ibagroup/r2z/CancelJobTest.kt
deleted file mode 100644
index 526a22b..0000000
--- a/src/test/kotlin/eu/ibagroup/r2z/CancelJobTest.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-
-package eu.ibagroup.r2z
-
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
-import retrofit2.Call
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-
-class CancelJobTest : BaseTest() {
- val JOB_ID = "JOB06200"
- val JOB_NAME = "NOTHINGJ"
-
- val JOB_CORRELATOR = "J0001561S0W1....D940967F.......:"
-
- // 0 - request was successful
- val SUCCESSFUL_REQUEST_RESULT = "0"
-
- @Test
- fun cancelJobTest() {
- val retrofit = Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .client(getUnsafeOkHttpClient())
- .build()
-
- val request = retrofit.create(JESApi::class.java)
- val call: Call = request.cancelJobRequest(BASIC_AUTH_TOKEN, JOB_NAME,
- JOB_ID, CancelJobRequestBody())
- enqueueCancelJobCallAndCheckResult(call)
- }
-
- fun enqueueCancelJobCallAndCheckResult(call: Call) {
- val response = call.execute()
-
- if (response.isSuccessful)
- {
- val jobStatus: CancelJobRequest = response.body() as CancelJobRequest
- println(jobStatus.status)
- Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
- Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner?.toLowerCase(), "hlh")
- } else
- {
- println(response.errorBody())
- Assertions.assertTrue(false)
- }
- }
-}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/HoldJobFor10sThenReleaseTest.kt b/src/test/kotlin/eu/ibagroup/r2z/HoldJobFor10sThenReleaseTest.kt
deleted file mode 100644
index 5a55f18..0000000
--- a/src/test/kotlin/eu/ibagroup/r2z/HoldJobFor10sThenReleaseTest.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-
-import eu.ibagroup.r2z.BaseTest
-import eu.ibagroup.r2z.HoldJobRequestBody
-import eu.ibagroup.r2z.JESApi
-import eu.ibagroup.r2z.ReleaseJobRequestBody
-import eu.ibagroup.r2z.HoldJobRequest
-import eu.ibagroup.r2z.ReleaseJobRequest
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
-import retrofit2.Call
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-import java.util.*
-
-class HoldFor20sThenReleaseJobTest : BaseTest() {
- val JOB_ID = "JOB06152"
- val JOB_NAME = "NOTHINGJ"
-
- val JOB_CORRELATOR = "J0001561S0W1....D940967F.......:"
-
- // 0 - request was successful
- val SUCCESSFUL_REQUEST_RESULT = 0
-
- @Test
- fun holdFor10sThenReleaseJobTest() {
- val retrofit = Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .client(getUnsafeOkHttpClient())
- .build()
-
- val request = retrofit.create(JESApi::class.java)
- val firstCall: Call = request.holdJobRequest(BASIC_AUTH_TOKEN,
- JOB_NAME, JOB_ID, HoldJobRequestBody()
- )
-
- enqueueHoldCallAndCheckResult(firstCall)
-
- Thread.sleep(10000)
-
- val secondCall: Call = request.releaseJobRequest(BASIC_AUTH_TOKEN,
- JOB_NAME, JOB_ID, ReleaseJobRequestBody()
- )
-
- enqueueReleaseCallAndCheckResult(secondCall)
- }
-
- fun enqueueHoldCallAndCheckResult(call: Call) {
- val response = call.execute()
- if (response.isSuccessful) {
- val jobStatus: HoldJobRequest = response.body() as HoldJobRequest
- println(jobStatus.status)
- Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
- Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner?.lowercase(Locale.getDefault()), "hlh")
- } else {
- println(response.errorBody())
- Assertions.assertTrue(false)
- }
- }
-
- fun enqueueReleaseCallAndCheckResult(call: Call) {
- val response = call.execute()
- if (response.isSuccessful) {
- val jobStatus: ReleaseJobRequest = response.body() as ReleaseJobRequest
- println(jobStatus.status)
- Assertions.assertEquals(SUCCESSFUL_REQUEST_RESULT, jobStatus.status)
- Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner?.lowercase(Locale.getDefault()), "hlh")
- } else {
- println(response.errorBody())
- Assertions.assertTrue(false)
- }
- }
-}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/SubmitJobRequestTest.kt b/src/test/kotlin/eu/ibagroup/r2z/SubmitJobRequestTest.kt
deleted file mode 100644
index 569fe20..0000000
--- a/src/test/kotlin/eu/ibagroup/r2z/SubmitJobRequestTest.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright © 2020 IBA Group, a.s. All rights reserved. Use of this source code is governed by Eclipse Public License – v 2.0 that can be found at: https://www.eclipse.org/legal/epl-2.0/
-
-package eu.ibagroup.r2z
-
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
-import retrofit2.Call
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-import retrofit2.converter.scalars.ScalarsConverterFactory
-
-class SubmitJobRequestTest : BaseTest() {
- val JOB_PATH = "//'HHAL.PLUGIN.TEST.JOBS(JOB1)'"
-
- @Test
- fun submitJobOnZOS_System() {
- val retrofit = Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .client(getUnsafeOkHttpClient())
- .build()
-
- val request = retrofit.create(JESApi::class.java)
- val call: Call = request.submitJobRequest(BASIC_AUTH_TOKEN,
- body = SubmitFileNameBody(file = JOB_PATH))
- enqueueSubmitJob(call)
- }
-
- @Test
- fun submitJobFromInputText() {
- val retrofit = Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(ScalarsConverterFactory.create())
- .addConverterFactory(GsonConverterFactory.create())
- .client(getUnsafeOkHttpClient())
- .build()
-
- val request = retrofit.create(JESApi::class.java)
- val body = "" +
- "//NOTHINGJ JOB CLASS=B,MSGLEVEL=(1,1),MSGCLASS=X,\n" +
- "// NOTIFY=HAL,REGION=6M\n" +
- "//*********\n" +
- "//STEP0 EXEC PGM=IEFBR14\n" +
- "//SYSPRINT DD SYSOUT=*\n" +
- "//SYSIN DD *\n" +
- "//STEP1 EXEC PGM=IKJEFT01,PARM='JOB2'\n" +
- "//SYSPROC DD DSN=HHAL.PLUGIN.TEST.JOBS,DISP=SHR\n" +
- "//SYSTSPRT DD SYSOUT=*\n" +
- "//SYSTSIN DD DUMMY,DCB=BLKSIZE=80"
- val call: Call = request.submitJobRequest(BASIC_AUTH_TOKEN, body = body)
- enqueueSubmitJob(call)
- }
-
- fun enqueueSubmitJob(call: Call) {
- val response = call.execute()
- if (response.isSuccessful) {
- val jobStatus: SubmitJobRequest = response.body() as SubmitJobRequest
- println(jobStatus.jobid)
- println(jobStatus.jobname)
- println(jobStatus.status)
- Assertions.assertNotNull(jobStatus.owner)
- Assertions.assertEquals(jobStatus.owner?.toLowerCase(), "hlh")
- } else {
- println(response.errorBody())
- Assertions.assertTrue(false)
- }
- }
-}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/MockResponseDispatcher.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/MockResponseDispatcher.kt
index bd2f3cb..ff79d5c 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/MockResponseDispatcher.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/MockResponseDispatcher.kt
@@ -1,9 +1,9 @@
package eu.ibagroup.r2z.zowe
-import com.squareup.okhttp.mockwebserver.Dispatcher
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.RecordedRequest
import eu.ibagroup.r2z.zowe.config.decodeFromBase64
+import okhttp3.mockwebserver.Dispatcher
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.RecordedRequest
import org.junit.jupiter.api.Assertions
class MockResponseDispatcher : Dispatcher() {
@@ -31,8 +31,8 @@ class MockResponseDispatcher : Dispatcher() {
validationList.clear()
}
- override fun dispatch(request: RecordedRequest?): MockResponse {
- val authTokenRequest = request?.getHeader("Authorization") ?: Assertions.fail("auth token must be presented.")
+ override fun dispatch(request: RecordedRequest): MockResponse {
+ val authTokenRequest = request.getHeader("Authorization") ?: Assertions.fail("auth token must be presented.")
val credentials = decodeBasicAuthToken(authTokenRequest).split(":")
val usernameRequest = credentials[0]
val passwordRequest = credentials[1]
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/ZoweConfigParsingTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/ZoweConfigParsingTest.kt
index e43a43e..5e2eea3 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/ZoweConfigParsingTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/ZoweConfigParsingTest.kt
@@ -10,15 +10,12 @@
package eu.ibagroup.r2z.zowe
-import com.squareup.okhttp.mockwebserver.MockWebServer
-import eu.ibagroup.r2z.DataAPI
-import eu.ibagroup.r2z.buildGsonApi
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.config.*
import okhttp3.OkHttpClient
import org.junit.jupiter.api.*
import java.net.InetSocketAddress
import java.net.Proxy
-import kotlin.concurrent.thread
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ZoweConfigParsingTest: ZoweConfigTestBase() {
@@ -32,10 +29,8 @@ class ZoweConfigParsingTest: ZoweConfigTestBase() {
fun createMockServer () {
keytarWrapper = DefaultMockKeytarWrapper()
mockServer = MockWebServer()
- mockServer.setDispatcher(MockResponseDispatcher())
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = MockResponseDispatcher()
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -92,31 +87,13 @@ class ZoweConfigParsingTest: ZoweConfigTestBase() {
Assertions.assertDoesNotThrow { zoweConfig.getAuthEncoding() }
}
-
- @Test
- fun readConfigAndListDatasets() {
- val authToken = zoweConfig.getAuthEncoding().withBasicPrefix()
-
- val dataApi = buildGsonApi("http://${zoweConfig.host}:${zoweConfig.port}", proxyClient)
- val response = dataApi.listDataSets(
- authorizationToken = authToken,
- dsLevel = "TEST.*"
- ).execute()
- if (response.isSuccessful) {
- val datasetLists = response.body()
- Assertions.assertEquals(datasetLists?.items?.size, 4)
- } else {
- Assertions.fail("response must be successful.")
- }
- }
-
fun checkZoweConfig(zoweConfig: ZoweConfig) {
Assertions.assertEquals(zoweConfig.user, TEST_USER)
Assertions.assertEquals(zoweConfig.password, TEST_PASSWORD)
Assertions.assertEquals(zoweConfig.host, "example.host1")
Assertions.assertEquals(zoweConfig.rejectUnauthorized, true)
Assertions.assertEquals(zoweConfig.port, 10443)
- Assertions.assertEquals(zoweConfig.protocol, "http")
+ Assertions.assertEquals(zoweConfig.protocol, "https")
Assertions.assertEquals(zoweConfig.basePath, "/")
Assertions.assertEquals(zoweConfig.encoding, 1047)
Assertions.assertEquals(zoweConfig.responseTimeout, 600)
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnCopyTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnCopyTest.kt
index afa462e..d8d2f01 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnCopyTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnCopyTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
import eu.ibagroup.r2z.zowe.client.sdk.zosfiles.ZosDsnCopy
@@ -24,10 +24,8 @@ class ZosDsnCopyTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -48,7 +46,7 @@ class ZosDsnCopyTest {
)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/NBEL.TEST.DATA")) == true && it.method?.equals("PUT") == true
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restfiles/ds/NBEL.TEST.DATA HTTP/.*")) == true
},
{
MockResponse().setResponseCode(200)
@@ -66,7 +64,7 @@ class ZosDsnCopyTest {
val zosDsnCopy = ZosDsnCopy(conn, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/NBEL.TEST.DATA")) == true && it.method?.equals("PUT") == true
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restfiles/ds/NBEL.TEST.DATA HTTP/.*")) == true
}, {
MockResponse().setResponseCode(200)
}
@@ -77,4 +75,4 @@ class ZosDsnCopyTest {
responseDispatcher.clearValidationList()
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnDownloadTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnDownloadTest.kt
index 4d5f28e..cc45157 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnDownloadTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnDownloadTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
import eu.ibagroup.r2z.zowe.client.sdk.zosfiles.ZosDsnDownload
@@ -24,10 +24,8 @@ class ZosDsnDownloadTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -43,10 +41,10 @@ class ZosDsnDownloadTest {
val zosDsnDownload = ZosDsnDownload(conn, proxyClient)
val downloadParams = DownloadParams(
)
- val responseBody = javaClass.classLoader.getResource("mock/downloadDsnMember.txt")?.readText()
+ val responseBody = javaClass.classLoader.getResource("mock/downloadDsnMember.txt")?.readText() ?: ""
responseDispatcher.injectEndpoint(
- { it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/TEST.JCL\\(TESTJOB\\)")) == true &&
- it.method?.equals("GET") == true
+ {
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/ds/TEST.JCL\\(TESTJOB\\) HTTP/.*")) == true
},
{ MockResponse().setBody(responseBody) }
)
@@ -57,4 +55,4 @@ class ZosDsnDownloadTest {
responseDispatcher.clearValidationList()
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnListTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnListTest.kt
index 7ffbe0b..2f01a92 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnListTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnListTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
import eu.ibagroup.r2z.zowe.client.sdk.zosfiles.ZosDsnList
@@ -25,10 +25,8 @@ class ZosDsnListTest {
fun createMockServer () {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -46,9 +44,9 @@ class ZosDsnListTest {
)
val zosDsnList = ZosDsnList(conn, proxyClient)
responseDispatcher.injectEndpoint({
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/ds.* HTTP/.*")) == true
}, {
- MockResponse().setBody(responseDispatcher.readMockJson("listDatasets"))
+ MockResponse().setBody(responseDispatcher.readMockJson("listDatasets") ?: "")
})
val dsnList = zosDsnList.listDsn("TEST.**.TEST1", listParams)
responseDispatcher.clearValidationList()
@@ -61,9 +59,9 @@ class ZosDsnListTest {
val listParams = ListParams()
val zosDsnList = ZosDsnList(conn, proxyClient)
responseDispatcher.injectEndpoint({
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/ds.* HTTP/.*")) == true
}, {
- MockResponse().setBody(responseDispatcher.readMockJson("listDatasetMembers"))
+ MockResponse().setBody(responseDispatcher.readMockJson("listDatasetMembers") ?: "")
})
val dsnMembersList = zosDsnList.listDsnMembers("SYS1.PROCLIB", listParams)
Assertions.assertEquals(87, dsnMembersList.items.size)
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnTest.kt
index 66e6782..f9e5acb 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosfiles/ZosDsnTest.kt
@@ -3,8 +3,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
import com.google.gson.Gson
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.CreateDataset
import eu.ibagroup.r2z.DatasetOrganization
import eu.ibagroup.r2z.RecordFormat
@@ -28,10 +28,8 @@ class ZosDsnTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -47,8 +45,8 @@ class ZosDsnTest {
val zosDsn = ZosDsn(connection, proxyClient)
responseDispatcher.injectEndpoint(
- { it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds.*")) == true },
- { MockResponse().setBody(responseDispatcher.readMockJson("listDatasets")) }
+ { it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/ds.* HTTP/.*")) == true },
+ { MockResponse().setBody(responseDispatcher.readMockJson("listDatasets") ?: "") }
)
val datasetInfo = zosDsn.getDatasetInfo("TEST.IJMP.DATASET1")
Assertions.assertEquals(4500, datasetInfo.blockSize)
@@ -64,8 +62,8 @@ class ZosDsnTest {
val zosDsn = ZosDsn(connection, proxyClient)
responseDispatcher.injectEndpoint(
- { it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds.*")) == true },
- { MockResponse().setBody(responseDispatcher.readMockJson("listDatasets")) }
+ { it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/ds.* HTTP/.*")) == true },
+ { MockResponse().setBody(responseDispatcher.readMockJson("listDatasets") ?: "") }
)
val datasetInfo = zosDsn.getDatasetInfo("TEST.IJMP.DATASET5")
Assertions.assertEquals(null, datasetInfo.blockSize)
@@ -79,8 +77,8 @@ class ZosDsnTest {
val zosDsn = ZosDsn(connection, proxyClient)
responseDispatcher.injectEndpoint(
- { it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET")) == true &&
- it.method?.equals("DELETE") == true
+ {
+ it?.requestLine?.matches(Regex("DELETE http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET HTTP/.*")) == true
},
{ MockResponse().setResponseCode(204) }
)
@@ -96,7 +94,7 @@ class ZosDsnTest {
val zosDsn = ZosDsn(connection, proxyClient)
responseDispatcher.injectEndpoint(
- { it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET\\(TESTMEM\\)")) == true },
+ { it?.requestLine?.matches(Regex("DELETE http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET\\(TESTMEM\\) HTTP/.*")) == true },
{ MockResponse().setResponseCode(204) }
)
val response = zosDsn.deleteDsn("TEST.IJMP.DATASET", "TESTMEM")
@@ -111,13 +109,16 @@ class ZosDsnTest {
val zosDsn = ZosDsn(conn, proxyClient)
val memberText = "member"
val dsnText = "dataset"
- responseDispatcher.injectEndpoint({
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/TEST\\.IJMP\\.DATASET1(\\(TEST\\))?")) == true
- }, {
- val textToCheck = if (it?.path?.contains(Regex("TEST.IJMP.DATASET1\\(TEST\\)")) == true) memberText else dsnText
- Assertions.assertEquals(String(it?.body ?: byteArrayOf()), textToCheck)
- MockResponse().setResponseCode(204)
- })
+ responseDispatcher.injectEndpoint(
+ {
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restfiles/ds/TEST\\.IJMP\\.DATASET1(\\(TEST\\))? HTTP/.*")) == true
+ },
+ {
+ val textToCheck = if (it?.requestLine?.contains(Regex("TEST.IJMP.DATASET1\\(TEST\\)")) == true) memberText else dsnText
+ Assertions.assertEquals(it?.body?.readUtf8(), textToCheck)
+ MockResponse().setResponseCode(204)
+ }
+ )
val datasetResponse = zosDsn.writeDsn("TEST.IJMP.DATASET1", dsnText.toByteArray())
Assertions.assertEquals(204, datasetResponse.code())
val memberResponse = zosDsn.writeDsn("TEST.IJMP.DATASET1", "TEST", memberText.toByteArray())
@@ -139,8 +140,8 @@ class ZosDsnTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET")) == true &&
- Gson().fromJson(String(it.body), CreateDataset::class.java) == params
+ it?.requestLine?.matches(Regex("POST http://.*/zosmf/restfiles/ds/TEST.IJMP.DATASET HTTP/.*")) == true &&
+ Gson().fromJson(it.body.readUtf8(), CreateDataset::class.java) == params
},
{ MockResponse().setResponseCode(201) }
)
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/CancelJobsTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/CancelJobsTest.kt
index ade20c3..eb3a81d 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/CancelJobsTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/CancelJobsTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosjobs
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.*
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
@@ -24,10 +24,8 @@ class CancelJobsTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -43,10 +41,10 @@ class CancelJobsTest {
val cancelJobs = CancelJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/TESTJOB2/JOB00084")) == true
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs/TESTJOB2/JOB00084 HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("cancelJobs")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("cancelJobs") ?: "").setResponseCode(200)
}
)
val response = cancelJobs.cancelJob("TESTJOB2", "JOB00084", RequestVersion.SYNCHRONOUS)
@@ -61,10 +59,10 @@ class CancelJobsTest {
val cancelJobs = CancelJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/TESTJOB2/JOB00084")) == true
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs/TESTJOB2/JOB00084 HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("cancelJobs")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("cancelJobs") ?: "").setResponseCode(200)
}
)
val response = cancelJobs.cancelJobForJob(
@@ -76,4 +74,4 @@ class CancelJobsTest {
)
Assertions.assertEquals("0", response.status)
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/DeleteJobsTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/DeleteJobsTest.kt
index cd20240..8cdc38c 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/DeleteJobsTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/DeleteJobsTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosjobs
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.Job
import eu.ibagroup.r2z.RequestVersion
import eu.ibagroup.r2z.zowe.*
@@ -13,7 +13,6 @@ import okhttp3.OkHttpClient
import org.junit.jupiter.api.*
import java.net.InetSocketAddress
import java.net.Proxy
-import kotlin.concurrent.thread
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DeleteJobsTest {
@@ -26,10 +25,8 @@ class DeleteJobsTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -45,11 +42,11 @@ class DeleteJobsTest {
val deleteJobs = DeleteJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/TESTJOBW/JOB00085")) == true &&
+ it?.requestLine?.matches(Regex("DELETE http://.*/zosmf/restjobs/jobs/TESTJOBW/JOB00085 HTTP/.*")) == true &&
it.getHeader("X-IBM-Job-Modify-Version") == RequestVersion.SYNCHRONOUS.value
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("deleteJobs")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("deleteJobs") ?: "").setResponseCode(200)
}
)
val response = deleteJobs.deleteJob("TESTJOBW", "JOB00085", RequestVersion.SYNCHRONOUS)
@@ -64,11 +61,11 @@ class DeleteJobsTest {
val deleteJobs = DeleteJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/TESTJOBW/JOB00085")) == true &&
+ it?.requestLine?.matches(Regex("DELETE http://.*/zosmf/restjobs/jobs/TESTJOBW/JOB00085 HTTP/.*")) == true &&
it.getHeader("X-IBM-Job-Modify-Version") == RequestVersion.SYNCHRONOUS.value
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("deleteJobs")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("deleteJobs") ?: "").setResponseCode(200)
}
)
val response = deleteJobs.deleteJobForJob(
@@ -80,4 +77,4 @@ class DeleteJobsTest {
)
Assertions.assertEquals("0", response.status)
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/GetJobsTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/GetJobsTest.kt
index 7ae3091..7cc2498 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/GetJobsTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/GetJobsTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosjobs
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.Job
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
@@ -27,10 +27,8 @@ class GetJobsTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -46,13 +44,13 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?owner=IBMUSER")) == true ||
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?prefix=\\*")) == true ||
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?jobid=JOB00023")) == true ||
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?owner=testUser")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?owner=IBMUSER HTTP/.*")) == true ||
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?prefix=\\* HTTP/.*")) == true ||
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?jobid=JOB00023 HTTP/.*")) == true ||
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?owner=testUser HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJobs")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJobs") ?: "").setResponseCode(200)
}
)
var jobs = getJobs.getJobsCommon(GetJobParams(owner = "IBMUSER"))
@@ -77,10 +75,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?jobid=JOB00023")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?jobid=JOB00023 HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJob")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJob") ?: "").setResponseCode(200)
}
)
val job = getJobs.getJob("JOB00023")
@@ -96,10 +94,10 @@ class GetJobsTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getStatus")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getStatus") ?: "").setResponseCode(200)
}
)
val job = getJobs.getStatusCommon(CommonJobParams("BLSJPRMI", "STC00052"))
@@ -114,10 +112,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?owner=${connection.user}")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?owner=${connection.user} HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJobsTest")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJobsTest") ?: "").setResponseCode(200)
}
)
val jobs = getJobs.getJobs()
@@ -133,10 +131,10 @@ class GetJobsTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getStatus")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getStatus") ?: "").setResponseCode(200)
}
)
val status = getJobs.getStatusValue("BLSJPRMI", "STC00052")
@@ -152,10 +150,10 @@ class GetJobsTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getStatus")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getStatus") ?: "").setResponseCode(200)
}
)
val status = getJobs.getStatusValueForJob(
@@ -182,10 +180,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getStatus")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getStatus") ?: "").setResponseCode(200)
}
)
val job = getJobs.getStatus(jobId = "STC00052", jobName = "BLSJPRMI")
@@ -202,10 +200,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/BLSJPRMI/STC00052.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getStatus")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getStatus") ?: "").setResponseCode(200)
}
)
val job = getJobs.getStatusForJob(Job(
@@ -229,10 +227,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?owner=ZOSMFAD")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?owner=ZOSMFAD HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJobsByOwner")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJobsByOwner") ?: "").setResponseCode(200)
}
)
val jobs = getJobs.getJobsByOwner("ZOSMFAD")
@@ -247,10 +245,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?prefix=IJMP\\*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?prefix=IJMP\\* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJobsByPrefix")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJobsByPrefix") ?: "").setResponseCode(200)
}
)
val jobs = getJobs.getJobsByPrefix("IJMP*")
@@ -265,10 +263,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?owner=ZOSMFAD&prefix=\\*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?owner=ZOSMFAD&prefix=\\* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getJobsByOwnerAndPrefix")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getJobsByOwnerAndPrefix") ?: "").setResponseCode(200)
}
)
val jobs = getJobs.getJobsByOwnerAndPrefix("ZOSMFAD" ,"*")
@@ -284,10 +282,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles") ?: "").setResponseCode(200)
}
)
val spoolFiles = getJobs.getSpoolFilesCommon(CommonJobParams(jobName = "NBEL", jobId = "TSU00555"))
@@ -305,10 +303,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles") ?: "").setResponseCode(200)
}
)
val spoolFiles = getJobs.getSpoolFilesForJob(Job(
@@ -336,10 +334,10 @@ class GetJobsTest {
val getJobs = GetJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files HTTP/.*")) == true
},
{
- MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles")).setResponseCode(200)
+ MockResponse().setBody(responseDispatcher.readMockJson("getSpoolFiles") ?: "").setResponseCode(200)
}
)
val spoolFiles = getJobs.getSpoolFiles("NBEL", "TSU00555")
@@ -357,10 +355,10 @@ class GetJobsTest {
val responseBody = javaClass.classLoader.getResource("mock/getJcl.txt")?.readText()
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records\\?mode=text")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records\\?mode=text HTTP/.*")) == true
},
{
- MockResponse().setBody(responseBody).setResponseCode(200)
+ MockResponse().setBody(responseBody ?: "").setResponseCode(200)
}
)
val jcl = getJobs.getJclCommon(CommonJobParams(jobName = "NBEL", jobId = "TSU00555"))
@@ -375,10 +373,10 @@ class GetJobsTest {
val responseBody = javaClass.classLoader.getResource("mock/getJcl.txt")?.readText()
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records\\?mode=text")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records\\?mode=text HTTP/.*")) == true
},
{
- MockResponse().setBody(responseBody).setResponseCode(200)
+ MockResponse().setBody(responseBody ?: "").setResponseCode(200)
}
)
val jcl = getJobs.getJcl(jobName = "NBEL", jobId = "TSU00555")
@@ -393,10 +391,10 @@ class GetJobsTest {
val responseBody = javaClass.classLoader.getResource("mock/getJcl.txt")?.readText()
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/NBEL/TSU00555/files/JCL/records.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseBody).setResponseCode(200)
+ MockResponse().setBody(responseBody ?: "").setResponseCode(200)
}
)
val jcl = getJobs.getJclForJob(
@@ -428,10 +426,10 @@ class GetJobsTest {
val responseBody = javaClass.classLoader.getResource("mock/getSpoolFileContent.txt")?.readText()
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/TESTJCL/JOB09502/files/2/records.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/TESTJCL/JOB09502/files/2/records.* HTTP/.*")) == true
},
{
- MockResponse().setBody(responseBody).setResponseCode(200)
+ MockResponse().setBody(responseBody ?: "").setResponseCode(200)
}
)
val spoolFile = getJobs.getSpoolContentById("TESTJCL", "JOB09502", 2)
@@ -445,4 +443,4 @@ class GetJobsTest {
// TODO: implement!!! Use getSpoolContent mock.
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/MonitorJobsTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/MonitorJobsTest.kt
index de78bd8..63a6100 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/MonitorJobsTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/MonitorJobsTest.kt
@@ -3,8 +3,8 @@
package eu.ibagroup.r2z.zowe.zosjobs
import com.google.gson.Gson
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.Job
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
@@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.net.InetSocketAddress
import java.net.Proxy
-import kotlin.concurrent.thread
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MonitorJobsTest {
@@ -29,10 +28,8 @@ class MonitorJobsTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -57,11 +54,11 @@ class MonitorJobsTest {
var requestTimes = 0
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.*")) == true
},
{
++requestTimes
- val jobRsp = if (System.currentTimeMillis() - startTime < 12000) job.cloneWithChangedStatus(Job.Status.ACTIVE)
+ val jobRsp = if (System.currentTimeMillis() - startTime < 3000) job.cloneWithChangedStatus(Job.Status.ACTIVE)
else job
MockResponse().setBody(Gson().toJson(jobRsp)).setResponseCode(200)
}
@@ -69,7 +66,7 @@ class MonitorJobsTest {
monitorJobs.waitForJobOutputStatus(job.jobName, job.jobId)
val jobResponse = monitorJobs.waitForJobStatus(job.jobName, job.jobId, Job.Status.OUTPUT)
Assertions.assertEquals(jobResponse.status, Job.Status.OUTPUT)
- Assertions.assertEquals(6, requestTimes)
+ Assertions.assertEquals(3, requestTimes)
responseDispatcher.clearValidationList()
}
@@ -85,11 +82,11 @@ class MonitorJobsTest {
var requestTimes = 0
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.* HTTP/.*")) == true
},
{
++requestTimes
- val jobRsp = if (System.currentTimeMillis() - startTime < 12000) job.cloneWithChangedStatus(Job.Status.ACTIVE)
+ val jobRsp = if (System.currentTimeMillis() - startTime < 3000) job.cloneWithChangedStatus(Job.Status.ACTIVE)
else job
MockResponse().setBody(Gson().toJson(jobRsp)).setResponseCode(200)
}
@@ -97,7 +94,7 @@ class MonitorJobsTest {
monitorJobs.waitForJobOutputStatus(job)
val jobResponse = monitorJobs.waitForJobStatus(job, Job.Status.OUTPUT)
Assertions.assertEquals(jobResponse.status, Job.Status.OUTPUT)
- Assertions.assertEquals(4, requestTimes)
+ Assertions.assertEquals(3, requestTimes)
responseDispatcher.clearValidationList()
}
@@ -113,7 +110,7 @@ class MonitorJobsTest {
val mockSpoolFileContent = javaClass.classLoader.getResource("mock/getJcl.txt")?.readText()
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs\\?prefix=IJMP05&jobid=JOB09502")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs\\?prefix=IJMP05&jobid=JOB09502 HTTP/.*")) == true
},
{
MockResponse().setBody(mockJobString).setResponseCode(200)
@@ -121,7 +118,7 @@ class MonitorJobsTest {
)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}/files.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}/files.* HTTP/.*")) == true
},
{
MockResponse().setBody(mockSpoolFiles).setResponseCode(200)
@@ -129,15 +126,15 @@ class MonitorJobsTest {
)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}/files/2/records")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}/files/2/records HTTP/.*")) == true
},
{
- MockResponse().setBody(mockSpoolFileContent).setResponseCode(200)
+ MockResponse().setBody(mockSpoolFileContent ?: "").setResponseCode(200)
}
)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restjobs/jobs/${job.jobName}/${job.jobId}.* HTTP/.*")) == true
},
{
MockResponse().setBody(Gson().toJson(job)).setResponseCode(200)
@@ -149,4 +146,4 @@ class MonitorJobsTest {
responseDispatcher.clearValidationList()
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/SubmitJobsTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/SubmitJobsTest.kt
index e750c45..6518e43 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/SubmitJobsTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosjobs/SubmitJobsTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosjobs
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.Intrdr_Recfm
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
@@ -26,10 +26,8 @@ class SubmitJobsTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -46,10 +44,10 @@ class SubmitJobsTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs")) == true &&
- String(it.body).matches(Regex(".*\"file\":\"//'TEST.JOBS\\(JOBNAME\\)'\".*"))
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs HTTP/.*")) == true &&
+ it.body.toString().matches(Regex(".*\"file\":\"//'TEST.JOBS\\(JOBNAME\\)'\".*"))
},
- { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs")) }
+ { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs") ?: "") }
)
val response = submitJobs.submitJob("//'TEST.JOBS(JOBNAME)'")
Assertions.assertEquals("ZOSMFAD", response.owner)
@@ -66,10 +64,10 @@ class SubmitJobsTest {
jobDataSet = "//'TEST.JCL(TESTJOB)'"
)
responseDispatcher.injectEndpoint({
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs")) == true &&
- String(it.body).matches(Regex(".*\"file\":\"//'TEST.JCL\\(TESTJOB\\)'\".*"))
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs HTTP/.*")) == true &&
+ it.body.toString().matches(Regex(".*\"file\":\"//'TEST.JCL\\(TESTJOB\\)'\".*"))
}, {
- MockResponse().setBody(responseDispatcher.readMockJson("submitJobCommonResponse"))
+ MockResponse().setBody(responseDispatcher.readMockJson("submitJobCommonResponse") ?: "")
})
val jobSubmitResponse = submitJobs.submitJobCommon(params)
Assertions.assertEquals("TESTJOB", jobSubmitResponse.jobname)
@@ -83,11 +81,11 @@ class SubmitJobsTest {
val submitJobs = SubmitJobs(connection, proxyClient)
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs")) == true &&
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs HTTP/.*")) == true &&
it.getHeader("X-IBM-Intrdr-Recfm") == Intrdr_Recfm.F.value &&
it.getHeader("X-IBM-Intrdr-Lrecl") == "F"
},
- { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs")).setResponseCode(201) }
+ { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs") ?: "").setResponseCode(201) }
)
val response = submitJobs.submitJcl(
javaClass.classLoader.getResource("mock/submitJcl.txt")?.readText() ?: "nothing",
@@ -104,11 +102,11 @@ class SubmitJobsTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restjobs/jobs")) == true &&
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restjobs/jobs HTTP/.*")) == true &&
it.getHeader("X-IBM-Intrdr-Recfm") == Intrdr_Recfm.F.value &&
it.getHeader("X-IBM-Intrdr-Lrecl") == "F"
},
- { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs")).setResponseCode(201) }
+ { MockResponse().setBody(responseDispatcher.readMockJson("submitJobs") ?: "").setResponseCode(201) }
)
val params = SubmitJclParams(
jcl = javaClass.classLoader.getResource("mock/submitJcl.txt")?.readText() ?: "nothing",
@@ -119,4 +117,4 @@ class SubmitJobsTest {
Assertions.assertEquals("ZOSMFAD", response.owner)
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssDownloadTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssDownloadTest.kt
index 99d14a2..bd67e1b 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssDownloadTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssDownloadTest.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
import eu.ibagroup.r2z.zowe.client.sdk.zosfiles.ZosDsnDownload
@@ -25,10 +25,8 @@ class ZosUssDownloadTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -43,10 +41,10 @@ class ZosUssDownloadTest {
val conn = ZOSConnection(TEST_HOST, TEST_PORT, TEST_USER, TEST_PASSWORD, "http")
val zosUssFileDownload = ZosUssFileDownload(conn, proxyClient)
- val responseBody = javaClass.classLoader.getResource("mock/downloadDsnMember.txt")?.readText()
+ val responseBody = javaClass.classLoader.getResource("mock/downloadDsnMember.txt")?.readText() ?: ""
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs/u/IJMP/text.txt")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/fs/u/IJMP/text.txt HTTP/.*")) == true
},
{ MockResponse().setBody(responseBody) }
)
@@ -57,4 +55,4 @@ class ZosUssDownloadTest {
responseDispatcher.clearValidationList()
}
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileList.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileList.kt
index 72dd8ce..9a2e000 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileList.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileList.kt
@@ -2,8 +2,8 @@
package eu.ibagroup.r2z.zowe.zosfiles
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
import eu.ibagroup.r2z.zowe.client.sdk.zosfiles.ZosDsnList
@@ -27,10 +27,8 @@ class ZosUssFileList {
fun createMockServer () {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -46,9 +44,9 @@ class ZosUssFileList {
val listParams = UssListParams()
val zosUssFileList = ZosUssFileList(conn, proxyClient)
responseDispatcher.injectEndpoint({
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs.*")) == true
+ it?.requestLine?.matches(Regex("GET http://.*/zosmf/restfiles/fs.* HTTP/.*")) == true
}, {
- MockResponse().setBody(responseDispatcher.readMockJson("listDatasets"))
+ MockResponse().setBody(responseDispatcher.readMockJson("listDatasets") ?: "")
})
val fileList = zosUssFileList.listFiles("/u/STV", listParams)
responseDispatcher.clearValidationList()
diff --git a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileTest.kt b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileTest.kt
index 4748c68..a4c8192 100644
--- a/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileTest.kt
+++ b/src/test/kotlin/eu/ibagroup/r2z/zowe/zosuss/ZosUssFileTest.kt
@@ -3,8 +3,8 @@
package eu.ibagroup.r2z.zowe.zosuss
import com.google.gson.Gson
-import com.squareup.okhttp.mockwebserver.MockResponse
-import com.squareup.okhttp.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
import eu.ibagroup.r2z.*
import eu.ibagroup.r2z.zowe.*
import eu.ibagroup.r2z.zowe.client.sdk.core.ZOSConnection
@@ -26,10 +26,8 @@ class ZosUssFileTest {
fun createMockServer() {
mockServer = MockWebServer()
responseDispatcher = MockResponseDispatcher()
- mockServer.setDispatcher(responseDispatcher)
- thread(start = true) {
- mockServer.play()
- }
+ mockServer.dispatcher = responseDispatcher
+ mockServer.start()
val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(mockServer.hostName, mockServer.port))
proxyClient = OkHttpClient.Builder().proxy(proxy).build()
}
@@ -46,7 +44,7 @@ class ZosUssFileTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs/u/IJMP/text.txt")) == true
+ it?.requestLine?.matches(Regex("DELETE http://.*/zosmf/restfiles/fs/u/IJMP/text.txt HTTP/.*")) == true
},
{ MockResponse().setResponseCode(204) }
)
@@ -67,7 +65,7 @@ class ZosUssFileTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs/u/IJMP/text.txt")) == true //&&
+ it?.requestLine?.matches(Regex("POST http://.*/zosmf/restfiles/fs/u/IJMP/text.txt HTTP/.*")) == true //&&
//Gson().fromJson(String(it.body), CreateUssFile::class.java) == params
},
{ MockResponse().setResponseCode(201) }
@@ -89,7 +87,7 @@ class ZosUssFileTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs/u/IJMP/newdir")) == true //&&
+ it?.requestLine?.matches(Regex("POST http://.*/zosmf/restfiles/fs/u/IJMP/newdir HTTP/.*")) == true //&&
//Gson().fromJson(String(it.body), CreateUssFile::class.java) == params
},
{ MockResponse().setResponseCode(201) }
@@ -108,7 +106,7 @@ class ZosUssFileTest {
responseDispatcher.injectEndpoint(
{
- it?.path?.matches(Regex("http://.*/zosmf/restfiles/fs/u/IJMP/text.txt")) == true
+ it?.requestLine?.matches(Regex("PUT http://.*/zosmf/restfiles/fs/u/IJMP/text.txt HTTP/.*")) == true
},
{ MockResponse().setResponseCode(201) }
)