-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle resource file key in xslt,jsontransform,payload,script,validat…
…e,xquery mediators
- Loading branch information
1 parent
4ea7214
commit 76f646f
Showing
15 changed files
with
314 additions
and
25 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
modules/core/src/main/java/org/apache/synapse/mediators/Utils.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,17 @@ | ||
package org.apache.synapse.mediators; | ||
|
||
import java.io.File; | ||
|
||
public class Utils { | ||
|
||
public static final String RESOURCES_IDENTIFIER = "resources:"; | ||
public static final String CONVERTED_RESOURCES_IDENTIFIER = "gov:mi-resources" + File.separator; | ||
|
||
public static String transformFileKey(String fileKey) { | ||
|
||
if (fileKey.startsWith(RESOURCES_IDENTIFIER)) { | ||
return CONVERTED_RESOURCES_IDENTIFIER + fileKey.substring(RESOURCES_IDENTIFIER.length()); | ||
} | ||
return fileKey; | ||
} | ||
} |
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
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
33 changes: 33 additions & 0 deletions
33
.../core/src/test/java/org/apache/synapse/mediators/transform/JSONTransformMediatorTest.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,33 @@ | ||
package org.apache.synapse.mediators.transform; | ||
|
||
import org.apache.synapse.MessageContext; | ||
import org.apache.synapse.TestMessageContextBuilder; | ||
import org.apache.synapse.mediators.Value; | ||
import org.apache.synapse.mediators.builtin.JSONTransformMediator; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class JSONTransformMediatorTest { | ||
|
||
@Test | ||
public void testWithResourceKey() throws Exception { | ||
|
||
JSONTransformMediator jsonTransformMediator = new JSONTransformMediator(); | ||
jsonTransformMediator.setSchemaKey(new Value("resources:xslt/sample.json")); | ||
|
||
String payload = "<jsonObject>\n" + | ||
" <fruit>12345</fruit>\n" + | ||
" <quantity>10</quantity>\n" + | ||
"</jsonObject>"; | ||
|
||
MessageContext synCtx = new TestMessageContextBuilder().addFileEntry("gov:mi-resources/xslt/sample.json", | ||
"../../repository/conf/sample/resources/transform/schema.json") | ||
.setBodyFromString(payload).setRequireAxis2MessageContext(true).build(); | ||
|
||
try { | ||
jsonTransformMediator.mediate(synCtx); | ||
} catch (Exception ex) { | ||
Assert.assertTrue(ex.getMessage().contains("\"required\":[\"price\"]")); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.