Skip to content

Commit

Permalink
fluent-builder: add failing test with multiple episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
flaktack committed Sep 12, 2024
1 parent 6edaa7d commit a5d93ef
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
32 changes: 32 additions & 0 deletions plugin/src/test/java/com/kscs/util/test/PluginRunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package com.kscs.util.test;

import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -142,6 +144,36 @@ public void testGenerateSiri() throws Exception {
);
}

@Test
public void testGenerateNetex() throws Exception {
final var subDir = "netex";
final var episodeFile = generatedSourcesDir.resolve(subDir).resolve("siri.episode");
final var compiledCodeSubDir = compiledCodeDir.resolve(subDir);

generateAndCompile(subDir,
"-episode", episodeFile.toString(),
inFile("siri.xsd"),
"-Xfluent-builder"
);

ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader testClassLoader =
URLClassLoader.newInstance(new URL[]{compiledCodeSubDir.toUri().toURL()}, previousClassLoader);

try {
Thread.currentThread().setContextClassLoader(testClassLoader);

runPlugin(subDir,
"-b", episodeFile.toString(),
inFile("netex.xsd"),
"-Xfluent-builder"
);
compileTestCode(subDir);
} finally {
Thread.currentThread().setContextClassLoader(previousClassLoader);
}
}

@Test
public void testGenerateAll() throws Exception {
generateAndCompile("all","-b", inFile("binding-config.xjb"),
Expand Down
24 changes: 24 additions & 0 deletions plugin/src/test/resources/netex.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.netex.org.uk/netex"
xmlns:siri="http://www.siri.org.uk/siri"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.netex.org.uk/netex"
elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.siri.org.uk/siri siri.xsd">

<xs:import namespace="http://www.siri.org.uk/siri"
schemaLocation="siri.xsd"/>

<xsd:element name="DataObjectSubscriptionRequest" type="DataObjectSubscriptionStructure" />

<xsd:complexType name="DataObjectSubscriptionStructure">
<xsd:complexContent>
<xsd:extension base="siri:AbstractSubscriptionStructure">
<xsd:sequence>
<xsd:element name="DataObjectRequest"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
11 changes: 11 additions & 0 deletions plugin/src/test/resources/siri.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<xsd:schema xmlns="http://www.siri.org.uk/siri" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.siri.org.uk/siri" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="2.1" id="siri_vehicleMonitoring_service">

<xsd:complexType name="AbstractSubscriptionStructure" abstract="true">
<xsd:sequence>
<xsd:element name="InitialTerminationTime" type="xsd:dateTime">
<xsd:annotation>
<xsd:documentation>Requested end time for subscription.</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="VehicleActivityStructure">
<xsd:sequence>
<xsd:element name="MonitoredVehicleJourney">
Expand Down

0 comments on commit a5d93ef

Please sign in to comment.