Skip to content

Commit

Permalink
Merge pull request #131 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Dennis Labordus authored Oct 3, 2022
2 parents 95ac7e1 + eaf96bc commit ad76af3
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SclValidatorServerEndpointTest {
@InjectMock
private SclValidatorService sclValidatorService;

@TestHTTPResource("/compas-scl-validator/validate-ws/v1/SCD")
@TestHTTPResource("/validate-ws/v1/SCD")
private URI uri;

@Test
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ SPDX-License-Identifier: Apache-2.0
<compas.scl.xsd.version>0.0.4</compas.scl.xsd.version>
<compas.core.version>0.9.3</compas.core.version>

<quarkus.platform.version>2.12.2.Final</quarkus.platform.version>
<slf4j.version>2.0.1</slf4j.version>
<quarkus.platform.version>2.13.0.Final</quarkus.platform.version>
<slf4j.version>2.0.3</slf4j.version>
<openpojo.version>0.9.1</openpojo.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion riseclipse/riseclipse-p2-to-m2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SPDX-License-Identifier: Apache-2.0
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<version>2.7.5</version>
<version>3.0.0</version>
<configuration>
<work>${project.build.directory}/maven/tmp/cbi</work>
<executionEnvironment>JavaSE-17</executionEnvironment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
Expand All @@ -35,10 +36,12 @@ public XSDValidator(List<ValidationError> errorList, String sclData) {
var sclVersion = info.getSclVersion();

try {
var sclXsd = new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL" + sclVersion + "/SCL.xsd"));
var compasXsd = new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL_CoMPAS.xsd"));

var factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
factory.setResourceResolver(new ResourceResolver(sclVersion));
var schema = factory.newSchema(
new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL" + sclVersion + "/SCL.xsd")));
var schema = factory.newSchema(new Source[]{sclXsd, compasXsd});
validator = schema.newValidator();
validator.setErrorHandler(new XSDErrorHandler(errorList));
} catch (SAXException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ void validate_WhenCalledWithSclDataWithXsdValidationErrors_ThenErrorsAreRetrieve
}
}

@Test
void validate_WhenCalledWithSclDataWithCompasXsdValidationErrors_ThenErrorsAreRetrieved() throws IOException {
var errorList = new ArrayList<ValidationError>();
try (var inputStream = getClass()
.getResourceAsStream("/scl/validation/example-with-compas-validation-errors.scd")) {
var data = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
new XSDValidator(errorList, data).validate();

assertEquals(4, errorList.size());

var error = errorList.get(0);
assertEquals("Value 'INVALID' is not facet-valid with respect to enumeration '[SSD, IID, ICD, SCD, CID, " +
"SED, ISD, STD]'. It must be a value from the enumeration.", error.getMessage());
assertEquals("XSD/cvc-enumeration-valid", error.getRuleName());
assertEquals(10, error.getLineNumber());
assertEquals(57, error.getColumnNumber());

error = errorList.get(2);
assertEquals("Value 'Invalid Label' is not facet-valid with respect to pattern '[A-Za-z][0-9A-Za-z_-]*' " +
"for type 'tCompasLabel'.", error.getMessage());
assertEquals("XSD/cvc-pattern-valid", error.getRuleName());
assertEquals(12, error.getLineNumber());
assertEquals(55, error.getColumnNumber());
}
}

@Test
void validate_WhenCalledWithSclDataContainingInvalidVersion_ThenExceptionIsThrown() throws IOException {
var errorList = new ArrayList<ValidationError>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- SPDX-FileCopyrightText: 2020 RTE FRANCE -->
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:compas="https://www.lfenergy.org/compas/extension/v1"
version="2007" revision="B" release="4">
<Private type="compas_scl">
<compas:SclName>MiniGrid</compas:SclName>
<compas:SclFileType>INVALID</compas:SclFileType>
<compas:Labels>
<compas:Label>Invalid Label</compas:Label>
</compas:Labels>
</Private>
<Header id="f9283708-bf4f-412c-a1d6-f947b9ac3000" version="1.0.0" revision="Revision" toolID="toolID"
nameStructure="IEDName"/>
<IED name="IED_NAME">
<AccessPoint name="AP_NAME">
<Server>
<Authentication/>
<LDevice inst="LDPO">
<LN0 lnType="LN2" lnClass="LLN0" inst="">
<Inputs>
<ExtRef intAddr="INTADDR" pDO="DO1" desc="DESC1"/>
<ExtRef intAddr="INTADDR" pDO="DO2" desc="DESC2"/>
</Inputs>
</LN0>
<LN lnType="LN1" lnClass="PIOC" inst="1">
<Inputs>
<ExtRef intAddr="INTADDR" pDO="DO1" desc="DESC1"/>
<ExtRef intAddr="INTADDR" pDO="DO2" desc="DESC2"/>
</Inputs>
</LN>
<LN lnType="LN1" lnClass="PIOC" inst="2">
<Inputs>
<ExtRef intAddr="INTADDR" pDO="DO1" desc="DESC1"/>
<ExtRef intAddr="INTADDR" pDO="DO2" desc="DESC2"/>
</Inputs>
</LN>
</LDevice>
</Server>
</AccessPoint>
</IED>
<DataTypeTemplates>
<LNodeType lnClass="LLN0" id="LN2">
<DO name="Beh" type="DO1" transient="false"/>
<DO name="FACntRs" type="DO2" transient="true"/>
<DO name="StrVal" type="DO3" transient="false"/>
</LNodeType>
<LNodeType lnClass="PIOC" id="LN1">
<DO name="Beh" type="DO1" transient="false"/>
<DO name="FACntRs" type="DO2" transient="true"/>
<DO name="StrVal" type="DO3" transient="false"/>
</LNodeType>
<DOType cdc="WYE" id="DO1">
<DA fc="DC" dchg="false" qchg="false" dupd="false" name="dataNs" bType="VisString255">
<Val>IEC 61850-7-3:2007B</Val>
</DA>
<DA fc="CF" dchg="true" qchg="false" dupd="false" name="smpRate" bType="INT32U"/>
</DOType>
<DOType cdc="WYE" id="DO2">
<SDO name="phsBHar" type="DO4"/>
<DA fc="CF" dchg="true" qchg="false" dupd="true" name="angRef" bType="Enum" type="PhaseAngleReferenceKind"/>
</DOType>
<DOType cdc="WYE" id="DO3">
<SDO name="neutHar" type="DO4"/>
<DA fc="CF" dchg="true" qchg="false" dupd="false" name="smpRate" bType="INT32U"/>
<DA fc="ST" dchg="false" qchg="false" dupd="false" name="origin" bType="Struct" type="DA3"/>
</DOType>
<DOType cdc="WYE" id="DO4">
<DA fc="DC" dchg="false" qchg="false" dupd="false" name="configRev" bType="VisString255" valKind="RO"
valImport="false"/>
</DOType>
<DAType id="DA1">
<BDA name="operTm" bType="Timestamp"/>
<BDA name="origin" bType="Struct" type="DA3"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="DA2">
<BDA name="T" bType="Timestamp"/>
<BDA name="ctlVal" bType="Enum" type="RecCycModKind"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="DA3">
<BDA name="Check" bType="Check"/>
<BDA name="Test" bType="BOOLEAN"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<EnumType id="RecCycModKind">
<EnumVal ord="1">Completed</EnumVal>
<EnumVal ord="2">Cancelled</EnumVal>
<EnumVal ord="3">New adjustments</EnumVal>
<EnumVal ord="4">AnotherValue</EnumVal>
</EnumType>
<EnumType id="PhaseAngleReferenceKind">
<EnumVal ord="0">Va</EnumVal>
<EnumVal ord="1">Vb</EnumVal>
<EnumVal ord="2">Vc</EnumVal>
<EnumVal ord="3">Aa</EnumVal>
<EnumVal ord="4">Ab</EnumVal>
<EnumVal ord="5">Ac</EnumVal>
<EnumVal ord="6">Vab</EnumVal>
<EnumVal ord="7">Vbc</EnumVal>
<EnumVal ord="8">Vca</EnumVal>
<EnumVal ord="9">AnotherValue</EnumVal>
</EnumType>
</DataTypeTemplates>
</SCL>

0 comments on commit ad76af3

Please sign in to comment.