Skip to content

Commit

Permalink
fix: data dictionary resolve for classpath resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Nov 21, 2023
1 parent 93e85c2 commit f764536
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initialize() {

Properties props = new Properties();
try (InputStream inputStream = mappingFile.getInputStream()) {
if (mappingFile.getFile().getName().endsWith(".xml")) {
if (mappingFile.getLocation().endsWith(".xml")) {
props.loadFromXML(inputStream);
} else {
props.load(inputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.File;
import java.io.InputStream;
import java.util.InvalidPropertiesFormatException;

Expand Down Expand Up @@ -48,7 +47,7 @@ public void testInitializeWithNormalPropertiesFile() {

// Setup mock resource
doReturn(inputStream).when(mappingFile).getInputStream();
doReturn(new File("test.properties")).when(mappingFile).getFile();
doReturn("test.properties").when(mappingFile).getLocation();

fixture.initialize();

Expand All @@ -69,7 +68,7 @@ public void testInitializeWithXMLPropertiesFile() {

// Setup mock resource
doReturn(inputStream).when(mappingFile).getInputStream();
doReturn(new File("test.properties.xml")).when(mappingFile).getFile(); // Note the .xml-suffix
doReturn("test.properties.xml").when(mappingFile).getLocation(); // Note the .xml-suffix

fixture.initialize();

Expand All @@ -83,7 +82,7 @@ public void testInitializeThrowsExceptionWithInvalidXMLPropertiesFile() {

// Setup mock resource
doReturn(inputStream).when(mappingFile).getInputStream();
doReturn(new File("test.properties.xml")).when(mappingFile).getFile(); // Note the .xml-suffix
doReturn("test.properties.xml").when(mappingFile).getLocation(); // Note the .xml-suffix

CitrusRuntimeException exception = expectThrows(CitrusRuntimeException.class, () -> fixture.initialize());
assertTrue(exception.getCause() instanceof InvalidPropertiesFormatException);
Expand Down

0 comments on commit f764536

Please sign in to comment.