Package org.drools.solver.examples.nqueens

Source Code of org.drools.solver.examples.nqueens.NQueensSmokeTest

package org.drools.solver.examples.nqueens;

import junit.framework.TestCase;
import org.drools.solver.core.Solver;
import org.drools.solver.core.solution.Solution;
import org.drools.solver.config.XmlSolverConfigurer;
import org.drools.solver.examples.common.persistence.XstreamSolutionDaoImpl;
import org.drools.solver.examples.common.persistence.SolutionDao;

/**
* @author Geoffrey De Smet
*/
public class NQueensSmokeTest extends TestCase {

    public static final String SOLVER_CONFIG
            = "/org/drools/solver/examples/nqueens/solver/nqueensSmokeSolverConfig.xml";
    public static final String UNSOLVED_DATA
            = "/org/drools/solver/examples/nqueens/data/unsolvedNQueensSmoke.xml";


    public void testSmoke() {
        XmlSolverConfigurer configurer = new XmlSolverConfigurer();
        configurer.configure(SOLVER_CONFIG);
        Solver solver = configurer.buildSolver();
        SolutionDao solutionDao = new XstreamSolutionDaoImpl();
        Solution startingSolution = solutionDao.readSolution(getClass().getResourceAsStream(UNSOLVED_DATA));
        solver.setStartingSolution(startingSolution);
        solver.solve();
        Solution bestSolution = solver.getBestSolution();
        assertNotNull(bestSolution);
        double bestScore = solver.getBestScore();
        assertEquals(0.0, bestScore);
    }

}
TOP

Related Classes of org.drools.solver.examples.nqueens.NQueensSmokeTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.