Esempio n. 1
0
  public void testContentFilterCreation() throws Exception {
    assertEquals("", factory.loadContentFilter());
    assertEquals(null, SaveResponder.contentFilter);

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

    String content = factory.loadContentFilter();
    assertEquals(
        "\tContent filter installed: " + SaveResponder.contentFilter.getClass().getName() + "\n",
        content);
    assertNotNull(SaveResponder.contentFilter);
    assertEquals(TestContentFilter.class, SaveResponder.contentFilter.getClass());
  }
Esempio n. 2
0
  public void testAuthenticatorCustomCreation() throws Exception {
    testProperties.setProperty(ComponentFactory.AUTHENTICATOR, SimpleAuthenticator.class.getName());

    Authenticator authenticator = factory.getAuthenticator(new PromiscuousAuthenticator());
    assertNotNull(authenticator);
    assertEquals(SimpleAuthenticator.class, authenticator.getClass());
  }
Esempio n. 3
0
  public void testShouldUseSpecifiedRevisionController() throws Exception {
    testProperties.setProperty(
        ComponentFactory.VERSIONS_CONTROLLER, NullVersionsController.class.getName());

    VersionsController defaultRevisionController = factory.loadVersionsController();
    assertEquals(NullVersionsController.class, defaultRevisionController.getClass());
  }
Esempio n. 4
0
  public void testWikiWidgetPlugins() throws Exception {
    String symbolValues = Today.class.getName();
    testProperties.setProperty(ComponentFactory.SYMBOL_TYPES, symbolValues);

    String output = factory.loadSymbolTypes();

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

    assertMatch("!today", true);
  }
Esempio n. 5
0
  public void testDefaultRootPage() throws Exception {
    WikiPageFactory wikiPageFactory = new WikiPageFactory();
    factory.loadWikiPage(wikiPageFactory);
    assertEquals(FileSystemPage.class, wikiPageFactory.getWikiPageClass());

    WikiPage page = wikiPageFactory.makeRootPage("testPath", "TestRoot", factory);
    assertNotNull(page);
    assertEquals(FileSystemPage.class, page.getClass());
    assertEquals("TestRoot", page.getName());
  }
Esempio n. 6
0
  public void testRootPageCreation() throws Exception {
    testProperties.setProperty(ComponentFactory.WIKI_PAGE_CLASS, InMemoryPage.class.getName());

    WikiPageFactory wikiPageFactory = new WikiPageFactory();
    factory.loadWikiPage(wikiPageFactory);
    assertEquals(InMemoryPage.class, wikiPageFactory.getWikiPageClass());

    WikiPage page = wikiPageFactory.makeRootPage(null, "", factory);
    assertNotNull(page);
    assertEquals(InMemoryPage.class, page.getClass());
  }
Esempio n. 7
0
 public WikiPage makeRootPage(
     String rootPath, String rootPageName, ComponentFactory componentFactory) throws Exception {
   try {
     Constructor<?> constructorMethod =
         wikiPageClass.getConstructor(String.class, String.class, ComponentFactory.class);
     return (WikiPage) constructorMethod.newInstance(rootPath, rootPageName, componentFactory);
   } catch (NoSuchMethodException e) {
     Method makeRootMethod = wikiPageClass.getMethod("makeRoot", Properties.class);
     return (WikiPage) makeRootMethod.invoke(wikiPageClass, componentFactory.getProperties());
   }
 }
  @Ignore
  @Test
  public void Junit382() throws Exception {
    // Very simple test : only 1 dependency resolved, jar is a dependency of
    // the current module

    String output = factory.loadSymbolTypes();

    // assertSubString(MavenArtifact.class.getName(), output);

    assertMatch("!artifact", true);
  }
Esempio n. 9
0
  private static FitNesseContext initContext(String rootPath, int port) throws Exception {
    Builder builder = new Builder();
    WikiPageFactory wikiPageFactory = new WikiPageFactory();
    ComponentFactory componentFactory = new ComponentFactory(rootPath);

    builder.port = port;
    builder.rootPath = rootPath;
    builder.rootDirectoryName = "FitNesseRoot";

    builder.pageTheme = componentFactory.getProperty(ComponentFactory.THEME);
    builder.defaultNewPageContent =
        componentFactory.getProperty(ComponentFactory.DEFAULT_NEWPAGE_CONTENT);

    builder.root =
        wikiPageFactory.makeRootPage(builder.rootPath, builder.rootDirectoryName, componentFactory);

    builder.logger = null;
    builder.authenticator = new PromiscuousAuthenticator();

    FitNesseContext context = builder.createFitNesseContext();
    return context;
  }
