Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.adoc #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'

permissions:
checks: write
Expand All @@ -19,13 +21,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
java: [ '11', '17' ]
os: [ ubuntu-latest, windows-latest ]
java: [ '8', '11', '17', '20' ]
arch: [ 'x64' ]
# include:
# - os: windows-latest
# java: '17'
# arch: x86
include:
- os: windows-latest
java: '17'
arch: x86

name: Java ${{ matrix.java }}/${{ matrix.arch }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -42,6 +44,7 @@ jobs:
cache: maven

- name: Build with Maven
shell: bash
run: |
mvn verify \
-B \
Expand Down Expand Up @@ -75,8 +78,8 @@ jobs:
filename: ${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}
path: target/jacoco-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}.exec

coverage:
name: JaCoCo Report
report:
name: JUnit Reports/JaCoCo Merge
runs-on: ubuntu-latest
needs: build
steps:
Expand All @@ -100,7 +103,7 @@ jobs:
with:
name: classes

- name: Merge and output
- name: Merge JaCoCo and output
run: mvn -B jacoco:merge jacoco:report

- name: Upload
Expand All @@ -125,7 +128,7 @@ jobs:
analyze:
name: Analyze Code
runs-on: ubuntu-latest
needs: coverage
needs: report
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.owner.login == 'dnsjava' }}
steps:
- name: Checkout
Expand All @@ -139,6 +142,9 @@ jobs:
with:
cache: maven

# doesn't work with PRs from forks, see
# https://portal.productboard.com/sonarsource/1-sonarcloud/c/50-sonarcloud-analyzes-external-pull-request
# or https://jira.sonarsource.com/browse/MMF-1371 (not public anymore)
- name: Run SonarQube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
= dnsjava
= dnsjava-actions-test

image:https://github.com/dnsjava/dnsjava/actions/workflows/build.yml/badge.svg["GitHub CI Build Status",link="https://github.com/dnsjava/dnsjava/actions/workflows/build.yml"]
image:https://codecov.io/gh/dnsjava/dnsjava/branch/master/graph/badge.svg?token=FKmcwl1Oys["codecov",link="https://codecov.io/gh/dnsjava/dnsjava"]
image:https://maven-badges.herokuapp.com/maven-central/dnsjava/dnsjava/badge.svg["Maven Central",link="https://search.maven.org/artifact/dnsjava/dnsjava"]
image:https://javadoc.io/badge/dnsjava/dnsjava.svg["Javadocs",link="https://javadoc.io/doc/dnsjava/dnsjava"]
image:https://github.com/dnsjava/dnsjava-actions-test/actions/workflows/build.yml/badge.svg["GitHub CI Build Status",link="https://github.com/dnsjava/dnsjava-actions-test/actions/workflows/build.yml"]
image:https://codecov.io/gh/dnsjava/dnsjava-actions-test/branch/master/graph/badge.svg?token=FKmcwl1Oys["codecov",link="https://codecov.io/gh/dnsjava/dnsjava-actions-test"]
image:https://maven-badges.herokuapp.com/maven-central/dnsjava/dnsjava-actions-test/badge.svg["Maven Central",link="https://search.maven.org/artifact/dnsjava/dnsjava-actions-test"]
image:https://javadoc.io/badge/dnsjava/dnsjava-actions-test.svg["Javadocs",link="https://javadoc.io/doc/dnsjava/dnsjava-actions-test"]

== Overview

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/xbill/DNS/TypeBitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public TypeBitmap(DNSInput in) throws WireParseException {
if ((current & (1 << (7 - j))) == 0) {
continue;
}
int typecode = mapbase * 256 + +i * 8 + j;
int typecode = mapbase * 256 + i * 8 + j;
types.add(typecode);
}
}
Expand Down Expand Up @@ -106,8 +106,7 @@ private static void mapToWire(DNSOutput out, TreeSet<Integer> map, int mapbase)
int[] array = new int[arraylength];
out.writeU8(mapbase);
out.writeU8(arraylength);
for (Integer integer : map) {
int typecode = integer;
for (int typecode : map) {
array[(typecode & 0xFF) / 8] |= 1 << (7 - typecode % 8);
}
for (int j = 0; j < arraylength; j++) {
Expand All @@ -116,7 +115,7 @@ private static void mapToWire(DNSOutput out, TreeSet<Integer> map, int mapbase)
}

public void toWire(DNSOutput out) {
if (types.size() == 0) {
if (types.isEmpty()) {
return;
}

Expand All @@ -127,7 +126,7 @@ public void toWire(DNSOutput out) {
int t = type;
int base = t >> 8;
if (base != mapbase) {
if (map.size() > 0) {
if (!map.isEmpty()) {
mapToWire(out, map, mapbase);
map.clear();
}
Expand Down
58 changes: 56 additions & 2 deletions src/test/java/org/xbill/DNS/TypeBitmapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//
package org.xbill.DNS;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
Expand All @@ -47,13 +48,66 @@ void empty() {

@Test
void typeA() {
TypeBitmap typeBitmap = new TypeBitmap(new int[] {1});
TypeBitmap typeBitmap = new TypeBitmap(new int[] {Type.A});
assertEquals("A", typeBitmap.toString());
}

@Test
void typeNSandSOA() {
TypeBitmap typeBitmap = new TypeBitmap(new int[] {2, 6});
TypeBitmap typeBitmap = new TypeBitmap(new int[] {Type.NS, Type.SOA});
assertEquals("NS SOA", typeBitmap.toString());
}

@Test
void typeNSandSOAArray() {
int[] typeArray = new int[] {Type.NS, Type.SOA};
TypeBitmap typeBitmap = new TypeBitmap(typeArray);
assertArrayEquals(typeArray, typeBitmap.toArray());
}

@Test
void typeAAndSOAToWire() {
int[] typeArray = new int[] {Type.A, Type.SOA};
TypeBitmap typeBitmap = new TypeBitmap(typeArray);
DNSOutput out = new DNSOutput();
typeBitmap.toWire(out);
assertArrayEquals(new byte[] {0, 1, 0b0100_0010}, out.toByteArray());
}

@Test
void typeAandNSEC3ToWireAndBack() throws WireParseException {
int[] typeArray = new int[] {Type.A, Type.NSEC3};
byte[] wire =
new byte[] {
// block
0,
// size
7,
// 0-7
0b0100_0000,
// 8-15,
0,
// 16-23,
0,
// 24-31,
0,
// 32-39
0,
// 40-47
0,
// 48-55
0b0010_0000
};

// Test serialization
TypeBitmap typeBitmapOut = new TypeBitmap(typeArray);
DNSOutput out = new DNSOutput();
typeBitmapOut.toWire(out);
assertArrayEquals(wire, out.toByteArray());

// Test parsing
DNSInput in = new DNSInput(wire);
TypeBitmap typeBitmapIn = new TypeBitmap(in);
assertArrayEquals(typeArray, typeBitmapIn.toArray());
}
}