コード例 #1
0
  private void indexSpeed(Directory dir) throws LockObtainFailedException, IOException {
    Central cram = SimpleCentralConfig.createCentral(dir);
    Indexer indexer = cram.newIndexer();

    final String readString =
        IOUtil.toString(
            new FileReader(
                new File("test/" + StringUtil.replace(this.getClass().getCanonicalName(), ".", "/"))
                    + ".java"));
    final String extString = IOUtil.toString(new FileReader(new File("build.xml")));
    indexer.index(
        new IndexJob<Void>() {

          public Void handle(IndexSession session) throws Exception {
            for (int i = 0; i < 1000; i++) {
              MyDocument doc = MyDocument.testDocument();
              doc.keyword("name", "bleujin");
              doc.text("file", extString);
              session.insertDocument(doc);
            }
            return null;
          }
        });
  }
コード例 #2
0
ファイル: TestNodeVfs.java プロジェクト: bleujin/mongoNode
  public void testRead() throws Exception {
    createSampleNode();

    VFile dept = entry.resolveFile("node://dept");
    assertEquals(FileType.FOLDER, dept.getType());
    assertEquals(true, dept.exists());

    String fileName = "node://dept/dept.node";
    VFile deptNode = entry.resolveFile(fileName);
    assertEquals(FileType.FILE, deptNode.getType());

    assertEquals(true, deptNode.exists());
    Reader reader = new InputStreamReader(deptNode.getInputStream(), "UTF-8");
    String result = IOUtil.toString(reader);
    JsonObject jso = JsonParser.fromString(result).getAsJsonObject();
    assertEquals(20, jso.asInt("year"));

    VFile bigboy = entry.resolveFile("node://dept/dev");
    assertEquals(FileType.FOLDER, bigboy.getType());
    // Debug.debug(IOUtil.toString(new InputStreamReader(bigboy.getInputStream(), "UTF-8"))) ;
  }