Skip to content

Commit

Permalink
Updated Mockserver to use config from yml
Browse files Browse the repository at this point in the history
Added README file to show how to launch instance with custom parameters
  • Loading branch information
Himanshu Virmani committed Sep 1, 2014
1 parent e187392 commit bcf778a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 4 additions & 0 deletions mock-server/README
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions mock-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<!--<dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
<version>0.6.2.patched</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-db</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions mock-server/src/main/java/configuration/MockServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
@Singleton
public class MockServer extends Service<MockServerConfiguration> {

public MockServerConfiguration configuration;
public Injector injector;
private Injector injector;

public static void main(String[] args) throws Exception {
new MockServer().run(args);
Expand Down
1 change: 0 additions & 1 deletion mock-server/src/main/java/resource/MockServerResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions mock-server/src/main/java/templates/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public static void loadAllTemplates(String templateFileBasePath) throws IOExcept
List<Template> templates = new ArrayList<Template>();
if(!isFileEmpty(templateAssocs))
templates = mapper.readValue(templateAssocs, new TypeReference<List<Template>>() {});
for(Template template:templates) {

for(Template template:templates) {
Template.templates.add(template);
}
Collections.sort(Template.templates);
Expand Down
4 changes: 2 additions & 2 deletions mock-server/src/main/resources/MockServer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
http:
port: 9000
adminPort: 9001
templateFileBasePath: "/Users/tushar.mahapatra/templates"

templateFileBasePath: configure_at_runtime_using_-Ddw.

0 comments on commit bcf778a

Please sign in to comment.