4 Commits

Author SHA1 Message Date
0ee348ee0d minor code clean-ups
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-30 12:42:18 +02:00
a91005967c update copyright notice 2022-08-30 12:40:15 +02:00
b7ce0a3c3e update dependencies
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-30 12:33:39 +02:00
a0bcd96054 migrate to GH actions for CI 2022-08-30 12:33:38 +02:00
19 changed files with 95 additions and 73 deletions

View File

@ -6,7 +6,7 @@ steps:
- name: test
image: maven:3-openjdk-8
commands:
- mvn clean test
- mvn -B clean test
---
kind: pipeline
@ -17,15 +17,15 @@ steps:
- name: test
image: maven:3-openjdk-11
commands:
- mvn clean test
- mvn -B clean test
---
kind: pipeline
type: docker
name: java15
name: java17
steps:
- name: test
image: maven:3-openjdk-15
image: maven:3-openjdk-17
commands:
- mvn clean test
- mvn -B clean test

33
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: CI
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
jdk: [ 8, 11, 17 ]
include:
- jdk: 11
analysis: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
- name: Test
run: mvn -B -P coverage clean verify
- name: Analysis
if: matrix.analysis && github.event_name == 'push'
run: >
mvn -B sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=stklcode-github
-Dsonar.login=$SONAR_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View File

@ -1,17 +0,0 @@
language: java
jdk:
- openjdk8
- openjdk11
- openjdk15
install: true
addons:
sonarcloud:
organization: "stklcode-github"
token:
secure: "FkEe/+MKpF4pSX3ZYOgu7oeIKf0460Q3XVLUhIX9bk2dyY8hoab74oCo4FtD7jim0+ZC13JVHGDX7iOQMUtS5EZ+x+pA0qpppzCK5zV8afN/l46HJ07kJldvr+EH0klbDVMFZQ5dT7r/w6CoDzjtENHzKQAJLcheUVDNpkcuBdaplTqIAVf3lQpKtOuVjQJ5qZDwwS5wsHNqPcYbcEGrPmcKDVnp3mD3bfI6dT1bbRt845QcD73rPYkQKxen8eIwJxFf5MZStgvbj7yphPxPGwoLAsoLP6LpThTDYcrg+vgUnSs+l9GckL3IbhPAmecixLbKVnphBZzRTvpdMTt5KeOoAJ2nM6RLs5cRCqiEgLEioWkVaSH5WxoBj38Z1h4fTsDV3dTcCuQWX8GFxdeeTelu+XbatdRWMnUgiF7oax+uNvR62fasTbAc7dWPJbARiD7ZbkWH4nHEY07xKKx87xzUz36ZeEHGoBXgqnLmv/FCwqMrEpOoIT41fc0WYtdIA4wjRoAyG0u+wNBMbVlf4PK72seM4b/bmU+TtmaaVla/SvNOiz+A3DHxtJEUScPcL3QGjviddglMf+wyD6VXVViq9VuYRKZFyjpuoNpb5lwEbwmRnmLabBx8jBgyPinjpmqHYlIntcPAwuyLRaqTHFcmCrbeeZEf7KaPRYKx+Cs="
cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'
script:
- if [ "$TRAVIS_JDK_VERSION" == "openjdk11" ]; then mvn -P coverage clean package sonar:sonar; else mvn clean test; fi

View File

