/*
 *  Copyright (C) 2011 The Animo Project
 *  http://animotron.org
 *
 *  This program 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 3
 *  of the License, or (at your option) any later version.
 *
 *  This program 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 program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
package org.animotron.games.geo;

import com.ctc.wstx.stax.WstxInputFactory;
import org.animotron.ATest;
import org.animotron.expression.StAXExpression;
import org.animotron.graph.builder.FastGraphBuilder;
import org.junit.Assert;
import org.junit.Test;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import static org.animotron.Properties.HASH;


/**
 * @author <a href="mailto:gazdovsky@gmail.com">Evgeny Gazdovsky</a>
 *
 */
public class GeoTest extends ATest {

    private XMLInputFactory FACTORY = new WstxInputFactory();

    private static final String OSM = "/geo/map.osm";

    private XMLStreamReader osm() throws XMLStreamException {
        return osm(OSM);
    }

    private XMLStreamReader osm(String resource) throws XMLStreamException {
        return FACTORY.createXMLStreamReader(getClass().getResourceAsStream(resource));
    }

    @Test
	public void test_01() throws Exception {
        String in = (String) HASH.get(new StAXExpression(new FastGraphBuilder(), osm()));
        cleanDb();
        String out = (String) HASH.get(new StAXExpression(osm()));
        Assert.assertEquals(in, out);
	}

    @Test
	public void test_02() throws Exception {
        String in = (String) HASH.get(new StAXExpression(new FastGraphBuilder(), osm()));
        String out = (String) HASH.get(new StAXExpression(osm()));
        Assert.assertEquals(in, out);
	}

    @Test
	public void test_03() throws Exception {
        String in = (String) HASH.get(new StAXExpression(osm()));
        String out = (String) HASH.get(new StAXExpression(new FastGraphBuilder(), osm()));
        Assert.assertEquals(in, out);
	}

    @Test
	public void test() throws Exception {
        new StAXExpression(osm());
	}

}

@@ -1225,16 +1225,61 @@
 s.HASH;%0A
+import static org.animotron.graph.Cache.key;%0A
 %0A%0A/**%0A *
@@ -1847,32 +1847,36 @@
 g in = (String) 
+key(
 HASH.get(new StA
@@ -1910,32 +1910,33 @@
 ilder(), osm()))
+)
 ;%0A        cleanD
@@ -1962,32 +1962,36 @@
  out = (String) 
+key(
 HASH.get(new StA
@@ -2001,32 +2001,33 @@
 pression(osm()))
+)
 ;%0A        Assert
@@ -2127,32 +2127,36 @@
 g in = (String) 
+key(
 HASH.get(new StA
@@ -2190,32 +2190,33 @@
 ilder(), osm()))
+)
 ;%0A        String
@@ -2223,32 +2223,36 @@
  out = (String) 
+key(
 HASH.get(new StA
@@ -2262,32 +2262,33 @@
 pression(osm()))
+)
 ;%0A        Assert
@@ -2388,32 +2388,36 @@
 g in = (String) 
+key(
 HASH.get(new StA
@@ -2431,24 +2431,25 @@
 sion(osm()))
+)
 ;%0A        St
@@ -2468,16 +2468,20 @@
 String) 
+key(
 HASH.get
@@ -2531,16 +2531,17 @@
  osm()))
+)
 ;%0A      

fix tests