• R/O
  • SSH

Pmd2XML: 提交

Pmd2XMLは、3D動画制作ツール、MikuMikuDance(MMD)で用いられるモデルデータファイル(*.pmd)の内容を、XML形式のデータファイルと交換するためのアプリケーションです。


Commit MetaInfo

修訂46e7649006782c0f1cc85cf25869787381b77044 (tree)
時間2013-12-03 02:31:20
作者 <olyutorskii@user...>

Log Message

ユニットテスト下請け修正

Change Summary

差異

diff -r fca3c8b23c40 -r 46e764900678 src/test/java/testdata/CnvAssert.java
--- a/src/test/java/testdata/CnvAssert.java Mon Dec 02 01:07:50 2013 +0900
+++ b/src/test/java/testdata/CnvAssert.java Tue Dec 03 02:31:20 2013 +0900
@@ -17,7 +17,7 @@
1717 import static org.junit.Assert.*;
1818
1919 /**
20- *
20+ * ファイル変換処理のユニットテスト下請け諸々。
2121 */
2222 public class CnvAssert {
2323
@@ -30,7 +30,7 @@
3030 * @return テンポラリファイル
3131 * @throws IOException エラー
3232 */
33- public static File openTempFile() throws IOException{
33+ private static File openTempFile() throws IOException{
3434 File file = File.createTempFile("pmd2xml", null);
3535 file.deleteOnExit();
3636 return file;
@@ -43,10 +43,9 @@
4343 * @param expPmdResource PMDリソース名
4444 * @throws Exception エラー
4545 */
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 )
5049 throws Exception{
5150 InputStream xmlis =
5251 klass.getResourceAsStream(xmlResource);
@@ -81,10 +80,43 @@
8180 * @param expXmlResource XMLリソース名
8281 * @throws Exception エラー
8382 */
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 )
88120 throws Exception{
89121 InputStream pmdis =
90122 klass.getResourceAsStream(pmdResource);
@@ -98,45 +130,7 @@
98130
99131 Pmd2XmlConv converter = new Pmd2XmlConv();
100132 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);
140134 converter.setNewline("\n");
141135 converter.setGenerator(null);
142136
@@ -157,10 +151,8 @@
157151 * @param resFile ファイル
158152 * @throws IOException 入力エラー
159153 */
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 )
164156 throws IOException{
165157 InputStream expis =
166158 klass.getResourceAsStream(resourceName);
@@ -197,12 +189,13 @@
197189 try{
198190 assertEquals(expCh, resCh);
199191 }catch(AssertionError e){
200- System.err.println("offset=" + offset);
192+ System.err.println("unmatch stream:offset=" + offset);
201193 throw e;
202194 }
203195 offset++;
204196
205197 if(expCh < 0) break;
198+ if(resCh < 0) break;
206199 }
207200
208201 return;
diff -r fca3c8b23c40 -r 46e764900678 src/test/java/testdata/DebugOutputStream.java
--- a/src/test/java/testdata/DebugOutputStream.java Mon Dec 02 01:07:50 2013 +0900
+++ b/src/test/java/testdata/DebugOutputStream.java Tue Dec 03 02:31:20 2013 +0900
@@ -12,7 +12,7 @@
1212 public class DebugOutputStream extends OutputStream{
1313
1414 private final OutputStream os;
15- private long offset = 0L;
15+ private long dumpedBytes = 0L;
1616
1717
1818 /**
@@ -30,6 +30,7 @@
3030 * デバッガ用監視場所。
3131 */
3232 private void before(){
33+ assert true;
3334 return;
3435 }
3536
@@ -37,7 +38,8 @@
3738 * デバッガ用監視場所。
3839 */
3940 private void after(){
40- this.offset++;
41+ assert true;
42+ this.dumpedBytes++;
4143 return;
4244 }
4345
diff -r fca3c8b23c40 -r 46e764900678 src/test/java/testdata/TestDriver.java
--- a/src/test/java/testdata/TestDriver.java Mon Dec 02 01:07:50 2013 +0900
+++ b/src/test/java/testdata/TestDriver.java Tue Dec 03 02:31:20 2013 +0900
@@ -7,17 +7,16 @@
77 import org.junit.AfterClass;
88 import org.junit.Before;
99 import org.junit.BeforeClass;
10+import org.junit.Ignore;
1011 import org.junit.Test;
1112
13+import static org.junit.Assert.*;
14+
1215 /**
1316 * 使い捨てテスト用ドライバ。
1417 */
1518 public class TestDriver {
1619
17- static{
18- assert Test.class != null;
19- }
20-
2120 @BeforeClass
2221 public static void setUpClass() {
2322 }
@@ -36,12 +35,16 @@
3635
3736 /**
3837 * 使い捨てテスト本体。
39- * <p>テストが終わったら必ず元に戻して
40- * アノテーション"Test"をコメントアウトするように。
38+ * <p>テストを行う時は
39+ * アノテーション"Ignore"をコメントアウト。
4140 * @throws Exception テスト失敗
4241 */
43- //@Test
42+ @Test
43+ @Ignore
4444 public void main() throws Exception{
45+ assertTrue(true);
46+// fail();
47+ return;
4548 }
4649
4750 }
Show on old repository browser