@Test
 public void testUpdateDocument() throws Exception {
   HashMap<String, Object> props = new HashMap<String, Object>();
   props.put("key1", "value1");
   String output = "Data for document";
   ByteArrayInputStream bais = new ByteArrayInputStream(output.getBytes("UTF-8"));
   long streamLength = output.length();
   processor.updateDocument(node, docPath1, props, bais, streamLength);
 }
  @Before
  public void setUp() throws Exception {
    when(node.getSession().getUserID()).thenReturn("ch1411");

    HashMap<String, Object> docProps = new HashMap<String, Object>();
    docProps.put("key1", "value1");
    docResult1 = new UrlDocumentResult(docPath1, "text/plain", 1000, docProps);
    docResult2 = new UrlDocumentResult(docPath2, "text/plain", 2000, null);
    docResult3 = new UrlDocumentResult(docPath3, "text/plain", 3000, null);
    docResult4 = new UrlDocumentResult(docPath4, "text/plain", 4000, null);
    docResult5 = new UrlDocumentResult(docPath5, "text/plain", 5000, null);

    docHandler = new DocumentRequestHandler(docResult1);
    metadataHandler = new MetadataRequestHandler(docResult1);
    removeHandler = new RemoveRequestHandler();
    searchHandler =
        new SearchRequestHandler(docResult1, docResult2, docResult3, docResult4, docResult5);
    updateHandler = new UpdateRequestHandler();

    // setup the local test server
    server = new LocalTestServer(null, null);
    server.register("/document", docHandler);
    server.register("/metadata", metadataHandler);
    server.register("/remove", removeHandler);
    server.register("/search", searchHandler);
    server.register("/update", updateHandler);
    server.start();

    // setup & activate the url doc processor
    String serverUrl = "http://" + server.getServiceHostName() + ":" + server.getServicePort();

    Properties props = new Properties();
    props.put(UrlRepositoryProcessor.DOCUMENT_URL, serverUrl + "/document?p=");
    props.put(UrlRepositoryProcessor.METADATA_URL, serverUrl + "/metadata?p=");
    props.put(UrlRepositoryProcessor.REMOVE_URL, serverUrl + "/remove?p=");
    props.put(UrlRepositoryProcessor.SEARCH_URL, serverUrl + "/search");
    props.put(UrlRepositoryProcessor.UPDATE_URL, serverUrl + "/update?p=");
    props.put(UrlRepositoryProcessor.HMAC_HEADER, "X-HMAC");
    props.put(UrlRepositoryProcessor.SHARED_KEY, "superSecretSharedKey");

    ComponentContext context = mock(ComponentContext.class);
    when(context.getProperties()).thenReturn(props);

    processor = new UrlRepositoryProcessor();
    processor.activate(context);
  }
 @Test
 public void testSearchDocument() throws Exception {
   HashMap<String, Object> props = new HashMap<String, Object>();
   props.put("key1", "value1");
   processor.search(node, props);
 }
 @Test
 public void testRemoveDocument() throws Exception {
   processor.removeDocument(node, docPath1);
 }
 @Test
 public void testGetDocumentMetadata() throws Exception {
   ExternalDocumentResultMetadata metadata = processor.getDocumentMetadata(node, docPath1);
   assertEquals(docResult1, metadata);
 }
 @Test
 public void testGetDocument() throws Exception {
   ExternalDocumentResult doc = processor.getDocument(node, "myDoc.ext");
   assertEquals(docResult1, doc);
 }
 @Test
 public void testGetType() {
   assertEquals(processor.getType(), UrlRepositoryProcessor.TYPE);
 }