From bcf778a31ebe74e7efbdae563f613b56b3f53ded Mon Sep 17 00:00:00 2001 From: Himanshu Virmani Date: Mon, 1 Sep 2014 17:00:54 +0530 Subject: [PATCH] Updated Mockserver to use config from yml Added README file to show how to launch instance with custom parameters --- mock-server/README | 4 ++++ mock-server/pom.xml | 4 ++-- mock-server/src/main/java/configuration/MockServer.java | 3 +-- mock-server/src/main/java/resource/MockServerResource.java | 1 - mock-server/src/main/java/templates/Template.java | 4 ++-- mock-server/src/main/resources/MockServer.yml | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 mock-server/README diff --git a/mock-server/README b/mock-server/README new file mode 100644 index 0000000..3652116 --- /dev/null +++ b/mock-server/README @@ -0,0 +1,4 @@ +*********USE THE BELOW COMMAND TO LAUNCH INSTANCE********* +**Configure the templateFileBasepath to the folder where templates should be saved** + +>$ sudo java -Ddw.templateFileBasePath=/Users/himanshu.virmani/templates -jar target/mock-server.jar server src/main/resources/MockServer.yml diff --git a/mock-server/pom.xml b/mock-server/pom.xml index 86c0e80..7d941c1 100644 --- a/mock-server/pom.xml +++ b/mock-server/pom.xml @@ -87,11 +87,11 @@ - + com.yammer.dropwizard dropwizard-db diff --git a/mock-server/src/main/java/configuration/MockServer.java b/mock-server/src/main/java/configuration/MockServer.java index c853a78..efb9f93 100644 --- a/mock-server/src/main/java/configuration/MockServer.java +++ b/mock-server/src/main/java/configuration/MockServer.java @@ -16,8 +16,7 @@ @Singleton public class MockServer extends Service { - public MockServerConfiguration configuration; - public Injector injector; + private Injector injector; public static void main(String[] args) throws Exception { new MockServer().run(args); diff --git a/mock-server/src/main/java/resource/MockServerResource.java b/mock-server/src/main/java/resource/MockServerResource.java index 5f61b19..e20cf74 100644 --- a/mock-server/src/main/java/resource/MockServerResource.java +++ b/mock-server/src/main/java/resource/MockServerResource.java @@ -139,7 +139,6 @@ public Response registerTemplate(@PathParam(value = "templateName")String templa if(null != node.get("content")) content = node.get("content").toString(); String method = node.get("method").asText(); - Template.createTemplate(content, templateName, config.getTemplateFileBasePath(), async, urlRegexPattern, urlEndpoint, method, params, headers, waitTimeInSec, fireCallbackAfter, priority, requestBodyRegexPattern); diff --git a/mock-server/src/main/java/templates/Template.java b/mock-server/src/main/java/templates/Template.java index fbb37b5..b672ee9 100644 --- a/mock-server/src/main/java/templates/Template.java +++ b/mock-server/src/main/java/templates/Template.java @@ -136,8 +136,8 @@ public static void loadAllTemplates(String templateFileBasePath) throws IOExcept List