serializationtests.java

来自「Mandarax是一个规则引擎的纯Java实现。它支持多类型的事实和基于反映的规」· Java 代码 · 共 108 行

JAVA
108
字号
/*
 * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
 *
 * 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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package test.org.mandarax.ser;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.mandarax.kernel.LogicFactory;
/**
 * Test suite for serialization of mandarax related objects.
 * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
 * @version 3.4 <7 March 05>
 * @since 1.9.1
 */
public class SerializationTests {
    /**
     * Launch the test suite. See TestRunner for interpretation
     * of command line parameters.
     * @see test.org.mandarax.testsupport.TestRunner
     * @param args parameters
     */
    public static void main(String[] args) {
        org.apache.log4j.BasicConfigurator.configure ();
        test.org.mandarax.testsupport.TestRunner.run (SerializationTests.class, args);
    }
    /**
     * Get the test suite.
     * @return the test suite
     */
    public static Test suite() {
    	LogicFactory lfactory = LogicFactory.getDefaultFactory();
    	
        TestSuite suite = new TestSuite ("Test cases for serialization");
        
        // objects referenced in other test cases
        addTest(SerializationTestCase4SerializableTestObjects.class,suite,lfactory);
        addTest(SerializationTestCase4SerializableDataSourceDummies.class,suite,lfactory);
        // functions and predicates
        addTest(SerializationTestCase4SimplePredicates.class,suite,lfactory);
        addTest(SerializationTestCase4JFunctions.class,suite,lfactory);
        addTest(SerializationTestCase4DynaBeanFunctions.class,suite,lfactory);
        addTest(SerializationTestCase4MandaraxLibFunctions.class,suite,lfactory);
        addTest(SerializationTestCase4JPredicates.class,suite,lfactory);
        addTest(SerializationTestCase4MandaraxLibPredicates.class,suite,lfactory);
        // sql functions, predicates and clause sets
        addTest(SerializationTestCase4SQLPredicates.class,suite,lfactory);
		addTest(SerializationTestCase4SQLFunctions.class,suite,lfactory);		
		addTest(SerializationTestCase4SQLClauseSets.class,suite,lfactory);
		
        // terms
        addTest(SerializationTestCase4ConstantTerms.class,suite,lfactory);
        addTest(SerializationTestCase4VariableTerms.class,suite,lfactory);
        addTest(SerializationTestCase4ComplexTerms.class,suite,lfactory);        
        // clause sets      
        addTest(SerializationTestCase4Rules.class,suite,lfactory);
        addTest(SerializationTestCase4Facts.class,suite,lfactory);
        addTest(SerializationTestCase4Queries.class,suite,lfactory);
        // knowledge bases
        addTest(SerializationTestCase4KnowledgeBases.class,suite,lfactory);
        addTest(SerializationTestCase4AdvancedKnowledgeBases.class,suite,lfactory);
        // misc
		addTest(SerializationTestCase4Comparators.class,suite,lfactory);
        
        return suite;
    }
    /**
     * Add a test to a test suite.
     * @param testClass the test class
     * @param suite a test suite
     * @param lfactory the logic factory used to create objects
     */
    private static void addTest(Class testClass,TestSuite suite,LogicFactory lfactory) {
    	try {
    		SerializationTestCase test = (SerializationTestCase)testClass.newInstance();
    		test.setSerializationMode(SerializationTestCase.BIN_SERIALIZE);
    		test.setLogicFactory(lfactory);
    		suite.addTest(test);
    		
			test = (SerializationTestCase)testClass.newInstance();
			test.setSerializationMode(SerializationTestCase.XML_SERIALIZE);
			test.setLogicFactory(lfactory);
			suite.addTest(test);   
			
			test = (SerializationTestCase)testClass.newInstance();
			test.setSerializationMode(SerializationTestCase.XML_SERIALIZE_WITH_DELEGATES);
			test.setLogicFactory(lfactory);
			suite.addTest(test);    	 		
    	}
    	catch (Exception x) {
    		x.printStackTrace();
    	}
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?