[Poem-commit] SF.net SVN: poem: [13] trunk/poem
Status: Planning
Brought to you by:
maledee
|
From: <poe...@li...> - 2008-02-17 12:42:51
|
Revision: 13
http://poem.svn.sourceforge.net/poem/?rev=13&view=rev
Author: rsinnema
Date: 2008-02-17 04:42:56 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
Added test coverage checking
Modified Paths:
--------------
trunk/poem/build-api.xml
trunk/poem/build-common.xml
trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
Added Paths:
-----------
trunk/poem/src/test/java/net/sf/poem/api/test/
trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java
trunk/poem/src/test/java/net/sf/poem/api/test/package.html
Removed Paths:
-------------
trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
trunk/poem/src/test/java/net/sf/poem/api/package.html
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-02-17 12:29:43 UTC (rev 12)
+++ trunk/poem/build-api.xml 2008-02-17 12:42:56 UTC (rev 13)
@@ -90,7 +90,7 @@
<param name="test.src.dir" value="${test.java.dir}"/>
<param name="test.src.path" value="test.class.path"/>
<param name="dest.dir" value="${report.dir}"/>
- <param name="prefix.coverage" value="net\.sf\.xpstudio\.core\."/>
+ <param name="coverage.prefix" value="net\.sf\.poem\.api\."/>
</antcall>
</target>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-02-17 12:29:43 UTC (rev 12)
+++ trunk/poem/build-common.xml 2008-02-17 12:42:56 UTC (rev 13)
@@ -42,6 +42,7 @@
<property name="java.source.version" value="1.5"/>
<property name="tar.compression" value="gzip"/>
+ <property name="test.coverage.linerate" value="80"/>
<property name="site.upload.timestamp" value="${build.dir}latest.site.upload"/>
@@ -186,7 +187,7 @@
datafile="${test.coverage.file}">
<fileset dir="${src.dir}" includes="**/*.java" />
</cobertura-report>
- <cobertura-check datafile="${test.coverage.file}" linerate="90" />
+ <cobertura-check datafile="${test.coverage.file}" linerate="${test.coverage.linerate}" />
</target>
@@ -198,6 +199,7 @@
<pathelement path="${fit.lib.dir}fitlibraryRunner.jar"/>
<pathelement path="${fit.lib.dir}poi-2.5-final-20040302.jar"/>
<pathelement path="${fit.lib.path}"/>
+ <path refid="test.coverage.path" />
</classpath>
</java>
</target>
Modified: trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java 2008-02-17 12:29:43 UTC (rev 12)
+++ trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java 2008-02-17 12:42:56 UTC (rev 13)
@@ -16,14 +16,11 @@
package net.sf.poem.api.impl;
import java.io.File;
-import java.io.IOException;
import net.sf.poem.api.Poem;
import net.sf.poem.xml.PoemDocument;
-import org.apache.xmlbeans.XmlException;
-
/**
* Implementation of {@see Poem}.
*/
@@ -44,9 +41,7 @@
if (poem == null) {
try {
poem = PoemDocument.Factory.parse(file).getPoem();
- } catch (final XmlException e) {
- throw new IllegalArgumentException("XML error while parsing poem file", e);
- } catch (final IOException e) {
+ } catch (final Exception e) {
throw new IllegalArgumentException("Error while reading poem file", e);
}
}
Deleted: trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-17 12:29:43 UTC (rev 12)
+++ trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-17 12:42:56 UTC (rev 13)
@@ -1,82 +0,0 @@
-// Copyright (C) 2008 Remon Sinnema
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package net.sf.poem.api;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-import net.sf.poem.util.FileUtil;
-import net.sf.poem.util.XmlUtil;
-
-
-/**
- * Test poem creation.
- */
-public class PoemFactoryTest extends TestCase {
-
- private Poem poem;
-
- @Override
- protected void tearDown() throws Exception {
- if (poem != null) {
- final File file = poem.getFile();
- FileUtil.delete(file);
- }
-
- super.tearDown();
- }
-
- public void testCreate() throws IOException {
- poem = PoemFactory.newInstance("en_UK", "sonnet", "Shall I compare thee to a Summer's day?");
- assertNotNull("Missing poem", poem);
-
- final File file = poem.getFile();
- assertNotNull("Missing file", file);
-
- assertEquals("file name", "shall-i-compare-thee-to-a-summers-day.xml", file.getName());
- assertXml("file contents", "<poem type=\"sonnet\" language=\"en_UK\">"
- + "<title>Shall I compare thee to a Summer's day?</title>"
- + "<paragraph><line></line></paragraph></poem>", FileUtil.getContents(file));
-
- assertEquals("language", "en_UK", poem.getContents().getLanguage());
- assertEquals("title", "Shall I compare thee to a Summer's day?", poem.getContents().getTitle());
- }
-
- public void testMissingType() {
- poem = PoemFactory.newInstance("en_UK", "", "Shall I compare thee to a Summer's day?");
- assertEquals("default type", "free", poem.getContents().getType());
- }
-
- public void testMissingTitle() {
- poem = PoemFactory.newInstance("en_UK", "sonnet", "");
- assertEquals("title", "", poem.getContents().getTitle());
- assertEquals("file name", "poem1.xml", poem.getFile().getName());
-
- final File file = PoemFactory.newInstance("en_UK", "sonnet", "").getFile();
- try {
- assertEquals("file name 2", "poem2.xml", file.getName());
- } finally {
- FileUtil.delete(file);
- }
- }
-
- private void assertXml(final String message, final String expected, final String actual) {
- assertEquals(message, XmlUtil.normalizeWhitespace("<?xml version=\"1.0\"?>" + expected),
- XmlUtil.normalizeWhitespace(actual));
- }
-
-}
Deleted: trunk/poem/src/test/java/net/sf/poem/api/package.html
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/package.html 2008-02-17 12:29:43 UTC (rev 12)
+++ trunk/poem/src/test/java/net/sf/poem/api/package.html 2008-02-17 12:42:56 UTC (rev 13)
@@ -1,5 +0,0 @@
-<html>
- <body>
- These are the <a href="http://junit.org">unit tests</a> for the API.
- </body>
-</html>
Copied: trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java (from rev 12, trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java)
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java 2008-02-17 12:42:56 UTC (rev 13)
@@ -0,0 +1,84 @@
+// Copyright (C) 2008 Remon Sinnema
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package net.sf.poem.api.test;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+import net.sf.poem.api.Poem;
+import net.sf.poem.api.PoemFactory;
+import net.sf.poem.util.FileUtil;
+import net.sf.poem.util.XmlUtil;
+
+
+/**
+ * Test poem creation.
+ */
+public class PoemFactoryTest extends TestCase {
+
+ private Poem poem;
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (poem != null) {
+ final File file = poem.getFile();
+ FileUtil.delete(file);
+ }
+
+ super.tearDown();
+ }
+
+ public void testCreate() throws IOException {
+ poem = PoemFactory.newInstance("en_UK", "sonnet", "Shall I compare thee to a Summer's day?");
+ assertNotNull("Missing poem", poem);
+
+ final File file = poem.getFile();
+ assertNotNull("Missing file", file);
+
+ assertEquals("file name", "shall-i-compare-thee-to-a-summers-day.xml", file.getName());
+ assertXml("file contents", "<poem type=\"sonnet\" language=\"en_UK\">"
+ + "<title>Shall I compare thee to a Summer's day?</title>"
+ + "<paragraph><line></line></paragraph></poem>", FileUtil.getContents(file));
+
+ assertEquals("language", "en_UK", poem.getContents().getLanguage());
+ assertEquals("title", "Shall I compare thee to a Summer's day?", poem.getContents().getTitle());
+ }
+
+ public void testMissingType() {
+ poem = PoemFactory.newInstance("en_UK", "", "Shall I compare thee to a Summer's day?");
+ assertEquals("default type", "free", poem.getContents().getType());
+ }
+
+ public void testMissingTitle() {
+ poem = PoemFactory.newInstance("en_UK", "sonnet", "");
+ assertEquals("title", "", poem.getContents().getTitle());
+ assertEquals("file name", "poem1.xml", poem.getFile().getName());
+
+ final File file = PoemFactory.newInstance("en_UK", "sonnet", "").getFile();
+ try {
+ assertEquals("file name 2", "poem2.xml", file.getName());
+ } finally {
+ FileUtil.delete(file);
+ }
+ }
+
+ private void assertXml(final String message, final String expected, final String actual) {
+ assertEquals(message, XmlUtil.normalizeWhitespace("<?xml version=\"1.0\"?>" + expected),
+ XmlUtil.normalizeWhitespace(actual));
+ }
+
+}
Copied: trunk/poem/src/test/java/net/sf/poem/api/test/package.html (from rev 10, trunk/poem/src/test/java/net/sf/poem/api/package.html)
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/test/package.html (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/api/test/package.html 2008-02-17 12:42:56 UTC (rev 13)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ These are the <a href="http://junit.org">unit tests</a> for the API.
+ </body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|