| 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.decorator; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.domain.SingleBlogTestCase; |
| 35 |
|
import net.sourceforge.pebble.domain.BlogEntry; |
| 36 |
|
import net.sourceforge.pebble.domain.Category; |
| 37 |
|
import net.sourceforge.pebble.api.decorator.ContentDecorator; |
| 38 |
|
import net.sourceforge.pebble.api.decorator.ContentDecoratorContext; |
| 39 |
|
|
| 40 |
|
import java.util.Calendar; |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@author |
| 46 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 3 |
Complexity Density: 0,15 |
|
| 47 |
|
public class TrackBackAutoDiscoveryDecoratorTest extends SingleBlogTestCase { |
| 48 |
|
|
| 49 |
|
private static final String DISCOVERY_TEXT_START; |
| 50 |
|
private static final String DISCOVERY_TEXT_END; |
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 51 |
2
|
static {... |
| 52 |
2
|
DISCOVERY_TEXT_START = "\n<!--\n" + |
| 53 |
|
"<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + |
| 54 |
|
" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" + |
| 55 |
|
" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">\n" + |
| 56 |
|
"<rdf:Description\n" + |
| 57 |
|
" rdf:about=\"http://www.yourdomain.com/blog/2006/07/14/1152860400000.html\"\n" + |
| 58 |
|
" dc:identifier=\"http://www.yourdomain.com/blog/2006/07/14/1152860400000.html\"\n" + |
| 59 |
|
" dc:title=\"Title\"\n" + |
| 60 |
|
" trackback:ping=\"http://www.yourdomain.com/blog/addTrackBack.action?entry=1152860400000&token="; |
| 61 |
2
|
DISCOVERY_TEXT_END = "\" />\n" + |
| 62 |
|
"</rdf:RDF>\n" + |
| 63 |
|
"-->"; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
private ContentDecorator decorator; |
| 67 |
|
private BlogEntry blogEntry; |
| 68 |
|
private ContentDecoratorContext context; |
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0,07 |
|
| 70 |
2
|
protected void setUp() throws Exception {... |
| 71 |
2
|
super.setUp(); |
| 72 |
|
|
| 73 |
2
|
blogEntry = new BlogEntry(blog); |
| 74 |
2
|
blogEntry.setTitle("Title"); |
| 75 |
2
|
blogEntry.setBody("Body"); |
| 76 |
2
|
Calendar cal= blog.getCalendar(); |
| 77 |
2
|
cal.set(Calendar.YEAR, 2006); |
| 78 |
2
|
cal.set(Calendar.MONTH, 6); |
| 79 |
2
|
cal.set(Calendar.DAY_OF_MONTH, 14); |
| 80 |
2
|
cal.set(Calendar.HOUR_OF_DAY, 8); |
| 81 |
2
|
cal.set(Calendar.MINUTE, 0); |
| 82 |
2
|
cal.set(Calendar.SECOND, 0); |
| 83 |
2
|
cal.set(Calendar.MILLISECOND, 0); |
| 84 |
2
|
blogEntry.setDate(cal.getTime()); |
| 85 |
2
|
decorator = new TrackBackAutoDiscoveryDecorator(); |
| 86 |
2
|
context = new ContentDecoratorContext(); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
| 92 |
2
|
public void testDecoration() throws Exception {... |
| 93 |
2
|
decorator.decorate(context, blogEntry); |
| 94 |
2
|
assertTrue(blogEntry.getBody().startsWith("Body" + DISCOVERY_TEXT_START)); |
| 95 |
2
|
assertTrue(blogEntry.getBody().endsWith(DISCOVERY_TEXT_END)); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
} |