Пример #1
0
  @Test
  public void testAlreadyExistingMuleConfigWithApikitRouter() throws Exception {
    List<File> ramls = Arrays.asList(getFile("scaffolder-existing/simple.raml"));
    File xmlFile = getFile("scaffolder-existing/mule-config-no-api-flows.xml");
    List<File> xmls = Arrays.asList(xmlFile);
    File muleXmlOut = folder.newFolder("mule-xml-out");

    Scaffolder scaffolder = createScaffolder(ramls, xmls, muleXmlOut);
    scaffolder.run();

    assertTrue(xmlFile.exists());
    String s = IOUtils.toString(new FileInputStream(xmlFile));
    assertEquals(
        1,
        countOccurences(
            s,
            "http:listener-config name=\"HTTP_Listener_Configuration\" host=\"localhost\" port=\"${serverPort}\""));
    assertEquals(
        1,
        countOccurences(
            s, "http:listener config-ref=\"HTTP_Listener_Configuration\" path=\"/api/*\""));
    assertEquals(1, countOccurences(s, "<apikit:router config-ref=\"apikit-config\" />"));
    assertEquals(0, countOccurences(s, "http:inbound-endpoint"));
    assertEquals(1, countOccurences(s, "get:/pet"));
    assertEquals(1, countOccurences(s, "post:/pet"));
    assertEquals(1, countOccurences(s, "get:/:"));
    Collection<File> newXmlConfigs = FileUtils.listFiles(muleXmlOut, new String[] {"xml"}, true);
    assertEquals(0, newXmlConfigs.size());
  }
Пример #2
0
  @Test
  public void testAlreadyExistsGenerate() throws Exception {
    List<File> ramls = Arrays.asList(getFile("scaffolder-existing/simple.raml"));
    File xmlFile = getFile("scaffolder-existing/simple.xml");
    List<File> xmls = Arrays.asList(xmlFile);
    File muleXmlOut = folder.newFolder("mule-xml-out");

    Scaffolder scaffolder = createScaffolder(ramls, xmls, muleXmlOut);
    scaffolder.run();

    assertTrue(xmlFile.exists());
    String s = IOUtils.toString(new FileInputStream(xmlFile));
    assertEquals(
        1,
        countOccurences(
            s,
            "http:listener-config name=\"HTTP_Listener_Configuration\" host=\"localhost\" port=\"${serverPort}\""));
    assertEquals(
        1,
        countOccurences(
            s, "http:listener config-ref=\"HTTP_Listener_Configuration\" path=\"/api/*\""));
    assertEquals(0, countOccurences(s, "http:inbound-endpoint"));
    assertEquals(1, countOccurences(s, "get:/pet"));
    assertEquals(1, countOccurences(s, "post:/pet"));
    assertEquals(1, countOccurences(s, "get:/\""));
  }
Пример #3
0
  private File simpleGeneration(String name) throws Exception {
    List<File> ramls = Arrays.asList(getFile("scaffolder/" + name + ".raml"));
    List<File> xmls = Arrays.asList();
    File muleXmlOut = folder.newFolder("mule-xml-out");

    Scaffolder scaffolder = createScaffolder(ramls, xmls, muleXmlOut);
    scaffolder.run();

    return new File(muleXmlOut, name + ".xml");
  }
Пример #4
0
  @Test
  public void testAlreadyExistsGenerateWithCustomDomain() throws Exception {
    List<File> ramls = Arrays.asList(getFile("scaffolder-existing-custom-lc/simple.raml"));
    File xmlFile = getFile("scaffolder-existing-custom-lc/simple.xml");
    File domainFile = getFile("custom-domain/mule-domain-config.xml");

    List<File> xmls = Arrays.asList(xmlFile);
    File muleXmlOut = folder.newFolder("mule-xml-out");
    Scaffolder scaffolder = createScaffolder(ramls, xmls, muleXmlOut, domainFile);
    scaffolder.run();

    assertTrue(xmlFile.exists());
    String s = IOUtils.toString(new FileInputStream(xmlFile));
    assertEquals(0, countOccurences(s, "<http:listener-config"));
    assertEquals(
        1, countOccurences(s, "http:listener config-ref=\"http-lc-0.0.0.0-8081\" path=\"/api/*\""));
    assertEquals(0, countOccurences(s, "http:inbound-endpoint"));
    assertEquals(1, countOccurences(s, "get:/pet"));
    assertEquals(1, countOccurences(s, "get:/\""));
  }
Пример #5
0
  @Test
  public void testAlreadyExistsOldWithAddressGenerate() throws Exception {
    List<File> ramls = Arrays.asList(getFile("scaffolder-existing-old-address/complex.raml"));
    File xmlFile = getFile("scaffolder-existing-old-address/complex.xml");
    List<File> xmls = Arrays.asList(xmlFile);
    File muleXmlOut = folder.newFolder("mule-xml-out");

    Scaffolder scaffolder = createScaffolder(ramls, xmls, muleXmlOut);
    scaffolder.run();

    assertTrue(xmlFile.exists());
    String s = IOUtils.toString(new FileInputStream(xmlFile));
    assertEquals(0, countOccurences(s, "http:listener-config"));
    assertEquals(0, countOccurences(s, "http:listener"));
    assertEquals(1, countOccurences(s, "http:inbound-endpoint address"));

    assertEquals(1, countOccurences(s, "put:/clients/{clientId}:complex-config"));
    assertEquals(1, countOccurences(s, "put:/invoices/{invoiceId}:complex-config"));
    assertEquals(1, countOccurences(s, "put:/items/{itemId}:application/json:complex-config"));
    assertEquals(1, countOccurences(s, "put:/providers/{providerId}:complex-config"));
    assertEquals(1, countOccurences(s, "delete:/clients/{clientId}:complex-config"));
    assertEquals(1, countOccurences(s, "delete:/invoices/{invoiceId}:complex-config"));
    assertEquals(
        1, countOccurences(s, "delete:/items/{itemId}:multipart/form-data:complex-config"));
    assertEquals(1, countOccurences(s, "delete:/providers/{providerId}:complex-config"));
    assertEquals(1, countOccurences(s, "get:/:complex-config"));
    assertEquals(1, countOccurences(s, "get:/clients/{clientId}:complex-config"));
    assertEquals(1, countOccurences(s, "get:/clients:complex-config"));
    assertEquals(1, countOccurences(s, "get:/invoices/{invoiceId}:complex-config"));
    assertEquals(1, countOccurences(s, "get:/invoices:complex-config"));
    assertEquals(1, countOccurences(s, "get:/items/{itemId}:complex-config"));
    assertEquals(1, countOccurences(s, "get:/items:complex-config"));
    assertEquals(1, countOccurences(s, "get:/providers/{providerId}:complex-config"));
    assertEquals(1, countOccurences(s, "get:/providers:complex-config"));
    assertEquals(1, countOccurences(s, "post:/clients:complex-config"));
    assertEquals(1, countOccurences(s, "post:/invoices:complex-config"));
    assertEquals(1, countOccurences(s, "post:/items:application/json:complex-config"));
    assertEquals(1, countOccurences(s, "post:/providers:complex-config"));
  }