Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.Document


  }

  public void testGetMetaDataHiddenFile() throws Exception {
    testFile.setIsHidden(true);
    try {
      Document document = retriever.getMetaData(testFileName);
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected exception.
    }
  }
View Full Code Here


  }

  public void testGetMetaDataFileUnderHiddenDirectory() throws Exception {
    testDir.setIsHidden(true);
    try {
      Document document = retriever.getMetaData(testFile2.getPath());
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected exception.
    }
  }
View Full Code Here

    root.setIsHidden(true);
    testGetMetaData();
  }

  public void testGetMetaData() throws Exception {
    Document document = retriever.getMetaData(testFileName);
    assertTrue(document instanceof FileDocument);
    assertEquals(testFileName, ((FileDocument) document).getDocumentId());
  }
View Full Code Here

  public void testGetMetaDataRepositoryDocumentException() throws Exception {
    testFile.setException(MockReadonlyFile.Where.ALL,
                          new RepositoryDocumentException("Test Exception"));
    try {
      Document document = retriever.getMetaData(testFileName);
      document.findProperty(SpiConstants.PROPNAME_LASTMODIFIED);
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected Exception.
    }
  }
View Full Code Here

  public void testGetMetaDataServerDown() throws Exception {
    testFile.setException(MockReadonlyFile.Where.ALL,
                          new RepositoryException("Server down."));
    try {
      Document document = retriever.getMetaData(testFileName);
      fail("Expected RepositoryException, but got none.");
    } catch (RepositoryException expected) {
      assertEquals("Server down.", expected.getMessage());
    }
  }
View Full Code Here

  }

  public void testGetInputStreamException() throws Exception {
    foo.setException(MockReadonlyFile.Where.GET_INPUT_STREAM,
                     new IOException("Test Exception"));
    Document doc = new FileDocument(foo, makeContext(false, true), root);
    try {
      getDocumentContents(doc);
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      assertTrue(expected.getMessage().contains("Failed to open"));
View Full Code Here

  public void testGetAclException() throws Exception {
    foo.setException(MockReadonlyFile.Where.GET_ACL,
                     new IOException("Test Exception"));
    try {
      Document doc = new FileDocument(foo, makeContext(true, false), root);
      doc.findProperty(SpiConstants.PROPNAME_ACLUSERS);
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected.
    }
  }
View Full Code Here

  }

  public void testGetLastModifiedException() throws Exception {
    foo.setException(MockReadonlyFile.Where.GET_LAST_MODIFIED,
                     new IOException("Test Exception"));
    Document doc = new FileDocument(foo, makeContext(false, true), root);
    assertNull(
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_LASTMODIFIED));
  }
View Full Code Here

    assertNull(
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_LASTMODIFIED));
  }

  public void testAddFile() throws Exception {
    Document doc = new FileDocument(foo, makeContext(false, true), root);
    String docId =
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_DOCID);
    assertEquals(foo.getPath(), docId);
    assertEquals(foo.getDisplayUrl(), Value.getSingleValueString(doc,
        SpiConstants.PROPNAME_DISPLAYURL));
    assertEquals("text/html", Value.getSingleValueString(doc,
        SpiConstants.PROPNAME_MIMETYPE));

    // Don't advertise the CONTENT property, but should be able to fetch it.
    assertFalse(doc.getPropertyNames().contains(SpiConstants.PROPNAME_CONTENT));
    assertEquals("contents of foo", getDocumentContents(doc));

    Calendar lastModified = Value.iso8601ToCalendar(
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_LASTMODIFIED));
    assertEquals(LAST_MODIFIED.getTimeInMillis(),
                 lastModified.getTimeInMillis());
    assertNotNull(doc.findProperty(SpiConstants.PROPNAME_ISPUBLIC));
    assertEquals(Boolean.TRUE.toString(),
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_ISPUBLIC));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS));
  }
View Full Code Here

  }

  private void testAddNotPublicFileWithAcl(String expectedInheritFrom)
      throws RepositoryException {
    foo.setAcl(acl);
    Document doc = new FileDocument(foo, makeContext(true, false), root);
    validateNotPublic(doc);
    Property usersProperty = doc.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    validateRepeatedProperty(users, usersProperty);
    Property groupsProperty = doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS);
    validateRepeatedProperty(groups, groupsProperty);
    Property denyUsersProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS);
    validateRepeatedProperty(denyUsers, denyUsersProperty);
    Property denyGroupsProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS);
    validateRepeatedProperty(denyGroups, denyGroupsProperty);

    Property aclInheritFrom =
        doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM_DOCID);
    assertNotNull(aclInheritFrom);
    assertEquals(expectedInheritFrom, aclInheritFrom.nextValue().toString());
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.