| 1 |
|
package net.sourceforge.pebble.util.importer; |
| 2 |
|
|
| 3 |
|
import net.sourceforge.pebble.domain.Blog; |
| 4 |
|
import net.sourceforge.pebble.domain.BlogEntry; |
| 5 |
|
import net.sourceforge.pebble.domain.Comment; |
| 6 |
|
import net.sourceforge.pebble.domain.SingleBlogTestCase; |
| 7 |
|
|
| 8 |
|
import java.io.File; |
| 9 |
|
import java.util.List; |
| 10 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (79) |
Complexity: 8 |
Complexity Density: 0,11 |
|
| 11 |
|
public class MovableTypeImporterTest extends SingleBlogTestCase { |
| 12 |
|
private File testCasesDir = new File(TEST_RESOURCE_LOCATION, "mt_testcases"); |
| 13 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
| 14 |
2
|
public void testImport() throws Exception {... |
| 15 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 16 |
2
|
File source = new File(testCasesDir, "exported.txt"); |
| 17 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 18 |
2
|
blog.reindex(); |
| 19 |
2
|
List list = blog.getBlogEntries(); |
| 20 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 21 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 22 |
2
|
assertEquals("excerpt", "excerpt", entry.getContent()); |
| 23 |
2
|
assertEquals("excerpt", "excerpt", entry.getExcerpt()); |
| 24 |
|
|
| 25 |
2
|
assertEquals("body", "body<br />extended body", entry.getBody()); |
| 26 |
|
} |
| 27 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 28 |
2
|
public void testNoPrimaryCategory() throws Exception {... |
| 29 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 30 |
2
|
File source = new File(testCasesDir, "noprimarycategory.txt"); |
| 31 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 32 |
2
|
blog.reindex(); |
| 33 |
2
|
List list = blog.getBlogEntries(); |
| 34 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 35 |
|
} |
| 36 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1
PASS
|
|
| 37 |
2
|
public void testMultipleSubCategory() throws Exception {... |
| 38 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 39 |
2
|
File source = new File(testCasesDir, "multiplesubcategory.txt"); |
| 40 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 41 |
2
|
blog.reindex(); |
| 42 |
2
|
blog.reindex(); |
| 43 |
2
|
List list = blog.getBlogEntries(); |
| 44 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
} |
| 52 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
| 53 |
2
|
public void testNoExcerpt() throws Exception {... |
| 54 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 55 |
2
|
File source = new File(testCasesDir, "noexcerpt.txt"); |
| 56 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 57 |
2
|
blog.reindex(); |
| 58 |
2
|
List list = blog.getBlogEntries(); |
| 59 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 60 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 61 |
2
|
assertEquals("content", "body", entry.getContent()); |
| 62 |
2
|
assertEquals("excerpt", "body", entry.getExcerpt()); |
| 63 |
|
|
| 64 |
2
|
assertEquals("body", "body<br />extended body", entry.getBody()); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
| 67 |
2
|
public void testNoExcerptNoExtendedBody() throws Exception {... |
| 68 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 69 |
2
|
File source = new File(testCasesDir, "noexcerpt_noextendedbody.txt"); |
| 70 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 71 |
2
|
blog.reindex(); |
| 72 |
2
|
List list = blog.getBlogEntries(); |
| 73 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 74 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 75 |
2
|
assertEquals("content", "body", entry.getContent()); |
| 76 |
2
|
assertEquals("excerpt", "", entry.getExcerpt()); |
| 77 |
|
|
| 78 |
2
|
assertEquals("body", "body", entry.getBody()); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
1
PASS
|
|
| 81 |
2
|
public void testUTF8() throws Exception {... |
| 82 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 83 |
2
|
File source = new File(testCasesDir, "utf8.txt"); |
| 84 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 85 |
2
|
blog.reindex(); |
| 86 |
2
|
List list = blog.getBlogEntries(); |
| 87 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 88 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 89 |
2
|
assertEquals("content", "\u65E5\u672C\u8A9Eexcerpt", entry.getContent()); |
| 90 |
2
|
assertEquals("title", "\u65E5\u672C\u8A9E", entry.getTitle()); |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
1
PASS
|
|
| 93 |
2
|
public void testPublished() throws Exception {... |
| 94 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 95 |
2
|
File source = new File(testCasesDir, "exported.txt"); |
| 96 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 97 |
2
|
blog.reindex(); |
| 98 |
2
|
List list = blog.getBlogEntries(); |
| 99 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 100 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 101 |
2
|
assertTrue("publised", entry.isPublished()); |
| 102 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
| 103 |
2
|
public void testComment() throws Exception {... |
| 104 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "Japan/Tokyo"); |
| 105 |
2
|
File source = new File(testCasesDir, "withcomment.txt"); |
| 106 |
2
|
MovableTypeImporter.main(new String[]{source.getAbsolutePath(), blog.getRoot(), "Tokyo/Japan"}); |
| 107 |
2
|
blog.reindex(); |
| 108 |
2
|
List list = blog.getBlogEntries(); |
| 109 |
2
|
assertEquals("size of entry", 1, list.size()); |
| 110 |
2
|
BlogEntry entry = (BlogEntry) list.get(0); |
| 111 |
2
|
assertTrue("publised", entry.isPublished()); |
| 112 |
2
|
List<Comment> comments = entry.getComments(); |
| 113 |
2
|
assertEquals("size of comments", 1, comments.size()); |
| 114 |
2
|
System.out.println(blog.getRoot()); |
| 115 |
|
} |
| 116 |
|
} |