james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew C. Oliver" <a...@superlinksoftware.com>
Subject [PATCH] add unordered blocks to IMAP testcases
Date Fri, 23 Aug 2002 16:01:23 GMT
* made "MimeMessageFileSource.java" implement the current signature of Source
   (added getSourceId())
* Changed IMAPTest.java from address to be sender@localhost
* set "mail.debug" property by default (compile time) in the  InitialMail.java test (oaj.imapserver.InitialMai)
* Added Block of unordered items markers to List1.test for all folder listings (because the
order is not guaranteed and should not
 break the test)
* Did the same for Subscribe.test
* Changed daz2000 to localhost.localdomain in Welcome.test (you'll proably have to change
it to your hostname but this will work for 
     more people than daz2000)
stubbed out the beginnings of an Alertnative test case in UserManagmenetTest (for a response
if the user already exists)
* Added new functionality to AbstractProtocolTest which adds the functionality to allow one
to put an unordered block in a testcase.
to do this put SUB: x (where x = a block number, presently ingored but do it anyhow) around
the block, for
example:

CL: bla bla
SUB: 1 
SL: byte me
SL: I don't feel like it
SL: the order of these lines is unimportant
SUB: 1
SL: Completed OK

This now allows List1.test and friends to work on my machine regardless of the fact they are
returned in the opposite
order.  (Which is what the rfc implies)

Commented things I learned in the process.  (Still needs more, will do so
as I understand it)