Esempio n. 10
0
  public void testSlimTablesWithColonCreation() throws ClassNotFoundException {
    testProperties.setProperty(
        ComponentFactory.SLIM_TABLES, "test::" + TestSlimTable.class.getName());
    String content = factory.loadSlimTables();

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

    HtmlTable table = makeMockTable("test:");
    SlimTable slimTable =
        new SlimTableFactory().makeSlimTable(table, "foo", new MockSlimTestContext());
    assertSame(TestSlimTable.class, slimTable.getClass());
  }
Esempio n. 11
0
  public static Authenticator makeAuthenticator(
      String authenticationParameter, ComponentFactory componentFactory) throws Exception {
    Authenticator authenticator = new PromiscuousAuthenticator();
    if (authenticationParameter != null) {
      if (new File(authenticationParameter).exists())
        authenticator = new MultiUserAuthenticator(authenticationParameter);
      else {
        String[] values = authenticationParameter.split(":");
        authenticator = new OneUserAuthenticator(values[0], values[1]);
      }
    }

    return componentFactory.getAuthenticator(authenticator);
  }
Esempio n. 12
0
  public void testAddPlugins() throws Exception {
    testProperties.setProperty(ComponentFactory.PLUGINS, DummyPlugin.class.getName());

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

    assertMatch("!today", false);

    String output = factory.loadPlugins(responderFactory, wikiPageFactory);

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

    assertEquals(InMemoryPage.class, wikiPageFactory.getWikiPageClass());
    assertEquals(WikiPageResponder.class, responderFactory.getResponderClass("custom1"));
    assertEquals(EditResponder.class, responderFactory.getResponderClass("custom2"));
    assertMatch("!today", true);
  }
Esempio n. 13
0
  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 = factory.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"));
  }
Esempio n. 14
0
  private static FitNesseContext loadContext(Arguments arguments) throws Exception {
    FitNesseContext context = new FitNesseContext();
    ComponentFactory componentFactory = new ComponentFactory(context.rootPath);
    context.port = arguments.getPort();
    context.rootPath = arguments.getRootPath();
    context.rootPageName = arguments.getRootDirectory();
    context.rootPagePath = context.rootPath + "/" + context.rootPageName;
    context.root =
        componentFactory.getRootPage(
            FileSystemPage.makeRoot(context.rootPath, context.rootPageName));
    context.responderFactory = new ResponderFactory(context.rootPagePath);
    context.logger = makeLogger(arguments);
    context.authenticator = makeAuthenticator(arguments.getUserpass(), componentFactory);
    context.htmlPageFactory = componentFactory.getHtmlPageFactory(new HtmlPageFactory());

    extraOutput = componentFactory.loadResponderPlugins(context.responderFactory);
    extraOutput += componentFactory.loadWikiWidgetPlugins();
    extraOutput += componentFactory.loadWikiWidgetInterceptors();
    extraOutput += componentFactory.loadContentFilter();

    WikiImportTestEventListener.register();

    return context;
  }
Esempio n. 15
0
 public void testAuthenticatorDefaultCreation() throws Exception {
   Authenticator authenticator = factory.getAuthenticator(new PromiscuousAuthenticator());
   assertNotNull(authenticator);
   assertEquals(PromiscuousAuthenticator.class, authenticator.getClass());
 }
Esempio n. 16
0
 public void testShouldUseZipFileRevisionControllerAsDefault() throws Exception {
   VersionsController defaultRevisionController = factory.loadVersionsController();
   assertEquals(ZipFileVersionsController.class, defaultRevisionController.getClass());
 }
Esempio n. 17
0
 private VersionsController createVersionsController(ComponentFactory factory) throws Exception {
   return (VersionsController)
       factory.createComponent(
           ComponentFactory.VERSIONS_CONTROLLER, ZipFileVersionsController.class);
 }