示例#1
0
  @Test
  public void testContentFilterCreation() throws Exception {
    assertEquals("", loader.loadContentFilter());
    assertEquals(null, SaveResponder.contentFilter);

    testProperties.setProperty(ComponentFactory.CONTENT_FILTER, TestContentFilter.class.getName());

    String content = loader.loadContentFilter();
    assertEquals(
        "\tContent filter installed: " + SaveResponder.contentFilter.getClass().getName() + "\n",
        content);
    assertNotNull(SaveResponder.contentFilter);
    assertEquals(TestContentFilter.class, SaveResponder.contentFilter.getClass());
  }
示例#2
0
 @Test
 public void testMakeOneUserAuthenticator() throws Exception {
   Authenticator a = loader.makeAuthenticator("bob:uncle");
   assertTrue(a instanceof OneUserAuthenticator);
   OneUserAuthenticator oua = (OneUserAuthenticator) a;
   assertEquals("bob", oua.getUser());
   assertEquals("uncle", oua.getPassword());
 }
示例#3
0
  @Test
  public void testAuthenticatorCustomCreation() throws Exception {
    testProperties.setProperty(ComponentFactory.AUTHENTICATOR, SimpleAuthenticator.class.getName());

    Authenticator authenticator = loader.getAuthenticator(new PromiscuousAuthenticator());
    assertNotNull(authenticator);
    assertEquals(SimpleAuthenticator.class, authenticator.getClass());
  }
示例#4
0
 @Test
 public void testMakeMultiUserAuthenticator() throws Exception {
   final String passwordFilename = "testpasswd";
   File passwd = new File(passwordFilename);
   passwd.createNewFile();
   Authenticator a = loader.makeAuthenticator(passwordFilename);
   assertTrue(a instanceof MultiUserAuthenticator);
   passwd.delete();
 }
示例#5
0
  @Test
  public void testWikiWidgetPlugins() throws Exception {
    String symbolValues = Today.class.getName();
    testProperties.setProperty(ComponentFactory.SYMBOL_TYPES, symbolValues);

    String output = loader.loadSymbolTypes(testProvider);

    assertSubString(Today.class.getName(), output);

    assertMatch("!today", true);
  }
示例#6
0
  public void testCustomComparatorsCreation()
      throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    testProperties.setProperty(
        ComponentFactory.CUSTOM_COMPARATORS, "test:" + TestCustomComparator.class.getName());
    String content = loader.loadCustomComparators();

    assertTrue(content.contains("test:"));
    assertTrue(content.contains("TestCustomComparator"));

    CustomComparator customComparator =
        CustomComparatorRegistry.getCustomComparatorForPrefix("test");
    assertNotNull(customComparator);
    assertTrue(customComparator instanceof TestCustomComparator);
  }
示例#7
0
  @Test
  public void testSlimTablesWithColonCreation() throws ClassNotFoundException {
    testProperties.setProperty(
        ComponentFactory.SLIM_TABLES, "test::" + TestSlimTable.class.getName());
    String content = loader.loadSlimTables();

    assertTrue(content.contains("test:"));
    assertTrue(content.contains("TestSlimTable"));

    HtmlTable table = makeMockTable("test:");
    SlimTable slimTable =
        new SlimTableFactory().makeSlimTable(table, "foo", new SlimTestContextImpl());
    assertSame(TestSlimTable.class, slimTable.getClass());
  }
示例#8
0
  @Test
  public void testAddPlugins() throws Exception {
    testProperties.setProperty(ComponentFactory.PLUGINS, DummyPlugin.class.getName());

    FileSystemPageFactory wikiPageFactory = new FileSystemPageFactory();
    ResponderFactory responderFactory = new ResponderFactory(".");

    assertMatch("!today", false);

    String output = loader.loadPlugins(responderFactory, testProvider);

    assertSubString(DummyPlugin.class.getName(), output);

    assertEquals(WikiPageResponder.class, responderFactory.getResponderClass("custom1"));
    assertEquals(EditResponder.class, responderFactory.getResponderClass("custom2"));
    assertMatch("!today", true);
  }
示例#9
0
  @Test
  public void testAddResponderPlugins() throws Exception {
    String respondersValue =
        "custom1:"
            + WikiPageResponder.class.getName()
            + ",custom2:"
            + EditResponder.class.getName();
    testProperties.setProperty(ComponentFactory.RESPONDERS, respondersValue);

    ResponderFactory responderFactory = new ResponderFactory(".");
    String output = loader.loadResponders(responderFactory);

    assertSubString("custom1:" + WikiPageResponder.class.getName(), output);
    assertSubString("custom2:" + EditResponder.class.getName(), output);

    assertEquals(WikiPageResponder.class, responderFactory.getResponderClass("custom1"));
    assertEquals(EditResponder.class, responderFactory.getResponderClass("custom2"));
  }
示例#10
0
 @Test
 public void testMakeNullAuthenticator() throws Exception {
   Authenticator a = loader.makeAuthenticator(null);
   assertTrue(a instanceof PromiscuousAuthenticator);
 }
示例#11
0
 @Test
 public void testAuthenticatorDefaultCreation() throws Exception {
   Authenticator authenticator = loader.getAuthenticator(new PromiscuousAuthenticator());
   assertNotNull(authenticator);
   assertEquals(PromiscuousAuthenticator.class, authenticator.getClass());
 }