<commit_before>// OO jDREW - An Object Oriented extension of the Java Deductive Reasoning Engine for the Web
// Copyright (C) 2005 <NAME>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

package org.ruleml.oojdrew.tests;

import junit.framework.TestCase;

import org.ruleml.oojdrew.Configuration;
import org.ruleml.oojdrew.parsing.RuleMLParser;
import org.ruleml.oojdrew.parsing.RuleMLParser.RuleMLFormat;

public class RuleMLParserTest extends TestCase {
	private Configuration config;
	
	public static void main(String[] args)
	{
		try
		{
			RuleMLParserTest test = new RuleMLParserTest("RuleML 0.91 Compatibility Parsing (discount)");
			test.testRuleML91CompatibilityParsing();
			
			test = new RuleMLParserTest("RuleML 0.91 Parsing (discount)");
			test.testRuleML91Parsing();
			
			test = new RuleMLParserTest("RuleML 1.0 Parsing (discount)");
			test.testRuleML100Parsing();
			
			System.out.println("All tests passed.");
		} catch (Exception e)
		{
			e.printStackTrace();
		}
		
	}
	
	public RuleMLParserTest(String testName)
	{
		super(testName);
		this.config = new MockConfiguration();
		config.setValidateRuleMLEnabled(false);
	}

	public void testRuleML91CompatibilityParsing()
	{
		genericRuleMLParsingTest("src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount_091_compat.ruleml.xml", false);
	}
	
	public void testRuleML91Parsing()
	{
		genericRuleMLParsingTest("src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount-0.91.ruleml.xml", false);
	}
	
	public void testRuleML100Parsing()
	{
		genericRuleMLParsingTest("src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount-1.0.ruleml.xml", false);
	}
	
	public void testRuleML100WithoutRoot()
	{
		genericRuleMLParsingTest("src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/studycourse.ruleml.xml", false);
	}
	
	public void genericRuleMLParsingTest(String ruleMLFile, boolean shouldThrow)
	{
		boolean thrown = false;

		RuleMLParser rmlParser = new RuleMLParser(config);
		
		try {
			rmlParser.parseFile(RuleMLFormat.RuleML91, ruleMLFile);
		} catch (Exception e1) {
			e1.printStackTrace();
			thrown = true;
		}
		
		// Parsing in compatibility mode should throw no exception
		assertEquals(shouldThrow, thrown);
	}
}<commit_msg>Fixed RuleML parser test: added distinction between RuleML versions<commit_after>// OO jDREW - An Object Oriented extension of the Java Deductive Reasoning Engine for the Web
// Copyright (C) 2005 <NAME>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

package org.ruleml.oojdrew.tests;

import junit.framework.TestCase;

import org.ruleml.oojdrew.Configuration;
import org.ruleml.oojdrew.parsing.RuleMLParser;
import org.ruleml.oojdrew.parsing.RuleMLParser.RuleMLFormat;

public class RuleMLParserTest extends TestCase {
    private Configuration config;

    public static void main(String[] args) {
	try {
	    RuleMLParserTest test = new RuleMLParserTest(
		    "RuleML 0.91 Compatibility Parsing (discount)");
	    test.testRuleML91CompatibilityParsing();

	    test = new RuleMLParserTest("RuleML 0.91 Parsing (discount)");
	    test.testRuleML91Parsing();

	    test = new RuleMLParserTest("RuleML 1.0 Parsing (discount)");
	    test.testRuleML100Parsing();

	    System.out.println("All tests passed.");
	} catch (Exception e) {
	    e.printStackTrace();
	}

    }

    public RuleMLParserTest(String testName) {
	super(testName);
	this.config = new MockConfiguration();
	config.setValidateRuleMLEnabled(false);
    }

    public void testRuleML91CompatibilityParsing() {
	genericRuleMLParsingTest(
		"src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount_091_compat.ruleml.xml",
		RuleMLFormat.RuleML91, false);
    }

    public void testRuleML91Parsing() {
	genericRuleMLParsingTest(
		"src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount-0.91.ruleml.xml",
		RuleMLFormat.RuleML91, false);
    }

    public void testRuleML100Parsing() {
	genericRuleMLParsingTest(
		"src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/discount-1.0.ruleml.xml",
		RuleMLFormat.RuleML100, false);
    }

    public void testRuleML100WithoutRoot() {
	genericRuleMLParsingTest(
		"src/test/java/org/ruleml/oojdrew/tests/RuleMLTestCases/studycourse.ruleml.xml",
		RuleMLFormat.RuleML100, false);
    }

    public void genericRuleMLParsingTest(String ruleMLFile,
	    RuleMLFormat rmlFormat, boolean shouldThrow) {
	boolean thrown = false;

	RuleMLParser rmlParser = new RuleMLParser(config);

	try {
	    rmlParser.parseFile(rmlFormat, ruleMLFile);
	} catch (Exception e1) {
	    e1.printStackTrace();
	    thrown = true;
	}

	// Parsing in compatibility mode should throw no exception
	assertEquals(shouldThrow, thrown);
    }
}
{'fraction_non_alphanumeric': 0.09499506091537702, 'fraction_numerical': 0.019097793875535066, 'mean_word_length': 4.201198630136986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '2274408', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1850, 'n_words': 519}