Skip to content

Commit 845c3ec

Browse files
committed
Code cleanup
1 parent 43ddcb2 commit 845c3ec

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

src/main/java/org/rutebanken/netex/OmitNullsToStringStyle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import org.apache.commons.lang3.builder.ToStringStyle;
1919

20-
public class OmitNullsToStringStyle extends org.apache.commons.lang3.builder.ToStringStyle {
20+
public class OmitNullsToStringStyle extends ToStringStyle {
2121

2222
/**
2323
*

src/main/java/org/rutebanken/netex/client/PublicationDeliveryClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515

1616
package org.rutebanken.netex.client;
1717

18+
import jakarta.xml.bind.JAXBContext;
19+
import jakarta.xml.bind.JAXBElement;
20+
import jakarta.xml.bind.JAXBException;
21+
import jakarta.xml.bind.Marshaller;
22+
import jakarta.xml.bind.Unmarshaller;
1823
import org.rutebanken.netex.model.ObjectFactory;
1924
import org.rutebanken.netex.model.PublicationDeliveryStructure;
2025
import org.rutebanken.netex.validation.NeTExValidator;
2126
import org.slf4j.Logger;
2227
import org.slf4j.LoggerFactory;
2328
import org.xml.sax.SAXException;
2429

25-
import jakarta.xml.bind.*;
2630
import java.io.IOException;
2731
import java.io.InputStream;
2832
import java.net.HttpURLConnection;

src/main/java/org/rutebanken/netex/validation/PredefinedSchemaListClasspathResourceResolver.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
import org.w3c.dom.ls.LSInput;
1919
import org.w3c.dom.ls.LSResourceResolver;
2020

21-
import java.io.*;
21+
import java.io.BufferedReader;
22+
import java.io.IOException;
23+
import java.io.InputStream;
24+
import java.io.InputStreamReader;
25+
import java.io.Reader;
26+
import java.nio.charset.StandardCharsets;
2227
import java.util.HashMap;
2328
import java.util.Map;
2429

@@ -29,10 +34,10 @@ public class PredefinedSchemaListClasspathResourceResolver implements LSResource
2934
public PredefinedSchemaListClasspathResourceResolver(String schemaList) throws IOException {
3035

3136
InputStream resourceAsStream = getClass().getResourceAsStream(schemaList);
32-
if(resourceAsStream == null) {
33-
throw new IOException("Unable to load "+schemaList+" as resource stream");
37+
if (resourceAsStream == null) {
38+
throw new IOException("Unable to load " + schemaList + " as resource stream");
3439
}
35-
BufferedReader r = new BufferedReader(new InputStreamReader(resourceAsStream));
40+
BufferedReader r = new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
3641
String resource;
3742
while ((resource = r.readLine()) != null) {
3843
String name = resource.substring(resource.lastIndexOf('/') + 1);

src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
import java.io.File;
3131
import java.io.FileInputStream;
3232
import java.io.FileNotFoundException;
33+
import java.io.IOException;
3334
import java.io.StringWriter;
3435
import java.nio.charset.StandardCharsets;
36+
import java.nio.file.Files;
37+
import java.nio.file.Paths;
3538
import java.time.LocalDateTime;
3639
import java.time.LocalTime;
3740
import java.time.temporal.ChronoField;
@@ -45,7 +48,7 @@ class MarshalUnmarshalTest {
4548

4649
private static JAXBContext jaxbContext;
4750

48-
private static ObjectFactory factory = new ObjectFactory();
51+
private static final ObjectFactory factory = new ObjectFactory();
4952

5053
@BeforeAll
5154
public static void initContext() throws JAXBException {
@@ -256,16 +259,16 @@ void datedCallWithLocalDateTime() throws JAXBException {
256259
}
257260

258261
@Test
259-
void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, FileNotFoundException {
262+
void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, IOException {
260263

261264
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
262265

263266
@SuppressWarnings("unchecked")
264267
JAXBElement<PublicationDeliveryStructure> jaxbElement = (JAXBElement<PublicationDeliveryStructure>) unmarshaller
265-
.unmarshal(new FileInputStream(new File("src/test/resources/date_time_examples.xml")));
268+
.unmarshal(Files.newInputStream(Paths.get("src/test/resources/date_time_examples.xml")));
266269
PublicationDeliveryStructure actual = jaxbElement.getValue();
267-
CompositeFrame compositeFrame = (CompositeFrame) ((JAXBElement<? extends Common_VersionFrameStructure>) actual.dataObjects.compositeFrameOrCommonFrame
268-
.get(0)).getValue();
270+
CompositeFrame compositeFrame = (CompositeFrame) actual.dataObjects.compositeFrameOrCommonFrame
271+
.get(0).getValue();
269272
ValidityConditions_RelStructure validityConditions = compositeFrame.getValidityConditions();
270273
ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_().get(0);
271274
assertThat(validBetweenWithTimezone.getFromDate()).isNotNull();

src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class NeTExValidatorTest {
2929

30-
private NeTExValidator neTExValidator = NeTExValidator.getNeTExValidator();
30+
private final NeTExValidator neTExValidator = NeTExValidator.getNeTExValidator();
3131

3232
public NeTExValidatorTest() throws IOException, SAXException { }
3333

@@ -43,9 +43,7 @@ void validationFailsForInvalidXml() {
4343
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
4444
"<PublicationDelivery xmlns=\"http://www.netex.org.uk/netex\" xmlns:ns2=\"http://www.opengis.net/gml/3.2\" xmlns:ns3=\"http://www.siri.org.uk/siri\"></PublicationDelivery>";
4545

46-
assertThatThrownBy(() -> {
47-
neTExValidator.validate(new StreamSource(new StringReader(xml)));
48-
}).isInstanceOf(SAXParseException.class);
46+
assertThatThrownBy(() -> neTExValidator.validate(new StreamSource(new StringReader(xml)))).isInstanceOf(SAXParseException.class);
4947
}
5048

5149
@Test

0 commit comments

Comments
 (0)