public void test_generateWithoutInclude() throws Exception {
    MockUtil util = MockUtil.setupEnvironment("withoutInclude/withoutInclude-pom.xml");
    Mojo mojo = lookupMojo("generate", util.getPomFile());

    mojo.execute();

    assertExist("./target/withoutInclude/server/resources/conf/role.xml");
    assertExist("./target/withoutInclude/server/resources/conf/castor-config.xml");

    String expected =
        "<?xml version='1.0' encoding='ISO-8859-1'?>"
            + "<database name='DirectUseDB' engine='sybase'>"
            + "    <driver class-name='com.sybase.jdbc2.jdbc.SybDataSource' url='jdbc:sybase:Tds:notUSED'/>"
            + "    <mapping href='Mapping.xml'/>"
            + "</database>";

    String actual =
        FileUtil.loadContent(
            toFile("./target/withoutInclude/server/resources/conf/castor-config.xml"));
    XmlUtil.assertEquals(expected, actual);

    List compileSourceRoots = util.getProject().getCompileSourceRoots();
    assertEquals(2, compileSourceRoots.size());
    assertPath("target/withoutInclude/server/java", compileSourceRoots.get(0));
    assertPath("target/withoutInclude/client/java", compileSourceRoots.get(1));
  }
Esempio n. 2
0
  public GitConfigUtil(File file, Properties properties) throws IOException {
    String[] gitConfigFile = FileUtil.loadContentAsLines(file);
    boolean categoryFound = false;

    for (String configLine : gitConfigFile) {
      if (!categoryFound) {
        categoryFound = "[http]".equalsIgnoreCase(configLine.trim());
      } else {
        String lineNospace = configLine.trim().replaceAll(" ", "").replaceAll("\t", "");
        String prefix = "proxy=";
        if (lineNospace.startsWith(prefix)) {
          int delimiterPosition = lineNospace.indexOf("@");

          String httpProxyAuthChain = lineNospace.substring(prefix.length(), delimiterPosition);
          String[] split = httpProxyAuthChain.split(":");
          proxyUserName = split[0];
          proxyPasword = split[1];

          String httpProxyChain = lineNospace.substring(delimiterPosition + 1);
          split = httpProxyChain.split(":");
          proxyHost = split[0];
          proxyPort = Integer.parseInt(split[1]);
          break;
        }

        if (lineNospace.startsWith("[")) {
          break;
        }
      }
    }

    githubAccount = properties.getProperty("githubAccount");
    githubPassword = properties.getProperty("githubPassword");
  }
Esempio n. 3
0
  public ModelManager loadModel() throws Exception {
    synchronized (file) {
      if (file.exists()) {
        String fileContent = FileUtil.loadContent(file);
        if (fileContent.length() != 0) {

          Pattern pattern =
              Pattern.compile(
                  "<xml version=\"(\\d)\">(.*)</xml>", Pattern.MULTILINE | Pattern.DOTALL);
          Matcher matcher = pattern.matcher(fileContent);

          if (!matcher.matches()) {
            throw new Exception("le contenu du fichier est mal formé");
          }

          if (matcher.groupCount() == 2) {
            Integer xmlModelVersion = Integer.valueOf(matcher.group(1));
            if (xmlModelVersion != XmlCodec.XML_VERSION) {
              throw new BadConfigurationException(
                  BAD_DATA + "La version du modèle '" + xmlModelVersion + "' n'est pas gérée.");
            }
            return fromXml(matcher.group(2));
          }
        }
      }
      return new DefaultModelManager();
    }
  }
Esempio n. 4
0
 public Timestamp saveModel(ModelManager manager) throws Exception {
   synchronized (file) {
     String fileContent =
         String.format("<xml version=\"%d\">%s</xml>", XmlCodec.XML_VERSION, toXml(manager));
     FileUtil.saveContent(file, fileContent);
     return getModelTimestamp();
   }
 }
 public String loadContent(Reader reader) {
   String content = null;
   try {
     content = FileUtil.loadContent(reader);
   } catch (IOException e) {
     e.printStackTrace(); // Todo
   }
   return removeSchemaAttributes(removeHeader(content));
 }
  public void test_generateWithoutInclude_mysql() throws Exception {
    MockUtil util = MockUtil.setupEnvironment("withoutInclude/withoutInclude-mysql-pom.xml");
    Mojo mojo = lookupMojo("generate", util.getPomFile());

    mojo.execute();

    String expected =
        "<?xml version='1.0' encoding='ISO-8859-1'?>"
            + "<database name='DirectUseDB' engine='mysql'>"
            + "    <driver class-name='com.mysql.jdbc.Driver' url='jdbc:mysql://notUSED'/>"
            + "    <mapping href='Mapping.xml'/>"
            + "</database>";

    String actual =
        FileUtil.loadContent(
            toFile("./target/withoutInclude/server/resources/conf/castor-config.xml"));
    XmlUtil.assertEquals(expected, actual);
  }
Esempio n. 7
0
 private String loadEtalon(String expectedResult) throws IOException {
   return FileUtil.loadContent(new File(expectedResult));
 }
 public String loadContent(File file) throws IOException {
   return removeSchemaAttributes(removeHeader(FileUtil.loadContent(file)));
 }
 public void after() {
   FileUtil.deleteRecursively(fileTest);
 }