| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
package net.sourceforge.pebble.index; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.domain.*; |
| 35 |
|
import net.sourceforge.pebble.search.SearchResults; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@author |
| 41 |
|
|
|
|
|
| 88% |
Uncovered Elements: 10 (83) |
Complexity: 11 |
Complexity Density: 0,14 |
|
| 42 |
|
public class SearchIndexTest extends SingleBlogTestCase { |
| 43 |
|
|
| 44 |
|
private SearchIndex index; |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
| 46 |
10
|
protected void setUp() throws Exception {... |
| 47 |
10
|
super.setUp(); |
| 48 |
|
|
| 49 |
10
|
index = new SearchIndex(blog); |
| 50 |
10
|
index.clear(); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 2 |
Complexity Density: 0,18 |
1
PASS
|
|
| 56 |
2
|
public void testSearchOnTitle() {... |
| 57 |
2
|
try { |
| 58 |
2
|
SearchResults results = index.search("jsp"); |
| 59 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 60 |
|
|
| 61 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 62 |
2
|
blogEntry.setTitle("Some JSP topic"); |
| 63 |
2
|
blogEntry.setPublished(true); |
| 64 |
2
|
index.index(blogEntry); |
| 65 |
|
|
| 66 |
2
|
results = index.search("jsp"); |
| 67 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 68 |
|
} catch (Exception e) { |
| 69 |
0
|
e.printStackTrace(); |
| 70 |
0
|
fail(); |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 2 |
Complexity Density: 0,18 |
1
PASS
|
|
| 77 |
2
|
public void testSearchOnBody() {... |
| 78 |
2
|
try { |
| 79 |
2
|
SearchResults results = index.search("jsp"); |
| 80 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 81 |
|
|
| 82 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 83 |
2
|
blogEntry.setBody("Some JSP topic"); |
| 84 |
2
|
blogEntry.setPublished(true); |
| 85 |
2
|
index.index(blogEntry); |
| 86 |
|
|
| 87 |
2
|
results = index.search("jsp"); |
| 88 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 89 |
|
} catch (Exception e) { |
| 90 |
0
|
e.printStackTrace(); |
| 91 |
0
|
fail(); |
| 92 |
|
} |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
|
|
|
| 89,5% |
Uncovered Elements: 2 (19) |
Complexity: 2 |
Complexity Density: 0,11 |
1
PASS
|
|
| 98 |
2
|
public void testSearchOnCategory() {... |
| 99 |
2
|
try { |
| 100 |
2
|
blog.addCategory(new Category("/category1", "Category 1")); |
| 101 |
2
|
blog.addCategory(new Category("/category2", "Category 2")); |
| 102 |
|
|
| 103 |
2
|
SearchResults results = index.search("category:/category1"); |
| 104 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 105 |
|
|
| 106 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 107 |
2
|
blogEntry.addCategory(blog.getCategory("/category1")); |
| 108 |
2
|
blogEntry.setPublished(true); |
| 109 |
2
|
index.index(blogEntry); |
| 110 |
|
|
| 111 |
2
|
results = index.search("category:/category1"); |
| 112 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 113 |
|
|
| 114 |
|
|
| 115 |
2
|
blogEntry.addCategory(blog.getCategory("/category2")); |
| 116 |
2
|
index.index(blogEntry); |
| 117 |
|
|
| 118 |
2
|
results = index.search("category:/category1"); |
| 119 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 120 |
2
|
results = index.search("category:/category2"); |
| 121 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 122 |
|
} catch (Exception e) { |
| 123 |
0
|
e.printStackTrace(); |
| 124 |
0
|
fail(); |
| 125 |
|
} |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
|
|
|
| 90,5% |
Uncovered Elements: 2 (21) |
Complexity: 2 |
Complexity Density: 0,1 |
1
PASS
|
|
| 131 |
2
|
public void testSearchOnComments() {... |
| 132 |
2
|
try { |
| 133 |
2
|
SearchResults results = index.search("swing"); |
| 134 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 135 |
|
|
| 136 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 137 |
2
|
blogEntry.addCategory(blog.getCategory("/category1")); |
| 138 |
2
|
blogEntry.setPublished(true); |
| 139 |
2
|
index.index(blogEntry); |
| 140 |
|
|
| 141 |
|
|
| 142 |
2
|
results = index.search("swing"); |
| 143 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 144 |
|
|
| 145 |
|
|
| 146 |
2
|
Comment comment = blogEntry.createComment("Comment title", "Comment body", "Some author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
| 147 |
2
|
blogEntry.addComment(comment); |
| 148 |
2
|
index.index(blogEntry); |
| 149 |
2
|
results = index.search("swing"); |
| 150 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 151 |
|
|
| 152 |
2
|
comment = blogEntry.createComment("Comment title", "Comment body with Swing in it", "Some author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
| 153 |
2
|
blogEntry.addComment(comment); |
| 154 |
2
|
index.index(blogEntry); |
| 155 |
2
|
results = index.search("swing"); |
| 156 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 157 |
|
} catch (Exception e) { |
| 158 |
0
|
e.printStackTrace(); |
| 159 |
0
|
fail(); |
| 160 |
|
} |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
|
|
|
| 83,3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0,17 |
1
PASS
|
|
| 166 |
2
|
public void testSearchOnRemovedBlogEntry() {... |
| 167 |
2
|
try { |
| 168 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 169 |
2
|
blogEntry.setTitle("Some JSP topic"); |
| 170 |
2
|
blogEntry.setPublished(true); |
| 171 |
2
|
index.index(blogEntry); |
| 172 |
|
|
| 173 |
2
|
SearchResults results = index.search("jsp"); |
| 174 |
2
|
assertEquals(1, results.getNumberOfHits()); |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
2
|
index.unindex(blogEntry); |
| 179 |
2
|
results = index.search("jsp"); |
| 180 |
2
|
assertEquals(0, results.getNumberOfHits()); |
| 181 |
|
} catch (Exception e) { |
| 182 |
0
|
e.printStackTrace(); |
| 183 |
0
|
fail(); |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
} |