User: ko5tik Date: 02/04/19 10:15:04 Modified: src/xjavadoc AbstractProgramElement.java XDoc.java XDocTest.java Log: all junit tests are green now. Implemented some CRUD tests for XDoc Revision Changes Path 1.13 +1 -0 xjavadoc/src/xjavadoc/AbstractProgramElement.java Index: AbstractProgramElement.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/AbstractProgramElement.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -r1.12 -r1.13 --- AbstractProgramElement.java 17 Apr 2002 07:32:41 -0000 1.12 +++ AbstractProgramElement.java 19 Apr 2002 17:15:04 -0000 1.13 @@ -164,6 +164,7 @@ * Sets the Name attribute of the SourceExecutableMember object * * @param name The new Name value + * @blurge foo */ public void setName( String name ) { 1.38 +24 -10 xjavadoc/src/xjavadoc/XDoc.java Index: XDoc.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/XDoc.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -w -r1.37 -r1.38 --- XDoc.java 17 Apr 2002 13:40:28 -0000 1.37 +++ XDoc.java 19 Apr 2002 17:15:04 -0000 1.38 @@ -137,6 +137,21 @@ _javadocToken.image = EMPTY_COMMENT; } } +// private final static boolean isTabOrSpace(String s) { +// return (s.charAt(0) == ' ') || (s.charAt(0) == '\t'); +// } + + private final static String tokenizeAndTrim( final String s ) + { + StringBuffer sb = new StringBuffer(); + StringTokenizer st = new StringTokenizer( s ); + + while( st.hasMoreTokens() ) + { + sb.append( st.nextToken() ).append( " " ); + } + return sb.toString().trim(); + } /** * Describe what the method does @@ -179,6 +194,10 @@ */ public void setCommentText( String commentText ) { + if( _dirty ) + { + parse(); + } _commentText = commentText; firstSentence = null; fireDocChanged(); @@ -896,10 +915,8 @@ } /** - * Describe what the method does - * - * @todo-javadoc Write javadocs for method - * @todo-javadoc Write javadocs for method parameter + * parse token into tags and everything here we remove excess spaces, since + * junit tests like this. not sure whether it has to be done */ private void parse() { @@ -922,12 +939,12 @@ if( tagName == null ) { // what we've been reading so far has been a general comment. - _commentText = docElement.toString().trim(); + _commentText = tokenizeAndTrim( docElement.toString() ); } else { // Add the previous tag - addTag_Impl( tagName, docElement.toString().trim() ); + addTag_Impl( tagName, tokenizeAndTrim( docElement.toString() ) ); } docElement = new StringBuffer(); @@ -955,7 +972,7 @@ else { // Add the previous tag - addTag_Impl( tagName, docElement.toString().trim() ); + addTag_Impl( tagName, tokenizeAndTrim( docElement.toString() ) ); } } catch( IOException e ) @@ -969,7 +986,4 @@ _dirty = false; } } -// private final static boolean isTabOrSpace(String s) { -// return (s.charAt(0) == ' ') || (s.charAt(0) == '\t'); -// } } 1.6 +69 -63 xjavadoc/src/xjavadoc/XDocTest.java Index: XDocTest.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/XDocTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- XDocTest.java 4 Apr 2002 22:36:33 -0000 1.5 +++ XDocTest.java 19 Apr 2002 17:15:04 -0000 1.6 @@ -1,37 +1,6 @@ /* - * Copyright (c) 2001, Aslak Hellesøy, BEKK Consulting + * Copyright (c) 2001,2002 The XDoclet team * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of BEKK Consulting nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ - -/* - * Change log - * */ package xjavadoc; @@ -48,23 +17,26 @@ * @param what about this one? Or this one? * @oh dear="we" should="go to bed" */ -public class XDocTest extends TestCase { +public class XDocTest extends TestCase +{ + + private XDoc doc; /** - * @param name Describe what the parameter does + * @param name name of the test * @todo-javadoc Write javadocs for method parameter */ - public XDocTest(String name) { + public XDocTest( String name ) + { super(name); } - /** - * A unit test for JUnit + * setup doc for testing * - * @exception IOException Describe the exception - * @todo-javadoc Write javadocs for exception + * @exception IOException */ - public void testIt() throws IOException { + public void setUp() throws IOException + { String javadoc = "/********************** This is in the doc too \n" + " * JUnit test for\n" + @@ -79,11 +51,45 @@ " */"; Token token = Token.newToken(0); + token.image = javadoc; -// XDoc doc = new XDoc(token, token); - XDoc doc = new XDoc(token, null); + doc = new XDoc( token, null ); + + } + + /** + * test comment text and first sentence + * + * @exception IOException Describe the exception + */ + public void testFirstSentence() throws IOException + { assertEquals("This is in the doc too JUnit test for JavaDocReader.", doc.firstSentence()); assertEquals("This is in the doc too JUnit test for JavaDocReader. This is sentence number two.", doc.commentText()); + + } + + public void testCommentChange() throws IOException + { + doc.setCommentText( "foo bar baz blurge. And this is second sentence" ); + + assertEquals( "foo bar baz blurge.", doc.firstSentence() ); + assertEquals( "foo bar baz blurge. And this is second sentence", doc.commentText() ); + + } + + public void testTagCreationAndRemoval() throws IOException + { + //check tag creation + doc.addTag( "foo:bar", "blurge=\"bang\" baz=\"blabla\" what's up?" ); + + assertTrue( doc.hasTag( "foo:bar" ) ); + + // and removal + doc.removeTag( doc.tag( "foo:bar" ) ); + + assertTrue( !doc.hasTag( "foo:bar" ) ); + } }
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel