コード例 #1
0
 @Override
 public void setSettings() throws Exception {
   // TODO change this, by either introducing a setter or overriding FileManagerController
   PrivilegedAccessor.setValue(QRPUpdater.class, "QRP_DELAY", 1000);
   SearchSettings.LIME_QRP_ENTRIES.set(new String[] {"badger"});
   SearchSettings.LIME_SEARCH_TERMS.set(new String[] {"badger"});
   SearchSettings.SEND_LIME_RESPONSES.setValue(1f);
 }
コード例 #2
0
  public void testResponse() throws Exception {
    QueryRequest qr = queryRequestFactory.createNonFirewalledQuery("badger", (byte) 1);
    testUP[0].send(qr);
    testUP[0].flush();
    Thread.sleep(1000);
    QueryReply r = BlockingConnectionUtils.getFirstQueryReply(testUP[0]);
    assertNotNull(r);
    QueryReply expected = staticMessages.getLimeReply();
    assertTrue(expected.getResultsAsList().containsAll(r.getResultsAsList()));
    assertTrue(r.getResultsAsList().containsAll(expected.getResultsAsList()));

    // change the words to something else
    SearchSettings.LIME_SEARCH_TERMS.set(new String[] {"mushroom"});
    qr = queryRequestFactory.createNonFirewalledQuery("badger", (byte) 1);
    testUP[0].send(qr);
    testUP[0].flush();
    Thread.sleep(1000);
    r = BlockingConnectionUtils.getFirstQueryReply(testUP[0]);
    assertNull(r);

    qr = queryRequestFactory.createNonFirewalledQuery("mushroom", (byte) 1);
    testUP[0].send(qr);
    testUP[0].flush();
    Thread.sleep(1000);
    r = BlockingConnectionUtils.getFirstQueryReply(testUP[0]);
    assertNotNull(r);
    assertTrue(expected.getResultsAsList().containsAll(r.getResultsAsList()));
    assertTrue(r.getResultsAsList().containsAll(expected.getResultsAsList()));

    // turn off responding completely
    SearchSettings.SEND_LIME_RESPONSES.setValue(0);
    qr = queryRequestFactory.createNonFirewalledQuery("mushroom", (byte) 1);
    testUP[0].send(qr);
    testUP[0].flush();
    Thread.sleep(1000);
    r = BlockingConnectionUtils.getFirstQueryReply(testUP[0]);
    assertNull(r);
  }