コード例 #1
0
 /**
  * Test method for {@link de.guruz.p300.webdav.search.client.SingleHostSearchWorker#run()}. Try to
  * search a nonexisting IP, creating an error
  */
 @Test
 public void testRunWithError() {
   Host mySearchHost = new Host("Testhost");
   mySearchHost.addIPAndPort("256.256.256.256", 0, 0);
   Document query = null;
   try {
     query =
         DOMUtils.documentFromInputStream(
             new FileInputStream(
                 "de/guruz/p300/tests/automated/WebDAVSearchTestResources/ExampleQuery"));
   } catch (FileNotFoundException fileNotFound) {
     fail("File not found");
   }
   SingleHostSearchWorker searchWorker =
       new SingleHostSearchWorker(
           Collections.singletonList(myResultCollector), mySearchHost, query);
   expectedResult = ResultType.ERROR;
   searchWorker.run();
   assertTrue(TestResultCollector.isCalled());
   TestResultCollector.resetCalled();
 }
コード例 #2
0
 /**
  * Test method for {@link de.guruz.p300.webdav.search.client.SingleHostSearchWorker#run()}.
  * Regular search, should return no result
  */
 @Test
 public void testRunWithNoResult() {
   Host mySearchHost = new Host("Testhost");
   int myPort = MainDialog.getCurrentHTTPPort();
   mySearchHost.addIPAndPort("127.0.0.1", myPort, 0);
   expectedResult = ResultType.NORESULT;
   Document query = null;
   try {
     query =
         DOMUtils.documentFromInputStream(
             new FileInputStream(
                 "de/guruz/p300/tests/automated/WebDAVSearchTestResources/ExampleQuery5"));
   } catch (FileNotFoundException fileNotFound) {
     fail("File not found");
   }
   SingleHostSearchWorker searchWorker =
       new SingleHostSearchWorker(
           Collections.singletonList(myResultCollector), mySearchHost, query);
   searchWorker.run();
   assertTrue(TestResultCollector.isCalled());
   TestResultCollector.resetCalled();
 }