diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..93f197d
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,26 @@
+version: 2
+
+updates:
+ # Keeps the SHA pins in .github/workflows/ current - pinning without this
+ # just means the actions silently rot instead of silently changing.
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ commit-message:
+ prefix: "ci"
+
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 10
+ commit-message:
+ prefix: "deps"
+ groups:
+ junit:
+ patterns:
+ - "org.junit*"
+ maven-plugins:
+ patterns:
+ - "org.apache.maven.plugins:*"
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..4004da1
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,95 @@
+name: Build
+
+on:
+ workflow_dispatch:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+# Least privilege by default; jobs opt into more where they need it.
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ name: Build (JDK ${{ matrix.java }})
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ checks: write
+ strategy:
+ fail-fast: false
+ matrix:
+ java: [ '17', '21' ]
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
+ with:
+ java-version: ${{ matrix.java }}
+ distribution: 'temurin'
+ cache: 'maven'
+
+ - name: Build, test and generate SBOM
+ run: mvn -B --no-transfer-progress verify
+
+ # Forked PRs get a read-only token, so the check-run API is unavailable there.
+ - name: Test report
+ uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
+ if: ${{ (success() || failure()) && github.event.pull_request.head.repo.fork != true }}
+ with:
+ name: Tests (JDK ${{ matrix.java }})
+ path: '**/target/surefire-reports/TEST-*.xml'
+ reporter: java-junit
+
+ - name: Upload SBOM
+ if: matrix.java == '17'
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: sbom
+ path: |
+ target/bom.json
+ target/bom.xml
+ if-no-files-found: error
+
+ dependency-track:
+ name: Publish SBOM to DependencyTrack
+ needs: build
+ if: github.event_name != 'pull_request'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ env:
+ DTRACK_URL: ${{ secrets.DEPENDENCYTRACK_URL }}
+ DTRACK_API_KEY: ${{ secrets.DEPENDENCYTRACK_API_KEY }}
+
+ steps:
+ - name: Download SBOM
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: sbom
+ path: sbom
+
+ - name: Not configured
+ if: env.DTRACK_URL == ''
+ run: |
+ echo "::notice::DEPENDENCYTRACK_URL is not set - skipping upload." \
+ "Add the DEPENDENCYTRACK_URL and DEPENDENCYTRACK_API_KEY repository secrets to enable it."
+
+ - name: Upload BOM
+ if: env.DTRACK_URL != ''
+ run: |
+ curl --fail-with-body -sS -X POST "${DTRACK_URL%/}/api/v1/bom" \
+ -H "X-Api-Key: ${DTRACK_API_KEY}" \
+ -F "autoCreate=true" \
+ -F "projectName=${{ github.event.repository.name }}" \
+ -F "projectVersion=${{ github.ref_name }}" \
+ -F "bom=@sbom/bom.json"
diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml
index d145452..65f5289 100644
--- a/.github/workflows/linter.yml
+++ b/.github/workflows/linter.yml
@@ -1,23 +1,36 @@
-name: Lint Code Base
+name: Lint
-on:
+on:
workflow_dispatch:
+ pull_request:
+ branches: [ "master" ]
+
+permissions:
+ contents: read
jobs:
- build:
- name: Lint Code Base
+ lint:
+ name: Lint code base
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ statuses: write
steps:
- - name: Checkout Code
- uses: actions/checkout@v2
+ - name: Checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- # Full git history is needed to get a proper list of changed files within `super-linter`
+ # super-linter needs full history to diff against the base branch.
fetch-depth: 0
- - name: Lint Code Base
- uses: github/super-linter@v6
+ - name: Lint
+ uses: github/super-linter@b807e99ddd37e444d189cfd2c2ca1274d8ae8ef1 # v7
env:
- VALIDATE_ALL_CODEBASE: false
- DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ DEFAULT_BRANCH: master
+ VALIDATE_ALL_CODEBASE: false
+ # Scoped deliberately: enabling any VALIDATE_* switch turns the rest off.
+ # The Java sources predate any shared format config, so linting them here
+ # would fail every PR for reasons unrelated to the change under review.
+ VALIDATE_YAML: true
+ VALIDATE_GITHUB_ACTIONS: true
diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
deleted file mode 100644
index ee25905..0000000
--- a/.github/workflows/maven-build.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-name: Java CI with Maven
-
-on:
- workflow_dispatch:
- push:
- branches: [ "master" ]
- pull_request:
- branches: [ "master" ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
- permissions:
- contents: read
- checks: write
-
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'temurin'
-
- - name: Build with Maven
- run: mvn clean install
-
- - name: Test Report
- uses: dorny/test-reporter@v1
- if: success() || failure() # run this step even if previous step failed
- with:
- name: Tests # Name of the check run which will be created
- path: '**/target/surefire-reports/TEST-*.xml' # Path to test results
- reporter: java-junit # Format of test results
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index d3359e4..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-name: Java CI with Maven
-
-on:
- workflow_dispatch:
- push:
- branches: [ "master" ]
- pull_request:
- branches: [ "master" ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
- permissions:
- contents: read
- checks: write
-
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: '1.8'
- distribution: 'temurin'
-
- - name: Build with Maven
- run: mvn clean install
diff --git a/.gitignore b/.gitignore
index 6edd03e..9e67d39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
-/build
.project
.classpath
-.gradle
.settings
.DS_Store
.svn
diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile
deleted file mode 100644
index bea40f0..0000000
--- a/.gitpod.Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM gitpod/workspace-full
-
-USER gitpod
-
-# Install custom tools, runtime, etc. using apt-get
-# For example, the command below would install "bastet" - a command line tetris clone:
-#
-# RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/*
-#
-# More information: https://www.gitpod.io/docs/config-docker/
diff --git a/.gitpod.yml b/.gitpod.yml
deleted file mode 100644
index d44c55a..0000000
--- a/.gitpod.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-tasks:
- - init: mvn clean install
-image:
- file: .gitpod.Dockerfile
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 9a1dfb5..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-sudo: false
-language: java
-install: ./gradlew --quiet install
-script: ./gradlew --quiet build
-jdk:
- - oraclejdk8
-notifications:
- email:
- - toni.menzel@rebaze.com
- slack: rebaze:W2NAFBrzwufg7HptbqgE3hgB
diff --git a/README.md b/README.md
index bd15d3e..c28bc2c 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,7 @@
-[](https://gitpod.io/#https://github.com/rebaze/integrity)
-
[
](http://rebaze.com)
-[](http://www.osgi.org)
-[](https://github.com/rebaze/integrity/workflows/cibuild/)
-[](https://maven-badges.herokuapp.com/maven-central/org.rebaze.integrity/org.rebaze.integrity.tree)
-[](http://www.apache.org/licenses/LICENSE-2.0)
+[](https://github.com/rebaze/integrity/actions/workflows/build.yml)
+[](http://www.apache.org/licenses/LICENSE-2.0)
# News
@@ -14,7 +10,6 @@
A small Java library for creating Merkle Trees (https://en.m.wikipedia.org/wiki/Merkle_tree) to be used in blockchain-like technologies.
- Composite hash- tree based java library (DAG)
-- OSGi compatible
- Embeddable
- Low footprint
@@ -135,6 +130,33 @@ Tags do not need to be unique.
IndexTree currently does not build indexes for tags, so that is a thing to do..;)
+# Building
+
+Requires JDK 17 or newer and Maven 3.9+. The library itself has **no runtime
+dependencies** - it is pure JDK.
+
+````
+mvn verify
+````
+
+## Software Bill of Materials
+
+Every build emits a [CycloneDX](https://cyclonedx.org/) 1.6 SBOM to
+`target/bom.json` and `target/bom.xml`. Because this project's only
+dependencies are test-scope, the BOM is generated with `includeTestScope`
+enabled - otherwise it would come out empty.
+
+CI publishes the SBOM as a workflow artifact, and pushes it to
+[DependencyTrack](https://dependencytrack.org/) when these repository secrets
+are set:
+
+| Secret | Purpose |
+| --- | --- |
+| `DEPENDENCYTRACK_URL` | Base URL of the DependencyTrack API server |
+| `DEPENDENCYTRACK_API_KEY` | API key with `BOM_UPLOAD` permission |
+
+Without them the upload step is skipped and the build still passes.
+
# LICENSE
Copyright 2014-2020 rebaze GmbH.
diff --git a/bnd.bnd b/bnd.bnd
deleted file mode 100644
index 50e3c85..0000000
--- a/bnd.bnd
+++ /dev/null
@@ -1,18 +0,0 @@
-Bundle-Vendor: rebaze.io
-
-Bundle-License: Apache Software License 2.0
-
-Bundle-Copyright: rebaze GmbH
-
-Bundle-Version:\
- ${project.version}
-
-Bundle-SymbolicName:\
- ${project.name}
-
-Import-Package:\
- *
-
-Export-Package:\
- org.rebaze.integrity.tree.api,\
- org.rebaze.integrity.tree.util
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 5ad4944..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,87 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.0'
- }
-}
-plugins {
- id 'java-library'
- id 'maven-publish'
- id "com.jfrog.bintray" version "1.8.4"
- // id 'signing'
-}
-
-bintray {
- user = System.getenv('BINTRAY_USER')
- key = System.getenv('BINTRAY_KEY')
- pkg {
- repo = 'rebaze-oss'
- name = 'integrity'
- userOrg = 'rebaze'
- licenses = ['Apache-2.0']
- vcsUrl = 'https://github.com/rebaze/integrity.git'
- publications = ['maven']
- }
-}
-
-apply plugin: 'biz.aQute.bnd.builder'
-
-task install() {}
-// install.dependsOn(publishToMavenLocal)
-
-group = 'org.rebaze.integrity'
-description = """rebaze integrity - tree library"""
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
-tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
-}
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- testRuntimeOnly group: 'org.slf4j', name: 'slf4j-simple', version:'1.6.1'
- testImplementation group: 'junit', name: 'junit', version:'4.12'
-}
-
-task sourcesJar(type: Jar) {
- from sourceSets.main.allJava
- archiveClassifier = 'sources'
-}
-
-publishing {
- publications {
- maven(MavenPublication) {
- from components.java
- artifact sourcesJar
- // artifact javadocJar
- pom {
- url = 'https://www.rebaze.com'
- licenses {
- license {
- name = '(c) Rebaze Developers'
- url = 'https://www.rebaze.com'
- }
- }
- developers {
- developer {
- id = 'tonit'
- name = 'Toni Menzel'
- email = 'toni.menzel@rebaze.com'
- }
- }
- scm {
- connection = 'scm:git:git://github.com/rebaze/integrity.git'
- developerConnection = 'scm:git:ssh://github.com/rebaze/integrity.git'
- url = 'https://github.com/rebaze/integrity/'
- }
- }
- }
- }
-}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index e708b1c..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
index e28350c..8ff23cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,4 @@
+
@@ -15,7 +16,7 @@
Apache License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0
+ https://www.apache.org/licenses/LICENSE-2.0
@@ -28,27 +29,58 @@
- scm:git:git://github.com/rebaze/integrity.git
- scm:git:ssh://github.com/rebaze/integrity.git
+ scm:git:https://github.com/rebaze/integrity.git
+ scm:git:ssh://git@github.com/rebaze/integrity.git
https://github.com/rebaze/integrity/
- 1.8
- 1.8
+ 17
+ UTF-8
+ UTF-8
+
+ 2026-08-27T00:00:00Z
+
+ 6.1.3
+ 2.0.18
+
+ 3.15.0
+ 3.5.6
+ 3.6.3
+ 2.9.3
+
+
+
+ org.junit
+ junit-bom
+ ${junit.version}
+ pom
+ import
+
+
+
+
+
- junit
- junit
- 4.12
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.junit.platform
+ junit-platform-launcher
test
org.slf4j
slf4j-simple
- 1.6.1
+ ${slf4j.version}
test
@@ -58,20 +90,74 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
-
+ ${maven-compiler-plugin.version}
+
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ ${maven-surefire-plugin.version}
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ ${maven-enforcer-plugin.version}
+
+
+ enforce-build-hygiene
+
+ enforce
+
+
+
+
+ [3.9,)
+
+
+ [17,)
+
+
+
+
+ No SNAPSHOT dependencies allowed.
+
+
+
+
+
+
+
+
+
+ org.cyclonedx
+ cyclonedx-maven-plugin
+ ${cyclonedx-maven-plugin.version}
+
+
+ make-bom
+ package
+
+ makeBom
+
+
+
-
- **/*Test.java
-
+ library
+ 1.6
+ all
+ bom
+ true
+ true
+ true
+ true
+ true
+ true
+ false
diff --git a/src/test/java/org/rebaze/integrity/tree/core/BranchHashTest.java b/src/test/java/org/rebaze/integrity/tree/core/BranchHashTest.java
index ce7b1ed..952b720 100644
--- a/src/test/java/org/rebaze/integrity/tree/core/BranchHashTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/core/BranchHashTest.java
@@ -1,6 +1,6 @@
package org.rebaze.integrity.tree.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.api.Tree;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.api.TreeIndex;
@@ -8,7 +8,7 @@
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
import org.rebaze.integrity.tree.util.TreeConsoleFormatter;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Created by tonit on 18/11/2016.
diff --git a/src/test/java/org/rebaze/integrity/tree/core/SimpleHashTest.java b/src/test/java/org/rebaze/integrity/tree/core/SimpleHashTest.java
index 35e9487..564d030 100644
--- a/src/test/java/org/rebaze/integrity/tree/core/SimpleHashTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/core/SimpleHashTest.java
@@ -8,15 +8,15 @@
*/
package org.rebaze.integrity.tree.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.rebaze.integrity.tree.api.Selector;
import org.rebaze.integrity.tree.api.Tree;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.internal.InMemoryTreeBuilderImpl;
@@ -73,8 +73,8 @@ public void simpleTreeTest()
sub4.add( "Four".getBytes() );
Tree tree2 = root2.seal();
- assertNotEquals( "roots must be different", tree1.value(), tree2.value() );
- assertNotEquals( "first childs must be different", tree1.branches()[0].value(), tree2.branches()[0].value() );
+ assertNotEquals( tree1.value(), tree2.value(), "roots must be different" );
+ assertNotEquals( tree1.branches()[0].value(), tree2.branches()[0].value(), "first childs must be different" );
}
@@ -88,6 +88,6 @@ public void testReuseCollectors()
TreeBuilder sn2 = session.createTreeBuilder();
sn2.branch( Selector.selector( "p1" ) ).add( "one".getBytes() ).add( "two".getBytes() );
- assertEquals( "Should no elements", sn1.seal(),sn2.seal() );
+ assertEquals( sn1.seal(), sn2.seal(), "Should no elements" );
}
}
diff --git a/src/test/java/org/rebaze/integrity/tree/core/TreeIndexTest.java b/src/test/java/org/rebaze/integrity/tree/core/TreeIndexTest.java
index 027c517..e495a10 100644
--- a/src/test/java/org/rebaze/integrity/tree/core/TreeIndexTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/core/TreeIndexTest.java
@@ -1,7 +1,7 @@
package org.rebaze.integrity.tree.core;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.api.Selector;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.api.TreeIndex;
@@ -10,8 +10,7 @@
import java.io.IOException;
-import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import static org.rebaze.integrity.tree.api.Tag.tag;
public class TreeIndexTest
@@ -34,7 +33,7 @@ public void testSameSelectorDifferentData() throws IOException
c1.branch( Selector.selector( "db1" ) ).add( "data".getBytes() );
c1.branch( Selector.selector( "db2" ) ).add( "dat2".getBytes() );
c1.branch( Selector.selector( "db1" ) ).add( "data3".getBytes() );
- Assert.assertEquals( 2, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
+ Assertions.assertEquals( 2, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
}
@Test
@@ -44,7 +43,7 @@ public void testSameDataDifferentSelector() throws IOException
c1.branch( Selector.selector( "db1" ) ).add( "data".getBytes() );
c1.branch( Selector.selector( "db2" ) ).add( "dat2".getBytes() );
c1.branch( Selector.selector( "db3" ) ).add( "data3".getBytes() );
- Assert.assertEquals( 3, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
+ Assertions.assertEquals( 3, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
}
@@ -55,7 +54,7 @@ public void testSameDataSameSelector() throws IOException
c1.branch( Selector.selector( "db1" ) ).add( "data".getBytes() );
c1.branch( Selector.selector( "db1" ) ).add( "data".getBytes() );
c1.branch( Selector.selector( "db3" ) ).add( "data".getBytes() );
- Assert.assertEquals( 2, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
+ Assertions.assertEquals( 2, TreeSession.wrapAsIndex( c1.seal() ).branches().length );
}
@Test
@@ -68,14 +67,14 @@ public void testContains() throws IOException
c1.branch( "db4" ).branch("deep").add( "foo" );
TreeIndex idx = TreeSession.wrapAsIndex( c1.seal());
- assertTrue("tree contains branch part",idx.contains(idx.branches()[0]));
- assertTrue("tree contains branch part",idx.contains(idx.branches()[1]));
- assertTrue("tree contains branch part",idx.contains(idx.branches()[2]));
- assertTrue("tree contains itself",idx.contains(idx));
- assertFalse("tree does not contain null",idx.contains(null));
- assertFalse("tree does not contain other tree",idx.contains(session.createTreeBuilder().add("data4").seal()));
+ assertTrue(idx.contains(idx.branches()[0]), "tree contains branch part");
+ assertTrue(idx.contains(idx.branches()[1]), "tree contains branch part");
+ assertTrue(idx.contains(idx.branches()[2]), "tree contains branch part");
+ assertTrue(idx.contains(idx), "tree contains itself");
+ assertFalse(idx.contains(null), "tree does not contain null");
+ assertFalse(idx.contains(session.createTreeBuilder().add("data4").seal()), "tree does not contain other tree");
- assertTrue("tree contained",idx.contains(session.createTreeBuilder().add("foo").seal()));
+ assertTrue(idx.contains(session.createTreeBuilder().add("foo").seal()), "tree contained");
}
diff --git a/src/test/java/org/rebaze/integrity/tree/internal/DefaultHashTest.java b/src/test/java/org/rebaze/integrity/tree/internal/DefaultHashTest.java
index e6a076e..d199b71 100644
--- a/src/test/java/org/rebaze/integrity/tree/internal/DefaultHashTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/internal/DefaultHashTest.java
@@ -13,11 +13,12 @@
import org.rebaze.integrity.tree.api.TreeException;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.rebaze.integrity.tree.api.Selector.selector;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class DefaultHashTest
{
@@ -30,10 +31,10 @@ public void equalityTest()
Tree sn2 = session.createTreeBuilder().selector( selector( "c1" ) ).branch( selector( "d" ) ).add( "Some".getBytes() ).seal();
Tree sn3 = session.createTreeBuilder().selector( selector( "c1" ) ).branch( selector( "d2" ) ).add( "Other".getBytes() ).seal();
- assertEquals( "Should be identical", sn1, sn2 );
- assertNotEquals( "Should not be identical", sn1, sn3 );
- assertNotEquals( "Should not be identical", sn2, sn3 );
- assertEquals( "Should be identical", sn3, sn3 );
+ assertEquals( sn1, sn2, "Should be identical" );
+ assertNotEquals( sn1, sn3, "Should not be identical" );
+ assertNotEquals( sn2, sn3, "Should not be identical" );
+ assertEquals( sn3, sn3, "Should be identical" );
}
@Test
@@ -41,23 +42,23 @@ public void equalityTestBeAwareThatHashesArePrimary()
{
Tree sn1 = session.createTreeBuilder().selector( selector( "Here" ) ).branch( selector( "whatnow" ) ).add( "Some".getBytes() ).seal();
Tree sn2 = session.createTreeBuilder().selector( selector( "There" ) ).branch( selector( "d" ) ).add( "Some".getBytes() ).seal();
- assertEquals( "Must be identical", sn1, sn2 );
+ assertEquals( sn1, sn2, "Must be identical" );
}
- @Test (expected = TreeException.class)
+ @Test
public void testDoNotAllowDataWithBranch()
{
TreeBuilder tb = session.createTreeBuilder();
tb.branch( selector ("foo") );
- tb.add( "Data".getBytes() );
+ assertThrows( TreeException.class, () -> tb.add( "Data".getBytes() ) );
}
- @Test (expected = TreeException.class)
+ @Test
public void testDoNotAllowBranchesWithData()
{
TreeBuilder tb = session.createTreeBuilder();
tb.add( "Data".getBytes() );
- tb.branch( selector ("foo") );
+ assertThrows( TreeException.class, () -> tb.branch( selector ("foo") ) );
}
@Test
@@ -67,14 +68,14 @@ public void testAddOrderMatters()
Tree sn2 = session.createTreeBuilder().branch( selector( "a" ) ).add( "Some".getBytes() ).add( "Other".getBytes() ).seal();
Tree sn3 = session.createTreeBuilder().branch( selector( "c" ) ).add( "Other".getBytes() ).add( "Some".getBytes() ).seal();
- assertEquals( "Must be identical", sn1, sn2 );
- assertNotEquals( "Must not be identical", sn1, sn3 );
+ assertEquals( sn1, sn2, "Must be identical" );
+ assertNotEquals( sn1, sn3, "Must not be identical" );
TreeBuilder tb = session.createTreeBuilder();
tb.branch( sn1 );
tb.branch( sn2 );
tb.branch( sn3 );
- assertEquals( "Collabsed to 2 branches", 2, tb.seal().branches().length );
+ assertEquals( 2, tb.seal().branches().length, "Collabsed to 2 branches" );
}
@Test
@@ -88,7 +89,7 @@ public void testSubTreeOrderDoesNotMatter()
sn2.branch( selector( "a" ) ).add( "Other".getBytes() );
sn2.branch( selector( "b" ) ).add( "Some".getBytes() );
- assertEquals( "Must be identical", sn1.seal(), sn2.seal() );
+ assertEquals( sn1.seal(), sn2.seal(), "Must be identical" );
}
@Test
@@ -96,6 +97,6 @@ public void testDeepEquality()
{
Tree sn1 = session.createTreeBuilder().selector( selector( "Here" ) ).branch( selector( "whatnow" ) ).branch( selector( "deeper" ) ).add( "Some".getBytes() ).seal();
Tree sn2 = session.createTreeBuilder().selector( selector( "There" ) ).branch( selector( "d" ) ).add( "Some".getBytes() ).seal();
- assertEquals( "Must not be identical", sn1, sn2 );
+ assertEquals( sn1, sn2, "Must not be identical" );
}
}
diff --git a/src/test/java/org/rebaze/integrity/tree/internal/InMemoryTreeImplTest.java b/src/test/java/org/rebaze/integrity/tree/internal/InMemoryTreeImplTest.java
index e3163ed..faa5a77 100644
--- a/src/test/java/org/rebaze/integrity/tree/internal/InMemoryTreeImplTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/internal/InMemoryTreeImplTest.java
@@ -1,14 +1,14 @@
package org.rebaze.integrity.tree.internal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import org.rebaze.integrity.tree.api.Selector;
import org.rebaze.integrity.tree.api.Tree;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -19,19 +19,19 @@ public class InMemoryTreeImplTest
@Test
public void testEmptyTreeSize()
{
- Assert.assertEquals( "Trunk only", 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).seal() ) );
+ Assertions.assertEquals( 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).seal() ), "Trunk only" );
}
@Test
public void testAddsOnlyOnSingle()
{
- Assert.assertEquals( "Trunk only", 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).add( "data".getBytes() ).seal() ) );
+ Assertions.assertEquals( 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).add( "data".getBytes() ).seal() ), "Trunk only" );
}
@Test
public void testSingleBranch()
{
- Assert.assertEquals( 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).branch( Selector.selector( "branch" ) ).seal() ) );
+ Assertions.assertEquals( 1, TreeSession.nodes( session.createTreeBuilder().selector( Selector.selector( "foo" ) ).branch( Selector.selector( "branch" ) ).seal() ) );
}
@Test
@@ -40,7 +40,7 @@ public void testMore()
TreeBuilder tb = session.createTreeBuilder().selector( Selector.selector( "trunk" ) );
tb.branch( Selector.selector( "branch2" ) ).add( "data1".getBytes() );
tb.branch( Selector.selector( "branch3" ) ).add( "data1".getBytes() );
- Assert.assertEquals( 3, TreeSession.nodes( tb.seal() ) );
+ Assertions.assertEquals( 3, TreeSession.nodes( tb.seal() ) );
}
@Test
diff --git a/src/test/java/org/rebaze/integrity/tree/internal/operators/CombinatorIntegrityTest.java b/src/test/java/org/rebaze/integrity/tree/internal/operators/CombinatorIntegrityTest.java
index 53a343b..6b21b54 100644
--- a/src/test/java/org/rebaze/integrity/tree/internal/operators/CombinatorIntegrityTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/internal/operators/CombinatorIntegrityTest.java
@@ -4,16 +4,16 @@
import org.rebaze.integrity.tree.api.Tree;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.util.TreeConsoleFormatter;
import static org.rebaze.integrity.tree.api.Selector.selector;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* This is the ultimate combiner test as we combine computed parts from other combiners,
@@ -26,7 +26,7 @@ public class CombinatorIntegrityTest
private TreeConsoleFormatter formatter = TreeConsoleFormatter.formatter();
private TreeSession session = new DefaultTreeSessionFactory().create();
- @Ignore
+ @Disabled
@Test
public void testCombinerIntegrity() {
TreeBuilder sn1 = session.createTreeBuilder();
@@ -47,7 +47,7 @@ public void testCombinerIntegrity() {
formatter.prettyPrint( intersection, combinedDelta );
assertEquals( intersection, combinedDelta );
- Assert.assertEquals( union, new UnionTreeCombiner(session).combine( delta, intersection ) );
+ Assertions.assertEquals( union, new UnionTreeCombiner(session).combine( delta, intersection ) );
assertEquals( delta, new DiffTreeCombiner(session).combine( union, intersection ) );
}
}
diff --git a/src/test/java/org/rebaze/integrity/tree/internal/operators/DiffTreeCombinatorTest.java b/src/test/java/org/rebaze/integrity/tree/internal/operators/DiffTreeCombinatorTest.java
index 0cd8681..a52e8fc 100644
--- a/src/test/java/org/rebaze/integrity/tree/internal/operators/DiffTreeCombinatorTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/internal/operators/DiffTreeCombinatorTest.java
@@ -9,7 +9,7 @@
package org.rebaze.integrity.tree.internal.operators;
import static org.rebaze.integrity.tree.api.Selector.selector;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
@@ -18,8 +18,8 @@
import org.rebaze.integrity.tree.api.TreeIndex;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.util.TreeConsoleFormatter;
@@ -36,7 +36,7 @@ public void diffIdenticalEmpty()
Tree sn1 = session.createTreeBuilder().selector( Selector.selector( "c1" ) ).seal();
Tree sn2 = session.createTreeBuilder().selector( Selector.selector( "c2" ) ).seal();
Tree result = new DiffTreeCombiner(session).combine( sn1, sn2 );
- assertEquals( "Should no elements", 0, result.branches().length );
+ assertEquals( 0, result.branches().length, "Should no elements" );
}
@Test
@@ -49,7 +49,7 @@ public void diffIdenticalMedium()
b2.add( "Some".getBytes() );
Tree sn2 = b2.seal();
Tree result = new DiffTreeCombiner(session).combine( sn1, sn2 );
- assertEquals( "Should no elements", 0, result.branches().length );
+ assertEquals( 0, result.branches().length, "Should no elements" );
}
@Test
@@ -61,9 +61,9 @@ public void diffDifferentSimple()
TreeBuilder b2 = session.createTreeBuilder().selector( Selector.selector( "c2" ) );
Tree sn2 = b2.seal();
Tree result = new DiffTreeCombiner(session).combine( sn1, sn2 );
- assertEquals( "Should no elements", 1, result.branches().length );
- Assert.assertEquals( "Select what is different", Selector.selector( "c2" ), result.branches()[0].selector() );
- assertEquals( "Select what is different", DiffTreeCombiner.MODIFIED, result.branches()[0].tags() );
+ assertEquals( 1, result.branches().length, "Should no elements" );
+ Assertions.assertEquals( Selector.selector( "c2" ), result.branches()[0].selector(), "Select what is different" );
+ assertEquals( DiffTreeCombiner.MODIFIED, result.branches()[0].tags(), "Select what is different" );
}
@@ -91,9 +91,9 @@ public void diff() throws IOException
// Display both for visual reference..
FORMAT.prettyPrint( sn1,sn2,result );
- assertEquals( "Detect 3 modifications", 3, result.select( Selector.selector( "db1" ) ).branches().length );
- assertEquals( "Modification in db2.table2", DiffTreeCombiner.MODIFIED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table2" ) ).tags() );
- assertEquals( "Modification in db2.table2", DiffTreeCombiner.REMOVED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table3" ) ).tags() );
- assertEquals( "Modification in db2.table2", DiffTreeCombiner.ADDED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table4" ) ).tags() );
+ assertEquals( 3, result.select( Selector.selector( "db1" ) ).branches().length, "Detect 3 modifications" );
+ assertEquals( DiffTreeCombiner.MODIFIED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table2" ) ).tags(), "Modification in db2.table2" );
+ assertEquals( DiffTreeCombiner.REMOVED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table3" ) ).tags(), "Modification in db2.table2" );
+ assertEquals( DiffTreeCombiner.ADDED, result.select( Selector.selector( "db1" ) ).select( Selector.selector( "table4" ) ).tags(), "Modification in db2.table2" );
}
}
diff --git a/src/test/java/org/rebaze/integrity/tree/internal/operators/UnionTreeCombinerTest.java b/src/test/java/org/rebaze/integrity/tree/internal/operators/UnionTreeCombinerTest.java
index ab298a0..31d9d37 100644
--- a/src/test/java/org/rebaze/integrity/tree/internal/operators/UnionTreeCombinerTest.java
+++ b/src/test/java/org/rebaze/integrity/tree/internal/operators/UnionTreeCombinerTest.java
@@ -4,21 +4,22 @@
import org.rebaze.integrity.tree.api.TreeIndex;
import org.rebaze.integrity.tree.api.TreeSession;
import org.rebaze.integrity.tree.util.DefaultTreeSessionFactory;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.rebaze.integrity.tree.api.TreeBuilder;
import org.rebaze.integrity.tree.util.TreeConsoleFormatter;
import static org.rebaze.integrity.tree.api.Selector.selector;
import static org.rebaze.integrity.tree.api.Tag.tag;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Created by tonit on 10/03/15.
*/
-@Ignore
+@Disabled
public class UnionTreeCombinerTest
{
private TreeConsoleFormatter formatter = TreeConsoleFormatter.formatter();
@@ -67,7 +68,7 @@ public void testDiscreteUnion() {
assertEquals( "d0941e", union.select( selector( "p3" ) ).fingerprint().substring( 0, 6 ) );
}
- @Test (expected = TreeException.class )
+ @Test
public void testDeepUnionWithIncompatibleBranchData() {
TreeBuilder sn1 = session.createTreeBuilder();
sn1.branch(selector("p1")).branch( selector( "deep" ) ).add( "one".getBytes() );
@@ -77,13 +78,8 @@ public void testDeepUnionWithIncompatibleBranchData() {
sn2.branch(selector("p1")).add( "one".getBytes() );
sn2.branch(selector("p3")).add( "other".getBytes() );
- TreeIndex union = TreeSession.wrapAsIndex( new UnionTreeCombiner(session).combine( sn1.seal(), sn2.seal() ) );
- formatter.prettyPrint( sn1.seal(), sn2.seal(), union );
-
- assertEquals( 3, union.branches().length );
- assertEquals( "fe05bc", union.select( selector( "p1" ) ).fingerprint().substring( 0, 6 ) ) ;
- assertEquals( "ad782e", union.select( selector( "p2" ) ).fingerprint().substring( 0, 6 ) );
- assertEquals( "d0941e", union.select( selector( "p3" ) ).fingerprint().substring( 0, 6 ) );
+ assertThrows( TreeException.class,
+ () -> new UnionTreeCombiner( session ).combine( sn1.seal(), sn2.seal() ) );
}
@Test