-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DeviceFactory: added a model.raw option
If "model.raw" is set to true, then the model string is not sanitized. This allows to give existing URLs as models instead of simple names.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -378,4 +378,29 @@ void testNameAsciiSanitize() throws Exception { | |
assertEquals(value, getResourceValue(provider, "_Greek", "________", Integer.class)); | ||
assertEquals(value, getResourceValue(provider, "_int", "_finally", Integer.class)); | ||
} | ||
|
||
@Test | ||
void testRawModel() throws Exception { | ||
final String rawModel = "http://user:[email protected]:8080/model.xml?format=emf#"; | ||
final String provider = "provider"; | ||
parser.setRecords(Map.of("m", rawModel, "p", provider)); | ||
|
||
// Test with an escaped model | ||
final DeviceMappingConfigurationDTO config = prepareConfig(); | ||
config.mappingOptions.useRawModel = false; | ||
config.mapping.put("@model", "m"); | ||
config.mapping.put("@provider", "p"); | ||
config.mapping.put("@name", "p"); | ||
deviceMapper.handle(config, Map.of(), new byte[0]); | ||
|
||
GenericDto dto = getResourceValue(provider, "admin", "friendlyName"); | ||
assertEquals("http___user_test_some_emf_model_8080_model_xml_format_emf_", dto.model); | ||
|
||
// Test with a raw model | ||
bulks.clear(); | ||
config.mappingOptions.useRawModel = true; | ||
deviceMapper.handle(config, Map.of(), new byte[0]); | ||
dto = getResourceValue(provider, "admin", "friendlyName"); | ||
assertEquals(rawModel, dto.model); | ||
} | ||
} |