jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r739185 - in /incubator/jspwiki/trunk: ./ src/java/com/ecyrd/jspwiki/ src/java/com/ecyrd/jspwiki/action/ src/java/com/ecyrd/jspwiki/util/ tests/etc/selenium/tests/all/ tests/java/com/ecyrd/jspwiki/util/
Date Fri, 30 Jan 2009 05:49:22 GMT
Author: ajaquith
Date: Fri Jan 30 05:49:22 2009
New Revision: 739185

URL: http://svn.apache.org/viewvc?rev=739185&view=rev
Log:
Minor tweaks to Eclipse project so that tests run. Improvements to CommentedProperties. Seems
to mostly work now, although opportunities for cosmetic improvements remain.

Modified:
    incubator/jspwiki/trunk/.classpath
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/action/package.html
    incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/util/CommentedProperties.java
    incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePage.html
    incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePageNonAdmin.html
    incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RedirectAfterLogin.html
    incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RenamePage.html
    incubator/jspwiki/trunk/tests/java/com/ecyrd/jspwiki/util/CommentedPropertiesTest.java

Modified: incubator/jspwiki/trunk/.classpath
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/.classpath?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/.classpath (original)
+++ incubator/jspwiki/trunk/.classpath Fri Jan 30 05:49:22 2009
@@ -9,5 +9,7 @@
 	<classpathentry kind="lib" path="tests/lib/jetty-plus-5.1.14.jar"/>
 	<classpathentry kind="lib" path="tests/lib/jetty-jmx-5.1.14.jar"/>
 	<classpathentry kind="lib" path="tests/lib/selenium-server-1.0-beta1.jar"/>
+	<classpathentry kind="lib" path="tests/lib/hsqldb.jar"/>
+	<classpathentry kind="lib" path="tests/etc"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Fri Jan 30 05:49:22 2009
@@ -1,3 +1,13 @@
+2009-01-30  Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-59
+
+        * Minor tweaks to Eclipse project so that tests run.
+
+        * Improvements to CommentedProperties. Seems to mostly
+        work now, although opportunities for cosmetic improvements
+        remain.
+
 2009-01-30  Janne Jalkanen <jalkanen@apache.org>
 
         * 3.0.0-svn-58

Modified: incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/Release.java?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/Release.java Fri Jan 30 05:49:22 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "58";
+    public static final String     BUILD         = "59";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/action/package.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/action/package.html?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/action/package.html (original)
+++ incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/action/package.html Fri Jan 30 05:49:22
2009
@@ -29,7 +29,7 @@
 </ul>
 <p>For the impatient, here is the developer cheat sheet:</p>
 <ol>
-	<li>Move scriptlet code that extracts request parameters</a> into
+	<li>Move scriptlet code that extracts request parameters into
 	{@link net.sourceforge.stripes.action.ActionBean} getters and
 	setters.&nbsp;<a href="#1"><small>More...</small></a></li>
 	<li>Add <code><a
