Skip to content

Commit

Permalink
add unit test for resource file key lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
chathuranga-jayanath-99 committed Dec 20, 2024
1 parent 8a44fa1 commit 8a3bd05
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public void deployRegistryResource() {
String emptyMediaTypeFilePath = "conf:/custom/QueueName";
String emptyMediaTypeFileContent = "ordersQueue";
microIntegratorRegistry.newNonEmptyResource(emptyMediaTypeFilePath, false, "", emptyMediaTypeFileContent, "");

String resourceFilePath = "gov:mi-resources/custom/checkJsScript.js";
String resourceContent = "function checkLog(mc) {\n"
+ "\tvar log = mc.getServiceLog();\n"
+ "\tlog.info(\"Logging inside Script Mediator\");\n"
+ "}\n";

microIntegratorRegistry.newNonEmptyResource(resourceFilePath, false, "application/javascript", resourceContent, "");
}

@Test
Expand Down Expand Up @@ -123,6 +131,14 @@ public void testRegistryResourceRead() throws IOException {
Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType);
}

@Test
public void testResourceRead() {

OMNode omNode = microIntegratorRegistry.lookup("resources:custom/checkJsScript.js");
String mediaType = ((DataHandler) ((OMTextImpl) omNode).getDataHandler()).getContentType();
Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType);
}

@Test
public void testRegistryPropertiesDeploymentAndLookup() throws IOException {

Expand Down

0 comments on commit 8a3bd05

Please sign in to comment.