@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.
## 1.3.2 - 2022-08-30
### Improvements
* Dependency updates
## 1.3.1 - 2020-12-12
### Fixed
* Allow reopening an `AsyncUraTripReader` without raising an exception (#13)

View File

@ -63,7 +63,7 @@ List<Message> msgs = ura.forStop("100000")
<dependency>
<groupId>de.stklcode.pubtrans</groupId>
<artifactId>juraclient</artifactId>
<version>1.3.0</version>
<version>1.3.2</version>
</dependency>
```

24
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>de.stklcode.pubtrans</groupId>
<artifactId>juraclient</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -21,7 +21,7 @@
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
@ -49,12 +49,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.3</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0</version>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
@ -65,8 +65,8 @@
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<artifactId>wiremock-jre8</artifactId>
<version>2.33.2</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -76,7 +76,7 @@
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
<version>3.9.1.2184</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -86,7 +86,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -95,7 +95,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<configuration>
<archive>
<manifestEntries>
@ -120,7 +120,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<executions>
<execution>
<id>prepare-agent</id>
@ -175,7 +175,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.4.1</version>
<configuration>
<overview>${basedir}/src/main/javadoc/overview.html</overview>
<source>1.8</source>
@ -200,7 +200,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -236,7 +236,7 @@ public class UraClient implements Serializable {
String version = null;
String line = br.readLine();
while (line != null && (limit == null || trips.size() < limit)) {
List l = mapper.readValue(line, List.class);
List<?> l = mapper.readValue(line, List.class);
/* Check if result exists and has correct response type */
if (l != null && !l.isEmpty()) {
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {
@ -311,7 +311,7 @@ public class UraClient implements Serializable {
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = br.readLine()) != null) {
List l = mapper.readValue(line, List.class);
List<?> l = mapper.readValue(line, List.class);
/* Check if result exists and has correct response type */
if (l != null && !l.isEmpty() && l.get(0).equals(RES_TYPE_STOP)) {
stops.add(new Stop(l));
@ -361,7 +361,7 @@ public class UraClient implements Serializable {
String version = null;
String line = br.readLine();
while (line != null && (limit == null || messages.size() < limit)) {
List l = mapper.readValue(line, List.class);
List<?> l = mapper.readValue(line, List.class);
/* Check if result exists and has correct response type */
if (l != null && !l.isEmpty()) {
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {

View File

@ -87,7 +87,7 @@ public class Message implements Model {
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Message(final List raw) throws IOException {
public Message(final List<?> raw) throws IOException {
this(raw, null);
}
@ -98,7 +98,7 @@ public class Message implements Model {
* @param version API version
* @throws IOException Thrown on invalid line format.
*/
public Message(final List raw, final String version) throws IOException {
public Message(final List<?> raw, final String version) throws IOException {
if (raw == null || raw.size() < NUM_OF_FIELDS) {
throw new IOException("Invalid number of fields");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@ interface Model extends Serializable {
* @param actual Actual class.
* @return The Exception.
*/
static IOException typeErrorString(int field, Class actual) {
static IOException typeErrorString(int field, Class<?> actual) {
return typeError(field, actual, "String");
}
@ -45,7 +45,7 @@ interface Model extends Serializable {
* @param expected Expected type.
* @return The Exception.
*/
static IOException typeError(int field, Class actual, String expected) {
static IOException typeError(int field, Class<?> actual, String expected) {
return new IOException(String.format("Field %d not of expected type %s, found %s",
field, expected, actual.getSimpleName()));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -72,7 +72,7 @@ public final class Stop implements Model {
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Stop(final List raw) throws IOException {
public Stop(final List<?> raw) throws IOException {
if (raw == null || raw.size() < F_NUM_OF_FIELDS) {
throw new IOException("Invalid number of fields");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -142,7 +142,7 @@ public final class Trip implements Model {
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Trip(final List raw) throws IOException {
public Trip(final List<?> raw) throws IOException {
this(raw, null);
}
@ -153,7 +153,7 @@ public final class Trip implements Model {
* @param version API version
* @throws IOException Thrown on invalid line format.
*/
public Trip(final List raw, final String version) throws IOException {
public Trip(final List<?> raw, final String version) throws IOException {
if (raw == null || raw.size() < NUM_OF_FIELDS) {
throw new IOException("Invalid number of fields");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -83,7 +83,7 @@ public class AsyncUraTripReader implements AutoCloseable {
String version = null;
String line = br.readLine();
while (line != null && !this.canceled) {
List l = mapper.readValue(line, List.class);
List<?> l = mapper.readValue(line, List.class);
// Check if result exists and has correct response type.
if (l != null && !l.isEmpty()) {
if (l.get(0).equals(RES_TYPE_URA_VERSION)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -45,11 +45,11 @@ import static org.hamcrest.core.Is.is;
*
* @author Stefan Kalscheuer
*/
public class UraClientTest {
class UraClientTest {
private static WireMockServer httpMock;
@BeforeAll
public static void setUp() {
static void setUp() {
// Initialize HTTP mock.
httpMock = new WireMockServer(WireMockConfiguration.options().dynamicPort());
httpMock.start();
@ -57,13 +57,13 @@ public class UraClientTest {
}
@AfterAll
public static void tearDown() {
static void tearDown() {
httpMock.stop();
httpMock = null;
}
@Test
public void getStopsTest() {
void getStopsTest() {
// Mock the HTTP call.
mockHttpToFile(2, "instant_V2_stops.txt");
@ -89,7 +89,7 @@ public class UraClientTest {
}
@Test
public void getStopsForLineTest() {
void getStopsForLineTest() {
// Mock the HTTP call.
mockHttpToFile(2, "instant_V2_stops_line.txt");
@ -107,7 +107,7 @@ public class UraClientTest {
}
@Test
public void getStopsForPositionTest() {
void getStopsForPositionTest() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_stops_circle.txt");
@ -133,7 +133,7 @@ public class UraClientTest {
}
@Test
public void getTripsForDestinationNamesTest() {
void getTripsForDestinationNamesTest() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_destination.txt");
@ -156,7 +156,7 @@ public class UraClientTest {
}
@Test
public void getTripsTowardsTest() {
void getTripsTowardsTest() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_towards.txt");
@ -171,7 +171,7 @@ public class UraClientTest {
}
@Test
public void getTripsTest() {
void getTripsTest() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_all.txt");
@ -224,7 +224,7 @@ public class UraClientTest {
}
@Test
public void getTripsForStopTest() {
void getTripsForStopTest() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_stop.txt");
@ -254,7 +254,7 @@ public class UraClientTest {
}
@Test
public void getTripsForLine() {
void getTripsForLine() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_line.txt");
@ -303,7 +303,7 @@ public class UraClientTest {
}
@Test
public void getTripsForStopAndLine() {
void getTripsForStopAndLine() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_trips_stop_line.txt");
@ -324,7 +324,7 @@ public class UraClientTest {
@Test
public void getMessages() {
void getMessages() {
// Mock the HTTP call.
mockHttpToFile(1, "instant_V1_messages.txt");
@ -343,7 +343,7 @@ public class UraClientTest {
}
@Test
public void getMessagesForStop() {
void getMessagesForStop() {
// Mock the HTTP call.
mockHttpToFile(2, "instant_V2_messages_stop.txt");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Stefan Kalscheuer
* Copyright 2016-2022 Stefan Kalscheuer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -162,7 +162,7 @@ public class AsyncUraTripReaderTest {
* @throws IOException Error reading or writing mocked data.
*/
@Test
public void streamClosedTest() throws InterruptedException, IOException {
void streamClosedTest() throws InterruptedException, IOException {
// Callback counter for some unhandy async mockery.
final AtomicInteger counter = new AtomicInteger(0);