Exemplo n.º 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());
  }
Exemplo n.º 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());
 }
Exemplo n.º 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());
  }
Exemplo n.º 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();
 }
Exemplo n.º 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);
  }
Exemplo n.º 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);
  }
Exemplo n.º 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());
  }
Exemplo n.º 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);
  }
Exemplo n.º 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"));
  }
Exemplo n.º 10
0
 @Test
 public void testMakeNullAuthenticator() throws Exception {
   Authenticator a = loader.makeAuthenticator(null);
   assertTrue(a instanceof PromiscuousAuthenticator);
 }
Exemplo n.º 11
0
 @Test
 public void testAuthenticatorDefaultCreation() throws Exception {
   Authenticator authenticator = loader.getAuthenticator(new PromiscuousAuthenticator());
   assertNotNull(authenticator);
   assertEquals(PromiscuousAuthenticator.class, authenticator.getClass());
 }