Pmd2XMLは、3D動画制作ツール、MikuMikuDance(MMD)で用いられるモデルデータファイル(*.pmd)の内容を、XML形式のデータファイルと交換するためのアプリケーションです。
| Revision | 46e7649006782c0f1cc85cf25869787381b77044 (tree) |
|---|---|
| Time | 2013-12-03 02:31:20 |
| Author | <olyutorskii@user...> |
ユニットテスト下請け修正
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | import static org.junit.Assert.*; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * | |
| 20 | + * ファイル変換処理のユニットテスト下請け諸々。 | |
| 21 | 21 | */ |
| 22 | 22 | public class CnvAssert { |
| 23 | 23 |
| @@ -30,7 +30,7 @@ | ||
| 30 | 30 | * @return テンポラリファイル |
| 31 | 31 | * @throws IOException エラー |
| 32 | 32 | */ |
| 33 | - public static File openTempFile() throws IOException{ | |
| 33 | + private static File openTempFile() throws IOException{ | |
| 34 | 34 | File file = File.createTempFile("pmd2xml", null); |
| 35 | 35 | file.deleteOnExit(); |
| 36 | 36 | return file; |
| @@ -43,10 +43,9 @@ | ||
| 43 | 43 | * @param expPmdResource PMDリソース名 |
| 44 | 44 | * @throws Exception エラー |
| 45 | 45 | */ |
| 46 | - public static void assertXml2Pmd( | |
| 47 | - Class<?> klass, | |
| 48 | - String xmlResource, | |
| 49 | - String expPmdResource ) | |
| 46 | + public static void assertXml2Pmd(Class<?> klass, | |
| 47 | + String xmlResource, | |
| 48 | + String expPmdResource ) | |
| 50 | 49 | throws Exception{ |
| 51 | 50 | InputStream xmlis = |
| 52 | 51 | klass.getResourceAsStream(xmlResource); |
| @@ -81,10 +80,43 @@ | ||
| 81 | 80 | * @param expXmlResource XMLリソース名 |
| 82 | 81 | * @throws Exception エラー |
| 83 | 82 | */ |
| 84 | - public static void assertPmd2Xml( | |
| 85 | - Class<?> klass, | |
| 86 | - String pmdResource, | |
| 87 | - String expXmlResource ) | |
| 83 | + public static void assertPmd2Xml(Class<?> klass, | |
| 84 | + String pmdResource, | |
| 85 | + String expXmlResource ) | |
| 86 | + throws Exception{ | |
| 87 | + assertPmd2Xml(klass, pmdResource, expXmlResource, | |
| 88 | + ModelFileType.XML_101009 ); | |
| 89 | + return; | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * PMDリソースをXMLに変換した結果がXMLリソースに等しいと表明する。 | |
| 94 | + * @param klass リソース元クラス | |
| 95 | + * @param pmdResource PMDリソース名 | |
| 96 | + * @param expXmlResource XMLリソース名 | |
| 97 | + * @throws Exception エラー | |
| 98 | + */ | |
| 99 | + public static void assertPmd2Xml13(Class<?> klass, | |
| 100 | + String pmdResource, | |
| 101 | + String expXmlResource ) | |
| 102 | + throws Exception{ | |
| 103 | + assertPmd2Xml(klass, pmdResource, expXmlResource, | |
| 104 | + ModelFileType.XML_130128 ); | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * PMDリソースをXMLに変換した結果がXMLリソースに等しいと表明する。 | |
| 110 | + * @param klass リソース元クラス | |
| 111 | + * @param pmdResource PMDリソース名 | |
| 112 | + * @param expXmlResource XMLリソース名 | |
| 113 | + * @param type XML種別 | |
| 114 | + * @throws Exception エラー | |
| 115 | + */ | |
| 116 | + private static void assertPmd2Xml(Class<?> klass, | |
| 117 | + String pmdResource, | |
| 118 | + String expXmlResource, | |
| 119 | + ModelFileType type ) | |
| 88 | 120 | throws Exception{ |
| 89 | 121 | InputStream pmdis = |
| 90 | 122 | klass.getResourceAsStream(pmdResource); |
| @@ -98,45 +130,7 @@ | ||
| 98 | 130 | |
| 99 | 131 | Pmd2XmlConv converter = new Pmd2XmlConv(); |
| 100 | 132 | converter.setInType(ModelFileType.PMD); |
| 101 | - converter.setOutType(ModelFileType.XML_101009); | |
| 102 | - converter.setNewline("\n"); | |
| 103 | - converter.setGenerator(null); | |
| 104 | - | |
| 105 | - converter.convert(pmdis, destOut); | |
| 106 | - | |
| 107 | - pmdis.close(); | |
| 108 | - destOut.close(); | |
| 109 | - | |
| 110 | - assertSameFile(klass, expXmlResource, destFile); | |
| 111 | - | |
| 112 | - return; | |
| 113 | - } | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * PMDリソースをXMLに変換した結果がXMLリソースに等しいと表明する。 | |
| 117 | - * @param klass リソース元クラス | |
| 118 | - * @param pmdResource PMDリソース名 | |
| 119 | - * @param expXmlResource XMLリソース名 | |
| 120 | - * @throws Exception エラー | |
| 121 | - */ | |
| 122 | - public static void assertPmd2Xml13( | |
| 123 | - Class<?> klass, | |
| 124 | - String pmdResource, | |
| 125 | - String expXmlResource ) | |
| 126 | - throws Exception{ | |
| 127 | - InputStream pmdis = | |
| 128 | - klass.getResourceAsStream(pmdResource); | |
| 129 | - assertNotNull(pmdis); | |
| 130 | - pmdis = new BufferedInputStream(pmdis); | |
| 131 | - | |
| 132 | - File destFile = openTempFile(); | |
| 133 | - OutputStream destOut; | |
| 134 | - destOut = new FileOutputStream(destFile); | |
| 135 | - destOut = new BufferedOutputStream(destOut); | |
| 136 | - | |
| 137 | - Pmd2XmlConv converter = new Pmd2XmlConv(); | |
| 138 | - converter.setInType(ModelFileType.PMD); | |
| 139 | - converter.setOutType(ModelFileType.XML_130128); | |
| 133 | + converter.setOutType(type); | |
| 140 | 134 | converter.setNewline("\n"); |
| 141 | 135 | converter.setGenerator(null); |
| 142 | 136 |
| @@ -157,10 +151,8 @@ | ||
| 157 | 151 | * @param resFile ファイル |
| 158 | 152 | * @throws IOException 入力エラー |
| 159 | 153 | */ |
| 160 | - public static void assertSameFile( | |
| 161 | - Class<?> klass, | |
| 162 | - String resourceName, | |
| 163 | - File resFile ) | |
| 154 | + public static void assertSameFile(Class<?> klass, String resourceName, | |
| 155 | + File resFile ) | |
| 164 | 156 | throws IOException{ |
| 165 | 157 | InputStream expis = |
| 166 | 158 | klass.getResourceAsStream(resourceName); |
| @@ -197,12 +189,13 @@ | ||
| 197 | 189 | try{ |
| 198 | 190 | assertEquals(expCh, resCh); |
| 199 | 191 | }catch(AssertionError e){ |
| 200 | - System.err.println("offset=" + offset); | |
| 192 | + System.err.println("unmatch stream:offset=" + offset); | |
| 201 | 193 | throw e; |
| 202 | 194 | } |
| 203 | 195 | offset++; |
| 204 | 196 | |
| 205 | 197 | if(expCh < 0) break; |
| 198 | + if(resCh < 0) break; | |
| 206 | 199 | } |
| 207 | 200 | |
| 208 | 201 | return; |
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | public class DebugOutputStream extends OutputStream{ |
| 13 | 13 | |
| 14 | 14 | private final OutputStream os; |
| 15 | - private long offset = 0L; | |
| 15 | + private long dumpedBytes = 0L; | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
| @@ -30,6 +30,7 @@ | ||
| 30 | 30 | * デバッガ用監視場所。 |
| 31 | 31 | */ |
| 32 | 32 | private void before(){ |
| 33 | + assert true; | |
| 33 | 34 | return; |
| 34 | 35 | } |
| 35 | 36 |
| @@ -37,7 +38,8 @@ | ||
| 37 | 38 | * デバッガ用監視場所。 |
| 38 | 39 | */ |
| 39 | 40 | private void after(){ |
| 40 | - this.offset++; | |
| 41 | + assert true; | |
| 42 | + this.dumpedBytes++; | |
| 41 | 43 | return; |
| 42 | 44 | } |
| 43 | 45 |
| @@ -7,17 +7,16 @@ | ||
| 7 | 7 | import org.junit.AfterClass; |
| 8 | 8 | import org.junit.Before; |
| 9 | 9 | import org.junit.BeforeClass; |
| 10 | +import org.junit.Ignore; | |
| 10 | 11 | import org.junit.Test; |
| 11 | 12 | |
| 13 | +import static org.junit.Assert.*; | |
| 14 | + | |
| 12 | 15 | /** |
| 13 | 16 | * 使い捨てテスト用ドライバ。 |
| 14 | 17 | */ |
| 15 | 18 | public class TestDriver { |
| 16 | 19 | |
| 17 | - static{ | |
| 18 | - assert Test.class != null; | |
| 19 | - } | |
| 20 | - | |
| 21 | 20 | @BeforeClass |
| 22 | 21 | public static void setUpClass() { |
| 23 | 22 | } |
| @@ -36,12 +35,16 @@ | ||
| 36 | 35 | |
| 37 | 36 | /** |
| 38 | 37 | * 使い捨てテスト本体。 |
| 39 | - * <p>テストが終わったら必ず元に戻して | |
| 40 | - * アノテーション"Test"をコメントアウトするように。 | |
| 38 | + * <p>テストを行う時は | |
| 39 | + * アノテーション"Ignore"をコメントアウト。 | |
| 41 | 40 | * @throws Exception テスト失敗 |
| 42 | 41 | */ |
| 43 | - //@Test | |
| 42 | + @Test | |
| 43 | + @Ignore | |
| 44 | 44 | public void main() throws Exception{ |
| 45 | + assertTrue(true); | |
| 46 | +// fail(); | |
| 47 | + return; | |
| 45 | 48 | } |
| 46 | 49 | |
| 47 | 50 | } |