@@ -89,7 +89,7 @@
 com.ecyrd.jspwiki.ui.stripes.WikiActionBeanContext#getEngine()} and
 {@link
 com.ecyrd.jspwiki.ui.stripes.WikiActionBeanContext#getWikiSession()}.</p>
-WikiActionBeanContext also implements the {@link
+<p>WikiActionBeanContext also implements the {@link
 com.ecyrd.jspwiki.WikiContext} interface, so any methods that
 normally operate on WikiContext will work with WikiActionBeanContext
 also.
@@ -330,7 +330,7 @@
 tag's <code>name</code> attribute supplies the event to execute, in this
 case <code>createAssertedName</code>, As you can see from the code
 snippet, the event name "createAssertedName" matches the value of the <code>@HandlerEvent</code>
-annotation.</code> .</p>
+annotation.</p>
 
 <blockquote><a name="5" /><strong>Guideline #5
 for JSPWiki developers</strong>: processing code that handles form POST

Modified: incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/util/CommentedProperties.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/util/CommentedProperties.java?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/util/CommentedProperties.java (original)
+++ incubator/jspwiki/trunk/src/java/com/ecyrd/jspwiki/util/CommentedProperties.java Fri Jan
30 05:49:22 2009
@@ -38,7 +38,7 @@
     private static final long serialVersionUID = 8057284636436329669L;
 
     /** Map with property names as keys, and comments as values. */
-    private Map<String, String> m_propertyComments = new HashMap<String, String>();
+    private Map<String, List<String>> m_propertyComments = new HashMap<String,
List<String>>();
 
     /**
      * Ordered map with property names inserted in the order encountered in the
@@ -46,7 +46,7 @@
      */
     private Set<Object> m_keys = new LinkedHashSet<Object>();
 
-    private String m_trailingComment = null;
+    private List<String> m_trailingComments = null;
 
     private final String m_br;
 
@@ -106,32 +106,45 @@
 
     /**
      * {@inheritDoc}
+     * <p>
+     * <em>Notes specific to this implementation:</em>
+     * </p>
+     * <p>
+     * </p>
      */
     @Override
     public synchronized void store( OutputStream out, String comments ) throws IOException
     {
-        byte[] bytes = toString().getBytes( "ISO-8859-1" );
-        FileUtil.copyContents( new ByteArrayInputStream( bytes ), out );
-        out.flush();
+        BufferedWriter writer;
+        writer = new BufferedWriter( new OutputStreamWriter( out, "8859_1" ) );
+        writeProperties( writer, comments );
+        writer.flush();
     }
 
     /**
-     * {@inheritDoc}
+     * @param writer
+     * @param comments
      */
-    @Override
-    public synchronized String toString()
+    private void writeProperties( BufferedWriter writer, String comments ) throws IOException
     {
-        StringBuilder b = new StringBuilder();
+        if( comments != null )
+        {
+            writer.write( "# " );
+            writeText( writer, "# " + comments, EscapeMode.COMMENT );
+            writer.newLine();
+            writer.write( "# " + new Date().toString() );
+            writer.newLine();
+        }
+
         for( Object key : m_keys )
         {
             Object value = get( key );
-            String comment = m_propertyComments.get( key );
-            if( comment != null )
-            {
-                b.append( comment );
-                b.append( m_br );
-            }
-            printProperty( b, key, value );
+            List<String> commentList = m_propertyComments.get( key );
+            writeComments( writer, commentList );
+            writeText( writer, key, EscapeMode.KEY );
+            writer.write( '=' );
+            writeText( writer, value, EscapeMode.ENTRY );
+            writer.newLine();
         }
 
         // Now print the keys we did not encounter (i.e., were added after the
@@ -142,30 +155,142 @@
             if( !m_keys.contains( key ) )
             {
                 Object value = entry.getValue();
-                printProperty( b, key, value );
+                writeText( writer, key, EscapeMode.KEY );
+                writer.write( '=' );
+                writeText( writer, value, EscapeMode.ENTRY );
+                writer.newLine();
             }
         }
 
         // Add any trailing comments
-        if( m_trailingComment != null )
+        writeComments( writer, m_trailingComments );
+    }
+
+    enum EscapeMode
+    {
+        COMMENT, KEY, ENTRY;
+    }
+
+    private void writeComments( BufferedWriter writer, List<String> commentList ) throws
IOException
+    {
+        if( commentList != null )
         {
-            b.append( m_trailingComment );
-            b.append( m_br );
+            for( String comment : commentList )
+            {
+                if  ( BLANK_LINE_DETECTOR.matcher( comment ).matches() )
+                {
+                    writer.write( comment );
+                }
+                else
+                {
+                    writer.write( "#" );
+                    writeText( writer, comment, EscapeMode.COMMENT );
+                }
+                writer.newLine();
+            }
         }
-        return b.toString();
     }
+    
+    private void writeText( BufferedWriter writer, Object entry, EscapeMode mode ) throws
IOException
+    {
+        String e = entry.toString();
+        boolean leadingSpaces = true;
+        for( int i = 0; i < e.length(); i++ )
+        {
+            char ch = e.charAt( i );
 
-    private void printProperty( StringBuilder b, Object key, Object value )
+            // Escape linefeeds, newline, carriage returns and tabs
+            switch( ch )
+            {
+                case '\t': {
+                    leadingSpaces = false;
+                    writer.write( "\\t" );
+                    break;
+                }
+                case '\f': {
+                    leadingSpaces = false;
+                    writer.write( "\\f" );
+                    break;
+                }
+                case '\n': {
+                    leadingSpaces = false;
+                    if( mode != EscapeMode.COMMENT )
+                    {
+                        writer.write( "\\n" );
+                    }
+                    break;
+                }
+                case '\r': {
+                    leadingSpaces = false;
+                    if( mode != EscapeMode.COMMENT )
+                    {
+                        writer.write( "\\r" );
+                    }
+                    break;
+                }
+                case ' ': {
+                    if ( leadingSpaces || mode == EscapeMode.KEY )
+                    {
+                        writer.write( '\\' );
+                    }
+                    writer.write( ' ' );
+                    break;
+                }
+                case '\\':
+                case '#':
+                case '!':
+                case '=':
+                case ':':
+                {
+                    leadingSpaces = false;
+                    if ( mode == EscapeMode.KEY )
+                    {
+                        writer.write( '\\' );
+                    }
+                    writer.write( ch );
+                    break;
+                }
+                default: {
+                    leadingSpaces = false;
+                    if( ch < 32 || ch > 126 )
+                    {
+                        writer.write( '\\' );
+                        writer.write( 'u' );
+                        writer.write( HEX[(ch >>> 12) & 15] );
+                        writer.write( HEX[(ch >>> 8) & 15] );
+                        writer.write( HEX[(ch >>> 4) & 15] );
+                        writer.write( HEX[ch & 15] );
+                    }
+                    else
+                    {
+                        writer.write( ch );
+                    }
+                }
+            }
+        }
+    }
+
+    private char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c',
'd', 'e', 'f' };
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public synchronized String toString()
     {
-        // Escape any linebreak characters in the value string
-        String pattern = " *[\\n\\r]+";
-        String valueString = value.toString().replaceAll( pattern, " \\\\" + m_br );
-        b.append( key.toString() );
-        b.append( ' ' );
-        b.append( '=' );
-        b.append( ' ' );
-        b.append( valueString );
-        b.append( m_br );
+        StringWriter s = new StringWriter();
+        BufferedWriter writer;
+        writer = new BufferedWriter( s );
+        try
+        {
+            writeProperties( writer, null );
+            writer.flush();
+            return s.toString();
+        }
+        catch( IOException e )
+        {
+        }
+        return null;
     }
 
     /**
@@ -187,7 +312,7 @@
         LineNumberReader reader = new LineNumberReader( new StringReader( propertyString
) );
         String line = null;
         boolean inProperty = false;
-        String comment = null;
+        List<String> commentList = new ArrayList<String>();
         while ( (line = reader.readLine()) != null )
         {
             // Trim line of leading/trailing whitespace
@@ -201,14 +326,14 @@
                 boolean isWhitespace = BLANK_LINE_DETECTOR.matcher( text ).matches();
                 if( isComment )
                 {
-                    comment = comment == null ? text : comment + m_br + text;
+                    commentList.add( text.substring( 1 ) );
                     inProperty = false;
                 }
 
                 // If all whitespace and part of comment, append it
                 else if( isWhitespace && !inProperty )
                 {
-                    comment = comment == null ? text : comment + m_br + text;
+                    commentList.add( text );
                 }
 
                 // Otherwise, see if we're starting a new property key
@@ -219,13 +344,13 @@
                     if( key != null )
                     {
                         String value = getProperty( key );
-                        if( value != null && comment != null )
+                        if( value != null && commentList.size() > 0 )
                         {
-                            m_propertyComments.put( key, comment );
+                            m_propertyComments.put( key, commentList );
                             m_keys.add( key );
                         }
                         inProperty = true;
-                        comment = null;
+                        commentList = new ArrayList<String>();
                     }
                 }
             }
@@ -233,7 +358,7 @@
 
         // Any leftover comments are "trailing" comments that go at the end of
         // the file
-        m_trailingComment = comment;
+        m_trailingComments = commentList;
 
         reader.close();
     }
@@ -273,21 +398,39 @@
      * Returns the comment for a supplied key, as parsed by the
      * {@link #load(Reader)} or {@link #load(InputStream)} methods, <em>or</em>
      * as supplied to the{@link #setProperty(String, String, String)} method.
+     * The leading <code>#</code> or <code>!</code> characters are
not
+     * included.
      * 
      * @param key the key to look up
-     * @return the comment (including the trailing <code>!</code> or
-     *         <code>#</code> character, or <code>null</code> if
not found
+     * @return the list of strings representing the comment, each item of which
+     *         represents a line, or <code>null</code> if not found
      */
     public String getComment( String key )
     {
-        return(m_propertyComments.get( key ));
+        StringBuffer b = new StringBuffer();
+        List<String> commentList = m_propertyComments.get( key );
+        if( commentList == null )
+        {
+            return null;
+        }
+        for( String comment : commentList )
+        {
+            b.append( comment );
+            if( commentList.indexOf( comment ) < commentList.size() - 1 )
+            {
+                b.append( m_br );
+            }
+        }
+        return b.toString();
     }
 
     /**
      * Sets a property value for a supplied key, and adds a comment that will be
      * written to disk when the {@link #store(OutputStream, String)} method is
      * called. This method behaves otherwise identically to
-     * {@link #setProperty(String, String)}.
+     * {@link #setProperty(String, String)}. The leading <code>#</code> or
+     * <code>!</code> characters should not be included unless it is meant to
+     * be part of the comment itself.
      * 
      * @param key the string key to store
      * @param value the property value associated with the key
@@ -302,11 +445,12 @@
             if( comment != null )
             {
                 comment = comment.trim();
-                if( !comment.startsWith( "#" ) )
+                if( comment.length() > 0 )
                 {
-                    comment = "# " + comment;
+                    List<String> commentList = new ArrayList<String>();
+                    commentList.add( comment );
+                    m_propertyComments.put( key, commentList );
                 }
-                m_propertyComments.put( key, comment );
             }
             m_keys.add( key );
         }

Modified: incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePage.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePage.html?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePage.html (original)
+++ incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePage.html Fri Jan 30 05:49:22
2009
@@ -20,13 +20,13 @@
 	<tr><td>store</td>	<td>${baseUrl}/Login.jsp</td>				<td>loginurl</td></tr>
     <tr><td>store</td>	<td>This page was created by the web unit
tests.</td>	<td>PageContent</td></tr>
 
-	<!-- Login --!>
+	<!-- Login -->
     <tr><td>open</td>	<td>${loginurl}</td>	<td>&nbsp;</td></tr>
     <tr><td>type</td>	<td>j_username</td>	<td>${TestUsername}</td></tr>
     <tr><td>type</td>	<td>j_password</td>	<td>${TestPassword}</td></tr>
     <tr><td>clickAndWait</td>	<td>submitlogin</td>	<td>&nbsp;</td></tr>
 
-	<!-- Create page --!>
+	<!-- Create page -->
     <tr><td>open</td>					<td>${editurl}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTitle</td>			<td>JSPWiki: Edit: ${page}</td>
<td>&nbsp;</td></tr>
     <tr><td>verifyElementPresent</td>	<td>ok</td>	<td></td></tr>
@@ -39,22 +39,22 @@
     <tr><td>verifyTitle</td>		<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTextPresent</td>	<td>${PageContent}</td>
<td>&nbsp;</td></tr>	
     
-	<!-- Delete Page --!>
+	<!-- Delete Page -->
     <tr><td>open</td>					<td>${infourl}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTitle</td>			<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>assertElementPresent</td>	<td>id=delete-all</td>
<td>&nbsp;</td></tr>	
     <tr><td>clickAndWait</td>			<td>id=delete-all</td> 	<td>&nbsp;</td></tr>
 
-    <!-- Confirm delete --!>
+    <!-- Confirm delete -->
     <tr><td>assertConfirmation</td>	<td>Please confirm that you want
to delete this content permanently!</td>	<td>&nbsp;</td></tr>

 
 
     <!-- This page does not exist. Why don&#8217;t you go and create it? --!>
     <tr><td>verifyTitle</td>		<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTextPresent</td>	<td>This page does not exist.
Why don&#8217;t you go and create it?</td> <td>&nbsp;</td></tr>

-	<!-- class= information --!>
+	<!-- class= information -->
 
-    <!-- Log out --!>
+    <!-- Log out -->
     <tr><td>clickAndWait</td>	<td>link=Log out</td> 	<td>&nbsp;</td></tr>
 
 	</tbody>

Modified: incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePageNonAdmin.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePageNonAdmin.html?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePageNonAdmin.html (original)
+++ incubator/jspwiki/trunk/tests/etc/selenium/tests/all/DeletePageNonAdmin.html Fri Jan 30
05:49:22 2009
@@ -20,13 +20,13 @@
 	<tr><td>store</td>	<td>${baseUrl}/Login.jsp</td>				<td>loginurl</td></tr>
     <tr><td>store</td>	<td>This page was created by the web unit
tests.</td>	<td>PageContent</td></tr>
 
-	<!-- Login --!>
+	<!-- Login -->
     <tr><td>open</td>	<td>${loginurl}</td>	<td>&nbsp;</td></tr>
     <tr><td>type</td>	<td>j_username</td>	<td>${TestUsername}</td></tr>
     <tr><td>type</td>	<td>j_password</td>	<td>${TestPassword}</td></tr>
     <tr><td>clickAndWait</td>	<td>submitlogin</td>	<td>&nbsp;</td></tr>
 
-	<!-- Create page --!>
+	<!-- Create page -->
     <tr><td>open</td>					<td>${editurl}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTitle</td>			<td>JSPWiki: Edit: ${page}</td>
<td>&nbsp;</td></tr>
     <tr><td>verifyElementPresent</td>	<td>ok</td>	<td></td></tr>
@@ -39,12 +39,12 @@
     <tr><td>verifyTitle</td>		<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTextPresent</td>	<td>${PageContent}</td>
<td>&nbsp;</td></tr>	
     
-	<!-- Delete Page --!>
+	<!-- Delete Page -->
     <tr><td>open</td>					<td>${infourl}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTitle</td>			<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>assertElementNotPresent</td>	<td>id=delete-all</td>
<td>&nbsp;</td></tr>	
 
-    <!-- Log out --!>
+    <!-- Log out -->
     <tr><td>clickAndWait</td>	<td>link=Log out</td> 	<td>&nbsp;</td></tr>
 
 	</tbody>

Modified: incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RedirectAfterLogin.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RedirectAfterLogin.html?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RedirectAfterLogin.html (original)
+++ incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RedirectAfterLogin.html Fri Jan 30
05:49:22 2009
@@ -59,7 +59,7 @@
     <!-- We should be able to see the page now -->
     <tr><td>verifyTextPresent</td>	<td>${RedirectText}</td>
<td>&nbsp;</td></tr>
 
-    <!-- Log out --!>
+    <!-- Log out -->
     <tr><td>clickAndWait</td>	<td>link=Log out</td> 	<td>&nbsp;</td></tr>
 
 	</tbody>

Modified: incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RenamePage.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RenamePage.html?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RenamePage.html (original)
+++ incubator/jspwiki/trunk/tests/etc/selenium/tests/all/RenamePage.html Fri Jan 30 05:49:22
2009
@@ -20,13 +20,13 @@
 	<tr><td>store</td>	<td>${baseUrl}/Login.jsp</td>				<td>loginurl</td></tr>
     <tr><td>store</td>	<td>This page was created by the rename web
unit tests.</td>	<td>PageContent</td></tr>
 
-	<!-- Login --!>
+	<!-- Login -->
     <tr><td>open</td>	<td>${loginurl}</td>	<td>&nbsp;</td></tr>
     <tr><td>type</td>	<td>j_username</td>	<td>${TestUsername}</td></tr>
     <tr><td>type</td>	<td>j_password</td>	<td>${TestPassword}</td></tr>
     <tr><td>clickAndWait</td>	<td>submitlogin</td>	<td>&nbsp;</td></tr>
 
-	<!-- Create a new page --!>
+	<!-- Create a new page -->
     <tr><td>open</td>	<td>${editurl}</td>	<td>&nbsp;</td></tr>
 
     <tr><td>verifyTitle</td>		<td>JSPWiki: Edit: ${page}</td>
<td>&nbsp;</td></tr>
@@ -38,7 +38,7 @@
     <tr><td>verifyTitle</td>		<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTextPresent</td>	<td>${PageContent}</td>
<td>&nbsp;</td></tr>	
     
-	<!-- Rename Page --!>
+	<!-- Rename Page -->
     <tr><td>open</td>					<td>${infourl}</td>	<td>&nbsp;</td></tr>
     <tr><td>verifyTitle</td>			<td>JSPWiki: ${page}</td>	<td>&nbsp;</td></tr>
     <tr><td>assertElementPresent</td>	<td>rename</td>			<td>&nbsp;</td></tr>

@@ -48,7 +48,7 @@
 
     <tr><td>verifyTitle</td>	<td>JSPWiki: ${page}-renamed</td>
<td>&nbsp;</td></tr>
 
-    <!-- Log out --!>
+    <!-- Log out -->
     <tr><td>clickAndWait</td>	<td>link=Log out</td> 	<td>&nbsp;</td></tr>
 
 	</tbody>

Modified: incubator/jspwiki/trunk/tests/java/com/ecyrd/jspwiki/util/CommentedPropertiesTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/com/ecyrd/jspwiki/util/CommentedPropertiesTest.java?rev=739185&r1=739184&r2=739185&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/com/ecyrd/jspwiki/util/CommentedPropertiesTest.java
(original)
+++ incubator/jspwiki/trunk/tests/java/com/ecyrd/jspwiki/util/CommentedPropertiesTest.java
Fri Jan 30 05:49:22 2009
@@ -63,12 +63,12 @@
         assertEquals( propsLen + 5, m_props.toString().length() );
         assertTrue( m_props.toString().indexOf( "newValue" ) != -1 );
 
-        // Create new property; should add 20 (7+3+9+1) bytes
+        // Create new property; should add 18 (7+1+9+1) bytes
         m_props.setProperty( "newProp", "newValue2" );
         m_props.containsKey( "newProp" );
         m_props.containsValue( "newValue2" );
-        assertEquals( propsLen + 5 + 20, m_props.toString().length() );
-        assertTrue( m_props.toString().indexOf( "newProp = newValue2" ) != -1 );
+        assertEquals( propsLen + 5 + 18, m_props.toString().length() );
+        assertTrue( m_props.toString().indexOf( "newProp=newValue2" ) != -1 );
     }
 
     public void testSetMultilineProperty() throws Exception
@@ -82,7 +82,7 @@
         // Make sure that the line was escaped properly
         String cr = System.getProperty( "line.separator" );
         String propString = props.toString();
-        assertEquals( "foo = This is a \\" + cr +"multiline \\" + cr + "property \\" + cr
+ "with 4 lines.\n", propString );
+        assertEquals( "foo=This is a \\" + cr +"multiline \\" + cr + "property \\" + cr +
"with 4 lines.\n", propString );
         
         // Reload and make sure the property is parsed in as 1 line
         props = new CommentedProperties();
@@ -101,22 +101,22 @@
     public void testGetComment()
     {
         String cr = System.getProperty( "line.separator" );
-        assertEquals( "# This is a sample properties file with comments", m_props.getComment(
"testProp1" ) );
-        assertEquals( "# This is a comment" + cr + "#   with two lines", m_props.getComment(
"testProp2" ) );
-        assertEquals( "# This is a property with no value", m_props.getComment( "testProp3"
) );
-        assertEquals( "# Two final properties", m_props.getComment( "testProp4" ) );
+        assertEquals( "This is a sample properties file with comments", m_props.getComment(
"testProp1" ) );
+        assertEquals( "This is a comment" + cr + "with two lines", m_props.getComment( "testProp2"
) );
+        assertEquals( "This is a property with no value", m_props.getComment( "testProp3"
) );
+        assertEquals( "Two final properties", m_props.getComment( "testProp4" ) );
         assertEquals( null, m_props.getComment( "testProp5" ) );
-        assertEquals( "# This is a property that spans more than 1 line", m_props.getComment(
"testProp6" ) );
+        assertEquals( "This is a property that spans more than 1 line", m_props.getComment(
"testProp6" ) );
     }
     
     public void testSetComment()
     {
         m_props.setProperty( "testProp7", "TestValue","This is a comment" );
         assertEquals( "TestValue", m_props.getProperty( "testProp7" ) );
-        assertEquals( "# This is a comment", m_props.getComment( "testProp7" ) );
+        assertEquals( "This is a comment", m_props.getComment( "testProp7" ) );
         
         // Make sure it was actually added to the string returned by toString()
-        assertTrue( m_props.toString().contains( "# This is a comment\ntestProp7 = TestValue"
) );
+        assertTrue( m_props.toString().contains( "# This is a comment\ntestProp7=TestValue"
) );
     }
     
     public void testMultilineProperties()
@@ -129,36 +129,36 @@
     {
         int propsLen = m_props.toString().length();
 
-        // Remove prop 1; length of stored string should be 16 (9+3+3+1) bytes
+        // Remove prop 1; length of stored string should be 14 (9+1+3+1) bytes
         // less for property
-        // and 49 bytes less for the comment above it. Total difference: 65
+        // and 49 bytes less for the comment above it. Total difference: 63
         // bytes
         m_props.remove( "testProp1" );
         assertFalse( m_props.containsKey( "testProp1" ) );
-        assertEquals( propsLen - 65, m_props.toString().length() );
+        assertEquals( propsLen - 63, m_props.toString().length() );
 
-        // Remove prop 2; length of stored string should be 55 (20+19+16) bytes
+        // Remove prop 2; length of stored string should be 53 (20+17+16) bytes
         // less
         m_props.remove( "testProp2" );
         assertFalse( m_props.containsKey( "testProp2" ) );
-        assertEquals( propsLen - 65 - 55, m_props.toString().length() );
+        assertEquals( propsLen - 63 - 53, m_props.toString().length() );
 
-        // Remove prop 3; length of stored string should be 48 (35+13) bytes
+        // Remove prop 3; length of stored string should be 46 (33+13) bytes
         // less
         m_props.remove( "testProp3" );
         assertFalse( m_props.containsKey( "testProp3" ) );
-        assertEquals( propsLen - 65 - 55 - 48, m_props.toString().length() );
+        assertEquals( propsLen - 63 - 53 - 46, m_props.toString().length() );
 
-        // Remove prop 4; length of stored string should be 44 (23+21) bytes
+        // Remove prop 4; length of stored string should be 44 (21+21) bytes
         // less
         m_props.remove( "testProp4" );
         assertFalse( m_props.containsKey( "testProp4" ) );
-        assertEquals( propsLen - 65 - 55 - 48 - 44, m_props.toString().length() );
+        assertEquals( propsLen - 63 - 53 - 46 - 42, m_props.toString().length() );
 
-        // Remove prop 5; length of stored string should be 21 bytes less
+        // Remove prop 5; length of stored string should be 19 bytes less
         m_props.remove( "testProp5" );
         assertFalse( m_props.containsKey( "testProp5" ) );
-        assertEquals( propsLen - 65 - 55 - 48 - 44 - 21, m_props.toString().length() );
+        assertEquals( propsLen - 63 - 53 - 46 - 42 - 19, m_props.toString().length() );
     }
 
     public void testStore() throws Exception



Mime
View raw message