001    /*
002     * (c) Copyright 2010 University of Bristol
003     * All rights reserved.
004     * [See end of file]
005     */
006    package net.rootdev.javardfa;
007    
008    import net.rootdev.javardfa.query.QueryUtilities;
009    import com.hp.hpl.jena.query.Query;
010    import com.hp.hpl.jena.query.QueryFactory;
011    import com.hp.hpl.jena.sparql.algebra.Algebra;
012    import com.hp.hpl.jena.sparql.sse.SSE;
013    import java.net.URL;
014    import java.util.Map;
015    import net.rootdev.javardfa.ParserFactory.Format;
016    import org.junit.Test;
017    import static org.junit.Assert.*;
018    
019    /**
020     *
021     * @author pldms
022     */
023    public class QueryUtilitiesTest {
024    
025        public QueryUtilitiesTest() {
026        }
027    
028        /**
029         * Test of makeQueries method, of class QueryUtilities.
030         */
031        @Test
032        public void testMakeQueries() throws Exception {
033            Map<String, Query> q =
034                    QueryUtilities.makeQueries(Format.XHTML,
035                    this.getClass().getResource("/query-tests/1.html").toExternalForm());
036            assertEquals("Just the one query", 1, q.entrySet().size());
037            String qId = q.entrySet().iterator().next().getKey();
038            assertTrue("Got the right id for the query", qId.endsWith("/query-tests/1.html#1"));
039            //System.out.println("Query:");
040            SSE.write(Algebra.compile(q.get(qId)));
041            URL u = this.getClass().getResource("/query-tests/1.rq");
042            Query exp = QueryFactory.read(u.toExternalForm());
043            //System.out.println("QueryE:");
044            SSE.write(Algebra.compile(exp));
045            assertEquals("Got the right query", Algebra.compile(exp), Algebra.compile(q.get(qId)));
046        }
047    
048        /**
049         * Test of extractBinding method, of class QueryUtilities.
050         */
051        @Test
052        public void testExtractBinding() {
053            
054        }
055    
056    }
057    
058    /*
059     * (c) Copyright 2010 University of Bristol
060     * All rights reserved.
061     *
062     * Redistribution and use in source and binary forms, with or without
063     * modification, are permitted provided that the following conditions
064     * are met:
065     * 1. Redistributions of source code must retain the above copyright
066     *    notice, this list of conditions and the following disclaimer.
067     * 2. Redistributions in binary form must reproduce the above copyright
068     *    notice, this list of conditions and the following disclaimer in the
069     *    documentation and/or other materials provided with the distribution.
070     * 3. The name of the author may not be used to endorse or promote products
071     *    derived from this software without specific prior written permission.
072     *
073     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
074     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
075     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
076     * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
077     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
078     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
079     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
080     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
081     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
082     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
083     */