{"action":"created","issue":{"url":"https://api.github.com/repos/tomakehurst/wiremock/issues/297","labels_url":"https://api.github.com/repos/tomakehurst/wiremock/issues/297/labels{/name}","comments_url":"https://api.github.com/repos/tomakehurst/wiremock/issues/297/comments","events_url":"https://api.github.com/repos/tomakehurst/wiremock/issues/297/events","html_url":"https://github.com/tomakehurst/wiremock/issues/297","id":104671630,"number":297,"title":"Creating Wiremock rules on-the-fly","user":{"login":"cajunesque","id":10366407,"avatar_url":"https://avatars.githubusercontent.com/u/10366407?v=3","gravatar_id":"","url":"https://api.github.com/users/cajunesque","html_url":"https://github.com/cajunesque","followers_url":"https://api.github.com/users/cajunesque/followers","following_url":"https://api.github.com/users/cajunesque/following{/other_user}","gists_url":"https://api.github.com/users/cajunesque/gists{/gist_id}","starred_url":"https://api.github.com/users/cajunesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cajunesque/subscriptions","organizations_url":"https://api.github.com/users/cajunesque/orgs","repos_url":"https://api.github.com/users/cajunesque/repos","events_url":"https://api.github.com/users/cajunesque/events{/privacy}","received_events_url":"https://api.github.com/users/cajunesque/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-03T11:29:43Z","updated_at":"2015-09-03T12:11:49Z","closed_at":null,"body":"Hi Tom,\r\n\r\nLoving wiremock. I have self-served my way thru docs and done quite well with it, but now that I am headed to the next level, I need some ideas. I am \"Accessing the stubbing and verification DSL from the rule\", and quite a few of them (each wiremock rule extended by my own VirtualLMSservice class with stubs passed to it) as per your docs:\r\n@Rule\r\npublic VirtualLMSservice service1 = new VirtualLMSservice(8081, stub1, stub2 );\r\n@Rule\r\npublic VirtualLMSservice service2 = new VirtualLMSservice(8082, stub1, stub3);\r\n... one hundred more\r\nand running tests on this \"farm\" of LMS services, testing throttling, retries, aggregation, etc on their results.\r\n\r\nDue to the amount of wiremocks I must create, and the fact that I will create them from data in a database, I need something more like this\r\n\r\n@Rule\r\npublic VirtualLMSservice[] services;     -or-\r\n\r\n@Rule\r\npublic Array < VirtualLMSservice >;\r\n\r\nIs there any way to do this or at least approximate it? \r\n\r\nThanks\r\n\r\nMark"},"comment":{"url":"https://api.github.com/repos/tomakehurst/wiremock/issues/comments/137418824","html_url":"https://github.com/tomakehurst/wiremock/issues/297#issuecomment-137418824","issue_url":"https://api.github.com/repos/tomakehurst/wiremock/issues/297","id":137418824,"user":{"login":"cajunesque","id":10366407,"avatar_url":"https://avatars.githubusercontent.com/u/10366407?v=3","gravatar_id":"","url":"https://api.github.com/users/cajunesque","html_url":"https://github.com/cajunesque","followers_url":"https://api.github.com/users/cajunesque/followers","following_url":"https://api.github.com/users/cajunesque/following{/other_user}","gists_url":"https://api.github.com/users/cajunesque/gists{/gist_id}","starred_url":"https://api.github.com/users/cajunesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cajunesque/subscriptions","organizations_url":"https://api.github.com/users/cajunesque/orgs","repos_url":"https://api.github.com/users/cajunesque/repos","events_url":"https://api.github.com/users/cajunesque/events{/privacy}","received_events_url":"https://api.github.com/users/cajunesque/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T12:11:49Z","updated_at":"2015-09-03T12:11:49Z","body":"Jeez that was fast!\r\nSo now I am taking a look at External Resource and it doesnt look so easy to me. (It's still early in the US, and coffee has not kicked in). This is an example I found...\r\n  @Rule\r\n  public ExternalResource resource= new ExternalResource() {\r\n      @Override\r\n      protected void before() throws Throwable {\r\n          myServer.connect();\r\n         };\r\n\r\n      @Override\r\n      protected void after() {\r\n          myServer.disconnect();\r\n         };\r\n     };\r\n\r\n  @Test\r\n  public void testFoo() {\r\n      new Client().run(myServer);\r\n     }\r\n }"}}