//
// $Id: XMLTileSetParserTest.java 3099 2004-08-27 02:21:06Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.threerings.media.tile.tools.xml;

import java.util.HashMap;
import java.util.Iterator;

import java.io.IOException;

import junit.framework.Test;
import junit.framework.TestCase;

import com.threerings.media.tile.TileSet;

public class XMLTileSetParserTest extends TestCase
{
    public XMLTileSetParserTest ()
    {
        super(XMLTileSetParserTest.class.getName());
    }

    @Override
    public void runTest ()
    {
        HashMap<String, TileSet> sets = new HashMap<String, TileSet>();

        XMLTileSetParser parser = new XMLTileSetParser();
        // add some rulesets
        parser.addRuleSet("tilesets/uniform", new UniformTileSetRuleSet());
        parser.addRuleSet("tilesets/swissarmy", new SwissArmyTileSetRuleSet());
        parser.addRuleSet("tilesets/object", new ObjectTileSetRuleSet());

        // load up the tilesets
        try {
            parser.loadTileSets(TILESET_PATH, sets);

            // print them out
            Iterator<TileSet> iter = sets.values().iterator();
            while (iter.hasNext()) {
                iter.next();
                // System.out.println(iter.next());
            }

        } catch (IOException ioe) {
            ioe.printStackTrace();
            fail("loadTileSets() failed");
        }
    }

    public static Test suite ()
    {
        return new XMLTileSetParserTest();
    }

    public static void main (String[] args)
    {
        XMLTileSetParserTest test = new XMLTileSetParserTest();
        test.runTest();
    }

    protected static final String TILESET_PATH =
        "rsrc/media/tile/tools/xml/tilesets.xml";
}
