Beispiel #1
0
  public static void main(String[] args) throws Exception {

    DBUtils util =
        new DBUtils(
            "root",
            "root",
            "jdbc:mysql://localhost:3306/fkcloud?useUnicode=true&characterEncoding=UTF-8");
    util.setNameconvert(
        new NameConvert(NameConvert.UNDERLINE_TO_UPPERCASE, NameConvert.IGNORE_UNDERLINE));
    TpDbquery query =
        new TpDbquery(
            "mysql",
            "select TABLE_NAME,TABLE_COMMENT from information_schema.TABLES where TABLE_TYPE='BASE TABLE' and TABLE_NAME like ? and TABLE_SCHEMA = ?",
            "select COLUMN_NAME,COLUMN_COMMENT,DATA_TYPE,case when CHARACTER_MAXIMUM_LENGTH is null then NUMERIC_PRECISION else CHARACTER_MAXIMUM_LENGTH end,EXTRA,IS_NULLABLE,COLUMN_DEFAULT  from information_schema.COLUMNS where  TABLE_NAME=? and TABLE_SCHEMA=?",
            "select COLUMN_NAME  from information_schema.COLUMNS where COLUMN_KEY = 'PRI' and TABLE_NAME=? and TABLE_SCHEMA=?",
            "com.mysql.jdbc.Driver",
            "",
            "",
            "fkcloud",
            new Timestamp(System.currentTimeMillis()));
    util.setDbquery(query);
    util.setDbschema("fkcloud");
    Map<String, Object> map = new HashMap<String, Object>();

    List<TableInfo> tableList = util.findTableList("%");
    for (TableInfo table : tableList) {
      map.put("table", table);
      String javaString = new Generate().generate("com/feng/vm/hibernate/model.vm", map);
      FileUtil.writeAsString(new File("d:\\" + table.getModelname() + ".java"), javaString);
    }
  }
Beispiel #2
0
 private void saveModel(File f) {
   if (debugTest) System.out.println("Saving model into " + f.getAbsolutePath());
   File modelFile = new File(modelFilename);
   try {
     FileUtil.copyFile(modelFile, f);
   } catch (IOException ioe) {
     ioe.printStackTrace();
     fail("Couldn't copy file to " + f.toString());
   }
 }
 /**
  * If destDir exists and property CLEAN is set, this cleans out the dest dir of any .class files,
  * and returns true to signal a recursive call.
  *
  * @return true if destDir was cleaned.
  */
 private boolean afterCleaningDirs() {
   String clean = javac.getProject().getProperty(CLEAN);
   if (null == clean) {
     return false;
   }
   File destDir = javac.getDestdir();
   if (null == destDir) {
     javac.log(CLEAN + " specified, but no dest dir to clean", Project.MSG_WARN);
     return false;
   }
   javac.log(CLEAN + " cleaning .class files from " + destDir, Project.MSG_VERBOSE);
   FileUtil.deleteContents(destDir, FileUtil.DIRS_AND_WRITABLE_CLASSES, true);
   return true;
 }
  /**
   * Tests that the UnwovenClassFiles corresponding to classes on the inpath have the correct class
   * name when there is no output directory (ultimately tests
   * AjState.createUnwovenClassFile(BinarySourceFile) and ensures the unwovenClassFile has the
   * correct name. Makes a change to a class file on the inpath to ensure we enter this method
   * (there is a check that says are we the first build))
   */
  public void testPathResolutionAfterChangeInClassOnInpath() throws Exception {
    String inpathDir = inpathTestingDir + File.separator + "injarBin" + File.separator + "pkg";
    addInpathEntry(inpathDir);
    build("inpathTesting");

    // build again so that we enter
    // AjState.createUnwovenClassFile(BinarySourceFile)
    File from =
        new File(
            testdataSrcDir
                + File.separatorChar
                + "inpathTesting"
                + File.separatorChar
                + "newInpathClass"
                + File.separatorChar
                + "InpathClass.class");
    File destination = new File(inpathDir + File.separatorChar + "InpathClass.class");
    FileUtil.copyFile(from, destination);

    // get hold of the state for this project - expect to find one
    AjState state = getState();
    AjBuildConfig buildConfig = state.getBuildConfig();
    state.prepareForNextBuild(buildConfig);

    Map binarySources = state.getBinaryFilesToCompile(true);
    assertFalse(
        "expected there to be binary sources from the inpath setting but didn't find any",
        binarySources.isEmpty());

    List unwovenClassFiles =
        (List) binarySources.get(inpathDir + File.separator + "InpathClass.class");
    List fileNames = new ArrayList();
    // the unwovenClassFiles should have filenames that point to the output dir
    // (which in this case is the sandbox dir) and not where they came from.
    for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext(); ) {
      UnwovenClassFile ucf = (UnwovenClassFile) iterator.next();
      if (ucf.getFilename().indexOf(expectedOutputDir) == -1) {
        fileNames.add(ucf.getFilename());
      }
    }
    assertTrue(
        "expected to find UnwovenClassFile from directory\n"
            + expectedOutputDir
            + ", \n but found files "
            + fileNames,
        fileNames.isEmpty());
  }