-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ issue #15 ] Added SparqlQParser Test case
- Loading branch information
agazzarini
committed
Feb 14, 2015
1 parent
a5d33ba
commit 5eaa108
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
solrdf/src/test/java/org/gazzax/labs/solrdf/search/qparser/SparqlQParserTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.gazzax.labs.solrdf.search.qparser; | ||
|
||
import static org.gazzax.labs.solrdf.TestUtility.randomString; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import org.apache.solr.common.params.SolrParams; | ||
import org.apache.solr.request.SolrQueryRequest; | ||
import org.apache.solr.search.QParser; | ||
import org.apache.solr.search.SyntaxError; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* {@link SparqlQParser} test case. | ||
* | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public class SparqlQParserTestCase { | ||
private QParser cut; | ||
|
||
private SolrQueryRequest request; | ||
private SolrParams localParams; | ||
private SolrParams params; | ||
|
||
@Before | ||
public void setUp() { | ||
request = mock(SolrQueryRequest.class); | ||
} | ||
|
||
/** | ||
* If a null query string is given, then an exception must be raised. | ||
*/ | ||
@Test | ||
public void nullQueryString() { | ||
cut = new SparqlQParser(null, localParams, params, request); | ||
|
||
try { | ||
cut.parse(); | ||
} catch(final SyntaxError expected) { | ||
// Nothing, as this is the expected behaviour | ||
} | ||
} | ||
|
||
/** | ||
* If an invalid query string is given, then an exception must be raised. | ||
*/ | ||
@Test | ||
public void invalidQueryString() { | ||
cut = new SparqlQParser(randomString(), localParams, params, request); | ||
|
||
try { | ||
cut.parse(); | ||
} catch(final SyntaxError expected) { | ||
// Nothing, as this is the expected behaviour | ||
} | ||
} | ||
|
||
/** | ||
* Positive test case. | ||
* | ||
* @throws Exception hopefully never, otherwise the test fails. | ||
*/ | ||
@Test | ||
public void validQueryString() throws Exception { | ||
cut = new SparqlQParser("SELECT * WHERE { ?s ?p ?o }", localParams, params, request); | ||
|
||
try { | ||
cut.parse(); | ||
} catch(final SyntaxError expected) { | ||
// Nothing, as this is the expected behaviour | ||
} | ||
} | ||
} |