Permalink
Browse files

Added a couple more tests.

  • Loading branch information...
1 parent 4bb0440 commit 94383689a7f08fef83b4a11d30210fe4ab9e3c1f @ncb000gt ncb000gt committed Oct 7, 2009
Showing with 68 additions and 0 deletions.
  1. +44 −0 apps/test/LuceneKitchenSink/tests.js
  2. +24 −0 src/java/test/axiom/objectmodel/dom/UrlAnalyzerTest.java
@@ -1076,6 +1076,50 @@ this._test = {
var sink_result = app.getObjects('LuceneKitchenSink', new Filter({url: 'http://www.axiomstack.com/test/path?param1=value1&param2=value2'}, "axiom.objectmodel.dom.UrlAnalyzer"))[0];
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink);
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink_result);
+ Assert.assertEquals("test_url_search_query_string_with_amp_exact failed.", sink, sink_result);
+ },
+ test_url_search_underscore: function() {
+ var sink = this.getKitchenSink();
+ sink.url = "http://www.axiomstack.com/test/path_to_something";
+ res.commit();
+
+ var sink_result = app.getObjects('LuceneKitchenSink', new Filter({url: 'path'}, "axiom.objectmodel.dom.UrlAnalyzer"))[0];
+
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink);
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink_result);
+ Assert.assertEquals("test_url_search_query_string_with_amp_exact failed.", sink, sink_result);
+ },
+ test_url_search_underscore_partial: function() {
+ var sink = this.getKitchenSink();
+ sink.url = "http://www.axiomstack.com/test/path_to_something";
+ res.commit();
+
+ var sink_result = app.getObjects('LuceneKitchenSink', new Filter({url: 'path_to'}, "axiom.objectmodel.dom.UrlAnalyzer"))[0];
+
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink);
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink_result);
+ Assert.assertEquals("test_url_search_query_string_with_amp_exact failed.", sink, sink_result);
+ },
+ test_url_search_underscore_full: function() {
+ var sink = this.getKitchenSink();
+ sink.url = "http://www.axiomstack.com/test/path_to_something";
+ res.commit();
+
+ var sink_result = app.getObjects('LuceneKitchenSink', new Filter({url: 'path_to_something'}, "axiom.objectmodel.dom.UrlAnalyzer"))[0];
+
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink);
+ Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink_result);
+ Assert.assertEquals("test_url_search_query_string_with_amp_exact failed.", sink, sink_result);
+ },
+ test_url_search_underscore_exact: function() {
+ var sink = this.getKitchenSink();
+ sink.url = "http://www.axiomstack.com/test/path_to_something";
+ res.commit();
+
+ var sink_result = app.getObjects('LuceneKitchenSink', new Filter({url: 'http://www.axiomstack.com/test/path_to_something'}, "axiom.objectmodel.dom.UrlAnalyzer"))[0];
+
Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink);
Assert.assertNotUndefined("test_url_search_query_string_with_amp_exact failed.", sink_result);
Assert.assertEquals("test_url_search_query_string_with_amp_exact failed.", sink, sink_result);
@@ -117,4 +117,28 @@ public void testQueryStreamWithAmp() {
assertEquals("Unexpected token found.", "param2", (String)terms.get(5));
assertEquals("Unexpected token found.", "value2", (String)terms.get(6));
}
+
+ public void testQueryStreamWithUnderscore() {
+ UrlAnalyzer analyzer = new UrlAnalyzer();
+ TokenStream ts = analyzer.tokenStream("searchable_url", new StringReader("http://www.axiomstack.com/test/path_to_something"));
+ ArrayList<String> terms = new ArrayList<String>();
+
+ try {
+ Token t = null;
+ while ((t=ts.next())!=null) {
+ terms.add(t.termText());
+ }
+ } catch(IOException ioe) {
+ ioe.printStackTrace();
+ fail("There was an exception.");
+ }
+
+ assertEquals("There were an unexpected number of tokens returned.", 6, terms.size());
+ assertEquals("Unexpected token found.", "http", (String)terms.get(0));
+ assertEquals("Unexpected token found.", "axiomstack", (String)terms.get(1));
+ assertEquals("Unexpected token found.", "test", (String)terms.get(2));
+ assertEquals("Unexpected token found.", "path", (String)terms.get(3));
+ assertEquals("Unexpected token found.", "to", (String)terms.get(4));
+ assertEquals("Unexpected token found.", "something", (String)terms.get(5));
+ }
}

0 comments on commit 9438368

Please sign in to comment.