-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from com-pas/fix/287_invalid_prefix_for_compa…
…s_privates_when_marshalling fix(#287): fix invalid prefix for Compas Privates when marshalling
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
sct-commons/src/main/java/org/lfenergy/compas/scl2007b4/model/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
@XmlSchema( | ||
namespace = "http://www.iec.ch/61850/2003/SCL", | ||
xmlns = { | ||
@XmlNs(namespaceURI = "http://www.iec.ch/61850/2003/SCL", prefix = ""), | ||
@XmlNs(namespaceURI = "https://www.lfenergy.org/compas/extension/v1", prefix = "compas") | ||
}, | ||
elementFormDefault = XmlNsForm.QUALIFIED) | ||
|
||
|
||
package org.lfenergy.compas.scl2007b4.model; | ||
|
||
import javax.xml.bind.annotation.XmlNs; | ||
import javax.xml.bind.annotation.XmlNsForm; | ||
import javax.xml.bind.annotation.XmlSchema; | ||
|
||
/* This file is used by the Marshaller to set prefix "compas" for Compas Privates when marshalling JAXB objects */ |
39 changes: 39 additions & 0 deletions
39
...commons/src/test/java/org/lfenergy/compas/scl2007b4/model/NamespaceConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.scl2007b4.model; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.lfenergy.compas.sct.commons.scl.PrivateService; | ||
import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class NamespaceConfigurationTest { | ||
|
||
@Test | ||
void marshalling_SCL_and_Compas_Privates_should_set_correct_prefix() { | ||
// Given | ||
SCL scl = createValidScl(); | ||
TPrivate aCompasPrivate = PrivateService.createPrivate(TCompasSclFileType.SCD); | ||
scl.getPrivate().add(aCompasPrivate); | ||
// When | ||
String result = MarshallerWrapper.marshall(scl); | ||
// Then | ||
assertThat(result) | ||
.containsPattern("(?s)<SCL[^>]* xmlns=\"http://www\\.iec\\.ch/61850/2003/SCL\"") | ||
.containsPattern("(?s)<SCL[^>]* xmlns:compas=\"https://www\\.lfenergy\\.org/compas/extension/v1\""); | ||
} | ||
|
||
private static SCL createValidScl() { | ||
SCL scl = new SCL(); | ||
scl.setVersion("2007"); | ||
scl.setRevision("B"); | ||
scl.setRelease((short) 4); | ||
THeader tHeader = new THeader(); | ||
tHeader.setId("headerId"); | ||
scl.setHeader(tHeader); | ||
return scl; | ||
} | ||
} |