Skip to content

Commit

Permalink
Updated dependency version, switched to should-test library
Browse files Browse the repository at this point in the history
  • Loading branch information
pwall567 committed Dec 12, 2024
1 parent 6f81366 commit 6d4273b
Show file tree
Hide file tree
Showing 11 changed files with 659 additions and 645 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [3.4] - 2024-12-12
### Changed
- `pom.xml`: updated dependency version
- tests : switched to `should-test` library

## [3.3] - 2024-09-04
### Changed
- `pom.xml`: updated dependency version
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,25 @@ in the test section of this project.

## Dependency Specification

The latest version of the library is 3.3, and it may be obtained from the Maven Central repository.
The latest version of the library is 3.4, and it may be obtained from the Maven Central repository.

### Maven
```xml
<dependency>
<groupId>io.kjson</groupId>
<artifactId>kjson-yaml</artifactId>
<version>3.3</version>
<version>3.4</version>
</dependency>
```
### Gradle
```groovy
implementation 'io.kjson:kjson-yaml:3.3'
implementation 'io.kjson:kjson-yaml:3.4'
```
### Gradle (kts)
```kotlin
implementation("io.kjson:kjson-yaml:3.3")
implementation("io.kjson:kjson-yaml:3.4")
```

Peter Wall

2024-09-04
2024-12-12
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>kjson-yaml</artifactId>
<version>3.3</version>
<version>3.4</version>
<name>Kotlin YAML processor</name>
<packaging>jar</packaging>
<url>https://github.com/pwall567/kjson-yaml</url>
Expand Down Expand Up @@ -62,12 +62,12 @@
<dependency>
<groupId>io.kjson</groupId>
<artifactId>kjson-core</artifactId>
<version>9.1</version>
<version>9.2</version>
</dependency>
<dependency>
<groupId>io.kjson</groupId>
<artifactId>kjson-pointer</artifactId>
<version>8.3</version>
<version>8.4</version>
</dependency>
<dependency>
<groupId>net.pwall.text</groupId>
Expand All @@ -93,6 +93,12 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>io.kstuff</groupId>
<artifactId>should-test</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
Expand Down
31 changes: 16 additions & 15 deletions src/test/kotlin/io/kjson/yaml/YAMLDocumentTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @(#) YAMLDocumentTest.kt
*
* kjson-yaml Kotlin YAML processor
* Copyright (c) 2020, 2021, 2023 Peter Wall
* Copyright (c) 2020, 2021, 2023, 2024 Peter Wall
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,11 +26,12 @@
package io.kjson.yaml

import kotlin.test.Test
import kotlin.test.assertFailsWith
import kotlin.test.expect

import java.io.File

import io.kstuff.test.shouldBe
import io.kstuff.test.shouldThrow

import io.kjson.JSONString
import io.kjson.pointer.JSONPointer

Expand All @@ -39,26 +40,26 @@ class YAMLDocumentTest {
@Test fun `should create YAMLDocument`() {
val testNode = JSONString("hello")
val doc = YAMLDocument(testNode, emptyMap())
expect(testNode) { doc.rootNode }
expect(1) { doc.majorVersion }
expect(2) { doc.minorVersion }
doc.rootNode shouldBe testNode
doc.majorVersion shouldBe 1
doc.minorVersion shouldBe 2
}

@Test fun `should get default tags`() {
val document = YAML.parse(File("src/test/resources/alltypes.yaml"))
expect("tag:yaml.org,2002:str") { document.getTag(JSONPointer("/string")) }
expect("tag:yaml.org,2002:int") { document.getTag(JSONPointer("/int")) }
expect("tag:yaml.org,2002:float") { document.getTag(JSONPointer("/decimal")) }
expect("tag:yaml.org,2002:bool") { document.getTag(JSONPointer("/boolean")) }
expect("tag:yaml.org,2002:null") { document.getTag(JSONPointer("/empty")) }
expect("tag:yaml.org,2002:seq") { document.getTag(JSONPointer("/array")) }
expect("tag:yaml.org,2002:map") { document.getTag(JSONPointer("/object")) }
document.getTag(JSONPointer("/string")) shouldBe "tag:yaml.org,2002:str"
document.getTag(JSONPointer("/int")) shouldBe "tag:yaml.org,2002:int"
document.getTag(JSONPointer("/decimal")) shouldBe "tag:yaml.org,2002:float"
document.getTag(JSONPointer("/boolean")) shouldBe "tag:yaml.org,2002:bool"
document.getTag(JSONPointer("/empty")) shouldBe "tag:yaml.org,2002:null"
document.getTag(JSONPointer("/array")) shouldBe "tag:yaml.org,2002:seq"
document.getTag(JSONPointer("/object")) shouldBe "tag:yaml.org,2002:map"
}

@Test fun `should throw exception getting tag for unknown node`() {
val document = YAML.parse(File("src/test/resources/alltypes.yaml"))
assertFailsWith<YAMLException> { document.getTag(JSONPointer("/rubbish")) }.let {
expect("Node does not exist - /rubbish") { it.message }
shouldThrow<YAMLException>("Node does not exist - /rubbish") {
document.getTag(JSONPointer("/rubbish"))
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/kotlin/io/kjson/yaml/YAMLExceptionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@
package io.kjson.yaml

import kotlin.test.Test
import kotlin.test.expect

import io.kstuff.test.shouldBe

class YAMLExceptionTest {

@Test fun `should create YAMLException`() {
val ye = YAMLException("Something went wrong")
expect("Something went wrong") { ye.message }
ye.message shouldBe "Something went wrong"
}

@Test fun `should create YAMLException with nested exception`() {
val nested = IllegalArgumentException("Dummy")
val ye = YAMLException("Oh no!").withCause(nested)
expect("Oh no!") { ye.message }
expect(nested) { ye.cause }
ye.message shouldBe "Oh no!"
ye.cause shouldBe nested
}

}
17 changes: 9 additions & 8 deletions src/test/kotlin/io/kjson/yaml/YAMLTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @(#) YAMLTest.kt
*
* kjson-yaml Kotlin YAML processor
* Copyright (c) 2020, 2021, 2023 Peter Wall
* Copyright (c) 2020, 2021, 2023, 2024 Peter Wall
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,10 +26,11 @@
package io.kjson.yaml

import kotlin.test.Test
import kotlin.test.expect

import java.io.File

import io.kstuff.test.shouldBe

import io.kjson.JSON.asObject
import io.kjson.JSON.asString

Expand All @@ -38,21 +39,21 @@ class YAMLTest {
@Test fun `should use YAML object functions`() {
val file = File("src/test/resources/keyblock.yaml")
val result = YAML.parse(file)
expect("data") { result.rootNode.asObject["key"].asString }
result.rootNode.asObject["key"].asString shouldBe "data"
val inputStream = file.inputStream()
expect("data") { YAML.parse(inputStream).rootNode.asObject["key"].asString }
YAML.parse(inputStream).rootNode.asObject["key"].asString shouldBe "data"
val reader = file.reader()
expect("data") { YAML.parse(reader).rootNode.asObject["key"].asString }
YAML.parse(reader).rootNode.asObject["key"].asString shouldBe "data"
}

@Test fun `should use YAML object functions for multi-document streams`() {
val file = File("src/test/resources/keyblock.yaml")
val result = YAML.parseStream(file)
expect("data") { result.single().rootNode.asObject["key"].asString }
result.single().rootNode.asObject["key"].asString shouldBe "data"
val inputStream = file.inputStream()
expect("data") { YAML.parseStream(inputStream).single().rootNode.asObject["key"].asString }
YAML.parseStream(inputStream).single().rootNode.asObject["key"].asString shouldBe "data"
val reader = file.reader()
expect("data") { YAML.parseStream(reader).single().rootNode.asObject["key"].asString }
YAML.parseStream(reader).single().rootNode.asObject["key"].asString shouldBe "data"
}

}
9 changes: 5 additions & 4 deletions src/test/kotlin/io/kjson/yaml/parser/JSONCompatibilityTest.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @(#) NoCommitJSONCompatibilityTest.kt
* @(#) JSONCompatibilityTest.kt
*
* kjson-yaml Kotlin YAML processor
* Copyright (c) 2020, 2021 Peter Wall
* Copyright (c) 2020, 2021, 2024 Peter Wall
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,18 +26,19 @@
package io.kjson.yaml.parser

import kotlin.test.Test
import kotlin.test.expect

import java.io.File

import io.kstuff.test.shouldBe

import io.kjson.JSON

class JSONCompatibilityTest {

@Test fun `should create identical structure for matching YAML and JSON`() {
val json = JSON.parse(File("src/test/resources/example.schema.json").readText())
val yaml = Parser().parse(File("src/test/resources/example.schema.yaml"))
expect(json) { yaml.rootNode }
yaml.rootNode shouldBe json
}

}
12 changes: 5 additions & 7 deletions src/test/kotlin/io/kjson/yaml/parser/LoggingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @(#) LoggingTest.kt
*
* kjson-yaml Kotlin YAML processor
* Copyright (c) 2020, 2021 Peter Wall
* Copyright (c) 2020, 2021, 2024 Peter Wall
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,11 +26,11 @@
package io.kjson.yaml.parser

import kotlin.test.Test
import kotlin.test.assertNull
import kotlin.test.assertTrue

import java.io.File

import io.kstuff.test.shouldBe

import net.pwall.log.LogList
import net.pwall.log.isDebug

Expand All @@ -40,10 +40,8 @@ class LoggingTest {
LogList().use { logList ->
val emptyFile = File("src/test/resources/empty.yaml")
val result = Parser().parse(emptyFile)
assertNull(result.rootNode)
assertTrue {
logList.any { it.isDebug("Parse complete; result is null") }
}
result.rootNode shouldBe null
logList.any { it.isDebug("Parse complete; result is null") } shouldBe true
}
}

Expand Down
Loading

0 comments on commit 6d4273b

Please sign in to comment.