package net.jforum.bbcode;


/*
 * Copyright (c) JForum Team. All rights reserved.
 *
 * The software in this package is published under the terms of the LGPL
 * license a copy of which has been included with this distribution in the
 * license.txt file.
 *
 * The JForum Project
 * http://www.jforum.net
 */

import net.jforum.formatters.BBCode;
import net.jforum.formatters.BBCodeConfigParser;
import net.jforum.formatters.BBConfigFormatter;

 import java.io.File;
 import java.util.HashMap;
import java.util.Map;
import net.jforum.formatters.PostOptions;
import org.junit.Before;

/**
 * @author Rafael Steil
 */
public abstract class TagBaseTest {
    protected BBConfigFormatter formatter = new BBConfigFormatter();
    protected Map<String, BBCode> bbCodes = new HashMap<String, BBCode>();

    @Before
    public void setup() {
        String filePath = this.getClass().getResource("/").getFile();
        filePath = filePath.substring(0, filePath.length() - "/target/tests/".length())
                + "/webapp/WEB-INF/classes/jforumConfig/bb_config.xml";

        File file = new File(filePath);
        BBConfigFormatter customFormatter = new BBConfigFormatter() {
            @Override
            public void addBb(BBCode code) {
                bbCodes.put(code.getTagName(), code);
            }
        };

        new BBCodeConfigParser(file,customFormatter);
    }

    protected PostOptions defaultOptions() {
        return new PostOptions(false, false, true, false, null);
    }
}