package ws.prova.test;

/*
 * Copyright (C) 2002-2007 <a href="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</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
 */

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.mandarax.reference.VariableTermImpl;
import ws.prova.Calc;
import ws.prova.RMessageQueue;
import ws.prova.reagent;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Test the ws.prova.Calc class including built-in predicates
 * <p>Title: Prova </p>
 * <p>Description: Test ws.prova.Calc including built-in predicates</p>
 * <p>Copyright: Copyright (C) 2002-2007</p>
 * <p>Company: City University, London, United Kingdom</p>
 *
 * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
 * @version 2.0 <25 March 2007>
 */

public class CalcTest extends TestCase {
	final String k_agent = "prova";
	final String k_port = "7778";

	reagent prova;
	Calc calc;

	public CalcTest(String s) {
		super(s);
	}

	protected void setUp() throws Exception {
		super.setUp();
		RMessageQueue queue = new RMessageQueue(k_agent, 0);

		//Create a Prova engine without communication protocols and empty input rulebase
		prova = new reagent(k_agent, k_port, queue, new ws.prova.TaskQueue(),
				null, "", true, null);
		// .. and run it
		prova.run();
		calc = prova.getCalc();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public static Test suite() {
		TestSuite suite = new TestSuite(CalcTest.class);
		return suite;
	}

	public void testFopen() throws Exception {
		try {
			List bindings = new ArrayList();
			Object[] r = new Object[]{"nosuchfile.xml", new VariableTermImpl()};
			calc.fopen(r, bindings);
			fail("Should have thrown a java.io.IOException");
		} catch (IOException ex) {
		}
	}

	public void testCapture_enum() throws Exception {
//		fail("Test is not implemented");
	}
}