-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move httpclient configuration into the config class and add (ignored)…
… tests
- Loading branch information
1 parent
7e31758
commit 1c85f5a
Showing
6 changed files
with
214 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
radar-commons/src/test/java/org/radarbase/producer/schema/SchemaRestClientIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright 2017 The Hyve and King's College London | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.radarbase.producer.schema | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.cio.CIO | ||
import io.ktor.http.* | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.coroutines.test.runTest | ||
import okhttp3.mockwebserver.MockWebServer | ||
import org.apache.avro.Schema | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.radarbase.producer.io.timeout | ||
import org.radarbase.producer.rest.RestKafkaSenderTest.Companion.enqueueJson | ||
import java.io.IOException | ||
import kotlin.time.Duration.Companion.seconds | ||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.auth.* | ||
import io.ktor.client.plugins.auth.providers.* | ||
import io.ktor.client.statement.* | ||
import org.junit.Ignore | ||
|
||
class SchemaRestClientIntegrationTest { | ||
private lateinit var retriever: SchemaRestClient | ||
|
||
// This testclass requires a functioning confluent cloud provider, therefore all tests here are ignored | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
val apiSecret = "exampleSecret" | ||
val apiKey = "exampleKey" | ||
retriever = SchemaRestClient( | ||
httpClient = HttpClient { | ||
timeout(30.seconds) | ||
install(Auth) { | ||
basic { | ||
sendWithoutRequest { true } | ||
credentials { | ||
BasicAuthCredentials(username = apiKey, password = apiSecret) | ||
} | ||
} | ||
} | ||
}, | ||
baseUrl = "https://SOME_EXAMPLE.westeurope.azure.confluent.cloud", | ||
) | ||
} | ||
|
||
@Ignore | ||
@AfterEach | ||
@Throws(IOException::class) | ||
fun tearDown() { | ||
} | ||
|
||
@Ignore | ||
@Test | ||
fun testSchemaGet() = runBlocking { | ||
val actualSchemaMetadata = retriever.schemaGet("/schemas/ids/100042") | ||
println(actualSchemaMetadata) | ||
} | ||
|
||
@Ignore | ||
@Test | ||
fun testSchemaPost() = runBlocking { | ||
val postResult = retriever.schemaPost("subjects/d90c8b88-5793-438a-b27d-6c87580cc3d9", Schema.create(Schema.Type.STRING)) | ||
|
||
println(postResult) | ||
} | ||
|
||
@Test | ||
fun testRetrieveSchemaById() = runBlocking { | ||
val res = retriever.retrieveSchemaById(100086) | ||
println(res) | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
radar-commons/src/test/java/org/radarbase/producer/schema/SchemaRetrieverIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright 2017 The Hyve and King's College London | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.radarbase.producer.schema | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.cio.CIO | ||
import io.ktor.http.* | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.coroutines.test.runTest | ||
import okhttp3.mockwebserver.MockWebServer | ||
import org.apache.avro.Schema | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.radarbase.producer.io.timeout | ||
import org.radarbase.producer.rest.RestKafkaSenderTest.Companion.enqueueJson | ||
import java.io.IOException | ||
import kotlin.time.Duration.Companion.seconds | ||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.auth.* | ||
import io.ktor.client.plugins.auth.providers.* | ||
import io.ktor.client.statement.* | ||
import org.junit.Ignore | ||
|
||
class SchemaRetrieverIntegrationTest { | ||
private lateinit var retriever: SchemaRetriever | ||
|
||
// This testclass requires a functioning confluent cloud provider, therefore all tests here are ignored | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
val apiSecret = "exampleSecret" | ||
val apiKey = "exampleKey" | ||
retriever = SchemaRetriever.schemaRetriever(baseUrl = "https://SOME_EXAMPLE.westeurope.azure.confluent.cloud") | ||
{ | ||
httpClient = HttpClient(CIO) { | ||
timeout(30.seconds) | ||
install(Auth) { | ||
basic { | ||
sendWithoutRequest { true } | ||
credentials { | ||
BasicAuthCredentials(username = apiKey, password = apiSecret) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
val restClient = SchemaRestClient( | ||
httpClient = HttpClient { | ||
timeout(30.seconds) | ||
install(Auth) { | ||
basic { | ||
sendWithoutRequest { true } | ||
credentials { | ||
BasicAuthCredentials(username = apiKey, password = apiSecret) | ||
} | ||
} | ||
} | ||
}, | ||
baseUrl = "https://SOME_EXAMPLE.westeurope.azure.confluent.cloud", | ||
) | ||
} | ||
|
||
@AfterEach | ||
@Throws(IOException::class) | ||
fun tearDown() { | ||
} | ||
|
||
@Ignore | ||
@Test | ||
fun testGetById() = runBlocking { | ||
val topic = "android_phone_acceleration" | ||
val id = 100042 | ||
val ofValue = true | ||
val res = retriever.getById(topic, ofValue, id) | ||
println(res) | ||
} | ||
} |