aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-domain/src/test
diff options
context:
space:
mode:
authorfkrzywka <filip.krzywka@nokia.com>2018-06-05 12:55:06 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-01 11:14:55 +0200
commit23438166832778b36f3aac7b3cc0b81ab6e8da1e (patch)
treee0f6c70b8c3f105849d16351cfc3d7882b618f45 /hv-collector-domain/src/test
parentf895b8628fbc9cde4013dcf68607b4e18a8ce85b (diff)
Extract domain module
WireFrame extracted to domain module Domain package name in collector-core changed to avoid collision Merged Protobuf module with new domain module Closes ONAP-253. Change-Id: Ie7ac0bb877eae018a7520b4f3ceebe9fd51dbf65 Signed-off-by: fkrzywka <filip.krzywka@nokia.com> Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-domain/src/test')
-rw-r--r--hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt55
-rw-r--r--hv-collector-domain/src/test/resources/logback.xml54
2 files changed, 109 insertions, 0 deletions
diff --git a/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt b/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt
new file mode 100644
index 00000000..5a923c4e
--- /dev/null
+++ b/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt
@@ -0,0 +1,55 @@
+package org.onap.dcae.collectors.veshv.domain
+
+import io.netty.buffer.ByteBufAllocator
+import io.netty.buffer.Unpooled
+import org.assertj.core.api.Assertions.assertThat
+import org.jetbrains.spek.api.Spek
+import org.jetbrains.spek.api.dsl.describe
+import org.jetbrains.spek.api.dsl.it
+
+/**
+ * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
+ * @since June 2018
+ */
+object WireFrameTest : Spek({
+ describe("Wire Frame codec") {
+ describe("encode-decode methods' compatibility") {
+ val payloadContent = "test"
+ val payload = Unpooled.wrappedBuffer(payloadContent.toByteArray(Charsets.US_ASCII))
+ val frame = WireFrame(payload = payload,
+ majorVersion = 1,
+ minorVersion = 2,
+ mark = 0xFF,
+ payloadSize = payload.readableBytes())
+
+ val encoded = frame.encode(ByteBufAllocator.DEFAULT)
+ val decoded = WireFrame.decode(encoded)
+
+ it("should decode major version") {
+ assertThat(decoded.majorVersion).isEqualTo(frame.majorVersion)
+ }
+
+ it("should decode minor version") {
+ assertThat(decoded.minorVersion).isEqualTo(frame.minorVersion)
+ }
+
+ it("should decode mark") {
+ assertThat(decoded.mark).isEqualTo(frame.mark)
+ }
+
+ it("should decode payload size") {
+ assertThat(decoded.payloadSize).isEqualTo(frame.payloadSize)
+ }
+
+ it("should decode payload") {
+ assertThat(decoded.payload.toString(Charsets.US_ASCII))
+ .isEqualTo(payloadContent)
+ }
+
+ it("should retain decoded payload") {
+ encoded.release()
+ assertThat(decoded.payload.refCnt()).isEqualTo(1)
+ }
+ }
+ }
+}) \ No newline at end of file
diff --git a/hv-collector-domain/src/test/resources/logback.xml b/hv-collector-domain/src/test/resources/logback.xml
new file mode 100644
index 00000000..0bf2cb02
--- /dev/null
+++ b/hv-collector-domain/src/test/resources/logback.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ dcaegen2-collectors-veshv
+ ~ ================================================================================
+ ~ Copyright (C) 2018 NOKIA
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+ -->
+<configuration>
+ <property name="LOG_FILE"
+ value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}ves-hv.log}"/>
+ <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %-5level [%-40.40logger{10}] - %msg%n"/>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %highlight(%-5level) [%-40.40logger{10}] - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="ROLLING-FILE"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <encoder>
+ <pattern>${FILE_LOG_PATTERN}</pattern>
+ </encoder>
+ <file>${LOG_FILE}</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ </appender>
+
+ <logger name="org.onap.dcae.collectors.veshv" level="DEBUG"/>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="ROLLING-FILE"/>
+ </root>
+</configuration> \ No newline at end of file