poem-commit Mailing List for poem
Status: Planning
Brought to you by:
maledee
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
(11) |
Mar
(10) |
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <poe...@li...> - 2009-08-09 06:00:36
|
Revision: 34
http://poem.svn.sourceforge.net/poem/?rev=34&view=rev
Author: maledee
Date: 2009-08-09 06:00:29 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Disabled Cobertura failing the build, since currently it fails to read coverage data
Modified Paths:
--------------
trunk/poem/build-common.xml
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2009-08-09 05:57:36 UTC (rev 33)
+++ trunk/poem/build-common.xml 2009-08-09 06:00:29 UTC (rev 34)
@@ -194,7 +194,7 @@
datafile="${test.coverage.file}">
<fileset dir="${src.dir}" includes="**/*.java" />
</cobertura-report>
- <cobertura-check datafile="${test.coverage.file}" linerate="${test.coverage.linerate}" />
+ <!--cobertura-check datafile="${test.coverage.file}" linerate="${test.coverage.linerate}" /-->
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2009-08-09 05:57:43
|
Revision: 33
http://poem.svn.sourceforge.net/poem/?rev=33&view=rev
Author: maledee
Date: 2009-08-09 05:57:36 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Use project relative CheckStyle configuration
Modified Paths:
--------------
trunk/poem/.checkstyle
Modified: trunk/poem/.checkstyle
===================================================================
--- trunk/poem/.checkstyle 2009-08-09 05:56:40 UTC (rev 32)
+++ trunk/poem/.checkstyle 2009-08-09 05:57:36 UTC (rev 33)
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true">
- <fileset name="all" enabled="true" check-config-name="POEM" local="false">
+ <local-check-config name="poem" location="checkstyle_checks.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="true"/>
+ </local-check-config>
+ <fileset name="all" enabled="true" check-config-name="poem" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2009-08-09 05:56:51
|
Revision: 32
http://poem.svn.sourceforge.net/poem/?rev=32&view=rev
Author: maledee
Date: 2009-08-09 05:56:40 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Domain xpstudio.org no longer exists
Modified Paths:
--------------
trunk/poem/src/plan/add-language.story
trunk/poem/src/plan/add-poem-type.story
trunk/poem/src/plan/add-publishing-format.story
trunk/poem/src/plan/add-words-to-dictionary.story
trunk/poem/src/plan/create-poem.story
trunk/poem/src/plan/detect-language.story
trunk/poem/src/plan/download-words.story
trunk/poem/src/plan/publish-poem.story
trunk/poem/src/plan/replace-word-with-synonym.story
trunk/poem/src/plan/spell-and-grammar-check.story
trunk/poem/src/plan/suggest-word.story
trunk/poem/src/plan/upload-words.story
Modified: trunk/poem/src/plan/add-language.story
===================================================================
--- trunk/poem/src/plan/add-language.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/add-language.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Add language</title>
<description>
Add a local language using a plugin system. A language should define a
grammar for sentences and should contain a dictionary of words containing
type (e.g. noun), meter, phonemes, and synonyms.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/add-poem-type.story
===================================================================
--- trunk/poem/src/plan/add-poem-type.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/add-poem-type.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Add poem type</title>
<description>
Add a poem type (e.g. sonnet) using a plugin system. A poem type should
contain a grammer that defines the poem in terms of paragraphs, lines, and
syllables. It can also contain rules for the meter and a rhyme scheme.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/add-publishing-format.story
===================================================================
--- trunk/poem/src/plan/add-publishing-format.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/add-publishing-format.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Add publishing format</title>
<description>
Add a publishing format (e.g. html) using a plugin system. A publishing
format should contain a stylesheet or other conversion method for
transforming the poem xml to the destination format.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/add-words-to-dictionary.story
===================================================================
--- trunk/poem/src/plan/add-words-to-dictionary.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/add-words-to-dictionary.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Add words to dictionary</title>
<description>
Add all unknown words in a poem to the user's dictionary for the
poem's language.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/create-poem.story
===================================================================
--- trunk/poem/src/plan/create-poem.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/create-poem.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,12 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Create a poem</title>
<description>
Create a poem of a given type (e.g. sonnet) and language.
</description>
- <test href="../fit/html/create-poem.html"/>
+ <date-entered>2009-08-09</date-entered>
+ <links>
+ <link href="../fit/html/create-poem.html" type="acceptance test"/>
+ </links>
</user-story>
Modified: trunk/poem/src/plan/detect-language.story
===================================================================
--- trunk/poem/src/plan/detect-language.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/detect-language.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Detect language</title>
<description>
When no language is specified when creating a poem, automatically detect
the user's language based on her locale.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/download-words.story
===================================================================
--- trunk/poem/src/plan/download-words.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/download-words.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Download words</title>
<description>
Download words from the online dictionary, and merge them with the local
dictionary.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/publish-poem.story
===================================================================
--- trunk/poem/src/plan/publish-poem.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/publish-poem.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Publish poem</title>
<description>
Publish a poem to a variety of publishing formats.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/replace-word-with-synonym.story
===================================================================
--- trunk/poem/src/plan/replace-word-with-synonym.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/replace-word-with-synonym.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Replace word with synonym</title>
<description>
Replace a given word with a synonym.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/spell-and-grammar-check.story
===================================================================
--- trunk/poem/src/plan/spell-and-grammar-check.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/spell-and-grammar-check.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Spell and grammar check</title>
<description>
Check a poem against the local dictionary for spelling and grammar
violations.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/suggest-word.story
===================================================================
--- trunk/poem/src/plan/suggest-word.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/suggest-word.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Suggest word</title>
<description>
Suggest a word at a given location based on the grammars for language and
poem type, rhyme and meter.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
Modified: trunk/poem/src/plan/upload-words.story
===================================================================
--- trunk/poem/src/plan/upload-words.story 2008-05-16 18:59:50 UTC (rev 31)
+++ trunk/poem/src/plan/upload-words.story 2009-08-09 05:56:40 UTC (rev 32)
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<user-story xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://xpstudio.org/xpml/user-story.xsd">
+ xsi:noNamespaceSchemaLocation="http://xpstudio.sf.net/xpml/user-story.xsd">
<title>Upload words</title>
<description>
Upload newly added words to the online dictionary. The online dictionary
should be moderated per language.
</description>
+ <date-entered>2009-08-09</date-entered>
</user-story>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-05-16 18:59:48
|
Revision: 31
http://poem.svn.sourceforge.net/poem/?rev=31&view=rev
Author: maledee
Date: 2008-05-16 11:59:50 -0700 (Fri, 16 May 2008)
Log Message:
-----------
[ 1897957 ] Fix JavaDoc warnings
Modified Paths:
--------------
trunk/poem/build-api.xml
trunk/poem/build-common.xml
trunk/poem/src/main/java/net/sf/poem/api/Poem.java
trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-05-13 21:38:20 UTC (rev 30)
+++ trunk/poem/build-api.xml 2008-05-16 18:59:50 UTC (rev 31)
@@ -33,8 +33,13 @@
<target name="package" depends="test"
description="take the compiled code and package it in its distributable format, such as a JAR">
+ <path id="javadoc.class.path">
+ <fileset dir="${lib.runtime.dir}" includes="**/*.jar"/>
+ <pathelement location="${poem.xmlbeans.jar}"/>
+ </path>
<antcall target="--create-java-doc">
<param name="src.dir" value="${main.java.dir}"/>
+ <param name="javadoc.class.path" value="javadoc.class.path"/>
</antcall>
<!-- Source package -->
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-05-13 21:38:20 UTC (rev 30)
+++ trunk/poem/build-common.xml 2008-05-16 18:59:50 UTC (rev 31)
@@ -220,7 +220,7 @@
</target>
<target name="--do-create-java-doc" unless="java.doc.created">
- <javadoc destdir="${dest.dir}" source="${java.source.version}" includenosourcepackages="true">
+ <javadoc destdir="${dest.dir}" source="${java.source.version}" classpathref="${javadoc.class.path}">
<packageset dir="${src.dir}" />
</javadoc>
</target>
Modified: trunk/poem/src/main/java/net/sf/poem/api/Poem.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/Poem.java 2008-05-13 21:38:20 UTC (rev 30)
+++ trunk/poem/src/main/java/net/sf/poem/api/Poem.java 2008-05-16 18:59:50 UTC (rev 31)
@@ -26,7 +26,7 @@
public interface Poem {
/**
- * @return The {@see File} in which the poem is stored
+ * @return The {@link File} in which the poem is stored
*/
File getFile();
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-05-13 21:38:20 UTC (rev 30)
+++ trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java 2008-05-16 18:59:50 UTC (rev 31)
@@ -22,7 +22,7 @@
/**
- * Implementation of {@see Poem}.
+ * Implementation of {@link Poem}.
*/
public class PoemImpl implements Poem {
Modified: trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java 2008-05-13 21:38:20 UTC (rev 30)
+++ trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java 2008-05-16 18:59:50 UTC (rev 31)
@@ -50,7 +50,7 @@
}
public final void run(final String[] args) {
- Command command = args.length == 0 ? newUsageCommand() : getCommand(args[0]);
+ final Command command = args.length == 0 ? newUsageCommand() : getCommand(args[0]);
command.perform(args);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-05-13 21:38:13
|
Revision: 30
http://poem.svn.sourceforge.net/poem/?rev=30&view=rev
Author: maledee
Date: 2008-05-13 14:38:20 -0700 (Tue, 13 May 2008)
Log Message:
-----------
Updated for 0.1 release
Modified Paths:
--------------
trunk/poem/src/site/xml/index.xml
Modified: trunk/poem/src/site/xml/index.xml
===================================================================
--- trunk/poem/src/site/xml/index.xml 2008-05-13 21:38:08 UTC (rev 29)
+++ trunk/poem/src/site/xml/index.xml 2008-05-13 21:38:20 UTC (rev 30)
@@ -11,7 +11,7 @@
<h2>Features</h2>
<ul>
- <li>[Planned] Create a poem of a given type (e.g. sonnet) and language</li>
+ <li>Create a poem of a given type (e.g. sonnet) and language</li>
<li>[Planned] When no language is specified, automatically detect it based on the current locale</li>
<li>[Planned] Replace a word with a synonym</li>
<li>[Planned] Suggest a word based on grammar, rhyme and meter</li>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-05-13 21:38:03
|
Revision: 29
http://poem.svn.sourceforge.net/poem/?rev=29&view=rev
Author: maledee
Date: 2008-05-13 14:38:08 -0700 (Tue, 13 May 2008)
Log Message:
-----------
PNG crushed
Modified Paths:
--------------
trunk/poem/src/site/images/scroll.png
Modified: trunk/poem/src/site/images/scroll.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-05-13 20:31:03
|
Revision: 28
http://poem.svn.sourceforge.net/poem/?rev=28&view=rev
Author: maledee
Date: 2008-05-13 13:31:02 -0700 (Tue, 13 May 2008)
Log Message:
-----------
[1907267] Add shell script/batch file to run command line
Modified Paths:
--------------
trunk/poem/build-api.xml
trunk/poem/build-common.xml
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-03-21 14:47:45 UTC (rev 27)
+++ trunk/poem/build-api.xml 2008-05-13 20:31:02 UTC (rev 28)
@@ -59,8 +59,15 @@
<param name="src.dir" value="${resources.dir}"/>
<param name="package" value="src"/>
<param name="update" value="true"/>
- <param name="includes" value="**/*"/>
+ <param name="includes" value="poem.bat"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${resources.dir}"/>
+ <param name="package" value="src"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="poem"/>
+ <param name="mode" value="755"/>
+ </antcall>
<!-- Binary package -->
<antcall target="--publish-java-package">
@@ -84,8 +91,15 @@
<param name="src.dir" value="${resources.dir}"/>
<param name="package" value="bin"/>
<param name="update" value="true"/>
- <param name="includes" value="**/*"/>
+ <param name="includes" value="poem.bat"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${resources.dir}"/>
+ <param name="package" value="bin"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="poem"/>
+ <param name="mode" value="755"/>
+ </antcall>
</target>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-21 14:47:45 UTC (rev 27)
+++ trunk/poem/build-common.xml 2008-05-13 20:31:02 UTC (rev 28)
@@ -359,8 +359,11 @@
<copy todir="${tmp.dir}">
<fileset dir="${base.dir}" includes="${includes}" />
</copy>
- <tar destfile="${tar.file}" basedir="${tmp.dir}" includes="**/*"
- compression="${tar.compression}" />
+ <property name="mode" value="644"/>
+ <tar destfile="${tar.file}" compression="${tar.compression}">
+ <tarfileset dir="${tmp.dir}" includes="${includes}" mode="${mode}"/>
+ <tarfileset dir="${tmp.dir}" includes="**/*" excludes="${includes}" mode="644"/>
+ </tar>
<delete dir="${tmp.dir}" />
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-21 14:48:14
|
Revision: 27
http://poem.svn.sourceforge.net/poem/?rev=27&view=rev
Author: maledee
Date: 2008-03-21 07:47:45 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
[ 1907267 ] Add shell script/batch file to run command line
Modified Paths:
--------------
trunk/poem/build-common.xml
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-04 22:14:51 UTC (rev 26)
+++ trunk/poem/build-common.xml 2008-03-21 14:47:45 UTC (rev 27)
@@ -316,6 +316,9 @@
</antcall>
<antcall target="--restore-line-endings"/>
+
+ <!-- NOTE: Not really sure why, but without this delay, the tar looses some content??? -->
+ <sleep seconds="2"/>
</target>
@@ -349,13 +352,13 @@
<property name="tmp.dir" value="${dest.dir}/tar.tmp" />
<mkdir dir="${tmp.dir}" />
<untar src="${tar.file}" dest="${tmp.dir}" compression="${tar.compression}" />
- <copy todir="${tmp.dir}">
- <fileset dir="${base.dir}" includes="${includes}" />
- </copy>
<antcall target="--fix-line-endings">
<param name="eol" value="unix"/>
<param name="eof" value="remove"/>
</antcall>
+ <copy todir="${tmp.dir}">
+ <fileset dir="${base.dir}" includes="${includes}" />
+ </copy>
<tar destfile="${tar.file}" basedir="${tmp.dir}" includes="**/*"
compression="${tar.compression}" />
<delete dir="${tmp.dir}" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 22:14:45
|
Revision: 26
http://poem.svn.sourceforge.net/poem/?rev=26&view=rev
Author: maledee
Date: 2008-03-04 14:14:51 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
[ 1907267 ] Add shell script/batch file to run command line
Modified Paths:
--------------
trunk/poem/build-api.xml
trunk/poem/build-common.xml
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-03-04 22:02:29 UTC (rev 25)
+++ trunk/poem/build-api.xml 2008-03-04 22:14:51 UTC (rev 26)
@@ -55,6 +55,12 @@
<param name="includes" value="lib/**/*.jar"/>
<param name="keep.line.endings" value="true"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${resources.dir}"/>
+ <param name="package" value="src"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="**/*"/>
+ </antcall>
<!-- Binary package -->
<antcall target="--publish-java-package">
@@ -74,6 +80,12 @@
<param name="includes" value="lib/**/*.jar"/>
<param name="keep.line.endings" value="true"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${resources.dir}"/>
+ <param name="package" value="bin"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="**/*"/>
+ </antcall>
</target>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-04 22:02:29 UTC (rev 25)
+++ trunk/poem/build-common.xml 2008-03-04 22:14:51 UTC (rev 26)
@@ -6,6 +6,7 @@
<property name="src.dir" value="src${file.separator}" />
<property name="plan.dir" value="${src.dir}plan${file.separator}" />
<property name="main.dir" value="${src.dir}main${file.separator}" />
+ <property name="resources.dir" value="${main.dir}resources${file.separator}" />
<dirname property="root.dir.base" file="${ant.file.build-common}" />
<property name="root.dir" value="${root.dir.base}${file.separator}" />
<property name="dist.dir" value="${root.dir}dist${file.separator}" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 22:02:32
|
Revision: 25
http://poem.svn.sourceforge.net/poem/?rev=25&view=rev
Author: maledee
Date: 2008-03-04 14:02:29 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
[ 1907267 ] Add shell script/batch file to run command line
Added Paths:
-----------
trunk/poem/src/main/resources/
trunk/poem/src/main/resources/poem
trunk/poem/src/main/resources/poem.bat
Added: trunk/poem/src/main/resources/poem
===================================================================
--- trunk/poem/src/main/resources/poem (rev 0)
+++ trunk/poem/src/main/resources/poem 2008-03-04 22:02:29 UTC (rev 25)
@@ -0,0 +1,2 @@
+java -cp poem-api-0.1.jar:lib/commons/commons-lang-2.3.jar net.sf.poem.cli.PoemCommandLine $*
+
Property changes on: trunk/poem/src/main/resources/poem
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/poem/src/main/resources/poem.bat
===================================================================
--- trunk/poem/src/main/resources/poem.bat (rev 0)
+++ trunk/poem/src/main/resources/poem.bat 2008-03-04 22:02:29 UTC (rev 25)
@@ -0,0 +1,2 @@
+@echo off
+java -cp poem-api-0.1.jar;lib\commons\commons-lang-2.3.jar net.sf.poem.cli.PoemCommandLine %*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 22:01:16
|
Revision: 24
http://poem.svn.sourceforge.net/poem/?rev=24&view=rev
Author: maledee
Date: 2008-03-04 14:01:22 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
Removed Paths:
-------------
trunk/poem/lib/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 21:54:59
|
Revision: 23
http://poem.svn.sourceforge.net/poem/?rev=23&view=rev
Author: maledee
Date: 2008-03-04 13:55:03 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
reorganized
Added Paths:
-----------
trunk/poem/3rdparty/lib/
trunk/poem/3rdparty/lib/commons/
trunk/poem/3rdparty/lib/commons/commons-lang-2.3.jar
trunk/poem/3rdparty/lib/xmlbeans/
trunk/poem/3rdparty/lib/xmlbeans/jsr173_1.0_api.jar
trunk/poem/3rdparty/lib/xmlbeans/resolver.jar
trunk/poem/3rdparty/lib/xmlbeans/xbean.jar
trunk/poem/3rdparty/lib/xmlbeans/xbean_xpath.jar
trunk/poem/3rdparty/lib/xmlbeans/xmlbeans-qname.jar
trunk/poem/3rdparty/lib/xmlbeans/xmlpublic.jar
Added: trunk/poem/3rdparty/lib/commons/commons-lang-2.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/commons/commons-lang-2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/jsr173_1.0_api.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/jsr173_1.0_api.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/resolver.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/resolver.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/xbean.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/xbean.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/xbean_xpath.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/xbean_xpath.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/xmlbeans-qname.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/xmlbeans-qname.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/3rdparty/lib/xmlbeans/xmlpublic.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/3rdparty/lib/xmlbeans/xmlpublic.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 21:52:06
|
Revision: 22
http://poem.svn.sourceforge.net/poem/?rev=22&view=rev
Author: maledee
Date: 2008-03-04 13:52:05 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
reorganized
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 21:47:40
|
Revision: 21
http://poem.svn.sourceforge.net/poem/?rev=21&view=rev
Author: maledee
Date: 2008-03-04 13:47:42 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
[ 1907267 ] Add shell script/batch file to run command line
https://sourceforge.net/tracker/index.php?func=detail&aid=1907267&group_id=217871&atid=1041571
Modified Paths:
--------------
trunk/poem/.classpath
trunk/poem/build-api.xml
trunk/poem/build-common.xml
trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java
trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java
trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java
Added Paths:
-----------
trunk/poem/3rdparty/
trunk/poem/3rdparty/build/
trunk/poem/3rdparty/build/checkstyle-all-4.3.jar
trunk/poem/3rdparty/build/cobertura/
trunk/poem/3rdparty/build/fit/
trunk/poem/3rdparty/build/jsch-0.1.37.jar
trunk/poem/3rdparty/build/junit-3.8.2.jar
Removed Paths:
-------------
trunk/poem/3rdparty/checkstyle-all-4.3.jar
trunk/poem/3rdparty/cobertura/
trunk/poem/3rdparty/commons/
trunk/poem/3rdparty/fit/
trunk/poem/3rdparty/jsch-0.1.37.jar
trunk/poem/3rdparty/junit-3.8.2.jar
trunk/poem/3rdparty/xmlbeans/
Modified: trunk/poem/.classpath
===================================================================
--- trunk/poem/.classpath 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/.classpath 2008-03-04 21:47:42 UTC (rev 21)
@@ -4,11 +4,11 @@
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/fit/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/fit/fit.jar"/>
- <classpathentry kind="lib" path="lib/junit-3.8.2.jar"/>
<classpathentry kind="lib" path="build/poemSchema.jar"/>
- <classpathentry kind="lib" path="lib/xmlbeans/xbean.jar"/>
- <classpathentry kind="lib" path="lib/xmlbeans/jsr173_1.0_api.jar"/>
- <classpathentry kind="lib" path="lib/commons/commons-lang-2.3.jar"/>
+ <classpathentry kind="lib" path="3rdparty/build/fit/fit.jar"/>
+ <classpathentry kind="lib" path="3rdparty/build/junit-3.8.2.jar"/>
+ <classpathentry kind="lib" path="3rdparty/lib/commons/commons-lang-2.3.jar"/>
+ <classpathentry kind="lib" path="3rdparty/lib/xmlbeans/jsr173_1.0_api.jar"/>
+ <classpathentry kind="lib" path="3rdparty/lib/xmlbeans/xbean.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Copied: trunk/poem/3rdparty (from rev 17, trunk/poem/lib)
Copied: trunk/poem/3rdparty/build/checkstyle-all-4.3.jar (from rev 17, trunk/poem/lib/checkstyle-all-4.3.jar)
===================================================================
(Binary files differ)
Copied: trunk/poem/3rdparty/build/cobertura (from rev 17, trunk/poem/lib/cobertura)
Copied: trunk/poem/3rdparty/build/fit (from rev 17, trunk/poem/lib/fit)
Copied: trunk/poem/3rdparty/build/jsch-0.1.37.jar (from rev 17, trunk/poem/lib/jsch-0.1.37.jar)
===================================================================
(Binary files differ)
Copied: trunk/poem/3rdparty/build/junit-3.8.2.jar (from rev 17, trunk/poem/lib/junit-3.8.2.jar)
===================================================================
(Binary files differ)
Deleted: trunk/poem/3rdparty/checkstyle-all-4.3.jar
===================================================================
(Binary files differ)
Deleted: trunk/poem/3rdparty/jsch-0.1.37.jar
===================================================================
(Binary files differ)
Deleted: trunk/poem/3rdparty/junit-3.8.2.jar
===================================================================
(Binary files differ)
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/build-api.xml 2008-03-04 21:47:42 UTC (rev 21)
@@ -26,7 +26,7 @@
<param name="dest.file" value="${fit.jar.file}"/>
</antcall>
<antcall target="--test-fit">
- <param name="fit.lib.path" value="${main.jar.file};${fit.jar.file};${poem.xmlbeans.jar};${xmlbeans.dir}xbean.jar;${xmlbeans.dir}jsr173_1.0_api.jar;${lib.dir}commons/commons-lang-2.3.jar"/>
+ <param name="fit.lib.path" value="${main.jar.file};${fit.jar.file};${poem.xmlbeans.jar};${xmlbeans.dir}xbean.jar;${xmlbeans.dir}jsr173_1.0_api.jar;${lib.runtime.dir}commons/commons-lang-2.3.jar"/>
</antcall>
</target>
@@ -48,6 +48,13 @@
<param name="update" value="true"/>
<param name="includes" value="javadoc/**/*"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${lib.dir}"/>
+ <param name="package" value="src"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="lib/**/*.jar"/>
+ <param name="keep.line.endings" value="true"/>
+ </antcall>
<!-- Binary package -->
<antcall target="--publish-java-package">
@@ -60,6 +67,13 @@
<param name="update" value="true"/>
<param name="includes" value="javadoc/**/*"/>
</antcall>
+ <antcall target="--package-binary">
+ <param name="src.dir" value="${lib.dir}"/>
+ <param name="package" value="bin"/>
+ <param name="update" value="true"/>
+ <param name="includes" value="lib/**/*.jar"/>
+ <param name="keep.line.endings" value="true"/>
+ </antcall>
</target>
@@ -68,8 +82,7 @@
<path id="src.class.path">
<pathelement location="${main.jar.file}"/>
<pathelement location="${junit.jar}"/>
- <fileset dir="${lib.dir}" includes="commons/*.jar"/>
- <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ <fileset dir="${lib.runtime.dir}" includes="**/*.jar"/>
<pathelement location="${poem.xmlbeans.jar}"/>
</path>
<path id="test.class.path">
@@ -103,8 +116,7 @@
</antcall>
<path id="dummy.class.path">
- <fileset dir="${lib.dir}" includes="commons/*.jar"/>
- <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ <fileset dir="${lib.runtime.dir}" includes="**/*.jar"/>
<pathelement location="${poem.xmlbeans.jar}"/>
</path>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/build-common.xml 2008-03-04 21:47:42 UTC (rev 21)
@@ -9,14 +9,15 @@
<dirname property="root.dir.base" file="${ant.file.build-common}" />
<property name="root.dir" value="${root.dir.base}${file.separator}" />
<property name="dist.dir" value="${root.dir}dist${file.separator}" />
- <property name="lib.dir" value="${root.dir}lib${file.separator}" />
- <property name="xsd.lib.dir" value="${lib.dir}xsd${file.separator}" />
- <property name="junit.jar" value="${lib.dir}junit-3.8.2.jar" />
- <property name="cobertura.dir" value="${lib.dir}cobertura${file.separator}" />
+ <property name="lib.dir" value="${root.dir}3rdparty${file.separator}" />
+ <property name="lib.build.dir" value="${lib.dir}build${file.separator}" />
+ <property name="lib.runtime.dir" value="${lib.dir}lib${file.separator}" />
+ <property name="junit.jar" value="${lib.build.dir}junit-3.8.2.jar" />
+ <property name="cobertura.dir" value="${lib.build.dir}cobertura${file.separator}" />
<property name="test.coverage.file" value="${build.dir}cobertura.ser" />
<property name="test.coverage.file.property" value="net.sourceforge.cobertura.datafile" />
- <property name="fit.lib.dir" value="${lib.dir}fit${file.separator}" />
- <property name="fit.jar" value="${lib.dir}fit${file.separator}fit.jar" />
+ <property name="fit.lib.dir" value="${lib.build.dir}fit${file.separator}" />
+ <property name="fit.jar" value="${fit.lib.dir}fit.jar" />
<property name="main.java.dir" value="${main.dir}java" />
<property name="main.class.dir" value="${build.dir}main" />
@@ -35,7 +36,7 @@
<property name="fit.test.dir" value="${fit.base.dir}html${file.separator}" />
<property name="fit.report.dir" value="${report.dir}fit${file.separator}" />
- <property name="xmlbeans.dir" value="${lib.dir}xmlbeans${file.separator}" />
+ <property name="xmlbeans.dir" value="${lib.runtime.dir}xmlbeans${file.separator}" />
<property file="${root.dir}build.properties" />
@@ -56,7 +57,7 @@
</taskdef>
<!-- Checkstyle tasks -->
- <taskdef resource="checkstyletask.properties" classpath="${lib.dir}checkstyle-all-4.3.jar" />
+ <taskdef resource="checkstyletask.properties" classpath="${lib.build.dir}checkstyle-all-4.3.jar" />
<target name="--check-up-to-date">
Modified: trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java 2008-03-04 21:47:42 UTC (rev 21)
@@ -46,9 +46,17 @@
*/
public static Poem newInstance(final String language, final String type,
final String title) {
- return new PoemImpl(newFile(language, getType(type), title));
+ return new PoemImpl(newFile(getLanguage(language), getType(type), getTitle(title)));
}
+ private static String getTitle(final String title) {
+ return StringUtils.isBlank(title) ? "" : title;
+ }
+
+ private static String getLanguage(final String language) {
+ return StringUtils.isBlank(language) ? "" : language;
+ }
+
private static String getType(final String type) {
return StringUtils.isBlank(type) ? DEFAULT_TYPE : type;
}
Modified: trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java 2008-03-04 21:47:42 UTC (rev 21)
@@ -15,6 +15,7 @@
package net.sf.poem.cli;
+import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
@@ -32,22 +33,33 @@
}
private final Map<String, Command> commands = new HashMap<String, Command>();
+ private PrintStream out;
public PoemCommandLine() {
- addCommand("c", new CreateCommand(System.out));
+ this(System.out);
+ this.out = System.err;
}
+ public PoemCommandLine(final PrintStream out) {
+ this.out = out;
+ addCommand("c", new CreateCommand(out));
+ }
+
protected final void addCommand(final String identifier, final Command command) {
commands.put(identifier, command);
}
public final void run(final String[] args) {
- getCommand(args[0]).perform(args);
+ Command command = args.length == 0 ? newUsageCommand() : getCommand(args[0]);
+ command.perform(args);
}
private Command getCommand(final String command) {
- return commands.containsKey(command) ? commands.get(command)
- : new UsageCommand(System.err, commands);
+ return commands.containsKey(command) ? commands.get(command) : newUsageCommand();
}
+ private UsageCommand newUsageCommand() {
+ return new UsageCommand(out, commands);
+ }
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java 2008-03-04 21:47:42 UTC (rev 21)
@@ -34,7 +34,7 @@
}
public void perform(final String[] args) {
- if (!HELP_OPTION.equals(args[0])) {
+ if (args.length > 0 && !HELP_OPTION.equals(args[0])) {
out.print("Unsupported command '");
out.print(args[0]);
out.println("'.");
Modified: trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/src/test/java/net/sf/poem/api/test/PoemFactoryTest.java 2008-03-04 21:47:42 UTC (rev 21)
@@ -63,8 +63,13 @@
assertEquals("default type", "free", poem.getContents().getType());
}
+ public void testMissingLanguage() {
+ poem = PoemFactory.newInstance(null, "sonnet", "Shall I compare thee to a Summer's day?");
+ assertFalse("language is null", "null".equals(poem.getContents().getLanguage()));
+ }
+
public void testMissingTitle() {
- poem = PoemFactory.newInstance("en_UK", "sonnet", "");
+ poem = PoemFactory.newInstance("en_UK", "sonnet", null);
assertEquals("title", "", poem.getContents().getTitle());
assertEquals("file name", "poem1.xml", poem.getFile().getName());
Modified: trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java 2008-03-04 20:02:25 UTC (rev 20)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java 2008-03-04 21:47:42 UTC (rev 21)
@@ -15,6 +15,9 @@
package net.sf.poem.cli.test;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
import junit.framework.TestCase;
import net.sf.poem.cli.Command;
import net.sf.poem.cli.PoemCommandLine;
@@ -40,7 +43,7 @@
/**
- *
+ * Descendant of PoemCommandLine for testing purposes.
*/
public class TestPoemCommandLine extends PoemCommandLine {
@@ -59,4 +62,11 @@
assertSame("Command line", args, performArgs);
}
+ public void testUsage() {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ new PoemCommandLine(new PrintStream(baos)).run(new String[]{});
+ String output = new String(baos.toByteArray()).toLowerCase();
+ assertTrue("No usage message", output.indexOf("supported commands") >= 0);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-04 20:02:23
|
Revision: 20
http://poem.svn.sourceforge.net/poem/?rev=20&view=rev
Author: maledee
Date: 2008-03-04 12:02:25 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
[ 1905255 ] binary distro is broken
https://sourceforge.net/tracker/index.php?func=detail&aid=1905255&group_id=217871&atid=1041571
Modified Paths:
--------------
trunk/poem/build-common.xml
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-02 13:04:04 UTC (rev 19)
+++ trunk/poem/build-common.xml 2008-03-04 20:02:25 UTC (rev 20)
@@ -276,6 +276,7 @@
<param name="dest.file" value="${dist.dir}${project}-${client}-bin-${version}.zip" />
<param name="base.dir" value="${build.dir}" />
<param name="includes" value="${src.file.name}" />
+ <param name="keep.line.endings" value="true"/>
</antcall>
<delete file="${dist.jar.file}" />
</target>
@@ -292,7 +293,10 @@
<property name="zip.file" value="${dest.dir}${file.separator}${dest.base}.zip" />
<property name="tar.file" value="${dest.dir}${file.separator}${dest.base}.tar.gz" />
- <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="dos" eof="add" />
+ <antcall target="--fix-line-endings">
+ <param name="eol" value="dos"/>
+ <param name="eof" value="add"/>
+ </antcall>
<zip destfile="${zip.file}" basedir="${base.dir}" includes="${includes}" update="${update}"
level="9" />
<antcall target="--checksum">
@@ -309,12 +313,24 @@
<param name="file" value="${tar.file}" />
</antcall>
- <fixcrlf srcdir="${base.dir}" includes="${includes}" />
+ <antcall target="--restore-line-endings"/>
</target>
+ <target name="--fix-line-endings" unless="keep.line.endings">
+ <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="${eol}" eof="${eof}" />
+ </target>
+
+ <target name="--restore-line-endings" unless="keep.line.endings">
+ <fixcrlf srcdir="${base.dir}" includes="${includes}" />
+ </target>
+
+
<target name="--create-tar" unless="update.tar">
- <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="unix" eof="remove" />
+ <antcall target="--fix-line-endings">
+ <param name="eol" value="unix"/>
+ <param name="eof" value="remove"/>
+ </antcall>
<tar destfile="${tar.file}" basedir="${base.dir}" includes="${includes}"
compression="${tar.compression}" />
</target>
@@ -334,7 +350,10 @@
<copy todir="${tmp.dir}">
<fileset dir="${base.dir}" includes="${includes}" />
</copy>
- <fixcrlf srcdir="${tmp.dir}" includes="${includes}" eol="unix" eof="remove" />
+ <antcall target="--fix-line-endings">
+ <param name="eol" value="unix"/>
+ <param name="eof" value="remove"/>
+ </antcall>
<tar destfile="${tar.file}" basedir="${tmp.dir}" includes="**/*"
compression="${tar.compression}" />
<delete dir="${tmp.dir}" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-02 13:04:05
|
Revision: 19
http://poem.svn.sourceforge.net/poem/?rev=19&view=rev
Author: maledee
Date: 2008-03-02 05:04:04 -0800 (Sun, 02 Mar 2008)
Log Message:
-----------
[ 1897277 ] Do not replace classes with instrumented version
http://sourceforge.net/tracker/index.php?func=detail&aid=1897277&group_id=217871&atid=1041571
Modified Paths:
--------------
trunk/poem/build-common.xml
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-03-01 11:38:12 UTC (rev 18)
+++ trunk/poem/build-common.xml 2008-03-02 13:04:04 UTC (rev 19)
@@ -138,16 +138,19 @@
<target name="--test-java">
- <uptodate property="java.tested" targetfile="${dest.dir}tests${file.separator}index.html">
+ <uptodate property="java.tested" targetfile="${dest.dir}test${file.separator}index.html">
<srcfiles dir="${src.dir}" includes="**/*.java" />
</uptodate>
<antcall target="--do-test-java" />
</target>
<target name="--do-test-java" unless="java.tested">
- <property name="test.reports.dir" value="temp.testreports" />
+ <property name="test.reports.dir" value="${build.dir}temp.testreports" />
+ <property name="instrumented.dir" value="${build.dir}instrumented${file.separator}${client}" />
+
<delete file="${test.coverage.file}" />
- <cobertura-instrument datafile="${test.coverage.file}">
+ <mkdir dir="${instrumented.dir}"/>
+ <cobertura-instrument datafile="${test.coverage.file}" todir="${instrumented.dir}">
<includeClasses regex="${coverage.prefix}.*" />
<excludeClasses regex=".*\.test\..*" />
<instrumentationClasspath>
@@ -162,9 +165,10 @@
<sysproperty key="${test.coverage.file.property}" file="${test.coverage.file}" />
<classpath>
- <path refid="${test.src.path}" />
+ <fileset dir="${instrumented.dir}" includes="**/*" />
<pathelement location="${junit.jar}" />
<path refid="test.coverage.path" />
+ <path refid="${test.src.path}" />
</classpath>
<formatter type="brief" usefile="false" />
@@ -178,12 +182,13 @@
<fileset dir="${test.reports.dir}">
<include name="TEST-*.xml" />
</fileset>
- <report format="frames" todir="${dest.dir}tests" />
+ <report format="frames" todir="${dest.dir}test${file.separator}${client}" />
</junitreport>
<delete dir="${test.reports.dir}" />
+ <delete dir="${instrumented.dir}" />
<fail message="Some test(s) failed" if="failure" />
- <cobertura-report format="html" destdir="${dest.dir}coverage"
+ <cobertura-report format="html" destdir="${dest.dir}coverage${file.separator}${client}"
datafile="${test.coverage.file}">
<fileset dir="${src.dir}" includes="**/*.java" />
</cobertura-report>
@@ -199,7 +204,6 @@
<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>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-03-01 11:43:32
|
Revision: 18
http://poem.svn.sourceforge.net/poem/?rev=18&view=rev
Author: maledee
Date: 2008-03-01 03:38:12 -0800 (Sat, 01 Mar 2008)
Log Message:
-----------
[ 1897961 ] Fix distribution
Modified Paths:
--------------
trunk/poem/build-api.xml
trunk/poem/build-common.xml
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-02-27 08:53:20 UTC (rev 17)
+++ trunk/poem/build-api.xml 2008-03-01 11:38:12 UTC (rev 18)
@@ -51,7 +51,7 @@
<!-- Binary package -->
<antcall target="--publish-java-package">
- <param name="sub.project" value="core"/>
+ <param name="client" value="api"/>
<param name="src.file" value="${main.jar.file}"/>
</antcall>
<antcall target="--package-binary">
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-02-27 08:53:20 UTC (rev 17)
+++ trunk/poem/build-common.xml 2008-03-01 11:38:12 UTC (rev 18)
@@ -60,17 +60,17 @@
<target name="--check-up-to-date">
- <property name="sub.project.dir" value="..${file.separator}${sub.project}${file.separator}" />
- <property name="sub.project.timestamp.file" value="${sub.project.dir}${timestamp.file}" />
- <available property="sub.project.timestamp.available" file="${sub.project.timestamp.file}" />
- <fail unless="sub.project.timestamp.available"
- message="Project '${sub.project}' is not up to date (not verified)" />
+ <property name="client.dir" value="..${file.separator}${client}${file.separator}" />
+ <property name="client.timestamp.file" value="${client.dir}${timestamp.file}" />
+ <available property="client.timestamp.available" file="${client.timestamp.file}" />
+ <fail unless="client.timestamp.available"
+ message="Project '${client}' is not up to date (not verified)" />
- <uptodate property="sub.project.uptodate" targetfile="${sub.project.timestamp.file}">
- <srcfiles dir="${sub.project.dir}" includes="**/*" excludes="${timestamp.file}" />
+ <uptodate property="client.uptodate" targetfile="${client.timestamp.file}">
+ <srcfiles dir="${client.dir}" includes="**/*" excludes="${timestamp.file}" />
</uptodate>
- <fail unless="sub.project.uptodate"
- message="Project '${sub.project}' is not up to date (newer files)" />
+ <fail unless="client.uptodate"
+ message="Project '${client}' is not up to date (newer files)" />
</target>
@@ -258,18 +258,18 @@
<target name="--package-binary">
<antcall target="--do-package-binary">
<param name="dest.file"
- value="${dist.dir}${project}-${sub.project}-${package}-${version}.zip" />
+ value="${dist.dir}${project}-${client}-${package}-${version}.zip" />
<param name="base.dir" value="${src.dir}" />
</antcall>
</target>
<target name="--publish-java-package">
- <property name="src.file.name" value="${project}-${sub.project}-${version}.jar" />
+ <property name="src.file.name" value="${project}-${client}-${version}.jar" />
<property name="dist.jar.file" value="${build.dir}${src.file.name}" />
<copy file="${src.file}" tofile="${dist.jar.file}" />
<antcall target="--do-package-binary">
- <param name="dest.file" value="${dist.dir}${project}-${sub.project}-bin-${version}.zip" />
+ <param name="dest.file" value="${dist.dir}${project}-${client}-bin-${version}.zip" />
<param name="base.dir" value="${build.dir}" />
<param name="includes" value="${src.file.name}" />
</antcall>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-27 08:53:18
|
Revision: 17
http://poem.svn.sourceforge.net/poem/?rev=17&view=rev
Author: maledee
Date: 2008-02-27 00:53:20 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
#1897951: cobertura.ser
Modified Paths:
--------------
trunk/poem/build-common.xml
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-02-20 15:16:18 UTC (rev 16)
+++ trunk/poem/build-common.xml 2008-02-27 08:53:20 UTC (rev 17)
@@ -1,417 +1,421 @@
-<project name="build-common">
-
- <property name="project" value="poem" />
- <property name="timestamp.file" value="latest.build" />
- <property name="build.dir" value="build${file.separator}"/>
- <property name="src.dir" value="src${file.separator}" />
- <property name="plan.dir" value="${src.dir}plan${file.separator}" />
- <property name="main.dir" value="${src.dir}main${file.separator}" />
- <dirname property="root.dir.base" file="${ant.file.build-common}" />
- <property name="root.dir" value="${root.dir.base}${file.separator}" />
- <property name="dist.dir" value="${root.dir}dist${file.separator}" />
- <property name="lib.dir" value="${root.dir}lib${file.separator}" />
- <property name="xsd.lib.dir" value="${lib.dir}xsd${file.separator}" />
- <property name="junit.jar" value="${lib.dir}junit-3.8.2.jar" />
- <property name="cobertura.dir" value="${lib.dir}cobertura${file.separator}" />
- <property name="test.coverage.file" value="${cobertura.dir}cobertura.ser" />
- <property name="test.coverage.file.property" value="net.sourceforge.cobertura.datafile" />
- <property name="fit.lib.dir" value="${lib.dir}fit${file.separator}"/>
- <property name="fit.jar" value="${lib.dir}fit${file.separator}fit.jar" />
-
- <property name="main.java.dir" value="${main.dir}java"/>
- <property name="main.class.dir" value="${build.dir}main"/>
- <property name="main.jar.file" value="${build.dir}main.jar"/>
-
- <property name="test.java.dir" value="${src.dir}test${file.separator}java"/>
- <property name="test.class.dir" value="${build.dir}test"/>
- <property name="test.jar.file" value="${build.dir}test.jar"/>
-
- <property name="report.dir" value="${build.dir}reports${file.separator}"/>
-
- <property name="fit.base.dir" value="${src.dir}fit${file.separator}"/>
- <property name="fit.java.dir" value="${fit.base.dir}java${file.separator}"/>
- <property name="fit.class.dir" value="${build.dir}fit"/>
- <property name="fit.jar.file" value="${build.dir}fit.jar"/>
- <property name="fit.test.dir" value="${fit.base.dir}html${file.separator}"/>
- <property name="fit.report.dir" value="${report.dir}fit${file.separator}"/>
+<project name="build-common">
- <property name="xmlbeans.dir" value="${lib.dir}xmlbeans${file.separator}"/>
-
- <property file="${root.dir}build.properties" />
-
-
- <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"/>
-
-
- <!-- Cobertura tasks -->
- <path id="test.coverage.path">
- <fileset dir="${cobertura.dir}" includes="cobertura.jar lib/**/*.jar" />
- </path>
- <taskdef resource="tasks.properties">
- <classpath refid="test.coverage.path" />
- </taskdef>
-
- <!-- Checkstyle tasks -->
- <taskdef resource="checkstyletask.properties" classpath="${lib.dir}checkstyle-all-4.3.jar"/>
-
-
- <target name="--check-up-to-date">
- <property name="sub.project.dir" value="..${file.separator}${sub.project}${file.separator}" />
- <property name="sub.project.timestamp.file" value="${sub.project.dir}${timestamp.file}" />
- <available property="sub.project.timestamp.available" file="${sub.project.timestamp.file}" />
- <fail unless="sub.project.timestamp.available" message="Project '${sub.project}' is not up to date (not verified)" />
-
- <uptodate property="sub.project.uptodate" targetfile="${sub.project.timestamp.file}">
- <srcfiles dir="${sub.project.dir}" includes="**/*" excludes="${timestamp.file}" />
- </uptodate>
- <fail unless="sub.project.uptodate" message="Project '${sub.project}' is not up to date (newer files)" />
- </target>
-
-
- <target name="--set-up-to-date">
- <touch file="${timestamp.file}" />
- </target>
-
-
- <target name="--clean">
- <delete file="${timestamp.file}" />
- <delete dir="${dist.dir}" />
- <delete dir="${build.dir}" />
- <delete file="${test.coverage.file}" />
- </target>
-
-
- <target name="--validate-xsd">
- <property name="xsd.validated.file" value="${build.dir}xsd.validated"/>
- <uptodate property="xsd.validated" targetfile="${xsd.validated.file}">
- <srcfiles dir="${src.dir}" includes="**/*.xsd" />
- </uptodate>
- <antcall target="--do-validate-xsd"/>
- </target>
-
- <target name="--do-validate-xsd" unless="xsd.validated">
- <schemavalidate lenient="false">
- <fileset dir="${src.dir}" includes="**/*.xsd" />
- <schema namespace="http://www.w3.org/2001/XMLSchema"
- url="http://www.w3.org/2001/XMLSchema.xsd" />
- </schemavalidate>
- <touch file="${xsd.validated.file}" mkdirs="true"/>
- </target>
-
-
- <target name="--validate-xml">
- <property name="xml.validated.file" value="${src.dir}xml.validated"/>
- <uptodate property="xml.validated" targetfile="${xml.validated.file}">
- <srcfiles dir="${src.dir}" includes="**/*" />
- </uptodate>
- <antcall target="--do-validate-xml"/>
- </target>
-
- <target name="--do-validate-xml" unless="xml.validated">
- <schemavalidate lenient="false">
- <fileset dir="${src.dir}" includes="**/*.story **/*.release **/*.xml"/>
- </schemavalidate>
- <touch file="${xml.validated.file}" mkdirs="true"/>
- </target>
-
-
- <target name="--compile-java">
- <!-- Check source -->
- <checkstyle config="${root.dir}checkstyle_checks.xml"
- failonviolation="true" maxwarnings="0">
- <fileset dir="${src.dir}" includes="**/*.java"/>
- </checkstyle>
-
- <!-- Compile source -->
- <mkdir dir="${dest.dir}" />
- <path id="compile.class.path">
- <path refid="${class.path}" />
- </path>
- <javac srcdir="${src.dir}" destdir="${dest.dir}" debug="true"
- classpathref="compile.class.path"
- source="${java.source.version}" target="${java.source.version}" />
- </target>
-
-
- <target name="--test-java">
- <uptodate property="java.tested" targetfile="${dest.dir}tests${file.separator}index.html">
- <srcfiles dir="${src.dir}" includes="**/*.java" />
- </uptodate>
- <antcall target="--do-test-java"/>
- </target>
-
- <target name="--do-test-java" unless="java.tested">
- <property name="test.reports.dir" value="temp.testreports" />
- <delete file="${test.coverage.file}" />
- <cobertura-instrument datafile="${test.coverage.file}">
- <includeClasses regex="${coverage.prefix}.*" />
- <excludeClasses regex=".*\.test\..*" />
- <instrumentationClasspath>
- <path refid="${test.src.path}" />
- </instrumentationClasspath>
- </cobertura-instrument>
-
- <mkdir dir="${dest.dir}" />
- <mkdir dir="${test.reports.dir}" />
-
- <junit fork="yes" forkmode="once">
- <sysproperty key="${test.coverage.file.property}" file="${test.coverage.file}" />
-
- <classpath>
- <path refid="${test.src.path}" />
- <pathelement location="${junit.jar}" />
- <path refid="test.coverage.path" />
- </classpath>
-
- <formatter type="brief" usefile="false" />
- <formatter type="xml" />
-
- <batchtest todir="${test.reports.dir}" failureproperty="failure">
- <fileset dir="${test.src.dir}" includes="**/*Test.java" excludes="**/Abstract*" />
- </batchtest>
- </junit>
- <junitreport todir="${test.reports.dir}">
- <fileset dir="${test.reports.dir}">
- <include name="TEST-*.xml" />
- </fileset>
- <report format="frames" todir="${dest.dir}tests" />
- </junitreport>
- <delete dir="${test.reports.dir}" />
- <fail message="Some test(s) failed" if="failure" />
-
- <cobertura-report format="html" destdir="${dest.dir}coverage"
- datafile="${test.coverage.file}">
- <fileset dir="${src.dir}" includes="**/*.java" />
- </cobertura-report>
- <cobertura-check datafile="${test.coverage.file}" linerate="${test.coverage.linerate}" />
- </target>
-
-
+ <property name="project" value="poem" />
+ <property name="timestamp.file" value="latest.build" />
+ <property name="build.dir" value="build${file.separator}" />
+ <property name="src.dir" value="src${file.separator}" />
+ <property name="plan.dir" value="${src.dir}plan${file.separator}" />
+ <property name="main.dir" value="${src.dir}main${file.separator}" />
+ <dirname property="root.dir.base" file="${ant.file.build-common}" />
+ <property name="root.dir" value="${root.dir.base}${file.separator}" />
+ <property name="dist.dir" value="${root.dir}dist${file.separator}" />
+ <property name="lib.dir" value="${root.dir}lib${file.separator}" />
+ <property name="xsd.lib.dir" value="${lib.dir}xsd${file.separator}" />
+ <property name="junit.jar" value="${lib.dir}junit-3.8.2.jar" />
+ <property name="cobertura.dir" value="${lib.dir}cobertura${file.separator}" />
+ <property name="test.coverage.file" value="${build.dir}cobertura.ser" />
+ <property name="test.coverage.file.property" value="net.sourceforge.cobertura.datafile" />
+ <property name="fit.lib.dir" value="${lib.dir}fit${file.separator}" />
+ <property name="fit.jar" value="${lib.dir}fit${file.separator}fit.jar" />
+
+ <property name="main.java.dir" value="${main.dir}java" />
+ <property name="main.class.dir" value="${build.dir}main" />
+ <property name="main.jar.file" value="${build.dir}main.jar" />
+
+ <property name="test.java.dir" value="${src.dir}test${file.separator}java" />
+ <property name="test.class.dir" value="${build.dir}test" />
+ <property name="test.jar.file" value="${build.dir}test.jar" />
+
+ <property name="report.dir" value="${build.dir}reports${file.separator}" />
+
+ <property name="fit.base.dir" value="${src.dir}fit${file.separator}" />
+ <property name="fit.java.dir" value="${fit.base.dir}java${file.separator}" />
+ <property name="fit.class.dir" value="${build.dir}fit" />
+ <property name="fit.jar.file" value="${build.dir}fit.jar" />
+ <property name="fit.test.dir" value="${fit.base.dir}html${file.separator}" />
+ <property name="fit.report.dir" value="${report.dir}fit${file.separator}" />
+
+ <property name="xmlbeans.dir" value="${lib.dir}xmlbeans${file.separator}" />
+
+ <property file="${root.dir}build.properties" />
+
+
+ <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" />
+
+
+ <!-- Cobertura tasks -->
+ <path id="test.coverage.path">
+ <fileset dir="${cobertura.dir}" includes="cobertura.jar lib/**/*.jar" />
+ </path>
+ <taskdef resource="tasks.properties">
+ <classpath refid="test.coverage.path" />
+ </taskdef>
+
+ <!-- Checkstyle tasks -->
+ <taskdef resource="checkstyletask.properties" classpath="${lib.dir}checkstyle-all-4.3.jar" />
+
+
+ <target name="--check-up-to-date">
+ <property name="sub.project.dir" value="..${file.separator}${sub.project}${file.separator}" />
+ <property name="sub.project.timestamp.file" value="${sub.project.dir}${timestamp.file}" />
+ <available property="sub.project.timestamp.available" file="${sub.project.timestamp.file}" />
+ <fail unless="sub.project.timestamp.available"
+ message="Project '${sub.project}' is not up to date (not verified)" />
+
+ <uptodate property="sub.project.uptodate" targetfile="${sub.project.timestamp.file}">
+ <srcfiles dir="${sub.project.dir}" includes="**/*" excludes="${timestamp.file}" />
+ </uptodate>
+ <fail unless="sub.project.uptodate"
+ message="Project '${sub.project}' is not up to date (newer files)" />
+ </target>
+
+
+ <target name="--set-up-to-date">
+ <touch file="${timestamp.file}" />
+ </target>
+
+
+ <target name="--clean">
+ <delete file="${timestamp.file}" />
+ <delete dir="${dist.dir}" />
+ <delete dir="${build.dir}" />
+ <delete file="${test.coverage.file}" />
+ </target>
+
+
+ <target name="--validate-xsd">
+ <property name="xsd.validated.file" value="${build.dir}xsd.validated" />
+ <uptodate property="xsd.validated" targetfile="${xsd.validated.file}">
+ <srcfiles dir="${src.dir}" includes="**/*.xsd" />
+ </uptodate>
+ <antcall target="--do-validate-xsd" />
+ </target>
+
+ <target name="--do-validate-xsd" unless="xsd.validated">
+ <schemavalidate lenient="false">
+ <fileset dir="${src.dir}" includes="**/*.xsd" />
+ <schema namespace="http://www.w3.org/2001/XMLSchema"
+ url="http://www.w3.org/2001/XMLSchema.xsd" />
+ </schemavalidate>
+ <touch file="${xsd.validated.file}" mkdirs="true" />
+ </target>
+
+
+ <target name="--validate-xml">
+ <property name="xml.validated.file" value="${src.dir}xml.validated" />
+ <uptodate property="xml.validated" targetfile="${xml.validated.file}">
+ <srcfiles dir="${src.dir}" includes="**/*" />
+ </uptodate>
+ <antcall target="--do-validate-xml" />
+ </target>
+
+ <target name="--do-validate-xml" unless="xml.validated">
+ <schemavalidate lenient="false">
+ <fileset dir="${src.dir}" includes="**/*.story **/*.release **/*.xml" />
+ </schemavalidate>
+ <touch file="${xml.validated.file}" mkdirs="true" />
+ </target>
+
+
+ <target name="--compile-java">
+ <!-- Check source -->
+ <checkstyle config="${root.dir}checkstyle_checks.xml" failonviolation="true" maxwarnings="0">
+ <fileset dir="${src.dir}" includes="**/*.java" />
+ </checkstyle>
+
+ <!-- Compile source -->
+ <mkdir dir="${dest.dir}" />
+ <path id="compile.class.path">
+ <path refid="${class.path}" />
+ </path>
+ <javac srcdir="${src.dir}" destdir="${dest.dir}" debug="true" classpathref="compile.class.path"
+ source="${java.source.version}" target="${java.source.version}" />
+ </target>
+
+
+ <target name="--test-java">
+ <uptodate property="java.tested" targetfile="${dest.dir}tests${file.separator}index.html">
+ <srcfiles dir="${src.dir}" includes="**/*.java" />
+ </uptodate>
+ <antcall target="--do-test-java" />
+ </target>
+
+ <target name="--do-test-java" unless="java.tested">
+ <property name="test.reports.dir" value="temp.testreports" />
+ <delete file="${test.coverage.file}" />
+ <cobertura-instrument datafile="${test.coverage.file}">
+ <includeClasses regex="${coverage.prefix}.*" />
+ <excludeClasses regex=".*\.test\..*" />
+ <instrumentationClasspath>
+ <path refid="${test.src.path}" />
+ </instrumentationClasspath>
+ </cobertura-instrument>
+
+ <mkdir dir="${dest.dir}" />
+ <mkdir dir="${test.reports.dir}" />
+
+ <junit fork="yes" forkmode="once">
+ <sysproperty key="${test.coverage.file.property}" file="${test.coverage.file}" />
+
+ <classpath>
+ <path refid="${test.src.path}" />
+ <pathelement location="${junit.jar}" />
+ <path refid="test.coverage.path" />
+ </classpath>
+
+ <formatter type="brief" usefile="false" />
+ <formatter type="xml" />
+
+ <batchtest todir="${test.reports.dir}" failureproperty="failure">
+ <fileset dir="${test.src.dir}" includes="**/*Test.java" excludes="**/Abstract*" />
+ </batchtest>
+ </junit>
+ <junitreport todir="${test.reports.dir}">
+ <fileset dir="${test.reports.dir}">
+ <include name="TEST-*.xml" />
+ </fileset>
+ <report format="frames" todir="${dest.dir}tests" />
+ </junitreport>
+ <delete dir="${test.reports.dir}" />
+ <fail message="Some test(s) failed" if="failure" />
+
+ <cobertura-report format="html" destdir="${dest.dir}coverage"
+ datafile="${test.coverage.file}">
+ <fileset dir="${src.dir}" includes="**/*.java" />
+ </cobertura-report>
+ <cobertura-check datafile="${test.coverage.file}" linerate="${test.coverage.linerate}" />
+ </target>
+
+
<target name="--test-fit">
- <java classname="fitlibrary.runner.FolderRunner" fork="yes" failonerror="true">
- <arg value="${fit.test.dir}"/>
- <arg value="${fit.report.dir}"/>
- <classpath>
- <pathelement path="${fit.lib.dir}fitlibraryRunner.jar"/>
- <pathelement path="${fit.lib.dir}poi-2.5-final-20040302.jar"/>
- <pathelement path="${fit.lib.path}"/>
+ <java classname="fitlibrary.runner.FolderRunner" fork="yes" failonerror="true">
+ <arg value="${fit.test.dir}" />
+ <arg value="${fit.report.dir}" />
+ <classpath>
+ <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>
-
-
- <target name="--create-java-doc">
- <property name="dest.dir" value="${build.dir}javadoc${file.separator}"/>
- <uptodate property="java.doc.created" targetfile="${dest.dir}index.html">
- <srcfiles dir="${src.dir}" includes="**/*.java" />
- </uptodate>
- <antcall target="--do-create-java-doc"/>
- </target>
-
- <target name="--do-create-java-doc" unless="java.doc.created">
- <javadoc destdir="${dest.dir}" source="${java.source.version}" includenosourcepackages="true">
- <packageset dir="${src.dir}" />
- </javadoc>
- </target>
-
-
- <target name="--package-java">
- <dirname file="${dest.file}" property="dest.dir"/>
- <mkdir dir="${dest.dir}"/>
- <mkdir dir="${src.dir}"/>
- <antcall target="--package-java-source"/>
- <antcall target="--package-java-source-and-resources"/>
- </target>
-
- <target name="--package-java-source" unless="resources.dir">
- <jar destfile="${dest.file}" filesetmanifest="merge">
- <fileset dir="${src.dir}" includes="**/*.class" />
- </jar>
- </target>
-
- <target name="--package-java-source-and-resources" if="resources.dir">
- <mkdir dir="${resources.dir}"/>
- <antcall target="--package-java-source-and-resources-without-manifest"/>
- <antcall target="--package-java-source-and-resources-with-manifest"/>
- </target>
-
- <target name="--package-java-source-and-resources-with-manifest" if="manifest">
- <jar destfile="${dest.file}" manifest="${manifest}">
- <fileset dir="${src.dir}" includes="**/*.class" />
- <fileset dir="${resources.dir}" includes="**/*" />
- </jar>
- </target>
-
- <target name="--package-java-source-and-resources-without-manifest" unless="manifest">
- <jar destfile="${dest.file}">
- <fileset dir="${src.dir}" includes="**/*.class" />
- <fileset dir="${resources.dir}" includes="**/*" />
- </jar>
- </target>
-
-
- <target name="--package-binary">
- <antcall target="--do-package-binary">
- <param name="dest.file" value="${dist.dir}${project}-${sub.project}-${package}-${version}.zip"/>
- <param name="base.dir" value="${src.dir}"/>
- </antcall>
- </target>
-
-
- <target name="--publish-java-package">
- <property name="src.file.name" value="${project}-${sub.project}-${version}.jar" />
- <property name="dist.jar.file" value="${build.dir}${src.file.name}" />
- <copy file="${src.file}" tofile="${dist.jar.file}" />
- <antcall target="--do-package-binary">
- <param name="dest.file" value="${dist.dir}${project}-${sub.project}-bin-${version}.zip" />
- <param name="base.dir" value="${build.dir}"/>
- <param name="includes" value="${src.file.name}"/>
- </antcall>
- <delete file="${dist.jar.file}" />
- </target>
-
-
- <target name="--do-package-binary">
- <property name="update" value="false" />
- <property name="includes" value="**/*" />
-
- <dirname file="${dest.file}" property="dest.dir"/>
- <mkdir dir="${dest.dir}"/>
-
- <basename file="${dest.file}" suffix=".zip" property="dest.base"/>
- <property name="zip.file" value="${dest.dir}${file.separator}${dest.base}.zip"/>
- <property name="tar.file" value="${dest.dir}${file.separator}${dest.base}.tar.gz"/>
-
- <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="dos" eof="add" />
- <zip destfile="${zip.file}" basedir="${base.dir}" includes="${includes}"
- update="${update}" level="9"/>
+ </classpath>
+ </java>
+ </target>
+
+
+ <target name="--create-java-doc">
+ <property name="dest.dir" value="${build.dir}javadoc${file.separator}" />
+ <uptodate property="java.doc.created" targetfile="${dest.dir}index.html">
+ <srcfiles dir="${src.dir}" includes="**/*.java" />
+ </uptodate>
+ <antcall target="--do-create-java-doc" />
+ </target>
+
+ <target name="--do-create-java-doc" unless="java.doc.created">
+ <javadoc destdir="${dest.dir}" source="${java.source.version}" includenosourcepackages="true">
+ <packageset dir="${src.dir}" />
+ </javadoc>
+ </target>
+
+
+ <target name="--package-java">
+ <dirname file="${dest.file}" property="dest.dir" />
+ <mkdir dir="${dest.dir}" />
+ <mkdir dir="${src.dir}" />
+ <antcall target="--package-java-source" />
+ <antcall target="--package-java-source-and-resources" />
+ </target>
+
+ <target name="--package-java-source" unless="resources.dir">
+ <jar destfile="${dest.file}" filesetmanifest="merge">
+ <fileset dir="${src.dir}" includes="**/*.class" />
+ </jar>
+ </target>
+
+ <target name="--package-java-source-and-resources" if="resources.dir">
+ <mkdir dir="${resources.dir}" />
+ <antcall target="--package-java-source-and-resources-without-manifest" />
+ <antcall target="--package-java-source-and-resources-with-manifest" />
+ </target>
+
+ <target name="--package-java-source-and-resources-with-manifest" if="manifest">
+ <jar destfile="${dest.file}" manifest="${manifest}">
+ <fileset dir="${src.dir}" includes="**/*.class" />
+ <fileset dir="${resources.dir}" includes="**/*" />
+ </jar>
+ </target>
+
+ <target name="--package-java-source-and-resources-without-manifest" unless="manifest">
+ <jar destfile="${dest.file}">
+ <fileset dir="${src.dir}" includes="**/*.class" />
+ <fileset dir="${resources.dir}" includes="**/*" />
+ </jar>
+ </target>
+
+
+ <target name="--package-binary">
+ <antcall target="--do-package-binary">
+ <param name="dest.file"
+ value="${dist.dir}${project}-${sub.project}-${package}-${version}.zip" />
+ <param name="base.dir" value="${src.dir}" />
+ </antcall>
+ </target>
+
+
+ <target name="--publish-java-package">
+ <property name="src.file.name" value="${project}-${sub.project}-${version}.jar" />
+ <property name="dist.jar.file" value="${build.dir}${src.file.name}" />
+ <copy file="${src.file}" tofile="${dist.jar.file}" />
+ <antcall target="--do-package-binary">
+ <param name="dest.file" value="${dist.dir}${project}-${sub.project}-bin-${version}.zip" />
+ <param name="base.dir" value="${build.dir}" />
+ <param name="includes" value="${src.file.name}" />
+ </antcall>
+ <delete file="${dist.jar.file}" />
+ </target>
+
+
+ <target name="--do-package-binary">
+ <property name="update" value="false" />
+ <property name="includes" value="**/*" />
+
+ <dirname file="${dest.file}" property="dest.dir" />
+ <mkdir dir="${dest.dir}" />
+
+ <basename file="${dest.file}" suffix=".zip" property="dest.base" />
+ <property name="zip.file" value="${dest.dir}${file.separator}${dest.base}.zip" />
+ <property name="tar.file" value="${dest.dir}${file.separator}${dest.base}.tar.gz" />
+
+ <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="dos" eof="add" />
+ <zip destfile="${zip.file}" basedir="${base.dir}" includes="${includes}" update="${update}"
+ level="9" />
<antcall target="--checksum">
- <param name="file" value="${zip.file}"/>
- </antcall>
-
- <!-- tar cannot update its contents like zip can, so simulate that -->
- <condition property="update.tar">
- <equals arg1="${update}" arg2="true"/>
- </condition>
- <antcall target="--create-tar"/>
- <antcall target="--update-tar"/>
+ <param name="file" value="${zip.file}" />
+ </antcall>
+
+ <!-- tar cannot update its contents like zip can, so simulate that -->
+ <condition property="update.tar">
+ <equals arg1="${update}" arg2="true" />
+ </condition>
+ <antcall target="--create-tar" />
+ <antcall target="--update-tar" />
<antcall target="--checksum">
- <param name="file" value="${tar.file}"/>
+ <param name="file" value="${tar.file}" />
</antcall>
-
- <fixcrlf srcdir="${base.dir}" includes="${includes}" />
- </target>
-
-
- <target name="--create-tar" unless="update.tar">
- <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="unix" eof="remove" />
- <tar destfile="${tar.file}" basedir="${base.dir}" includes="${includes}" compression="${tar.compression}" />
- </target>
-
-
+
+ <fixcrlf srcdir="${base.dir}" includes="${includes}" />
+ </target>
+
+
+ <target name="--create-tar" unless="update.tar">
+ <fixcrlf srcdir="${base.dir}" includes="${includes}" eol="unix" eof="remove" />
+ <tar destfile="${tar.file}" basedir="${base.dir}" includes="${includes}"
+ compression="${tar.compression}" />
+ </target>
+
+
<target name="--update-tar" if="update.tar">
- <available file="${tar.file}" property="tar.file.found"/>
- <antcall target="--do-update-tar"/>
+ <available file="${tar.file}" property="tar.file.found" />
+ <antcall target="--do-update-tar" />
</target>
-
-
- <target name="--do-update-tar" if="tar.file.found">
- <dirname property="dest.dir" file="${tar.file}"/>
- <property name="tmp.dir" value="${dest.dir}/tar.tmp"/>
- <mkdir dir="${tmp.dir}"/>
- <untar src="${tar.file}" dest="${tmp.dir}" compression="${tar.compression}"/>
- <copy todir="${tmp.dir}">
- <fileset dir="${base.dir}" includes="${includes}"/>
- </copy>
- <fixcrlf srcdir="${tmp.dir}" includes="${includes}" eol="unix" eof="remove" />
- <tar destfile="${tar.file}" basedir="${tmp.dir}" includes="**/*" compression="${tar.compression}" />
- <delete dir="${tmp.dir}"/>
+
+
+ <target name="--do-update-tar" if="tar.file.found">
+ <dirname property="dest.dir" file="${tar.file}" />
+ <property name="tmp.dir" value="${dest.dir}/tar.tmp" />
+ <mkdir dir="${tmp.dir}" />
+ <untar src="${tar.file}" dest="${tmp.dir}" compression="${tar.compression}" />
+ <copy todir="${tmp.dir}">
+ <fileset dir="${base.dir}" includes="${includes}" />
+ </copy>
+ <fixcrlf srcdir="${tmp.dir}" includes="${includes}" eol="unix" eof="remove" />
+ <tar destfile="${tar.file}" basedir="${tmp.dir}" includes="**/*"
+ compression="${tar.compression}" />
+ <delete dir="${tmp.dir}" />
</target>
-
-
+
+
<target name="--checksum">
- <available file="${file}" property="checksum.file.found"/>
- <antcall target="--do-checksum"/>
+ <available file="${file}" property="checksum.file.found" />
+ <antcall target="--do-checksum" />
</target>
-
-
+
+
<target name="--do-checksum" if="checksum.file.found">
- <checksum file="${file}" algorithm="MD5"/>
- <checksum file="${file}" algorithm="SHA"/>
- </target>
-
+ <checksum file="${file}" algorithm="MD5" />
+ <checksum file="${file}" algorithm="SHA" />
+ </target>
+
<target name="--xml-beans">
- <property name="includes" value="**/*.xsd*"/>
- <dirname file="${xml.beans.jar}" property="dest.dir"/>
+ <property name="includes" value="**/*.xsd*" />
+ <dirname file="${xml.beans.jar}" property="dest.dir" />
<uptodate property="xmlbeans.generated" targetfile="${xml.beans.jar}">
<srcfiles dir="${schema.dir}" includes="${includes}" />
</uptodate>
- <antcall target="--do-xml-beans"/>
+ <antcall target="--do-xml-beans" />
</target>
<target name="--do-xml-beans" unless="xmlbeans.generated">
- <mkdir dir="${dest.dir}"/>
+ <mkdir dir="${dest.dir}" />
<path id="xmlbeans.path">
- <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ <fileset dir="${xmlbeans.dir}" includes="**/*.jar" />
</path>
- <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean">
- <classpath>
- <path refid="xmlbeans.path"/>
- </classpath>
- </taskdef>
+ <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean">
+ <classpath>
+ <path refid="xmlbeans.path" />
+ </classpath>
+ </taskdef>
<xmlbean destfile="${xml.beans.jar}" javasource="${java.source.version}">
<classpath>
- <path refid="xmlbeans.path"/>
+ <path refid="xmlbeans.path" />
</classpath>
- <fileset dir="${schema.dir}" includes="${includes}"/>
+ <fileset dir="${schema.dir}" includes="${includes}" />
</xmlbean>
</target>
-
-
- <target name="--upload-to-sourceforge">
- <ftp server="upload.sourceforge.net" userid="anonymous" password="${user}@sf.net" remotedir="/incoming" verbose="true">
- <fileset dir="${dist.dir}" includes="${project}-*-${version}.*" />
- </ftp>
- </target>
-
-
- <target name="--upload-to-website">
- <fail unless="user" message="Specify '-Duser=<user>' on the command line"/>
- <fail unless="password" message="Specify '-Dpassword=<password>' on the command line"/>
- <fail unless="keyfile" message="Specify '-Dkeyfile=<keyfile>' on the command line"/>
- <available file="${keyfile}" property="keyfile.found"/>
- <fail unless="keyfile.found" message="Could not find keyfile: ${keyfile}"/>
-
- <!-- Defaults -->
- <property name="upload.from.dir" value="src/site"/>
- <property name="upload.to.dir" value=""/>
- <property name="upload.includes" value="**/*"/>
- <property name="upload.excludes" value=""/>
-
- <echo message="upload from ${upload.from.dir} to ${upload.to.dir}"/>
- <available file="${site.upload.timestamp}" property="site.uploaded"/>
- <antcall target="--warn-scp-dependencies"/>
-
- <scp todir="${user}@shell.sourceforge.net:/home/groups/p/po/poem/htdocs/${upload.to.dir}"
- passphrase="${password}" keyfile="${keyfile}" sftp="true" verbose="true">
- <fileset dir="${upload.from.dir}" includes="${upload.includes}" excludes="${upload.excludes}"/>
+ <target name="--upload-to-sourceforge">
+ <ftp server="upload.sourceforge.net" userid="anonymous" password="${user}@sf.net"
+ remotedir="/incoming" verbose="true">
+ <fileset dir="${dist.dir}" includes="${project}-*-${version}.*" />
+ </ftp>
+ </target>
+
+
+ <target name="--upload-to-website">
+ <fail unless="user" message="Specify '-Duser=<user>' on the command line" />
+ <fail unless="password" message="Specify '-Dpassword=<password>' on the command line" />
+
+ <fail unless="keyfile" message="Specify '-Dkeyfile=<keyfile>' on the command line" />
+ <available file="${keyfile}" property="keyfile.found" />
+ <fail unless="keyfile.found" message="Could not find keyfile: ${keyfile}" />
+
+ <!-- Defaults -->
+ <property name="upload.from.dir" value="src/site" />
+ <property name="upload.to.dir" value="" />
+ <property name="upload.includes" value="**/*" />
+ <property name="upload.excludes" value="" />
+
+ <echo message="upload from ${upload.from.dir} to ${upload.to.dir}" />
+
+ <available file="${site.upload.timestamp}" property="site.uploaded" />
+ <antcall target="--warn-scp-dependencies" />
+
+ <scp todir="${user}@shell.sourceforge.net:/home/groups/p/po/poem/htdocs/${upload.to.dir}"
+ passphrase="${password}" keyfile="${keyfile}" sftp="true" verbose="true">
+ <fileset dir="${upload.from.dir}" includes="${upload.includes}" excludes="${upload.excludes}" />
</scp>
- <touch file="${site.upload.timestamp}" mkdirs="true"/>
- </target>
+ <touch file="${site.upload.timestamp}" mkdirs="true" />
+ </target>
<target name="--warn-scp-dependencies" unless="site.uploaded">
- <echo message="WARNING: If the scp task fails, then make sure the jsch jar"/>
- <echo message="is on the class path. You find this file in the lib directory."/>
- <echo message="Follow the on screen instructions on how to add this jar to the class path."/>
- </target>
-
-</project>
+ <echo message="WARNING: If the scp task fails, then make sure the jsch jar" />
+ <echo message="is on the class path. You find this file in the lib directory." />
+ <echo message="Follow the on screen instructions on how to add this jar to the class path." />
+ </target>
+
+</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-20 15:16:13
|
Revision: 16
http://poem.svn.sourceforge.net/poem/?rev=16&view=rev
Author: rsinnema
Date: 2008-02-20 07:16:18 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
Create a poem from the command line
Modified Paths:
--------------
trunk/poem/src/fit/html/create-poem.html
trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java
trunk/poem/src/main/java/net/sf/poem/cli/Command.java
trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java
trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
Added Paths:
-----------
trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java
trunk/poem/src/test/java/net/sf/poem/cli/
trunk/poem/src/test/java/net/sf/poem/cli/test/
trunk/poem/src/test/java/net/sf/poem/cli/test/AbstractCommandTestCase.java
trunk/poem/src/test/java/net/sf/poem/cli/test/CreateCommandTest.java
trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java
trunk/poem/src/test/java/net/sf/poem/cli/test/UsageCommandTest.java
trunk/poem/src/test/java/net/sf/poem/cli/test/package.html
Removed Paths:
-------------
trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java
Modified: trunk/poem/src/fit/html/create-poem.html
===================================================================
--- trunk/poem/src/fit/html/create-poem.html 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/fit/html/create-poem.html 2008-02-20 15:16:18 UTC (rev 16)
@@ -54,7 +54,7 @@
</tr>
<tr>
<td>c</td>
- <td>--type=sonnet --language=nl_NL --title="De moeder de vrouw"</td>
+ <td>--type=sonnet --language=nl_NL "--title=De moeder de vrouw"</td>
<td>de-moeder-de-vrouw.xml</td>
<td><?xml version="1.0"?><poem type="sonnet" language="nl_NL"><title>De moeder de vrouw</title><paragraph><line></line></paragraph></poem></td>
</tr>
Modified: trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -21,7 +21,7 @@
import java.util.Arrays;
import java.util.List;
-import net.sf.poem.cli.PoemApplication;
+import net.sf.poem.cli.PoemCommandLine;
import net.sf.poem.util.FileUtil;
import net.sf.poem.util.XmlUtil;
import fit.ColumnFixture;
@@ -36,30 +36,33 @@
// stop visibilitymodifier check
public String command;
public String options;
-
// resume visibilitymodifier check
+ private File file;
+
public String fileName() {
- return getFile().getName();
+ return getFile(false).getName();
}
public String fileContents() throws IOException {
- return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile()));
+ return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile(true)));
}
- private File getFile() {
- final List<File> beforeFiles = Arrays.asList(new File(".").listFiles());
- PoemApplication.main(getCommandLine());
- final File[] afterFiles = new File(".").listFiles();
+ private File getFile(final boolean cached) {
+ if (!cached) {
+ final List<File> beforeFiles = Arrays.asList(new File(".").listFiles());
+ PoemCommandLine.main(getCommandLine());
- File result = new File(".");
- for (int i = 0; i < afterFiles.length; i++) {
- if (!beforeFiles.contains(afterFiles[i])) {
- result = afterFiles[i];
- break;
+ file = new File(".");
+ for (final File afterFile : new File(".").listFiles()) {
+ if (!beforeFiles.contains(afterFile)) {
+ file = afterFile;
+ break;
+ }
}
+ file.deleteOnExit();
}
- return result;
+ return file;
}
private String[] getCommandLine() {
@@ -76,12 +79,21 @@
if (options.charAt(i) == '\"') {
inQuote = true;
} else if (options.charAt(i) == ' ') {
- result.add(options.substring(start, i).trim());
+ result.add(getOption(start, i));
start = i + 1;
}
}
}
+ result.add(getOption(start, options.length()));
return result.toArray(new String[result.size()]);
}
+ private String getOption(final int start, final int end) {
+ String result = options.substring(start, end).trim();
+ if (result.startsWith("\"") && result.endsWith("\"")) {
+ result = result.substring(1, result.length() - 1).trim();
+ }
+ return result;
+ }
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/cli/Command.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/Command.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/main/java/net/sf/poem/cli/Command.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -21,6 +21,9 @@
*/
public interface Command {
+ String OPTION_PREFIX = "--";
+ String HELP_OPTION = OPTION_PREFIX + "help";
+
/**
* Perform the command.
* @param args The command line arguments. The first argument indicates
@@ -28,4 +31,9 @@
*/
void perform(String[] args);
+ /**
+ * @return A description on how to use the command
+ */
+ String getUsage();
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -16,20 +16,76 @@
package net.sf.poem.cli;
import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.sf.poem.api.Poem;
+import net.sf.poem.api.PoemFactory;
+
/**
* Create a poem.
*/
public class CreateCommand implements Command {
+ private static final String OPTION_TITLE = "title";
+ private static final String OPTION_TYPE = "type";
+ private static final String OPTION_LANGUAGE = "language";
+
+ private final PrintStream out;
+ private final Map<String, String> validOptions;
+
public CreateCommand(final PrintStream out) {
- // TODO Auto-generated constructor stub
+ this.out = out;
+
+ validOptions = new LinkedHashMap<String, String>();
+ validOptions.put(OPTION_LANGUAGE, "the poem's language in ISO format, e.g. 'en_UK'");
+ validOptions.put(OPTION_TYPE, "the kind of poem, e.g. 'sonnet'");
+ validOptions.put(OPTION_TITLE, "the poem's title");
}
public void perform(final String[] args) {
- // TODO Auto-generated method stub
+ try {
+ final Map<String, String> options = getOptions(args);
+ final Poem poem = PoemFactory.newInstance(options.get(OPTION_LANGUAGE),
+ options.get(OPTION_TYPE), options.get(OPTION_TITLE));
+ out.println("Created poem '" + poem.getFile().getName() + "'");
+ } catch (final Exception e) {
+ out.println(e.getMessage());
+ }
+ }
+ private Map<String, String> getOptions(final String[] args) {
+ final Map<String, String> result = new HashMap<String, String>();
+ for (int i = 1; i < args.length; i++) {
+ if (HELP_OPTION.equals(args[i])) {
+ throw new IllegalArgumentException(getUsage());
+ }
+ final String[] nameValue = args[i].split("=");
+ if (nameValue.length != 2 || !nameValue[0].startsWith(OPTION_PREFIX)) {
+ throw new IllegalArgumentException("Invalid option: '" + args[i]
+ + "'. Options look like '--<option>=<value>'.");
+ }
+ final String option = nameValue[0].substring(OPTION_PREFIX.length());
+ if (!validOptions.containsKey(option)) {
+ throw new UnsupportedOperationException("Unsupported option: '" + option
+ + "'. Use '--help' for a list of supported options.");
+ }
+ result.put(option, nameValue[1]);
+ }
+ return result;
}
+ public String getUsage() {
+ final StringBuffer result = new StringBuffer();
+ result.append("Supported options:\n");
+ for (final Entry<String, String> entry : validOptions.entrySet()) {
+ result.append(OPTION_PREFIX).append(entry.getKey()).append(": ");
+ result.append(entry.getValue()).append('\n');
+ }
+ return result.toString();
+ }
+
}
Deleted: trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -1,49 +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.cli;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * The main program.
- */
-public class PoemApplication {
-
- /**
- * @param args The command line arguments
- */
- public static void main(final String[] args) {
- new PoemApplication().run(args);
- }
-
- private final Map<String, Command> commands = new HashMap<String, Command>();
-
- public PoemApplication() {
- commands.put("c", new CreateCommand(System.out));
- }
-
- public void run(final String[] args) {
- getCommand(args[0]).perform(args);
- }
-
- private Command getCommand(final String command) {
- return commands.containsKey(command) ? commands.get(command)
- : new UsageCommand(System.err, commands);
- }
-
-}
Copied: trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java (from rev 15, trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java)
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/PoemCommandLine.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,53 @@
+// 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.cli;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * The main command line program.
+ */
+public class PoemCommandLine {
+
+ /**
+ * @param args The command line arguments
+ */
+ public static void main(final String[] args) {
+ new PoemCommandLine().run(args);
+ }
+
+ private final Map<String, Command> commands = new HashMap<String, Command>();
+
+ public PoemCommandLine() {
+ addCommand("c", new CreateCommand(System.out));
+ }
+
+ protected final void addCommand(final String identifier, final Command command) {
+ commands.put(identifier, command);
+ }
+
+ public final void run(final String[] args) {
+ getCommand(args[0]).perform(args);
+ }
+
+ private Command getCommand(final String command) {
+ return commands.containsKey(command) ? commands.get(command)
+ : new UsageCommand(System.err, commands);
+ }
+
+}
Modified: trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -17,6 +17,7 @@
import java.io.PrintStream;
import java.util.Map;
+import java.util.Map.Entry;
/**
@@ -24,10 +25,34 @@
*/
public class UsageCommand implements Command {
+ private final PrintStream out;
+ private final Map<String, Command> commands;
+
public UsageCommand(final PrintStream out, final Map<String, Command> commands) {
+ this.out = out;
+ this.commands = commands;
}
public void perform(final String[] args) {
+ if (!HELP_OPTION.equals(args[0])) {
+ out.print("Unsupported command '");
+ out.print(args[0]);
+ out.println("'.");
+ out.println("Usage: poem <command> [<options>]");
+ }
+
+ out.println("Supported commands:");
+ for (final Entry<String, Command> entry : commands.entrySet()) {
+ out.print(entry.getKey());
+ out.print(": ");
+ out.println(entry.getValue().getUsage());
+ }
+
+ out.println("poem <command> --help gives help on command <command>");
}
+ public String getUsage() {
+ throw new UnsupportedOperationException();
+ }
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java 2008-02-19 21:22:54 UTC (rev 15)
+++ trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
@@ -42,8 +43,14 @@
public static String getContents(final File file) throws IOException {
+ return getContents(new FileInputStream(file));
+ }
+
+
+ public static String getContents(final InputStream inputStream)
+ throws IOException {
final StringBuffer result = new StringBuffer();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
result.append(line).append('\n');
}
Added: trunk/poem/src/test/java/net/sf/poem/cli/test/AbstractCommandTestCase.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/AbstractCommandTestCase.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/AbstractCommandTestCase.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,43 @@
+// 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.cli.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import junit.framework.TestCase;
+import net.sf.poem.util.FileUtil;
+
+
+/**
+ * Abstract test case for testing commands.
+ */
+public abstract class AbstractCommandTestCase extends TestCase {
+
+ private ByteArrayOutputStream baos;
+
+ protected PrintStream newCommandStream() {
+ baos = new ByteArrayOutputStream();
+ return new PrintStream(baos);
+ }
+
+ protected String getCommandOutput() throws IOException {
+ return FileUtil.getContents(new ByteArrayInputStream(baos.toByteArray()));
+ }
+
+}
Added: trunk/poem/src/test/java/net/sf/poem/cli/test/CreateCommandTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/CreateCommandTest.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/CreateCommandTest.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,94 @@
+// 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.cli.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sf.poem.cli.CreateCommand;
+import net.sf.poem.util.FileUtil;
+
+
+/**
+ * Test for {@see CreateCommand}.
+ */
+public class CreateCommandTest extends AbstractCommandTestCase {
+
+ private List<File> beforeFiles;
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ beforeFiles = Arrays.asList(getCurrentDirFiles());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ final File[] afterFiles = getCurrentDirFiles();
+ for (final File file : afterFiles) {
+ if (!beforeFiles.contains(file)) {
+ FileUtil.delete(file);
+ }
+ }
+ }
+
+ public void testPerform() throws IOException {
+ final File poem = new File("ape.xml");
+ if (poem.exists()) {
+ poem.delete();
+ }
+
+ newCreateCommand().perform(new String[] {"c",
+ "--type=sonnet", "--title=ape", "--language=foo_Bar"});
+ assertTrue("poem not created", poem.exists());
+ assertEquals("output", "Created poem 'ape.xml'\n", getCommandOutput());
+ }
+
+ public void testIllegalOption() throws IOException {
+ newCreateCommand().perform(new String[]{"c", "bear"});
+ assertEquals("bear", "Invalid option: 'bear'. Options look like '--<option>=<value>'.\n",
+ getCommandOutput());
+
+ newCreateCommand().perform(new String[]{"c", "cheetah=dingo"});
+ assertEquals("cheetah=dingo", "Invalid option: 'cheetah=dingo'. Options look like '--<option>=<value>'.\n",
+ getCommandOutput());
+
+ newCreateCommand().perform(new String[]{"c", "--elephant=fox"});
+ assertEquals("--elephant=fox", "Unsupported option: 'elephant'. Use '--help' for a list of supported options.\n",
+ getCommandOutput());
+ }
+
+ public void testHelp() throws IOException {
+ newCreateCommand().perform(new String[]{"c", "--help"});
+ assertEquals("help", "Supported options:\n"
+ + "--language: the poem's language in ISO format, e.g. 'en_UK'\n"
+ + "--type: the kind of poem, e.g. 'sonnet'\n"
+ + "--title: the poem's title\n\n", getCommandOutput());
+ }
+
+ private CreateCommand newCreateCommand() {
+ return new CreateCommand(newCommandStream());
+ }
+
+ private File[] getCurrentDirFiles() {
+ return new File(".").listFiles();
+ }
+
+}
Added: trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/PoemCommandLineTest.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,62 @@
+// 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.cli.test;
+
+import junit.framework.TestCase;
+import net.sf.poem.cli.Command;
+import net.sf.poem.cli.PoemCommandLine;
+
+
+/**
+ * Test for the command line program.
+ */
+public class PoemCommandLineTest extends TestCase {
+
+ /**
+ * Mock command to test whether the command pattern is correctly implemented.
+ */
+ public class MockCommand implements Command {
+ public void perform(final String[] args) {
+ performArgs = args;
+ }
+
+ public String getUsage() {
+ return null;
+ }
+ }
+
+
+ /**
+ *
+ */
+ public class TestPoemCommandLine extends PoemCommandLine {
+
+ public TestPoemCommandLine() {
+ super();
+ addCommand("mock", new MockCommand());
+ }
+ }
+
+
+ private String[] performArgs;
+
+ public void testCommandPattern() {
+ final String[] args = new String[] {"mock", "me", "not"};
+ new TestPoemCommandLine().run(args);
+ assertSame("Command line", args, performArgs);
+ }
+
+}
Added: trunk/poem/src/test/java/net/sf/poem/cli/test/UsageCommandTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/UsageCommandTest.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/UsageCommandTest.java 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,83 @@
+// 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.cli.test;
+
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sf.poem.cli.Command;
+import net.sf.poem.cli.UsageCommand;
+
+
+
+/**
+ * Test usage help.
+ */
+public class UsageCommandTest extends AbstractCommandTestCase {
+
+ /**
+ * Mock command to test the usage command.
+ */
+ public class MockCommand implements Command {
+
+ private final String usage;
+
+ public MockCommand(final String usage) {
+ this.usage = usage;
+ }
+
+ public void perform(final String[] args) {
+ }
+
+ public String getUsage() {
+ return usage;
+ }
+
+ }
+
+
+ public void testUnsupportedCommand() throws IOException {
+ new UsageCommand(newCommandStream(), getCommands()).perform(new String[] {"q"});
+
+ assertEquals("output", "Unsupported command 'q'.\n"
+ + "Usage: poem <command> [<options>]\n"
+ + "Supported commands:\n"
+ + "m: Do something\n"
+ + "n: Do something else\n"
+ + "poem <command> --help gives help on command <command>\n",
+ getCommandOutput());
+ }
+
+
+ public void testHelp() throws IOException {
+ new UsageCommand(newCommandStream(), getCommands()).perform(new String[] {"--help"});
+
+ assertEquals("output", "Supported commands:\n"
+ + "m: Do something\n"
+ + "n: Do something else\n"
+ + "poem <command> --help gives help on command <command>\n",
+ getCommandOutput());
+ }
+
+ private Map<String, Command> getCommands() {
+ final Map<String, Command> commands = new LinkedHashMap<String, Command>();
+ commands.put("m", new MockCommand("Do something"));
+ commands.put("n", new MockCommand("Do something else"));
+ return commands;
+ }
+
+}
Added: trunk/poem/src/test/java/net/sf/poem/cli/test/package.html
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/cli/test/package.html (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/cli/test/package.html 2008-02-20 15:16:18 UTC (rev 16)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ These are the <a href="http://junit.org">unit tests</a> for the command line client.
+ </body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-19 21:24:19
|
Revision: 15
http://poem.svn.sourceforge.net/poem/?rev=15&view=rev
Author: rsinnema
Date: 2008-02-19 13:22:54 -0800 (Tue, 19 Feb 2008)
Log Message:
-----------
Added acceptance test for creating a poem from the command line
Modified Paths:
--------------
trunk/poem/src/fit/html/create-poem.html
Added Paths:
-----------
trunk/poem/src/fit/java/net/sf/poem/fit/api/
trunk/poem/src/fit/java/net/sf/poem/fit/api/CreatePoemFixture.java
trunk/poem/src/fit/java/net/sf/poem/fit/api/package.html
trunk/poem/src/fit/java/net/sf/poem/fit/cli/
trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java
trunk/poem/src/fit/java/net/sf/poem/fit/cli/package.html
trunk/poem/src/main/java/net/sf/poem/cli/
trunk/poem/src/main/java/net/sf/poem/cli/Command.java
trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java
trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java
trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
trunk/poem/src/main/java/net/sf/poem/cli/package.html
Removed Paths:
-------------
trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
trunk/poem/src/fit/java/net/sf/poem/fit/package.html
Modified: trunk/poem/src/fit/html/create-poem.html
===================================================================
--- trunk/poem/src/fit/html/create-poem.html 2008-02-17 12:43:34 UTC (rev 14)
+++ trunk/poem/src/fit/html/create-poem.html 2008-02-19 21:22:54 UTC (rev 15)
@@ -5,9 +5,11 @@
<body>
<h1>Create poem</h1>
<p>Create a poem of a given type (e.g. sonnet) and language.</p>
+
+ <h2>API</h2>
<table>
<tr>
- <td colspan="5">net.sf.poem.fit.CreatePoemFixture</td>
+ <td colspan="5">net.sf.poem.fit.api.CreatePoemFixture</td>
</tr>
<tr>
<td>language</td>
@@ -38,5 +40,24 @@
<td><?xml version="1.0"?><poem type="sonnet" language="en_UK"><title></title><paragraph><line></line></paragraph></poem></td>
</tr>
</table>
+
+ <h2>Command-line</h2>
+ <table>
+ <tr>
+ <td colspan="4">net.sf.poem.fit.cli.CommandLineFixture</td>
+ </tr>
+ <tr>
+ <td>command</td>
+ <td>options</td>
+ <td>file name()</td>
+ <td>file contents()</td>
+ </tr>
+ <tr>
+ <td>c</td>
+ <td>--type=sonnet --language=nl_NL --title="De moeder de vrouw"</td>
+ <td>de-moeder-de-vrouw.xml</td>
+ <td><?xml version="1.0"?><poem type="sonnet" language="nl_NL"><title>De moeder de vrouw</title><paragraph><line></line></paragraph></poem></td>
+ </tr>
+ </table>
</body>
</html>
Deleted: trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-17 12:43:34 UTC (rev 14)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -1,54 +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.fit;
-
-import java.io.File;
-import java.io.IOException;
-
-import net.sf.poem.api.PoemFactory;
-import net.sf.poem.util.FileUtil;
-import net.sf.poem.util.XmlUtil;
-import fit.ColumnFixture;
-
-
-/**
- * Fixture for <code>create-poem.story</code>.
- * @see <a href="http://fit.c2.com/">Framework for Integrated Tests</a>.
- */
-public class CreatePoemFixture extends ColumnFixture {
-
- // stop visibilitymodifier check
- public String language;
- public String type;
- public String title;
- // resume visibilitymodifier check
-
-
- public String fileName() {
- return getFile().getName();
- }
-
- public String fileContents() throws IOException {
- return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile()));
- }
-
- private File getFile() {
- final File result = PoemFactory.newInstance(language, type, title).getFile();
- result.deleteOnExit();
- return result;
- }
-
-}
Copied: trunk/poem/src/fit/java/net/sf/poem/fit/api/CreatePoemFixture.java (from rev 13, trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java)
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/api/CreatePoemFixture.java (rev 0)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/api/CreatePoemFixture.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,54 @@
+// 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.fit.api;
+
+import java.io.File;
+import java.io.IOException;
+
+import net.sf.poem.api.PoemFactory;
+import net.sf.poem.util.FileUtil;
+import net.sf.poem.util.XmlUtil;
+import fit.ColumnFixture;
+
+
+/**
+ * Fixture for the API part of <code>create-poem.story</code>.
+ * @see <a href="http://fit.c2.com/">Framework for Integrated Tests</a>.
+ */
+public class CreatePoemFixture extends ColumnFixture {
+
+ // stop visibilitymodifier check
+ public String language;
+ public String type;
+ public String title;
+ // resume visibilitymodifier check
+
+
+ public String fileName() {
+ return getFile().getName();
+ }
+
+ public String fileContents() throws IOException {
+ return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile()));
+ }
+
+ private File getFile() {
+ final File result = PoemFactory.newInstance(language, type, title).getFile();
+ result.deleteOnExit();
+ return result;
+ }
+
+}
Copied: trunk/poem/src/fit/java/net/sf/poem/fit/api/package.html (from rev 13, trunk/poem/src/fit/java/net/sf/poem/fit/package.html)
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/api/package.html (rev 0)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/api/package.html 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,6 @@
+<html>
+ <body>
+ These are the <a href="http://fit.c2.com">fixtures</a> for the
+ acceptance tests for the API.
+ </body>
+</html>
Added: trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java (rev 0)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/cli/CommandLineFixture.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,87 @@
+// 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.fit.cli;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sf.poem.cli.PoemApplication;
+import net.sf.poem.util.FileUtil;
+import net.sf.poem.util.XmlUtil;
+import fit.ColumnFixture;
+
+/**
+ * Fixture for the command-line part of <code>create-poem.story</code>.
+ *
+ * @see <a href="http://fit.c2.com/">Framework for Integrated Tests</a>.
+ */
+public class CommandLineFixture extends ColumnFixture {
+
+ // stop visibilitymodifier check
+ public String command;
+ public String options;
+
+ // resume visibilitymodifier check
+
+ public String fileName() {
+ return getFile().getName();
+ }
+
+ public String fileContents() throws IOException {
+ return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile()));
+ }
+
+ private File getFile() {
+ final List<File> beforeFiles = Arrays.asList(new File(".").listFiles());
+ PoemApplication.main(getCommandLine());
+ final File[] afterFiles = new File(".").listFiles();
+
+ File result = new File(".");
+ for (int i = 0; i < afterFiles.length; i++) {
+ if (!beforeFiles.contains(afterFiles[i])) {
+ result = afterFiles[i];
+ break;
+ }
+ }
+ return result;
+ }
+
+ private String[] getCommandLine() {
+ final List<String> result = new ArrayList<String>();
+ result.add(command);
+ boolean inQuote = false;
+ int start = 0;
+ for (int i = 0; i < options.length(); i++) {
+ if (inQuote) {
+ if (options.charAt(i) == '\"') {
+ inQuote = false;
+ }
+ } else {
+ if (options.charAt(i) == '\"') {
+ inQuote = true;
+ } else if (options.charAt(i) == ' ') {
+ result.add(options.substring(start, i).trim());
+ start = i + 1;
+ }
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+}
Added: trunk/poem/src/fit/java/net/sf/poem/fit/cli/package.html
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/cli/package.html (rev 0)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/cli/package.html 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,6 @@
+<html>
+ <body>
+ These are the <a href="http://fit.c2.com">fixtures</a> for the
+ acceptance tests for the command line.
+ </body>
+</html>
Deleted: trunk/poem/src/fit/java/net/sf/poem/fit/package.html
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/package.html 2008-02-17 12:43:34 UTC (rev 14)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/package.html 2008-02-19 21:22:54 UTC (rev 15)
@@ -1,5 +0,0 @@
-<html>
- <body>
- These are the <a href="http://fit.c2.com">fixtures</a> for the acceptance tests.
- </body>
-</html>
Added: trunk/poem/src/main/java/net/sf/poem/cli/Command.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/Command.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/Command.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,31 @@
+// 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.cli;
+
+
+/**
+ * Command that can be run from the command line.
+ */
+public interface Command {
+
+ /**
+ * Perform the command.
+ * @param args The command line arguments. The first argument indicates
+ * the command itself, the others indicate options to the command.
+ */
+ void perform(String[] args);
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/CreateCommand.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,35 @@
+// 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.cli;
+
+import java.io.PrintStream;
+
+
+/**
+ * Create a poem.
+ */
+public class CreateCommand implements Command {
+
+ public CreateCommand(final PrintStream out) {
+ // TODO Auto-generated constructor stub
+ }
+
+ public void perform(final String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/PoemApplication.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,49 @@
+// 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.cli;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * The main program.
+ */
+public class PoemApplication {
+
+ /**
+ * @param args The command line arguments
+ */
+ public static void main(final String[] args) {
+ new PoemApplication().run(args);
+ }
+
+ private final Map<String, Command> commands = new HashMap<String, Command>();
+
+ public PoemApplication() {
+ commands.put("c", new CreateCommand(System.out));
+ }
+
+ public void run(final String[] args) {
+ getCommand(args[0]).perform(args);
+ }
+
+ private Command getCommand(final String command) {
+ return commands.containsKey(command) ? commands.get(command)
+ : new UsageCommand(System.err, commands);
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/UsageCommand.java 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,33 @@
+// 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.cli;
+
+import java.io.PrintStream;
+import java.util.Map;
+
+
+/**
+ * Show the program's usage.
+ */
+public class UsageCommand implements Command {
+
+ public UsageCommand(final PrintStream out, final Map<String, Command> commands) {
+ }
+
+ public void perform(final String[] args) {
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/cli/package.html
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/cli/package.html (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/cli/package.html 2008-02-19 21:22:54 UTC (rev 15)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ This is the command line interface to Poem.
+ </body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-17 12:43:29
|
Revision: 14
http://poem.svn.sourceforge.net/poem/?rev=14&view=rev
Author: rsinnema
Date: 2008-02-17 04:43:34 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
Added to svn ignore
Property Changed:
----------------
trunk/poem/
Property changes on: trunk/poem
___________________________________________________________________
Name: svn:ignore
- build
dist
+ build
dist
cobertura.ser
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <poe...@li...> - 2008-02-17 12:29:41
|
Revision: 12
http://poem.svn.sourceforge.net/poem/?rev=12&view=rev
Author: rsinnema
Date: 2008-02-17 04:29:43 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
Finished Create Poem story
Modified Paths:
--------------
trunk/poem/.classpath
trunk/poem/build-api.xml
trunk/poem/build-common.xml
trunk/poem/checkstyle_checks.xml
trunk/poem/src/fit/html/create-poem.html
trunk/poem/src/main/java/net/sf/poem/api/Poem.java
trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
trunk/poem/src/main/xsd/dictionary.xsd
trunk/poem/src/main/xsd/poem.xsd
trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
Added Paths:
-----------
trunk/poem/lib/commons/
trunk/poem/lib/commons/commons-lang-2.3.jar
trunk/poem/src/main/xsd/dictionary.xsdconfig
trunk/poem/src/main/xsd/poem.xsdconfig
Modified: trunk/poem/.classpath
===================================================================
--- trunk/poem/.classpath 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/.classpath 2008-02-17 12:29:43 UTC (rev 12)
@@ -9,5 +9,6 @@
<classpathentry kind="lib" path="build/poemSchema.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans/xbean.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans/jsr173_1.0_api.jar"/>
+ <classpathentry kind="lib" path="lib/commons/commons-lang-2.3.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/build-api.xml 2008-02-17 12:29:43 UTC (rev 12)
@@ -26,7 +26,7 @@
<param name="dest.file" value="${fit.jar.file}"/>
</antcall>
<antcall target="--test-fit">
- <param name="fit.lib.path" value="${main.jar.file};${fit.jar.file}"/>
+ <param name="fit.lib.path" value="${main.jar.file};${fit.jar.file};${poem.xmlbeans.jar};${xmlbeans.dir}xbean.jar;${xmlbeans.dir}jsr173_1.0_api.jar;${lib.dir}commons/commons-lang-2.3.jar"/>
</antcall>
</target>
@@ -68,6 +68,7 @@
<path id="src.class.path">
<pathelement location="${main.jar.file}"/>
<pathelement location="${junit.jar}"/>
+ <fileset dir="${lib.dir}" includes="commons/*.jar"/>
<fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
<pathelement location="${poem.xmlbeans.jar}"/>
</path>
@@ -102,6 +103,7 @@
</antcall>
<path id="dummy.class.path">
+ <fileset dir="${lib.dir}" includes="commons/*.jar"/>
<fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
<pathelement location="${poem.xmlbeans.jar}"/>
</path>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/build-common.xml 2008-02-17 12:29:43 UTC (rev 12)
@@ -345,7 +345,7 @@
<target name="--xml-beans">
- <property name="includes" value="**/*.xsd"/>
+ <property name="includes" value="**/*.xsd*"/>
<dirname file="${xml.beans.jar}" property="dest.dir"/>
<uptodate property="xmlbeans.generated" targetfile="${xml.beans.jar}">
<srcfiles dir="${schema.dir}" includes="${includes}" />
Modified: trunk/poem/checkstyle_checks.xml
===================================================================
--- trunk/poem/checkstyle_checks.xml 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/checkstyle_checks.xml 2008-02-17 12:29:43 UTC (rev 12)
@@ -1,101 +1,99 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- This configuration file was written by the eclipse-cs plugin configuration editor
--->
-<!--
- Checkstyle-Configuration: POEM
- Description:
-Slightly modified Checkstyle configuration that checks the Sun coding conventions.
--->
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
-<module name="Checker">
- <property name="severity" value="warning"/>
- <module name="TreeWalker">
- <module name="FileContentsHolder"/>
- <module name="JavadocType">
- <property name="scope" value="public"/>
- </module>
- <module name="JavadocStyle">
- <property name="scope" value="public"/>
- </module>
- <module name="ConstantName"/>
- <module name="LocalFinalVariableName"/>
- <module name="LocalVariableName"/>
- <module name="MemberName"/>
- <module name="MethodName"/>
- <module name="PackageName"/>
- <module name="ParameterName"/>
- <module name="StaticVariableName"/>
- <module name="TypeName"/>
- <module name="AvoidStarImport"/>
- <module name="IllegalImport"/>
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
- <module name="FileLength"/>
- <module name="LineLength">
- <property name="max" value="120"/>
- <property name="tabWidth" value="2"/>
- </module>
- <module name="MethodLength"/>
- <module name="ParameterNumber"/>
- <module name="EmptyForIteratorPad"/>
- <module name="MethodParamPad"/>
- <module name="NoWhitespaceAfter"/>
- <module name="NoWhitespaceBefore"/>
- <module name="OperatorWrap"/>
- <module name="ParenPad"/>
- <module name="TypecastParenPad"/>
- <module name="TabCharacter"/>
- <module name="WhitespaceAfter"/>
- <module name="WhitespaceAround">
- <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/>
- </module>
- <module name="ModifierOrder"/>
- <module name="RedundantModifier"/>
- <module name="AvoidNestedBlocks"/>
- <module name="EmptyBlock"/>
- <module name="LeftCurly"/>
- <module name="NeedBraces"/>
- <module name="RightCurly"/>
- <module name="AvoidInlineConditionals"/>
- <module name="DoubleCheckedLocking"/>
- <module name="EmptyStatement"/>
- <module name="EqualsHashCode"/>
- <module name="IllegalInstantiation"/>
- <module name="InnerAssignment"/>
- <module name="MagicNumber"/>
- <module name="MissingSwitchDefault"/>
- <module name="RedundantThrows">
- <property name="logLoadErrors" value="true"/>
- <property name="suppressLoadErrors" value="true"/>
- </module>
- <module name="SimplifyBooleanExpression"/>
- <module name="SimplifyBooleanReturn"/>
- <module name="FinalClass"/>
- <module name="HideUtilityClassConstructor"/>
- <module name="InterfaceIsType"/>
- <module name="VisibilityModifier"/>
- <module name="ArrayTypeStyle"/>
- <module name="FinalParameters"/>
- <module name="GenericIllegalRegexp">
- <property name="format" value="\s+$"/>
- <property name="message" value="Line has trailing spaces."/>
- </module>
- <module name="UpperEll"/>
- <module name="RegexpHeader">
- <property name="header" value="^// Copyright \(C\) \d{4} .+$\n^//$\n^// This program is free software: you can redistribute it and/or modify$\n^// it under the terms of the GNU General Public License as published by$\n^// the Free Software Foundation, either version 3 of the License, or$\n^// \(at your option\) any later version.$\n^//$\n^// This program is distributed in the hope that it will be useful,$\n^// but WITHOUT ANY WARRANTY; without even the implied warranty of$\n^// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$\n^// GNU General Public License for more details.$\n^//$\n^// You should have received a copy of the GNU General Public License$\n^// along with this program. If not, see <http://www.gnu.org/licenses/>.$\n^$"/>
- </module>
- </module>
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="stop emptyblock check"/>
- <property name="onCommentFormat" value="resume emptyblock check"/>
- <property name="checkFormat" value="EmptyBlock"/>
- </module>
- <module name="PackageHtml"/>
- <module name="Translation"/>
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="stop visibilitymodifier check"/>
- <property name="onCommentFormat" value="resume visibilitymodifier check"/>
- <property name="checkFormat" value="VisibilityModifier"/>
- </module>
-</module>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This configuration file was written by the eclipse-cs plugin configuration editor
+-->
+<!--
+ Checkstyle-Configuration: POEM
+ Description: none
+-->
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<module name="Checker">
+ <property name="severity" value="warning"/>
+ <module name="TreeWalker">
+ <module name="FileContentsHolder"/>
+ <module name="JavadocType">
+ <property name="scope" value="public"/>
+ </module>
+ <module name="JavadocStyle">
+ <property name="scope" value="public"/>
+ </module>
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+ <module name="AvoidStarImport"/>
+ <module name="IllegalImport"/>
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="FileLength"/>
+ <module name="LineLength">
+ <property name="max" value="120"/>
+ <property name="tabWidth" value="2"/>
+ </module>
+ <module name="MethodLength"/>
+ <module name="ParameterNumber"/>
+ <module name="EmptyForIteratorPad"/>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <module name="TabCharacter"/>
+ <module name="WhitespaceAfter"/>
+ <module name="WhitespaceAround">
+ <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/>
+ </module>
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+ <module name="AvoidNestedBlocks"/>
+ <module name="EmptyBlock"/>
+ <module name="LeftCurly"/>
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <module name="IllegalInstantiation"/>
+ <module name="InnerAssignment"/>
+ <module name="MagicNumber"/>
+ <module name="MissingSwitchDefault"/>
+ <module name="RedundantThrows">
+ <property name="logLoadErrors" value="true"/>
+ <property name="suppressLoadErrors" value="true"/>
+ </module>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <module name="VisibilityModifier"/>
+ <module name="ArrayTypeStyle"/>
+ <module name="FinalParameters"/>
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ <module name="UpperEll"/>
+ <module name="RegexpHeader">
+ <property name="header" value="^// Copyright \(C\) \d{4} .+$\n^//$\n^// This program is free software: you can redistribute it and/or modify$\n^// it under the terms of the GNU General Public License as published by$\n^// the Free Software Foundation, either version 3 of the License, or$\n^// \(at your option\) any later version.$\n^//$\n^// This program is distributed in the hope that it will be useful,$\n^// but WITHOUT ANY WARRANTY; without even the implied warranty of$\n^// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$\n^// GNU General Public License for more details.$\n^//$\n^// You should have received a copy of the GNU General Public License$\n^// along with this program. If not, see <http://www.gnu.org/licenses/>.$\n^$"/>
+ </module>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="stop emptyblock check"/>
+ <property name="onCommentFormat" value="resume emptyblock check"/>
+ <property name="checkFormat" value="EmptyBlock"/>
+ </module>
+ <module name="PackageHtml"/>
+ <module name="Translation"/>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="stop visibilitymodifier check"/>
+ <property name="onCommentFormat" value="resume visibilitymodifier check"/>
+ <property name="checkFormat" value="VisibilityModifier"/>
+ </module>
+</module>
Added: trunk/poem/lib/commons/commons-lang-2.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/commons/commons-lang-2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/poem/src/fit/html/create-poem.html
===================================================================
--- trunk/poem/src/fit/html/create-poem.html 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/fit/html/create-poem.html 2008-02-17 12:29:43 UTC (rev 12)
@@ -21,21 +21,21 @@
<td>sonnet</td>
<td>Shall I compare thee to a Summer's day?</td>
<td>shall-i-compare-thee-to-a-summers-day.xml</td>
- <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="sonnet" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
+ <td><?xml version="1.0"?><poem type="sonnet" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
</tr>
<tr>
<td>en_UK</td>
<td>blank</td>
<td>Shall I compare thee to a Summer's day?</td>
<td>shall-i-compare-thee-to-a-summers-day.xml</td>
- <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="free" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
+ <td><?xml version="1.0"?><poem type="free" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
</tr>
<tr>
<td>en_UK</td>
<td>sonnet</td>
<td>blank</td>
<td>poem1.xml</td>
- <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="sonnet" language="en_UK"><title></title><paragraph><line></line></paragraph></poem></td>
+ <td><?xml version="1.0"?><poem type="sonnet" language="en_UK"><title></title><paragraph><line></line></paragraph></poem></td>
</tr>
</table>
</body>
Modified: trunk/poem/src/main/java/net/sf/poem/api/Poem.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/Poem.java 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/java/net/sf/poem/api/Poem.java 2008-02-17 12:29:43 UTC (rev 12)
@@ -17,7 +17,9 @@
import java.io.File;
+import net.sf.poem.xml.PoemDocument;
+
/**
* A poem.
*/
@@ -28,4 +30,10 @@
*/
File getFile();
+ /**
+ * @return The XML Beans representation of the poem
+ * @see <a href="http://xmlbeans.apache.org/">XML Beans</a>
+ */
+ PoemDocument.Poem getContents();
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java 2008-02-17 12:29:43 UTC (rev 12)
@@ -20,13 +20,18 @@
import java.io.PrintWriter;
import net.sf.poem.api.impl.PoemImpl;
+import net.sf.poem.util.FileUtil;
+import org.apache.commons.lang.StringUtils;
+
/**
* Factory class for creating poems.
*/
public final class PoemFactory {
+ private static final String DEFAULT_TYPE = "free";
+
private PoemFactory() {
// Utility class should not have a public constructor
}
@@ -41,15 +46,19 @@
*/
public static Poem newInstance(final String language, final String type,
final String title) {
- return new PoemImpl(newFile(language, type, title));
+ return new PoemImpl(newFile(language, getType(type), title));
}
+ private static String getType(final String type) {
+ return StringUtils.isBlank(type) ? DEFAULT_TYPE : type;
+ }
+
private static File newFile(final String language, final String type,
final String title) {
final File result = new File(getFileName(title));
final PrintWriter writer = newWriter(result);
writer.println("<?xml version=\"1.0\"?>");
- writer.print("<poem xmlns=\"http://poem.sf.net/poem\" type=\"");
+ writer.print("<poem type=\"");
writer.print(type);
writer.print("\" language=\"");
writer.print(language);
@@ -76,7 +85,13 @@
}
private static String getFileName(final String title) {
- return title.toLowerCase().replaceAll("\\s", "-").replaceAll("[^a-zA-Z0-9\\-]", "") + ".xml";
+ final String result;
+ if (StringUtils.isBlank(title)) {
+ result = FileUtil.getNumberedFile("poem", ".xml");
+ } else {
+ result = title.toLowerCase().replaceAll("\\s", "-").replaceAll("[^a-zA-Z0-9\\-]", "") + ".xml";
+ }
+ return result;
}
}
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-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java 2008-02-17 12:29:43 UTC (rev 12)
@@ -16,16 +16,21 @@
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}.
*/
public class PoemImpl implements Poem {
private final File file;
+ private net.sf.poem.xml.PoemDocument.Poem poem;
public PoemImpl(final File file) {
this.file = file;
@@ -35,4 +40,17 @@
return file;
}
+ public net.sf.poem.xml.PoemDocument.Poem getContents() {
+ 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) {
+ throw new IllegalArgumentException("Error while reading poem file", e);
+ }
+ }
+ return poem;
+ }
+
}
Modified: trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java 2008-02-17 12:29:43 UTC (rev 12)
@@ -32,6 +32,15 @@
}
+ public static void delete(final File file) {
+ if (file != null && file.exists()) {
+ if (!file.delete()) {
+ file.deleteOnExit();
+ }
+ }
+ }
+
+
public static String getContents(final File file) throws IOException {
final StringBuffer result = new StringBuffer();
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
@@ -41,4 +50,13 @@
return result.toString();
}
+
+ public static String getNumberedFile(final String base, final String extension) {
+ int number = 1;
+ while (new File(base + number + extension).exists()) {
+ number++;
+ }
+ return base + number + extension;
+ }
+
}
Modified: trunk/poem/src/main/xsd/dictionary.xsd
===================================================================
--- trunk/poem/src/main/xsd/dictionary.xsd 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/xsd/dictionary.xsd 2008-02-17 12:29:43 UTC (rev 12)
@@ -1,16 +1,14 @@
<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:dict="http://poem.sf.net/dictionary"
- targetNamespace="http://poem.sf.net/dictionary">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="common.xsd"/>
<xs:element name="dictionary">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="dict:word"/>
+ <xs:element ref="word"/>
</xs:sequence>
- <xs:attribute name="language" type="dict:language" use="required"/>
+ <xs:attribute name="language" type="language" use="required"/>
</xs:complexType>
</xs:element>
@@ -18,13 +16,13 @@
<xs:complexType mixed="true">
<xs:attribute name="id" type="xs:ID" use="optional"/>
<xs:attribute name="root" type="xs:IDREF" use="optional"/>
- <xs:attribute name="type" type="dict:type" use="required"/>
- <xs:attribute name="gender" type="dict:gender" use="optional"/>
- <xs:attribute name="tense" type="dict:tense" use="optional"/>
- <xs:attribute name="person" type="dict:person" use="optional"/>
- <xs:attribute name="number" type="dict:number" use="optional"/>
+ <xs:attribute name="type" type="type" use="required"/>
+ <xs:attribute name="gender" type="gender" use="optional"/>
+ <xs:attribute name="tense" type="tense" use="optional"/>
+ <xs:attribute name="person" type="person" use="optional"/>
+ <xs:attribute name="number" type="number" use="optional"/>
<xs:attribute name="synonyms" type="xs:IDREFS" use="optional"/>
- <xs:attribute name="pronunciation" type="dict:pronunciation" use="optional"/>
+ <xs:attribute name="pronunciation" type="pronunciation" use="optional"/>
</xs:complexType>
</xs:element>
Added: trunk/poem/src/main/xsd/dictionary.xsdconfig
===================================================================
--- trunk/poem/src/main/xsd/dictionary.xsdconfig (rev 0)
+++ trunk/poem/src/main/xsd/dictionary.xsdconfig 2008-02-17 12:29:43 UTC (rev 12)
@@ -0,0 +1,5 @@
+<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">
+ <xb:namespace uri="##local">
+ <xb:package>net.sf.poem.xml</xb:package>
+ </xb:namespace>
+</xb:config>
\ No newline at end of file
Modified: trunk/poem/src/main/xsd/poem.xsd
===================================================================
--- trunk/poem/src/main/xsd/poem.xsd 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/main/xsd/poem.xsd 2008-02-17 12:29:43 UTC (rev 12)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:poem="http://poem.sf.net/poem"
- targetNamespace="http://poem.sf.net/poem">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="common.xsd"/>
@@ -24,7 +22,7 @@
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="optional"/>
- <xs:attribute name="language" type="poem:language" use="required"/>
+ <xs:attribute name="language" type="language" use="required"/>
<xs:attribute name="author" type="xs:string" use="optional"/>
<xs:attribute name="date" type="xs:date" use="optional"/>
</xs:complexType>
Added: trunk/poem/src/main/xsd/poem.xsdconfig
===================================================================
--- trunk/poem/src/main/xsd/poem.xsdconfig (rev 0)
+++ trunk/poem/src/main/xsd/poem.xsdconfig 2008-02-17 12:29:43 UTC (rev 12)
@@ -0,0 +1,5 @@
+<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">
+ <xb:namespace uri="##local">
+ <xb:package>net.sf.poem.xml</xb:package>
+ </xb:namespace>
+</xb:config>
\ No newline at end of file
Modified: trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-16 21:50:44 UTC (rev 11)
+++ trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-17 12:29:43 UTC (rev 12)
@@ -28,24 +28,49 @@
*/
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 {
- final Poem poem = PoemFactory.newInstance("en_UK", "sonnet", "Shall I compare thee to a Summer's day?");
+ 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", "shall-i-compare-thee-to-a-summers-day.xml", file.getName());
- assertXml("file contents", "<poem xmlns=\"http://poem.sf.net/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("file name 2", "poem2.xml", file.getName());
} finally {
- if (file.exists()) {
- if (!file.delete()) {
- file.deleteOnExit();
- }
- }
+ FileUtil.delete(file);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-16 21:50:38
|
Revision: 11
http://poem.svn.sourceforge.net/poem/?rev=11&view=rev
Author: rsinnema
Date: 2008-02-16 13:50:44 -0800 (Sat, 16 Feb 2008)
Log Message:
-----------
Remove poem files created during test
Modified Paths:
--------------
trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
Modified: trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-16 21:47:12 UTC (rev 10)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-16 21:50:44 UTC (rev 11)
@@ -15,9 +15,9 @@
package net.sf.poem.fit;
+import java.io.File;
import java.io.IOException;
-import net.sf.poem.api.Poem;
import net.sf.poem.api.PoemFactory;
import net.sf.poem.util.FileUtil;
import net.sf.poem.util.XmlUtil;
@@ -38,15 +38,17 @@
public String fileName() {
- return getPoem().getFile().getName();
+ return getFile().getName();
}
public String fileContents() throws IOException {
- return XmlUtil.normalizeWhitespace(FileUtil.getContents(getPoem().getFile()));
+ return XmlUtil.normalizeWhitespace(FileUtil.getContents(getFile()));
}
- private Poem getPoem() {
- return PoemFactory.newInstance(language, type, title);
+ private File getFile() {
+ final File result = PoemFactory.newInstance(language, type, title).getFile();
+ result.deleteOnExit();
+ return result;
}
}
Modified: trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-16 21:47:12 UTC (rev 10)
+++ trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-16 21:50:44 UTC (rev 11)
@@ -15,6 +15,7 @@
package net.sf.poem.api;
+import java.io.File;
import java.io.IOException;
import junit.framework.TestCase;
@@ -30,11 +31,22 @@
public void testCreate() throws IOException {
final Poem poem = PoemFactory.newInstance("en_UK", "sonnet", "Shall I compare thee to a Summer's day?");
assertNotNull("Missing poem", poem);
- assertNotNull("Missing file", poem.getFile());
- assertEquals("file name", "shall-i-compare-thee-to-a-summers-day.xml", poem.getFile().getName());
- assertXml("file contents", "<poem xmlns=\"http://poem.sf.net/poem\" type=\"sonnet\" language=\"en_UK\">"
- + "<title>Shall I compare thee to a Summer's day?</title>"
- + "<paragraph><line></line></paragraph></poem>", FileUtil.getContents(poem.getFile()));
+
+ final File file = poem.getFile();
+ assertNotNull("Missing file", file);
+
+ try {
+ assertEquals("file name", "shall-i-compare-thee-to-a-summers-day.xml", file.getName());
+ assertXml("file contents", "<poem xmlns=\"http://poem.sf.net/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));
+ } finally {
+ if (file.exists()) {
+ if (!file.delete()) {
+ file.deleteOnExit();
+ }
+ }
+ }
}
private void assertXml(final String message, final String expected, final String actual) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <poe...@li...> - 2008-02-16 21:47:09
|
Revision: 10
http://poem.svn.sourceforge.net/poem/?rev=10&view=rev
Author: rsinnema
Date: 2008-02-16 13:47:12 -0800 (Sat, 16 Feb 2008)
Log Message:
-----------
Implemented simple case of creating a poem
Modified Paths:
--------------
trunk/poem/.classpath
trunk/poem/build-api.xml
trunk/poem/build-common.xml
trunk/poem/src/fit/html/create-poem.html
trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
trunk/poem/src/fit/java/net/sf/poem/fit/package.html
Added Paths:
-----------
trunk/poem/lib/xmlbeans/
trunk/poem/lib/xmlbeans/jsr173_1.0_api.jar
trunk/poem/lib/xmlbeans/resolver.jar
trunk/poem/lib/xmlbeans/xbean.jar
trunk/poem/lib/xmlbeans/xbean_xpath.jar
trunk/poem/lib/xmlbeans/xmlbeans-qname.jar
trunk/poem/lib/xmlbeans/xmlpublic.jar
trunk/poem/src/main/java/net/
trunk/poem/src/main/java/net/sf/
trunk/poem/src/main/java/net/sf/poem/
trunk/poem/src/main/java/net/sf/poem/api/
trunk/poem/src/main/java/net/sf/poem/api/Poem.java
trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
trunk/poem/src/main/java/net/sf/poem/api/impl/
trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
trunk/poem/src/main/java/net/sf/poem/api/impl/package.html
trunk/poem/src/main/java/net/sf/poem/api/package.html
trunk/poem/src/main/java/net/sf/poem/util/
trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
trunk/poem/src/main/java/net/sf/poem/util/XmlUtil.java
trunk/poem/src/main/java/net/sf/poem/util/package.html
trunk/poem/src/test/java/net/
trunk/poem/src/test/java/net/sf/
trunk/poem/src/test/java/net/sf/poem/
trunk/poem/src/test/java/net/sf/poem/api/
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/.classpath
===================================================================
--- trunk/poem/.classpath 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/.classpath 2008-02-16 21:47:12 UTC (rev 10)
@@ -5,5 +5,9 @@
<classpathentry kind="src" path="src/fit/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/fit/fit.jar"/>
+ <classpathentry kind="lib" path="lib/junit-3.8.2.jar"/>
+ <classpathentry kind="lib" path="build/poemSchema.jar"/>
+ <classpathentry kind="lib" path="lib/xmlbeans/xbean.jar"/>
+ <classpathentry kind="lib" path="lib/xmlbeans/jsr173_1.0_api.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/poem/build-api.xml
===================================================================
--- trunk/poem/build-api.xml 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/build-api.xml 2008-02-16 21:47:12 UTC (rev 10)
@@ -1,6 +1,9 @@
<project name="poem-api" default="verify">
<import file="build-common.xml"/>
+
+ <property name="poem.xmlbeans.jar" value="${build.dir}poemSchema.jar"/>
+
<target name="verify" depends="integration-test"
description="run any checks to verify the package is valid and meets quality criteria">
@@ -30,10 +33,10 @@
<target name="package" depends="test"
description="take the compiled code and package it in its distributable format, such as a JAR">
- <!--antcall target="-.-create-java-doc">
+ <antcall target="--create-java-doc">
<param name="src.dir" value="${main.java.dir}"/>
- </antcall-->
-
+ </antcall>
+
<!-- Source package -->
<antcall target="--package-binary">
<param name="src.dir" value="${main.java.dir}"/>
@@ -65,6 +68,8 @@
<path id="src.class.path">
<pathelement location="${main.jar.file}"/>
<pathelement location="${junit.jar}"/>
+ <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ <pathelement location="${poem.xmlbeans.jar}"/>
</path>
<path id="test.class.path">
<path refid="src.class.path"/>
@@ -91,7 +96,16 @@
<target name="compile" depends="validate"
description="compile the source code of the project">
- <path id="dummy.class.path"/>
+ <antcall target="--xml-beans">
+ <param name="xml.beans.jar" value="${poem.xmlbeans.jar}"/>
+ <param name="schema.dir" value="${main.dir}xsd"/>
+ </antcall>
+
+ <path id="dummy.class.path">
+ <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ <pathelement location="${poem.xmlbeans.jar}"/>
+ </path>
+
<antcall target="--compile-java">
<param name="src.dir" value="${main.java.dir}"/>
<param name="dest.dir" value="${main.class.dir}"/>
Modified: trunk/poem/build-common.xml
===================================================================
--- trunk/poem/build-common.xml 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/build-common.xml 2008-02-16 21:47:12 UTC (rev 10)
@@ -35,6 +35,8 @@
<property name="fit.test.dir" value="${fit.base.dir}html${file.separator}"/>
<property name="fit.report.dir" value="${report.dir}fit${file.separator}"/>
+ <property name="xmlbeans.dir" value="${lib.dir}xmlbeans${file.separator}"/>
+
<property file="${root.dir}build.properties" />
@@ -341,7 +343,36 @@
<checksum file="${file}" algorithm="SHA"/>
</target>
-
+
+ <target name="--xml-beans">
+ <property name="includes" value="**/*.xsd"/>
+ <dirname file="${xml.beans.jar}" property="dest.dir"/>
+ <uptodate property="xmlbeans.generated" targetfile="${xml.beans.jar}">
+ <srcfiles dir="${schema.dir}" includes="${includes}" />
+ </uptodate>
+ <antcall target="--do-xml-beans"/>
+ </target>
+
+
+ <target name="--do-xml-beans" unless="xmlbeans.generated">
+ <mkdir dir="${dest.dir}"/>
+ <path id="xmlbeans.path">
+ <fileset dir="${xmlbeans.dir}" includes="**/*.jar"/>
+ </path>
+ <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean">
+ <classpath>
+ <path refid="xmlbeans.path"/>
+ </classpath>
+ </taskdef>
+ <xmlbean destfile="${xml.beans.jar}" javasource="${java.source.version}">
+ <classpath>
+ <path refid="xmlbeans.path"/>
+ </classpath>
+ <fileset dir="${schema.dir}" includes="${includes}"/>
+ </xmlbean>
+ </target>
+
+
<target name="--upload-to-sourceforge">
<ftp server="upload.sourceforge.net" userid="anonymous" password="${user}@sf.net" remotedir="/incoming" verbose="true">
<fileset dir="${dist.dir}" includes="${project}-*-${version}.*" />
Added: trunk/poem/lib/xmlbeans/jsr173_1.0_api.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/jsr173_1.0_api.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/lib/xmlbeans/resolver.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/resolver.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/lib/xmlbeans/xbean.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/xbean.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/lib/xmlbeans/xbean_xpath.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/xbean_xpath.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/lib/xmlbeans/xmlbeans-qname.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/xmlbeans-qname.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/poem/lib/xmlbeans/xmlpublic.jar
===================================================================
(Binary files differ)
Property changes on: trunk/poem/lib/xmlbeans/xmlpublic.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/poem/src/fit/html/create-poem.html
===================================================================
--- trunk/poem/src/fit/html/create-poem.html 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/src/fit/html/create-poem.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -21,39 +21,21 @@
<td>sonnet</td>
<td>Shall I compare thee to a Summer's day?</td>
<td>shall-i-compare-thee-to-a-summers-day.xml</td>
- <td><?xml version="1.0"?>
-<poem type="sonnet" language="en_UK">
- <title>Shall I compare thee to a Summer's day?</title>
- <paragraph>
- <line></line>
- </paragraph>
-</poem></td>
+ <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="sonnet" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
</tr>
<tr>
<td>en_UK</td>
<td>blank</td>
<td>Shall I compare thee to a Summer's day?</td>
<td>shall-i-compare-thee-to-a-summers-day.xml</td>
- <td><?xml version="1.0"?>
-<poem type="free" language="en_UK">
- <title>Shall I compare thee to a Summer's day?</title>
- <paragraph>
- <line></line>
- </paragraph>
-</poem></td>
+ <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="free" language="en_UK"><title>Shall I compare thee to a Summer's day?</title><paragraph><line></line></paragraph></poem></td>
</tr>
<tr>
<td>en_UK</td>
<td>sonnet</td>
<td>blank</td>
<td>poem1.xml</td>
- <td><?xml version="1.0"?>
-<poem type="sonnet" language="en_UK">
- <title></title>
- <paragraph>
- <line></line>
- </paragraph>
-</poem></td>
+ <td><?xml version="1.0"?><poem xmlns="http://poem.sf.net/poem" type="sonnet" language="en_UK"><title></title><paragraph><line></line></paragraph></poem></td>
</tr>
</table>
</body>
Modified: trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/CreatePoemFixture.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -15,6 +15,12 @@
package net.sf.poem.fit;
+import java.io.IOException;
+
+import net.sf.poem.api.Poem;
+import net.sf.poem.api.PoemFactory;
+import net.sf.poem.util.FileUtil;
+import net.sf.poem.util.XmlUtil;
import fit.ColumnFixture;
@@ -30,12 +36,17 @@
public String title;
// resume visibilitymodifier check
+
public String fileName() {
- return "";
+ return getPoem().getFile().getName();
}
- public String fileContents() {
- return "";
+ public String fileContents() throws IOException {
+ return XmlUtil.normalizeWhitespace(FileUtil.getContents(getPoem().getFile()));
}
+ private Poem getPoem() {
+ return PoemFactory.newInstance(language, type, title);
+ }
+
}
Modified: trunk/poem/src/fit/java/net/sf/poem/fit/package.html
===================================================================
--- trunk/poem/src/fit/java/net/sf/poem/fit/package.html 2008-02-16 14:46:09 UTC (rev 9)
+++ trunk/poem/src/fit/java/net/sf/poem/fit/package.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -1,5 +1,5 @@
<html>
<body>
- This are the <a href="http://fit.c2.com">fixtures</a> for the acceptance tests.
+ These are the <a href="http://fit.c2.com">fixtures</a> for the acceptance tests.
</body>
</html>
Added: trunk/poem/src/main/java/net/sf/poem/api/Poem.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/Poem.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/api/Poem.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,31 @@
+// 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;
+
+
+/**
+ * A poem.
+ */
+public interface Poem {
+
+ /**
+ * @return The {@see File} in which the poem is stored
+ */
+ File getFile();
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/api/PoemFactory.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,82 @@
+// 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.FileNotFoundException;
+import java.io.PrintWriter;
+
+import net.sf.poem.api.impl.PoemImpl;
+
+
+/**
+ * Factory class for creating poems.
+ */
+public final class PoemFactory {
+
+ private PoemFactory() {
+ // Utility class should not have a public constructor
+ }
+
+ /**
+ * Create a new poem.
+ * @param language The language the poem will be written in
+ * @param type The type of poem, like sonnet
+ * @param title The poem's title
+ * @return A newly created poem
+ * @throws FileNotFoundException
+ */
+ public static Poem newInstance(final String language, final String type,
+ final String title) {
+ return new PoemImpl(newFile(language, type, title));
+ }
+
+ private static File newFile(final String language, final String type,
+ final String title) {
+ final File result = new File(getFileName(title));
+ final PrintWriter writer = newWriter(result);
+ writer.println("<?xml version=\"1.0\"?>");
+ writer.print("<poem xmlns=\"http://poem.sf.net/poem\" type=\"");
+ writer.print(type);
+ writer.print("\" language=\"");
+ writer.print(language);
+ writer.println("\">");
+ writer.print(" <title>");
+ writer.print(title);
+ writer.println("</title>");
+ writer.println(" <paragraph>");
+ writer.println(" <line></line>");
+ writer.println(" </paragraph>");
+ writer.println("</poem>");
+ writer.close();
+ return result;
+ }
+
+ private static PrintWriter newWriter(final File file) {
+ PrintWriter result = null;
+ try {
+ result = new PrintWriter(file);
+ } catch (final FileNotFoundException e) {
+ throw new IllegalStateException(e);
+ }
+ return result;
+ }
+
+ private static String getFileName(final String title) {
+ return title.toLowerCase().replaceAll("\\s", "-").replaceAll("[^a-zA-Z0-9\\-]", "") + ".xml";
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/api/impl/PoemImpl.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,38 @@
+// 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.impl;
+
+import java.io.File;
+
+import net.sf.poem.api.Poem;
+
+
+/**
+ * Implementation of {@see Poem}.
+ */
+public class PoemImpl implements Poem {
+
+ private final File file;
+
+ public PoemImpl(final File file) {
+ this.file = file;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/api/impl/package.html
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/impl/package.html (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/api/impl/package.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ This is the implementation of the core API.
+ </body>
+</html>
Added: trunk/poem/src/main/java/net/sf/poem/api/package.html
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/api/package.html (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/api/package.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ This is the core API.
+ </body>
+</html>
Added: trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/util/FileUtil.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,44 @@
+// 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.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+
+/**
+ * Utility methods for working with files.
+ */
+public final class FileUtil {
+
+ private FileUtil() {
+ // Utility class should not have a public constructor
+ }
+
+
+ public static String getContents(final File file) throws IOException {
+ final StringBuffer result = new StringBuffer();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ result.append(line).append('\n');
+ }
+ return result.toString();
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/util/XmlUtil.java
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/util/XmlUtil.java (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/util/XmlUtil.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,32 @@
+// 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.util;
+
+
+/**
+ * Utility methods for working with files.
+ */
+public final class XmlUtil {
+
+ private XmlUtil() {
+ // Utility class should not have a public constructor
+ }
+
+ public static String normalizeWhitespace(final String value) {
+ return value.replaceAll("\\s+<", "<").replaceAll(">\\s+", ">").replaceAll("\\s+", " ");
+ }
+
+}
Added: trunk/poem/src/main/java/net/sf/poem/util/package.html
===================================================================
--- trunk/poem/src/main/java/net/sf/poem/util/package.html (rev 0)
+++ trunk/poem/src/main/java/net/sf/poem/util/package.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ These are supporting classes.
+ </body>
+</html>
Added: trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/api/PoemFactoryTest.java 2008-02-16 21:47:12 UTC (rev 10)
@@ -0,0 +1,45 @@
+// 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.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 {
+
+ public void testCreate() throws IOException {
+ final Poem poem = PoemFactory.newInstance("en_UK", "sonnet", "Shall I compare thee to a Summer's day?");
+ assertNotNull("Missing poem", poem);
+ assertNotNull("Missing file", poem.getFile());
+ assertEquals("file name", "shall-i-compare-thee-to-a-summers-day.xml", poem.getFile().getName());
+ assertXml("file contents", "<poem xmlns=\"http://poem.sf.net/poem\" type=\"sonnet\" language=\"en_UK\">"
+ + "<title>Shall I compare thee to a Summer's day?</title>"
+ + "<paragraph><line></line></paragraph></poem>", FileUtil.getContents(poem.getFile()));
+ }
+
+ private void assertXml(final String message, final String expected, final String actual) {
+ assertEquals(message, XmlUtil.normalizeWhitespace("<?xml version=\"1.0\"?>" + expected),
+ XmlUtil.normalizeWhitespace(actual));
+ }
+
+}
Added: trunk/poem/src/test/java/net/sf/poem/api/package.html
===================================================================
--- trunk/poem/src/test/java/net/sf/poem/api/package.html (rev 0)
+++ trunk/poem/src/test/java/net/sf/poem/api/package.html 2008-02-16 21:47:12 UTC (rev 10)
@@ -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.
|