Skip to content

Commit

Permalink
th2-codec updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Smelov committed Sep 14, 2023
1 parent 07c7d9b commit 52bf0e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,22 @@ jar {
dependencies {
api platform("com.exactpro.th2:bom:4.5.0")
implementation "com.exactpro.th2:common:5.4.0-dev"
implementation "com.exactpro.th2:codec:5.3.0-new-proto-6049749662-17ae1b8-SNAPSHOT"
implementation "com.exactpro.th2:codec:5.3.0-dev"

implementation "org.slf4j:slf4j-api"
implementation "io.github.microutils:kotlin-logging:3.0.5"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

implementation "com.fasterxml.jackson.core:jackson-core"
implementation "com.github.javadev:underscore:1.92"
implementation "com.github.javadev:underscore:1.93"
implementation "commons-io:commons-io"

testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:${kotlin_version}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:$kotlin_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"

compileOnly "com.google.auto.service:auto-service:1.1.1"
annotationProcessor "com.google.auto.service:auto-service:1.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class XmlPipelineCodecTest : XmlTest() {
</Msg>
""".trimIndent())

Assertions.assertDoesNotThrow { withoutValidationCodec.decode(xml) }
Assertions.assertDoesNotThrow { withValidationCodec.decode(xml) }
Assertions.assertDoesNotThrow { withoutValidationCodec.decode(xml, reportingContext) }
Assertions.assertDoesNotThrow { withValidationCodec.decode(xml, reportingContext) }

// Formatted message with XML declaration
xml = createMessageGroup("""
Expand All @@ -103,8 +103,8 @@ class XmlPipelineCodecTest : XmlTest() {
</Msg>
""".trimIndent())

Assertions.assertDoesNotThrow { withoutValidationCodec.decode(xml) }
Assertions.assertThrows(IllegalStateException::class.java) { withValidationCodec.decode(xml) }
Assertions.assertDoesNotThrow { withoutValidationCodec.decode(xml, reportingContext) }
Assertions.assertThrows(IllegalStateException::class.java) { withValidationCodec.decode(xml, reportingContext) }
}

@Test
Expand All @@ -121,7 +121,7 @@ class XmlPipelineCodecTest : XmlTest() {
""".trimIndent())

Assertions.assertThrows(IllegalStateException::class.java) {
withoutValidationCodec.decode(xml)
withoutValidationCodec.decode(xml, reportingContext)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/com/exactpro/th2/codec/xml/XsdTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class XsdTest : XmlTest() {


assertFailsWith<IllegalStateException> ("Error needed due no xsd for xml validation") {
codec.decode(group)
codec.decode(group, reportingContext)
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/test/kotlin/com/exactpro/th2/codec/xml/utils/XmlTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.exactpro.th2.codec.xml.utils

import com.exactpro.th2.codec.api.IPipelineCodec
import com.exactpro.th2.codec.api.impl.ReportingContext
import com.exactpro.th2.codec.xml.XmlPipelineCodec
import com.exactpro.th2.codec.xml.XmlPipelineCodecFactory.Companion.decodeInputToDictionary
import com.exactpro.th2.codec.xml.XmlPipelineCodecSettings
Expand All @@ -33,11 +34,11 @@ import java.util.Base64
import kotlin.test.assertEquals

abstract class XmlTest(jsonPathToType: String? = null, nameOfXsdResource: String? = null) {

protected val reportingContext = ReportingContext()
protected val codec: IPipelineCodec

protected fun checkEncode(xml: String, message: Message.Builder) {
val group = codec.encode(MessageGroup.newBuilder().addMessages(AnyMessage.newBuilder().setMessage(message)).build())
val group = codec.encode(MessageGroup.newBuilder().addMessages(AnyMessage.newBuilder().setMessage(message)).build(), reportingContext)
assertEquals(1, group.messagesCount)

LOGGER.info("ENCODE_RESULT: ${TextFormat.shortDebugString(group)}")
Expand All @@ -49,7 +50,7 @@ abstract class XmlTest(jsonPathToType: String? = null, nameOfXsdResource: String
}

protected fun checkDecode(xml: String, message: Message.Builder) {
val group = codec.decode(createRawMessage(xml))
val group = codec.decode(createRawMessage(xml), reportingContext)
assertEquals(1, group.messagesCount)

LOGGER.info("DECODE_RESULT: ${TextFormat.shortDebugString(group)}")
Expand Down

0 comments on commit 52bf0e9

Please sign in to comment.