Skip to content

Commit

Permalink
Migrated from jaxb-api: 2.3.1 to jakarta.xml.bind-api: 4.0.2
Browse files Browse the repository at this point in the history
+ Migrated to th2 gradle plugin: `0.0.6`
  • Loading branch information
Nikita-Smirnov-Exactpro committed Apr 29, 2024
1 parent 2964744 commit 9948fcf
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 46 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AVRO codec (2.4.0)
# AVRO codec (2.5.0)
## Description
Designed for decode AVRO raw messages to parsed messages and encode back.
It is based on [th2-codec](https://github.com/th2-net/th2-codec).
Expand Down Expand Up @@ -85,6 +85,16 @@ Only one of settings `sessionAliasToDictionaryAlias` or `avroMessageIdToDictiona

## Release notes

### 3.0.0
+ Migrated from jaxb-api: `2.3.1` to jakarta.xml.bind-api: `4.0.2`
+ Because artifact was moved
+ Migrated to th2 gradle plugin: `0.0.6`
+ Updated:
+ bom `4.6.1`
+ common: `5.10.1-dev`
+ common: `2.2.3-dev`
+ avro: `1.11.3`

### 2.4.0
+ Updated common: `5.7.2-dev`
+ Updated common-utils: `2.2.2-dev`
Expand Down
81 changes: 50 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,66 @@
buildscript {
repositories {
maven {
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
plugins {
id "org.jetbrains.kotlin.jvm" version "1.8.22"
id("java-library")
id("maven-publish")

id "com.exactpro.th2.gradle.base" version "0.0.6"
id "com.exactpro.th2.gradle.publish" version "0.0.6"

id "me.champeau.jmh" version "0.7.2"
}

apply plugin: 'kotlin-kapt'

group = 'com.exactpro.th2'
version = release_version

repositories {
mavenCentral()
maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
dependencies {
classpath "com.exactpro.th2:th2-gradle-plugin:0.0.1-dev-5915772757-13a28ae-SNAPSHOT"
maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
mavenLocal()

plugins {
// for run ./gradlew jmh
id 'me.champeau.jmh' version '0.6.8'
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
}

apply plugin: "com.exactpro.th2.common-conventions"
apply plugin: "com.exactpro.th2.docker-conventions"
dependencies {
implementation "com.exactpro.th2:common:5.10.1-dev"
implementation "com.exactpro.th2:common-utils:2.2.3-dev"
implementation "com.exactpro.th2:codec:5.5.0-th2-gradle-plugin-+"
implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.2"

apply plugin: 'kotlin-kapt'

dependencies {
api platform('com.exactpro.th2:bom:4.5.0')
implementation 'org.apache.avro:avro:1.11.3'
implementation 'commons-io:commons-io'

implementation "io.github.microutils:kotlin-logging:3.0.5"

implementation "com.exactpro.th2:common:5.7.2-dev"
implementation "com.exactpro.th2:common-utils:2.2.2-dev"
implementation "com.exactpro.th2:codec:5.4.1-dev"
implementation 'javax.xml.bind:jaxb-api:2.3.1'
compileOnly 'com.google.auto.service:auto-service:1.1.1'
kapt 'com.google.auto.service:auto-service:1.1.1'

implementation 'org.apache.avro:avro:1.11.1'
implementation 'commons-io:commons-io:2.12.0'
jmh 'org.openjdk.jmh:jmh-core:1.37'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.37'

compileOnly 'com.google.auto.service:auto-service:1.0.1'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5:1.6.21'
kapt 'com.google.auto.service:auto-service:1.0.1'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.3.1'
testImplementation 'io.strikt:strikt-core:0.34.1'
}

jmh 'org.openjdk.jmh:jmh-core:1.36'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.36'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.36'
test {
useJUnitPlatform()
}

jmh {
//profilers = ['stack'] // Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr, async]
}
dependencyLocking {
lockAllConfigurations()
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
release_version=2.4.0
release_version=3.0.0
app_main_class=com.exactpro.th2.codec.MainKt
4 changes: 2 additions & 2 deletions src/main/kotlin/com/exactpro/th2/codec/AbstractAvroCodec.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,12 +32,12 @@ import com.google.protobuf.UnsafeByteOperations
import io.netty.buffer.ByteBuf
import io.netty.buffer.ByteBufUtil
import io.netty.buffer.Unpooled
import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.io.Decoder
import org.apache.avro.io.Encoder
import org.apache.avro.io.EncoderFactory
import java.io.ByteArrayOutputStream
import java.io.IOException
import javax.xml.bind.DatatypeConverter
import com.exactpro.th2.common.grpc.AnyMessage as ProtoAnyMessage
import com.exactpro.th2.common.grpc.Message as ProtoMessage
import com.exactpro.th2.common.grpc.MessageGroup as ProtoMessageGroup
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/exactpro/th2/codec/MessageDatumReader.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@ import com.exactpro.th2.common.grpc.Value
import com.exactpro.th2.common.message.addField
import com.exactpro.th2.common.value.toValue
import com.google.protobuf.TextFormat.shortDebugString
import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.Schema
import org.apache.avro.LogicalType
import org.apache.avro.Conversion
Expand All @@ -32,7 +33,6 @@ import org.apache.avro.io.Decoder
import org.apache.avro.io.ResolvingDecoder
import java.io.IOException
import java.nio.ByteBuffer
import javax.xml.bind.DatatypeConverter
import mu.KotlinLogging

class MessageDatumReader(
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/exactpro/th2/codec/MessageDatumWriter.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@ import com.exactpro.th2.common.grpc.Value
import com.exactpro.th2.common.message.getField
import com.exactpro.th2.common.value.getList
import com.exactpro.th2.common.value.getMessage
import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.UnresolvedUnionException
import org.apache.avro.AvroTypeException
import org.apache.avro.Schema
Expand All @@ -33,7 +34,6 @@ import org.apache.avro.path.LocationStep
import org.apache.avro.util.SchemaUtil
import java.io.IOException
import java.nio.ByteBuffer
import javax.xml.bind.DatatypeConverter

class MessageDatumWriter(schema: Schema, enableIdPrefixEnumFields: Boolean = false) :
AbstractMessageWriter<Message>(schema, enableIdPrefixEnumFields) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@ package com.exactpro.th2.codec

import com.exactpro.th2.codec.AbstractMessageWriter.Companion.UNION_FIELD_NAME_TYPE_DELIMITER
import com.exactpro.th2.codec.AbstractMessageWriter.Companion.UNION_ID_PREFIX
import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.Schema
import org.apache.avro.LogicalType
import org.apache.avro.Conversion
Expand All @@ -27,7 +28,6 @@ import org.apache.avro.io.Decoder
import org.apache.avro.io.ResolvingDecoder
import java.io.IOException
import java.nio.ByteBuffer
import javax.xml.bind.DatatypeConverter
import mu.KotlinLogging

class TransportMessageDatumReader(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package com.exactpro.th2.codec

import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.Schema
import org.apache.avro.AvroTypeException
import org.apache.avro.UnresolvedUnionException
Expand All @@ -27,7 +28,6 @@ import org.apache.avro.path.LocationStep
import org.apache.avro.util.SchemaUtil
import java.io.IOException
import java.nio.ByteBuffer
import javax.xml.bind.DatatypeConverter

class TransportMessageDatumWriter(schema: Schema, enableIdPrefixEnumFields: Boolean = false) :
AbstractMessageWriter<Map<String, Any?>>(schema, enableIdPrefixEnumFields) {
Expand Down
7 changes: 4 additions & 3 deletions src/test/kotlin/com/exactpro/th2/codec/TestAvroCodec.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@ import com.exactpro.th2.common.utils.message.toTransport
import com.google.protobuf.ByteString
import io.netty.buffer.Unpooled
import com.google.protobuf.UnsafeByteOperations
import jakarta.xml.bind.DatatypeConverter
import org.apache.avro.Schema.Parser
import org.apache.avro.generic.GenericDatumWriter
import org.apache.avro.io.BinaryEncoder
Expand All @@ -41,14 +42,14 @@ import org.junit.jupiter.api.Test
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.InputStream
import javax.xml.bind.DatatypeConverter
import kotlin.test.assertEquals
import org.junit.jupiter.api.Disabled
import java.time.Instant
import kotlin.test.assertNotNull
import kotlin.test.assertContentEquals
import kotlin.test.assertTrue

@Suppress("SpellCheckingInspection")
class TestAvroCodec {
private val pipelineCodecContext = CodecContext()
private val codecFactory: AvroCodecFactory = AvroCodecFactory().apply {init(pipelineCodecContext)}
Expand Down Expand Up @@ -176,7 +177,7 @@ class TestAvroCodec {

// transport decode
val transportDecodeGroup = transportDecode(rawBytes, sessionAlias)
assertEquals(expected, (transportDecodeGroup.messages[0].body as Map<String, Any>).size)
assertEquals(expected, (transportDecodeGroup.messages[0].body as Map<*, *>).size)

// transport encode
val transportEncoded = transportEncode(transportDecodeGroup)
Expand Down

0 comments on commit 9948fcf

Please sign in to comment.