/**
   * Test for modification of TypeName.xsd with invalid content.
   *
   * @throws IOException
   */
  @Test
  public void testGenTypeCleanBuildTypeLibraryModifyXsdWithInvalidContent() throws IOException {
    String xsdFileName = "CategoryProduct.xsd";

    // create library
    boolean createLibraryFlag = createTypeLibrary();
    assertTrue("Problem occured during Library creation.", createLibraryFlag);

    TestResourceUtil.copyResource(
        "types/CategoryProduct.xsd", testingdir, "CategoryTypeLibrary/meta-src/");

    // add types
    boolean addType = addTypeToLibrary(xsdFileName);
    assertTrue("Problem occured during Type addition.", addType);

    TestResourceUtil.copyResource(
        "types/CategoryProductInvalid.xsd", testingdir, "CategoryTypeLibrary/meta-src/");

    ServiceGenerator sGenerator = new ServiceGenerator();
    String[] pluginParameter = {
      "-gentype",
      "genTypeCleanBuildTypeLibrary",
      "-pr",
      PROJECT_ROOT_CATEGORY,
      "-libname",
      CATEGORY_TYPE_LIBRARY
    };
    try {
      sGenerator.startCodeGen(pluginParameter);
      assertTrue("Exception should be thrown. Exception: ", false);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Test
  public void serviceGeneratorWSDLWithImportReferringToHttpLink() throws Exception {
    // Initialize testing paths
    MavenTestingUtils.ensureEmpty(testingdir.getDir());
    File wsdl =
        TestResourceUtil.getResource(
            "org/ebayopensource/turmeric/test/tools/codegen/data/WsdlWith_HTTP_Import.wsdl");
    File srcDir = getTestSrcDir();
    File destDir = getTestDestDir();
    File binDir = testingdir.getFile("bin");

    // Setup arguments
    // @formatter:off
    String args[] =
        new String[] {
          "-servicename", "CalcService",
          "-wsdl", wsdl.getAbsolutePath(),
          "-gentype", "All",
          "-src", srcDir.getAbsolutePath(),
          "-dest", destDir.getAbsolutePath(),
          "-namespace", "http://www.ebay.com/soaframework/service/calc",
          "-scv", "1.0.0",
          "-gip", "org.ebayopensource.test.soaframework.tools.codegen",
          "-bin", binDir.getAbsolutePath()
        };
    // @formatter:on

    performDirectCodeGen(args);
  }
  /**
   * Test for modification of TypeIformation.xml
   *
   * <p>Quick bug 638
   *
   * @throws IOException
   */
  @Test
  public void testGenTypeCleanBuildTypeLibrarySimpleType() throws IOException {
    String folderConstant = "cleanBuildTypeLibrarySimpleType";
    String xsdFileName = "CategoryName.xsd";

    // create library
    boolean createLibraryFlag = createTypeLibrary();
    assertTrue("Problem occured during Library creation.", createLibraryFlag);

    TestResourceUtil.copyResource(
        "types/CategoryName.xsd", testingdir, "CategoryTypeLibrary/meta-src/");

    // add types
    boolean addType = addTypeToLibrary(xsdFileName);
    assertTrue("Problem occured during Type addition.", addType);

    // modify TypeInformation.xml
    String newTIXmlPath =
        getTestResrcDir().getAbsolutePath()
            + "/TypeLibraryCodegen/CategoryTypeLibrary/gen-meta-src/META-INF/CategoryTypeLibrary/cleanBuildTypeLibrarySimpleType/"
            + TYPE_INFO;
    String oldTIXmlPath =
        utility.getTypeInformationXMLPath(PROJECT_ROOT_CATEGORY, CATEGORY_TYPE_LIBRARY, null);

    MavenTestingUtils.ensureEmpty(testingdir.getFile("gen-meta-src"));
    MavenTestingUtils.ensureEmpty(testingdir.getFile("gen-src"));

    // Validate the changes.
    ServiceGenerator sGenerator = new ServiceGenerator();
    String[] pluginParameter = {
      "-gentype",
      "genTypeCleanBuildTypeLibrary",
      "-pr",
      PROJECT_ROOT_CATEGORY,
      "-libname",
      CATEGORY_TYPE_LIBRARY
    };
    try {

      sGenerator.startCodeGen(pluginParameter);

      boolean compareTIXml = utility.compareFiles(oldTIXmlPath, newTIXmlPath);
      assertTrue("TypeInformation.xml content does not match.", compareTIXml);

      File typeInformation = new File(oldTIXmlPath);
      Assert.assertTrue(typeInformation.exists());

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue("No exception should be thrown. Exception: " + e.getMessage(), false);
    }
  }
  @Test
  public void ebayCSSvcCSUpdateMACActivityAddAttachmentsWSDL() throws Exception {
    // Initialize testing paths
    testingdir.ensureEmpty();
    File wsdl =
        TestResourceUtil.getResource(
            "org/ebayopensource/turmeric/test/tools/codegen/data/ebayCSSvc-CSUpdateMACActivityAddAttachments.wsdl");
    File srcDir = getTestSrcDir();
    File destDir = getTestDestDir();
    File binDir = testingdir.getFile("bin");

    // Setup arguments
    // @formatter:off
    String args[] =
        new String[] {
          "-servicename",
          "eBayCSAPIInterfaceService",
          "-wsdl",
          wsdl.getAbsolutePath(),
          "-gentype",
          "All",
          "-src",
          srcDir.getAbsolutePath(),
          "-dest",
          destDir.getAbsolutePath(),
          "-namespace",
          SOAConstants.DEFAULT_SERVICE_NAMESPACE,
          "-scv",
          "1.0.0",
          "-gip",
          "org.ebayopensource.test.soaframework.service",
          "-bin",
          binDir.getAbsolutePath(),
          "-cn",
          "eBayCSAPIInterfaceService",
          "-icsi",
          "-gin",
          "eBayCSAPIInterfaceService"
        };
    // @formatter:on

    performDirectCodeGen(args);
  }
  @Test
  // @Ignore("failing")
  public void testGenTypeCreateTypeLibrary() {

    String[] pluginParameter = {
      "-gentype",
      "genTypeCreateTypeLibrary",
      "-pr",
      PROJECT_ROOT_CATEGORY,
      "-libname",
      CATEGORY_TYPE_LIBRARY,
      "-libVersion",
      "1.2.3",
      "-libNamespace",
      "http://www.ebayopensource.org/soaframework/examples/config"
    };
    try {
      // sGenerator.startCodeGen(pluginParameter);
      performDirectCodeGen(pluginParameter, binDir);
      // Validate the content of the TypeInformation.xml
      String typeInformationXmlCodegenPath =
          utility.getTypeInformationXMLPath(PROJECT_ROOT_CATEGORY, CATEGORY_TYPE_LIBRARY, null);
      String typeInformationXmlVanillaPath =
          TestResourceUtil.copyResource(
                  "TypeLibraryCodegen/CategoryTypeLibrary/gen-meta-src/META-INF/CategoryTypeLibrary/TypeInformation.xml",
                  testingdir,
                  "gen-meta-src")
              .getAbsolutePath();
      assertXML(
          typeInformationXmlVanillaPath,
          typeInformationXmlCodegenPath,
          new String[] {"xml-type-name"});
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue("No exception should be thrown", false);
    }
  }
  /**
   * Test for modification of TypeIformation.xml
   *
   * @throws IOException
   */
  @Test
  public void testGenTypeCleanBuildTypeLibraryModifyXsdWithValidContent() throws IOException {
    String folderConstant = "cleanBuildTypeLibraryModifyXsdWithValidContent";
    String xsdFileName = "CategoryProduct.xsd";
    String javaFileName = "CategoryProduct1.java";
    String episodeFileName = "CategoryProduct.episode";

    // create library
    boolean createLibraryFlag = createTypeLibrary();
    assertTrue("Problem occured during Library creation.", createLibraryFlag);

    TestResourceUtil.copyResource(
        "types/CategoryProduct.xsd", testingdir, "CategoryTypeLibrary/meta-src/");

    // add types
    boolean addType = addTypeToLibrary(xsdFileName);
    assertTrue("Problem occured during Type addition.", addType);

    // Update the xsd file
    /*String oldXsdPath = utility.getXsdFilePath(PROJECT_ROOT_CATEGORY, xsdFileName);
    String newXsdPath = utility.getXsdFilePath(GOLD_COPY_ROOT_CATEGORY, "CategoryProduct1.xsd");
    boolean updateXsd = utility.updateSourceFile(newXsdPath, oldXsdPath);
    assertTrue("Problem occured during updating CategoryName.xsd",updateXsd);*/

    TestResourceUtil.copyResource(
        "types/CategoryProduct1.xsd", testingdir, "CategoryTypeLibrary/meta-src/");

    // Validate the changes.
    ServiceGenerator sGenerator = new ServiceGenerator();
    String[] pluginParameter = {
      "-gentype",
      "genTypeCleanBuildTypeLibrary",
      "-pr",
      PROJECT_ROOT_CATEGORY,
      "-libname",
      CATEGORY_TYPE_LIBRARY
    };
    try {

      sGenerator.startCodeGen(pluginParameter);

      // Validate the contents of TypeInformation.xml
      String newTIXmlPath =
          getTestResrcDir().getAbsolutePath()
              + "/TypeLibraryCodegen/CategoryTypeLibrary/gen-meta-src/META-INF/CategoryTypeLibrary/cleanBuildTypeLibraryModifyXsdWithValidContent/"
              + TYPE_INFO;
      String oldTIXmlPath =
          utility.getTypeInformationXMLPath(PROJECT_ROOT_CATEGORY, CATEGORY_TYPE_LIBRARY, null);
      assertXML(oldTIXmlPath, newTIXmlPath, new String[] {"xml-type-name"});
      // assertTrue("TypeInformation.xml content does not match.", compareTIXml);

      // Validate the contents of the CategoryProduct.java file.
      String javaFilePathVanilla =
          getTestResrcDir().getAbsolutePath()
              + "/TypeLibraryCodegen/CategoryTypeLibrary/gen-src/org/ebayopensource/soaframework/examples/config/cleanBuildTypeLibraryModifyXsdWithValidContent/CategoryProduct1.java";
      String javaFileCodegenCopy =
          utility.getGeneratedJavaFilePath(
              PROJECT_ROOT_CATEGORY, CATEGORY_TYPE_LIBRARY, "CategoryProduct1.java", null);
      boolean javaFileCompare = utility.compareFiles(javaFileCodegenCopy, javaFilePathVanilla);
      assertTrue(javaFileName + " content does not match.", javaFileCompare);

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue("No exception should be thrown. Exception: " + e.getMessage(), false);
    }
  }