protected void setUriTemplate(String uriTemplate, String version) {
   config =
       new HttpMappingRuleBase(
           new SimplePathTemplate(uriTemplate),
           version,
           enabledVersion,
           loadBalancer,
           reverseHeaders);
   gateway.addMappingRuleConfiguration(config);
 }
  @Before
  public void init() throws Exception {
    String basedir = System.getProperty("basedir", ".");
    outputFile =
        new File(basedir + "/target/test-data/haproxy-" + testName.getMethodName() + ".cfg");
    outputFile.getParentFile().mkdirs();

    String reloadCommand = "cat " + outputFile.getAbsolutePath();
    gateway.setReloadCommand(reloadCommand);

    gateway.setConfigFile(outputFile.getAbsolutePath());
    String name = "config.mvel";
    URL resource = getClass().getResource(name);
    if (resource == null) {
      resource = getClass().getClassLoader().getResource("io/fabric8/gateway/haproxy/config.mvel");
    }
    assertNotNull("Should have found config file " + name + " on the classpath", resource);
    InputStream inputStream = resource.openStream();
    assertNotNull("Could not open the stream for " + resource, inputStream);
    String templateText = Files.toString(inputStream);
    assertNotNull("Should have loaded a the template from " + name);
    gateway.setTemplateText(templateText);
  }
  @Test
  public void testGenerateTemplate() throws Exception {
    setUriTemplate("/bar/{version}{contextPath}/", oldVersion);

    addQuickstartServices();

    // now lets load the generated file
    assertTrue("Should have generated " + outputFile, outputFile.exists() && outputFile.isFile());
    List<String> lines = Files.readLines(outputFile);
    assertLinesContains(
        lines,
        "use_backend b_bar_1.0_cxf_crm if { path_beg /bar/1.0/cxf/crm/ }",
        "use_backend b_bar_1.0_cxf_HelloWorld if { path_beg /bar/1.0/cxf/HelloWorld/ }",
        "backend b_bar_1.0_cxf_crm",
        "server resty  localhost:8182",
        "backend b_bar_1.0_cxf_HelloWorld",
        "server soapy  localhost:8183");

    LOG.info("About to reload the proxy command");
    gateway.reloadHaproxy();

    Thread.sleep(3000);
    LOG.info("Done!");
  }