jaroslav@181: /* jaroslav@181: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. jaroslav@181: * jaroslav@181: * The contents of this file are subject to the terms of either the GNU jaroslav@181: * General Public License Version 2 only ("GPL") or the Common jaroslav@181: * Development and Distribution License("CDDL") (collectively, the jaroslav@181: * "License"). You may not use this file except in compliance with the jaroslav@181: * License. You can obtain a copy of the License at jaroslav@181: * http://www.netbeans.org/cddl-gplv2.html jaroslav@181: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the jaroslav@181: * specific language governing permissions and limitations under the jaroslav@181: * License. When distributing the software, include this License Header jaroslav@181: * Notice in each file and include the License file at jaroslav@181: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this jaroslav@181: * particular file as subject to the "Classpath" exception as provided jaroslav@181: * by Sun in the GPL Version 2 section of the License file that jaroslav@181: * accompanied this code. If applicable, add the following below the jaroslav@181: * License Header, with the fields enclosed by brackets [] replaced by jaroslav@181: * your own identifying information: jaroslav@181: * "Portions Copyrighted [year] [name of copyright owner]" jaroslav@181: * jaroslav@181: * Contributor(s): jaroslav@181: * jaroslav@181: * Portions Copyrighted 2009 Jaroslav Tulach jaroslav@181: */ jaroslav@181: package cz.xelfi.quoridor; jaroslav@181: jaroslav@181: import cz.xelfi.quoridor.Player.Direction; jaroslav@181: import java.io.IOException; jaroslav@181: jaroslav@181: /** Basic tests in simple configuration. jaroslav@181: * jaroslav@181: * @author Jaroslav Tulach jaroslav@181: */ jaroslav@181: public class SerializeCodeTest extends BoardCase { jaroslav@181: public SerializeCodeTest (String testName) { jaroslav@181: super (testName); jaroslav@181: } jaroslav@181: jaroslav@181: @Override jaroslav@181: protected Board move(Board b, int player, Direction... where) throws IllegalPositionException { jaroslav@181: try { jaroslav@181: Board read = reread(b); jaroslav@181: return read.move(read.getPlayers().get(player), where); jaroslav@181: } catch (IOException ex) { jaroslav@181: throw new IllegalStateException(ex); jaroslav@181: } jaroslav@181: } jaroslav@181: protected Board fence(Board b, int player, char x, int y, Fence.Orientation orie) jaroslav@181: throws IllegalPositionException { jaroslav@181: try { jaroslav@181: Board read = reread(b); jaroslav@181: return read.fence(read.getPlayers().get(player), x, y, orie); jaroslav@181: } catch (IOException ex) { jaroslav@181: throw new IllegalStateException(ex); jaroslav@181: } jaroslav@181: } jaroslav@181: jaroslav@181: @Override jaroslav@181: protected Board apply(Board b, Move move) throws IllegalPositionException { jaroslav@181: try { jaroslav@181: Board read = reread(b); jaroslav@181: return read.apply(move); jaroslav@181: } catch (IOException ex) { jaroslav@181: throw new IllegalStateException(ex); jaroslav@181: } jaroslav@181: } jaroslav@181: jaroslav@181: private Board reread(Board b) throws IOException, IllegalPositionException { jaroslav@181: return Board.valueOf(b.getCode()); jaroslav@181: } jaroslav@181: jaroslav@181: }