Пример #1
0
  /**
   * The solo purpose of this testing is to the ensure the basic functions (insert and remove) of a
   * document function properly.
   */
  @Test
  public void BasicFuntionTest() throws InterruptedException {
    Document doc =
        new Document("samplefiles", new CopyOnWriteArrayList<String>(), "1000samplefiles1000", 0);
    assertEquals("samplefiles", doc.getName());

    // Check insert function.
    doc.insertChar(0, "60");
    Thread.sleep(25);
    assertEquals("60a", doc.toString());

    doc.insertChar(0, "100");
    Thread.sleep(25);
    assertEquals("100a60a", doc.toString());

    // Check remove function.
    doc.removeChar(1);
    Thread.sleep(25);
    assertEquals("60a", doc.toString());

    // Check series of commands.
    doc.insertChar(1, "10");
    doc.insertChar(2, "20");
    doc.insertChar(3, "30");
    doc.insertChar(4, "40");
    doc.removeChar(3); // when we remove on the server we automatically remove 1 less
    doc.insertChar(4, "50");
    Thread.sleep(50);
    assertEquals("60a10a30a40a50a", doc.toString());
  }
Пример #2
0
  @Test
  public void testAddDocumentsIntoTheFolder() {

    Folder folder = new Folder("Home", Visibility.PUBLIC, true);
    Document doc = new Paper();

    folder.addDocuments(doc);

    Assert.assertEquals(folder.getDocuments().iterator().next().getName(), doc.getName());
  }
 public void writeLibsvmData(String folder, Document doc) {
   try {
     String fileName = folder + File.pathSeparator + doc.getName() + ".libsvm";
     PrintWriter printWriter =
         new PrintWriter(new BufferedWriter(new FileWriter(new File(fileName), true)));
     printWriter.println(doc.getLibsvmData());
     printWriter.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 private void createHistoryEvent(
     HistoryEventType eventType,
     Long nID_Subject,
     String sSubjectName_Upload,
     Long nID_Document,
     Document document) {
   Map<String, String> values = new HashMap<>();
   try {
     Document oDocument = document == null ? documentDao.getDocument(nID_Document) : document;
     values.put(HistoryEventMessage.DOCUMENT_TYPE, oDocument.getDocumentType().getName());
     values.put(HistoryEventMessage.DOCUMENT_NAME, oDocument.getName());
     values.put(HistoryEventMessage.ORGANIZATION_NAME, sSubjectName_Upload);
   } catch (Throwable e) {
     log.warn("can't get document info!", e);
   }
   try {
     String eventMessage = HistoryEventMessage.createJournalMessage(eventType, values);
     historyEventDao.setHistoryEvent(nID_Subject, eventType.getnID(), eventMessage, eventMessage);
   } catch (IOException e) {
     log.error("error during creating HistoryEvent", e);
   }
 }
Пример #5
0
 /**
  * Add new document to the client
  *
  * @param d Document to be added
  */
 public void addDocument(Document d) {
   this.documents.put(d.getName(), d);
 }
 public Object saveDocument(Document doc) throws PersistenceException, SecurityException {
   return saveDocument(doc.getName(), doc);
 }