PATCH---->>>>>
Index: proposals/imap/build-imap.xml
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/build-imap.xml,v
retrieving revision 1.3
diff -r1.3 build-imap.xml
32c32
<   <property name="version" value="2.0a2"/>
---
>   <property name="version" value="2.0a3"/>
Index: proposals/imap/java/org/apache/james/imapserver/MimeMessageFileSource.java
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/java/org/apache/james/imapserver/MimeMessageFileSource.java,v
retrieving revision 1.2
diff -r1.2 MimeMessageFileSource.java
28a29,32
>     public String getSourceId() {
>       return filename;
>     }
> 
Index: proposals/imap/test/org/apache/james/imapserver/IMAPTest.java
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/imapserver/IMAPTest.java,v
retrieving revision 1.2
diff -r1.2 IMAPTest.java
19c19
<     public String FROM_ADDRESS = "sender@somewhere";
---
>     public String FROM_ADDRESS = "sender@localhost";
Index: proposals/imap/test/org/apache/james/imapserver/InitialMail.java
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/imapserver/InitialMail.java,v
retrieving revision 1.2
diff -r1.2 InitialMail.java
34a35
>         props.setProperty("mail.debug","true");
Index: proposals/imap/test/org/apache/james/imapserver/List1.test
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/imapserver/List1.test,v
retrieving revision 1.1
diff -r1.1 List1.test
25a26
> SUB: 1
31a33
> SUB: 1
38a41
> SUB: 2
43c46,47
< S: b4 OK LIST completed
\ No newline at end of file
---
> S: b4 OK LIST completed
> SUB: 2
Index: proposals/imap/test/org/apache/james/imapserver/Subscribe.test
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/imapserver/Subscribe.test,v
retrieving revision 1.1
diff -r1.1 Subscribe.test
17a18
> SUB: 1
20a22
> SUB: 1
24a27
> SUB: 1
27a31
> SUB: 1
Index: proposals/imap/test/org/apache/james/imapserver/Welcome.test
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/imapserver/Welcome.test,v
retrieving revision 1.1
diff -r1.1 Welcome.test
1c1
< S: * OK IMAP4rev1 Server daz2000 ready
\ No newline at end of file
---
> S: * OK IMAP4rev1 Server localhost.localdomain ready
Index: proposals/imap/test/org/apache/james/remotemanager/RemoteManagerLogin.test
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/remotemanager/RemoteManagerLogin.test,v
retrieving revision 1.1
diff -r1.1 RemoteManagerLogin.test
7c7
< S: Welcome root. HELP for a list of commands
\ No newline at end of file
---
> S: Welcome root. HELP for a list of commands
Index: proposals/imap/test/org/apache/james/remotemanager/UserManagementTest.java
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/remotemanager/UserManagementTest.java,v
retrieving revision 1.1
diff -r1.1 UserManagementTest.java
33c33
<         addUser( _userName, _password );
---
>           addUser( _userName, _password );
42a43,49
> 
>     /*protected void addExistingUser( String userName, String password )  
>         throws Exception{
>         CL( "adduser " + userName + " " + password );
>         SL( "user " + userName + " already exist" );
>         executeTests();
>     }*/
Index: proposals/imap/test/org/apache/james/smtpserver/Send.test
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/smtpserver/Send.test,v
retrieving revision 1.1
diff -r1.1 Send.test
5c5
< S: 220 ${ignore} SMTP Server (JAMES SMTP Server 2.0a2) ready ${rfcDate}
---
> S: 220 ${ignore} SMTP Server (JAMES SMTP Server 2.0a3-cvs) ready ${rfcDate}
Index: proposals/imap/test/org/apache/james/test/AbstractProtocolTest.java
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap/test/org/apache/james/test/AbstractProtocolTest.java,v
retrieving revision 1.1
diff -r1.1 AbstractProtocolTest.java
8a9,19
> /**
>  * Abstract Protocol Test is the root of all of the James Imap Server test
>  * cases.  It provides functionality to create text files for matching 
>  * client requests and server responses.  In order to use it however you
>  * must create a sub class and set all the file names, etc up yourself.
>  * All Comments are written by Andy Oliver who is still trying to figure out
>  * some of it himself so don't take this as gospel
>  *
>  * @author Unattributed Original Authors
>  * @author Andrew C. Oliver
>  */
27a39
>     // comment in TestCase 
38a51
>     // comment in TestCase 
46a60
>     // comment in TestCase 
53a68,74
>     /**
>      * executes the test case as specified in the file.  Commands in
>      * CL: elements are sent to the server, and the SL: lines are verified
>      * against those returning from the server.  The order is important
>      * unless in a "SUB:" block in which case the order is not important and
>      * the test will pass if any line in the SUB: block matches.
>      */
57c78,80
<             ProtocolLine test = (ProtocolLine) iter.next();
---
>             Object obj = iter.next(); 
>             if ( obj instanceof ProtocolLine ) {
>             ProtocolLine test = (ProtocolLine) obj;
58a82,89
>             } else if ( obj instanceof List ) {
>                //System.err.println("skipping over unordered block");
>                List testlist = (List) obj;
>                for (int k = 0; k < testlist.size(); k++) {
>                   ProtocolLine test = (ProtocolLine) testlist.get(k);
>                   test.testProtocolBlock( _out, _in, testlist);
>                } 
>             }
61a93,95
>     /**
>      * adds a new Client request line to the test elements
>      */
66a101,103
>     /**
>      * adds a new Server Response line to the test elements
>      */
71a109,112
>     /**
>      * This Line is sent to the server (everything after "CL: ") in expectation
>      * that the server will respond.  
>      */
80a122,124
>         /**
>          * Sends the request to the server
>          */
84a129,139
> 
>         /**
>          * This should NOT be called, CL is not blockable!  Runtime exception
>          * will be thrown.  Implemented because of "ProtocolLine"
>          */ 
>         public void testProtocolBlock( PrintWriter out, BufferedReader in, List list)
>         throws Exception {
>             //out.println( _msg ); 
>             throw new RuntimeException("Syntax error in test case, CL is not "+
>                                        "able to be used in a SUB: block");
>         }
86a142,145
>     /**
>      * This line is what is in the test case file, it is verified against hte
>      * actual line returned from the server.
>      */
93a153,159
>         /**
>          * Constructs a ServerResponse, builds the tests
>          * @param msg the server response line 
>          * @param location a string containing the location number for error 
>          *        messages to give you a clue of where in the file you where
>          * @param ignoreExtraCharacters whether to ignore EndOfLine or not
>          */
106a173,179
>         /**
>          * Cheap version of ServerResponse(String, String, boolean) this 
>          * assumes you don't want to ginore the end of line
>          * @param msg the server response line 
>          * @param location a string containing the location number for error 
>          *        messages to give you a clue of where in the file you where
>          */
112a186,191
>         /**
>          * Cheap version of ServerResponse(String, String, boolean) this 
>          * sends "null" for location
>          * @param msg the server response line 
>          * @param ignoreExtraCharacters whether to ignore EndOfLine or not
>          */
117a197,201
>         /**
>          * Cheap version of ServerResponse(String, String, boolean) this 
>          * sends "null" for location and false for ignore the EOL
>          * @param msg the server response line 
>          */
122a207,273
>         /**
>          * Special method for dealing with anything in the "SUB" block,
>          * it ignores the order of whats in the SUB block and only throws
>          * an assertion at the end if nothing matched
>          * @param out PrintWriter for talking to the server
>          * @param in BufferedReader for getting the server response
>          * @param testslist List containing the lines of the block, should
>          * contain ServerResponse objects
>          */
>         public void testProtocolBlock( PrintWriter out, BufferedReader in,
>                                       List testslist) throws Exception {
>             //System.err.println("in new TestProtocol");
>             String testLine = readLine( in );
>             if ( _ignoreExtraCharacters
>                     && ( testLine.length() > _msg.length() ) ) {
>                 testLine = testLine.substring( 0, _msg.length() );
>             }
> 
>             ListIterator testTokens = getMessageTokens( testLine ).listIterator();
>             Iterator theblock = testslist.iterator();
>             boolean assertval = false;
>             while (theblock.hasNext()) {
>               assertval = testProtocolInBlock( out, in, testTokens, testLine);
>               if (assertval = true) {
>                   break;
>               }
>             }
>             if (assertval == false)   {
>                     System.err.println("returning failure in block");
>             }
>             assertTrue("Someting in block matched (false)", assertval);
>             
>         }
>  
>         /** 
>          * Called by testProtocolBlock.  Tests one line and returns true or
>          * false.  
>          * @param out PrintWriter for talking to the server
>          * @param in BufferedReader for getting the server response
>          * @param testTokens ListIterator containing a list of the tokens in 
>          *        the testLine
>          * @param testLine is the response from the server
>          */
>         public boolean testProtocolInBlock( PrintWriter out, BufferedReader in, ListIterator
testTokens, String testLine) throws Exception
>         {
>             boolean retval = false;
>             Iterator tests = _elementTests.iterator();
>             while ( tests.hasNext() ) {
>                 ElementTest test = (ElementTest)tests.next();
>                 if ( _location != null ) {
>                     test.setLocation( _location );
>                 }
>                 //System.err.println("testLine="+testLine);
>                 retval = test.softTest( testTokens, testLine );
>                 if (retval == false) {
>                    break;
>                 }
>             }
>             return retval;
>         }
> 
>         /**
>          * Default version of testing.  Tests the response from the server and
>          * assumes that every SL line between CL lines is in the same order.
>          * @param out PrintWriter for talking to the server
>          * @param in BufferedReader for getting the server response
>          */
141a293,298
>         /**
>          * Grabs a line from the server and throws an error message if it  
>          * doesn't work out
>          * @param in BufferedReader for getting the server response
>          * @return String of the line from the server
>          */
209a367,370
>   
>             boolean softTest( ListIterator testElements, String line) throws Exception
{
>                 return doNonAssertingTest(testElements);
>             }
211a373,381
> 
>             /**
>              * non Asserting version of doTest that instead of throwing an
>              * assert, just gently retunrs a boolean 
>              * @param testElements the elements to test with
>              * @return boolean true if success false if failed
>              */    
>             abstract boolean doNonAssertingTest( ListIterator testElements)
>               throws Exception;
228a399,420
>         
>             //comment in ElementTest 
>             public boolean doNonAssertingTest( ListIterator testElements ) 
>             throws Exception {
>                 String next;
>                 if ( testElements.hasNext() ) {
>                     next = (String) testElements.next();
>                 }
>                 else {
>                     next = "No more elements";
>                 }
>                 if ( !_elementValue.equals(next) ) { 
>                   //System.err.println("emement value="+_elementValue+
>                   //" did not =next+"+
>                   //next);
>                   return false;
>                 }
>                   //System.err.println("emement value="+_elementValue+
>                   //" did =next+"+
>                   //next);
>                 return true;
>             }
291a484,494
>             public boolean doNonAssertingTest( ListIterator testElements ) throws Exception
>             {
>                 for ( int i = 0; i < _elementsToConsume; i++ )
>                 {
>                     if ( ! testElements.hasNext() ) {
>                         return false;
>                     }
>                     String ignored = (String)testElements.next();
>                 }
>                 return true;
>             }
316a520,529
>         
>             public boolean doNonAssertingTest( ListIterator testElements ) 
>             throws Exception
>             {
>                 if ( testElements.hasNext() ) {
>                     String nextElement = (String)testElements.next();
>                     return false;
>                 }
>                 return true;
>             }
322a536,537
>         void testProtocolBlock(PrintWriter out, BufferedReader in, List list)
>         throws Exception;
362,363c577,593
<             }
<             else if ( next.startsWith( "//" )
---
>             } else if ( next.startsWith("SUB: ") ) {
>               //System.err.println("Hit SUB ");
>               List unorderedBlock = new ArrayList(5);
>               next = reader.readLine();
>               //System.err.println("next = " + next);
>               String serverMsg = next.substring( 3 );
>               while ( !next.startsWith("SUB:") ) {
>                    unorderedBlock.add(
>                                new ServerResponse( serverMsg, location, false )
>                                      );
>                    next = reader.readLine();
>                    serverMsg = next.substring( 3 );
>                    lineNumber++;
>                    //System.err.println("next = " + next);
>               }
>               protocolLines.add(unorderedBlock);  
>             } else if ( next.startsWith( "//" )
Index: proposals/rmi-remotemanager/build.xml
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/rmi-remotemanager/build.xml,v
retrieving revision 1.2
diff -r1.2 build.xml
34c34
<   <property name="version" value="2.0a2"/>
---
>   <property name="version" value="2.0a3-cvs"/>



--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message