<commit_before>// Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the GNU General Public License version 2 or later.
package fitnesse;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import fitnesse.authentication.Authenticator;
import fitnesse.authentication.PromiscuousAuthenticator;
import fitnesse.html.HtmlPageFactory;
import fitnesse.responders.ResponderFactory;
import fitnesse.responders.WikiPageResponder;
import fitnesse.responders.editing.ContentFilter;
import fitnesse.responders.editing.EditResponder;
import fitnesse.responders.editing.SaveResponder;
import fitnesse.revisioncontrol.NullRevisionController;
import fitnesse.revisioncontrol.RevisionController;
import fitnesse.revisioncontrol.ZipFileRevisionController;
import fitnesse.testutil.RegexTestCase;
import fitnesse.testutil.SimpleAuthenticator;
import fitnesse.wiki.FileSystemPage;
import fitnesse.wiki.InMemoryPage;
import fitnesse.wiki.WikiPage;
import fitnesse.wikitext.WidgetBuilder;
import fitnesse.wikitext.WidgetInterceptor;
import fitnesse.wikitext.WikiWidget;
import fitnesse.wikitext.widgets.BoldWidget;
import fitnesse.wikitext.widgets.ItalicWidget;
import fitnesse.wikitext.widgets.WidgetRoot;

public class ComponentFactoryTest extends RegexTestCase {
    private Properties testProperties;
    private ComponentFactory factory;

    @Override
    public void setUp() throws Exception {
        testProperties = new Properties();
        factory = new ComponentFactory(".");
    }

    private void saveTestProperties() throws IOException {
        String propertiesFile = ComponentFactory.PROPERTIES_FILE;
        FileOutputStream fileOutputStream = new FileOutputStream(propertiesFile);
        testProperties.store(fileOutputStream, "Test ComponentFactory Properties File");
        fileOutputStream.close();
    }

    @Override
    public void tearDown() throws Exception {
        final File file = new File(ComponentFactory.PROPERTIES_FILE);
        FileOutputStream out = new FileOutputStream(file);
        out.write("".getBytes());
        out.close();
        file.delete();
        TestWidgetInterceptor.widgetsIntercepted.clear();
    }

    public void testRootPageCreation() throws Exception {
        testProperties.setProperty(ComponentFactory.WIKI_PAGE_CLASS, InMemoryPage.class.getName());
        saveTestProperties();

        factory.loadProperties();
        WikiPage page = factory.getRootPage(null);
        assertNotNull(page);
        assertEquals(InMemoryPage.class, page.getClass());
    }

    public void testDefaultRootPage() throws Exception {
        factory.loadProperties();
        WikiPage page = factory.getRootPage(FileSystemPage.makeRoot("testPath", "TestRoot"));
        assertNotNull(page);
        assertEquals(FileSystemPage.class, page.getClass());
        assertEquals("TestRoot", page.getName());
    }<commit_msg>Test was deleting Plugins.properties file which was causing some tests to break. <commit_after>// Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the GNU General Public License version 2 or later.
package fitnesse;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import fitnesse.authentication.Authenticator;
import fitnesse.authentication.PromiscuousAuthenticator;
import fitnesse.html.HtmlPageFactory;
import fitnesse.responders.ResponderFactory;
import fitnesse.responders.WikiPageResponder;
import fitnesse.responders.editing.ContentFilter;
import fitnesse.responders.editing.EditResponder;
import fitnesse.responders.editing.SaveResponder;
import fitnesse.revisioncontrol.NullRevisionController;
import fitnesse.revisioncontrol.RevisionController;
import fitnesse.revisioncontrol.ZipFileRevisionController;
import fitnesse.testutil.RegexTestCase;
import fitnesse.testutil.SimpleAuthenticator;
import fitnesse.wiki.FileSystemPage;
import fitnesse.wiki.InMemoryPage;
import fitnesse.wiki.WikiPage;
import fitnesse.wikitext.WidgetBuilder;
import fitnesse.wikitext.WidgetInterceptor;
import fitnesse.wikitext.WikiWidget;
import fitnesse.wikitext.widgets.BoldWidget;
import fitnesse.wikitext.widgets.ItalicWidget;
import fitnesse.wikitext.widgets.WidgetRoot;

public class ComponentFactoryTest extends RegexTestCase {
    private Properties testProperties;
    private ComponentFactory factory;

    @Override
    public void setUp() throws Exception {
        testProperties = new Properties();
        factory = new ComponentFactory(".");
    }

    private void saveTestProperties() throws IOException {
        String propertiesFile = ComponentFactory.PROPERTIES_FILE;
        FileOutputStream fileOutputStream = new FileOutputStream(propertiesFile);
        testProperties.store(fileOutputStream, "Test ComponentFactory Properties File");
        fileOutputStream.close();
    }

    @Override
    public void tearDown() throws Exception {
        final File file = new File(ComponentFactory.PROPERTIES_FILE);
        FileOutputStream out = new FileOutputStream(file);
        out.write("".getBytes());
        out.close();
        TestWidgetInterceptor.widgetsIntercepted.clear();
    }

    public void testRootPageCreation() throws Exception {
        testProperties.setProperty(ComponentFactory.WIKI_PAGE_CLASS, InMemoryPage.class.getName());
        saveTestProperties();

        factory.loadProperties();
        WikiPage page = factory.getRootPage(null);
        assertNotNull(page);
        assertEquals(InMemoryPage.class, page.getClass());
    }

    public void testDefaultRootPage() throws Exception {
        factory.loadProperties();
        WikiPage page = factory.getRootPage(FileSystemPage.makeRoot("testPath", "TestRoot"));
        assertNotNull(page);
        assertEquals(FileSystemPage.class, page.getClass());
        assertEquals("TestRoot", page.getName());
    }
{'fraction_non_alphanumeric': 0.08545603944124898, 'fraction_numerical': 0.0042728019720624484, 'mean_word_length': 4.6613953488372095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4425861', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1602, 'n_words': 357}