You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2008/09/18 23:45:03 UTC
svn commit: r696828 [19/32] - in /james/protocols/imap/trunk:
api/src/main/java/org/apache/james/api/imap/
api/src/main/java/org/apache/james/api/imap/display/
api/src/main/java/org/apache/james/api/imap/imap4rev1/
api/src/main/java/org/apache/james/ap...
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForAuthenticatedState.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForAuthenticatedState.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForAuthenticatedState.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForAuthenticatedState.java Thu Sep 18 14:44:56 2008
@@ -17,16 +17,17 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
-
/**
- * <p>Runs tests for commands valid in the AUTHENTICATED state. A login session precedes
- * the execution of the test elements.
- * </p><p>
+ * <p>
+ * Runs tests for commands valid in the AUTHENTICATED state. A login session
+ * precedes the execution of the test elements.
+ * </p>
+ * <p>
* Suggested tests:
- * </p><ul>
+ * </p>
+ * <ul>
* <li>ValidSelected</li>
* <li>ValidNonAuthenticated</li>
* <li>Capability</li>
@@ -43,36 +44,37 @@
* <li>Subscribe</li>
* <li>Delete</li>
* <li>Append</li>
- * <li>Compound:<ul>
+ * <li>Compound:
+ * <ul>
* <li>AppendExpunge</li>
* <li>SelectAppend</li>
* <li>StringArgs</li>
- * </ul></li>
+ * </ul>
+ * </li>
* </ul>
* </p>
*/
-public abstract class AbstractTestForAuthenticatedState
- extends AbstractSimpleScriptedTestProtocol implements ImapTestConstants
-{
- public AbstractTestForAuthenticatedState( HostSystem hostSystem)
- {
- super( hostSystem );
+public abstract class AbstractTestForAuthenticatedState extends
+ AbstractSimpleScriptedTestProtocol implements ImapTestConstants {
+ public AbstractTestForAuthenticatedState(HostSystem hostSystem) {
+ super(hostSystem);
}
/**
- * Sets up {@link #preElements} with a welcome message and login request/response.
+ * Sets up {@link #preElements} with a welcome message and login
+ * request/response.
+ *
* @throws Exception
*/
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- addTestFile( "Welcome.test", preElements );
- addLogin( USER, PASSWORD );
+ addTestFile("Welcome.test", preElements);
+ addLogin(USER, PASSWORD);
}
- protected void addLogin( String username, String password )
- {
- preElements.CL( "a001 LOGIN " + username + " " + password );
- preElements.SL( "a001 OK LOGIN completed.", "AbstractTestForAuthenticatedState.java:53" );
+ protected void addLogin(String username, String password) {
+ preElements.CL("a001 LOGIN " + username + " " + password);
+ preElements.SL("a001 OK LOGIN completed.",
+ "AbstractTestForAuthenticatedState.java:53");
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java Thu Sep 18 14:44:56 2008
@@ -31,84 +31,83 @@
public void testNoopUS() throws Exception {
scriptTest("Noop", Locale.US);
}
-
+
public void testLogoutUS() throws Exception {
scriptTest("Logout", Locale.US);
}
-
+
public void testCapabilityUS() throws Exception {
scriptTest("Capability", Locale.US);
}
-
+
public void testLoginUS() throws Exception {
scriptTest("Login", Locale.US);
}
-
+
public void testValidAuthenticatedUS() throws Exception {
scriptTest("ValidAuthenticated", Locale.US);
}
-
+
public void testValidSelectedUS() throws Exception {
scriptTest("ValidSelected", Locale.US);
}
-
+
public void testAuthenticateUS() throws Exception {
scriptTest("Authenticate", Locale.US);
}
-
public void testNoopITALY() throws Exception {
scriptTest("Noop", Locale.ITALY);
}
-
+
public void testLogoutITALY() throws Exception {
scriptTest("Logout", Locale.ITALY);
}
-
+
public void testCapabilityITALY() throws Exception {
scriptTest("Capability", Locale.ITALY);
}
-
+
public void testLoginITALY() throws Exception {
scriptTest("Login", Locale.ITALY);
}
-
+
public void testValidAuthenticatedITALY() throws Exception {
scriptTest("ValidAuthenticated", Locale.ITALY);
}
-
+
public void testValidSelectedITALY() throws Exception {
scriptTest("ValidSelected", Locale.ITALY);
}
-
+
public void testAuthenticateITALY() throws Exception {
scriptTest("Authenticate", Locale.ITALY);
}
-
+
public void testNoopKOREA() throws Exception {
scriptTest("Noop", Locale.KOREA);
}
-
+
public void testLogoutKOREA() throws Exception {
scriptTest("Logout", Locale.KOREA);
}
-
+
public void testCapabilityKOREA() throws Exception {
scriptTest("Capability", Locale.KOREA);
}
-
+
public void testLoginKOREA() throws Exception {
scriptTest("Login", Locale.KOREA);
}
-
+
public void testValidAuthenticatedKOREA() throws Exception {
scriptTest("ValidAuthenticated", Locale.KOREA);
}
-
+
public void testValidSelectedKOREA() throws Exception {
scriptTest("ValidSelected", Locale.KOREA);
}
-
+
public void testAuthenticateKOREA() throws Exception {
scriptTest("Authenticate", Locale.KOREA);
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestListing.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestListing.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestListing.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestListing.java Thu Sep 18 14:44:56 2008
@@ -21,16 +21,15 @@
import java.util.Locale;
+abstract public class AbstractTestListing extends
+ AbstractTestForAuthenticatedState {
-abstract public class AbstractTestListing extends AbstractTestForAuthenticatedState {
-
- public AbstractTestListing(HostSystem system) throws Exception
- {
+ public AbstractTestListing(HostSystem system) throws Exception {
super(system);
}
public void testListPlusUS() throws Exception {
- scriptTest("ListPlus", Locale.US);
+ scriptTest("ListPlus", Locale.US);
}
-
+
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestNonAuthenticatedState.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestNonAuthenticatedState.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestNonAuthenticatedState.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestNonAuthenticatedState.java Thu Sep 18 14:44:56 2008
@@ -19,14 +19,15 @@
package org.apache.james.test.functional.imap;
-
-
/**
- * <p>Runs tests for commands valid in the NON_AUTHENTICATED state.
- * A welcome message precedes the execution of the test elements.
- * </p><p>
+ * <p>
+ * Runs tests for commands valid in the NON_AUTHENTICATED state. A welcome
+ * message precedes the execution of the test elements.
+ * </p>
+ * <p>
* Recommended test scripts:
- * </p><ul>
+ * </p>
+ * <ul>
* <li>ValidAuthenticated</li>
* <li>ValidSelected</li>
* <li>Capability</li>
@@ -36,21 +37,19 @@
* <li>Login</li>
* </ul>
*/
-public abstract class AbstractTestNonAuthenticatedState
- extends AbstractSimpleScriptedTestProtocol
-{
- public AbstractTestNonAuthenticatedState( HostSystem system )
- {
- super( system );
+public abstract class AbstractTestNonAuthenticatedState extends
+ AbstractSimpleScriptedTestProtocol {
+ public AbstractTestNonAuthenticatedState(HostSystem system) {
+ super(system);
}
/**
* Adds a welcome message to the {@link #preElements}.
+ *
* @throws Exception
*/
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- addTestFile( "Welcome.test", preElements );
+ addTestFile("Welcome.test", preElements);
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestPartialFetch.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestPartialFetch.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestPartialFetch.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestPartialFetch.java Thu Sep 18 14:44:56 2008
@@ -21,48 +21,49 @@
import java.util.Locale;
-public abstract class AbstractTestPartialFetch extends AbstractTestSelectedStateBase {
+public abstract class AbstractTestPartialFetch extends
+ AbstractTestSelectedStateBase {
public AbstractTestPartialFetch(HostSystem system) {
super(system);
}
-
+
public void testBodyPartialFetchUS() throws Exception {
scriptTest("BodyPartialFetch", Locale.US);
}
-
+
public void testBodyPartialFetchIT() throws Exception {
scriptTest("BodyPartialFetch", Locale.ITALY);
}
-
+
public void testBodyPartialFetchKO() throws Exception {
scriptTest("BodyPartialFetch", Locale.KOREA);
}
-
+
public void testTextPartialFetchUS() throws Exception {
scriptTest("TextPartialFetch", Locale.US);
}
-
+
public void testTextPartialFetchKO() throws Exception {
scriptTest("TextPartialFetch", Locale.US);
}
-
+
public void testTextPartialFetchIT() throws Exception {
scriptTest("TextPartialFetch", Locale.US);
}
-
+
public void testMimePartialFetchUS() throws Exception {
scriptTest("MimePartialFetch", Locale.US);
}
-
+
public void testMimePartialFetchIT() throws Exception {
scriptTest("MimePartialFetch", Locale.ITALY);
}
-
+
public void testMimePartialFetchKO() throws Exception {
scriptTest("MimePartialFetch", Locale.KOREA);
}
-
+
public void testHeaderPartialFetchUS() throws Exception {
scriptTest("HeaderPartialFetch", Locale.US);
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java Thu Sep 18 14:44:56 2008
@@ -30,35 +30,35 @@
public void testRenameUS() throws Exception {
scriptTest("Rename", Locale.US);
}
-
+
public void testRenameKOREA() throws Exception {
scriptTest("Rename", Locale.KOREA);
}
-
+
public void testRenameITALY() throws Exception {
scriptTest("Rename", Locale.ITALY);
}
-
+
public void testRenameHierarchyUS() throws Exception {
scriptTest("RenameHierarchy", Locale.US);
}
-
+
public void testRenameHierarchyKO() throws Exception {
scriptTest("RenameHierarchy", Locale.KOREA);
}
-
+
public void testRenameHierarchyIT() throws Exception {
scriptTest("RenameHierarchy", Locale.ITALY);
}
-
+
public void testRenameSelectedUS() throws Exception {
scriptTest("RenameSelected", Locale.US);
}
-
+
public void testRenameSelectedIT() throws Exception {
scriptTest("RenameSelected", Locale.ITALY);
}
-
+
public void testRenameSelectedKO() throws Exception {
scriptTest("RenameSelected", Locale.KOREA);
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSearch.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSearch.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSearch.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSearch.java Thu Sep 18 14:44:56 2008
@@ -21,35 +21,34 @@
import java.util.Locale;
+abstract public class AbstractTestSearch extends
+ AbstractTestForAuthenticatedState {
-abstract public class AbstractTestSearch extends AbstractTestForAuthenticatedState {
-
- public AbstractTestSearch(HostSystem system) throws Exception
- {
+ public AbstractTestSearch(HostSystem system) throws Exception {
super(system);
}
-
+
public void testSearchAtomsUS() throws Exception {
- scriptTest("SearchAtoms", Locale.US);
+ scriptTest("SearchAtoms", Locale.US);
}
-
+
public void testSearchAtomsITALY() throws Exception {
- scriptTest("SearchAtoms", Locale.ITALY);
+ scriptTest("SearchAtoms", Locale.ITALY);
}
-
+
public void testSearchAtomsKOREA() throws Exception {
- scriptTest("SearchAtoms", Locale.KOREA);
+ scriptTest("SearchAtoms", Locale.KOREA);
}
-
+
public void testSearchCombinationsUS() throws Exception {
- scriptTest("SearchCombinations", Locale.US);
+ scriptTest("SearchCombinations", Locale.US);
}
-
+
public void testSearchCombinationsITALY() throws Exception {
- scriptTest("SearchCombinations", Locale.ITALY);
+ scriptTest("SearchCombinations", Locale.ITALY);
}
-
+
public void testSearchCombinationsKOREA() throws Exception {
- scriptTest("SearchCombinations", Locale.KOREA);
+ scriptTest("SearchCombinations", Locale.KOREA);
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java Thu Sep 18 14:44:56 2008
@@ -21,7 +21,8 @@
import java.util.Locale;
-public abstract class AbstractTestSecurity extends AbstractSimpleScriptedTestProtocol {
+public abstract class AbstractTestSecurity extends
+ AbstractSimpleScriptedTestProtocol {
public AbstractTestSecurity(HostSystem system) {
super(system);
@@ -30,83 +31,83 @@
public void testLoginThreeStrikesUS() throws Exception {
scriptTest("LoginThreeStrikes", Locale.US);
}
-
+
public void testLoginThreeStrikesKOREA() throws Exception {
scriptTest("LoginThreeStrikes", Locale.KOREA);
}
-
+
public void testLoginThreeStrikesITALY() throws Exception {
scriptTest("LoginThreeStrikes", Locale.ITALY);
}
-
+
public void testBadTagUS() throws Exception {
scriptTest("BadTag", Locale.US);
}
-
+
public void testBadTagKOREA() throws Exception {
scriptTest("BadTag", Locale.KOREA);
}
-
+
public void testBadTagITALY() throws Exception {
scriptTest("BadTag", Locale.ITALY);
}
-
+
public void testNoTagUS() throws Exception {
scriptTest("NoTag", Locale.US);
}
-
+
public void testNoTagKOREA() throws Exception {
scriptTest("NoTag", Locale.KOREA);
}
-
+
public void testNoTagITALY() throws Exception {
scriptTest("NoTag", Locale.ITALY);
}
-
+
public void testIllegalTagUS() throws Exception {
scriptTest("IllegalTag", Locale.US);
}
-
+
public void testIllegalTagKOREA() throws Exception {
scriptTest("IllegalTag", Locale.KOREA);
}
-
+
public void testIllegalTagITALY() throws Exception {
scriptTest("IllegalTag", Locale.ITALY);
}
-
+
public void testJustTagUS() throws Exception {
scriptTest("JustTag", Locale.US);
}
-
+
public void testJustTagKOREA() throws Exception {
scriptTest("JustTag", Locale.KOREA);
}
-
+
public void testJustTagITALY() throws Exception {
scriptTest("JustTag", Locale.ITALY);
}
-
+
public void testNoCommandUS() throws Exception {
scriptTest("NoCommand", Locale.US);
}
-
+
public void testNoCommandKOREA() throws Exception {
scriptTest("NoCommand", Locale.KOREA);
}
-
+
public void testNoCommandITALY() throws Exception {
scriptTest("NoCommand", Locale.ITALY);
}
-
+
public void testBogusCommandUS() throws Exception {
scriptTest("BogusCommand", Locale.US);
}
-
+
public void testBogusCommandKOREA() throws Exception {
scriptTest("BogusCommand", Locale.KOREA);
}
-
+
public void testNoBogusITALY() throws Exception {
scriptTest("BogusCommand", Locale.ITALY);
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelect.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelect.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelect.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelect.java Thu Sep 18 14:44:56 2008
@@ -21,23 +21,22 @@
import java.util.Locale;
+abstract public class AbstractTestSelect extends
+ AbstractTestForAuthenticatedState {
-abstract public class AbstractTestSelect extends AbstractTestForAuthenticatedState {
-
- public AbstractTestSelect(HostSystem system) throws Exception
- {
+ public AbstractTestSelect(HostSystem system) throws Exception {
super(system);
}
public void testSelectUnseenUS() throws Exception {
- scriptTest("SelectUnseen", Locale.US);
+ scriptTest("SelectUnseen", Locale.US);
}
-
+
public void testSelectUnseenKOREA() throws Exception {
- scriptTest("SelectUnseen", Locale.KOREA );
+ scriptTest("SelectUnseen", Locale.KOREA);
}
-
+
public void testSelectUnseenITALY() throws Exception {
- scriptTest("SelectUnseen", Locale.ITALY);
+ scriptTest("SelectUnseen", Locale.ITALY);
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java Thu Sep 18 14:44:56 2008
@@ -21,7 +21,8 @@
import java.util.Locale;
-public abstract class AbstractTestSelectedInbox extends AbstractBaseTestSelectedInbox {
+public abstract class AbstractTestSelectedInbox extends
+ AbstractBaseTestSelectedInbox {
public AbstractTestSelectedInbox(HostSystem system) {
super(system);
@@ -30,171 +31,169 @@
public void testValidNonAuthenticatedUS() throws Exception {
scriptTest("ValidNonAuthenticated", Locale.US);
}
-
+
public void testCapabilityUS() throws Exception {
scriptTest("Capability", Locale.US);
}
-
+
public void testNoopUS() throws Exception {
scriptTest("Noop", Locale.US);
}
-
+
public void testLogoutUS() throws Exception {
scriptTest("Logout", Locale.US);
}
-
+
public void testCreateUS() throws Exception {
scriptTest("Create", Locale.US);
}
-
+
public void testExamineEmptyUS() throws Exception {
scriptTest("ExamineEmpty", Locale.US);
}
-
+
public void testSelectEmptyUS() throws Exception {
scriptTest("SelectEmpty", Locale.US);
}
-
+
public void testListNamespaceUS() throws Exception {
scriptTest("ListNamespace", Locale.US);
}
-
+
public void testListMailboxesUS() throws Exception {
scriptTest("ListMailboxes", Locale.US);
}
-
+
public void testStatusUS() throws Exception {
scriptTest("Status", Locale.US);
}
-
+
public void testStringArgsUS() throws Exception {
scriptTest("StringArgs", Locale.US);
}
-
+
public void testSubscribeUS() throws Exception {
scriptTest("Subscribe", Locale.US);
}
-
+
public void testAppendUS() throws Exception {
scriptTest("Append", Locale.US);
}
-
+
public void testDeleteUS() throws Exception {
scriptTest("Delete", Locale.US);
}
-
public void testValidNonAuthenticatedITALY() throws Exception {
scriptTest("ValidNonAuthenticated", Locale.ITALY);
}
-
+
public void testCapabilityITALY() throws Exception {
scriptTest("Capability", Locale.ITALY);
}
-
+
public void testNoopITALY() throws Exception {
scriptTest("Noop", Locale.ITALY);
}
-
+
public void testLogoutITALY() throws Exception {
scriptTest("Logout", Locale.ITALY);
}
-
+
public void testCreateITALY() throws Exception {
scriptTest("Create", Locale.ITALY);
}
-
+
public void testExamineEmptyITALY() throws Exception {
scriptTest("ExamineEmpty", Locale.ITALY);
}
-
+
public void testSelectEmptyITALY() throws Exception {
scriptTest("SelectEmpty", Locale.ITALY);
}
-
+
public void testListNamespaceITALY() throws Exception {
scriptTest("ListNamespace", Locale.ITALY);
}
-
+
public void testListMailboxesITALY() throws Exception {
scriptTest("ListMailboxes", Locale.ITALY);
}
-
+
public void testStatusITALY() throws Exception {
scriptTest("Status", Locale.ITALY);
}
-
+
public void testStringArgsITALY() throws Exception {
scriptTest("StringArgs", Locale.ITALY);
}
-
+
public void testSubscribeITALY() throws Exception {
scriptTest("Subscribe", Locale.ITALY);
}
-
+
public void testAppendITALY() throws Exception {
scriptTest("Append", Locale.ITALY);
}
-
+
public void testDeleteITALY() throws Exception {
scriptTest("Delete", Locale.ITALY);
}
-
public void testValidNonAuthenticatedKOREA() throws Exception {
scriptTest("ValidNonAuthenticated", Locale.KOREA);
}
-
+
public void testCapabilityKOREA() throws Exception {
scriptTest("Capability", Locale.KOREA);
}
-
+
public void testNoopKOREA() throws Exception {
scriptTest("Noop", Locale.KOREA);
}
-
+
public void testLogoutKOREA() throws Exception {
scriptTest("Logout", Locale.KOREA);
}
-
+
public void testCreateKOREA() throws Exception {
scriptTest("Create", Locale.KOREA);
}
-
+
public void testExamineEmptyKOREA() throws Exception {
scriptTest("ExamineEmpty", Locale.KOREA);
}
-
+
public void testSelectEmptyKOREA() throws Exception {
scriptTest("SelectEmpty", Locale.KOREA);
}
-
+
public void testListNamespaceKOREA() throws Exception {
scriptTest("ListNamespace", Locale.KOREA);
}
-
+
public void testListMailboxesKOREA() throws Exception {
scriptTest("ListMailboxes", Locale.KOREA);
}
-
+
public void testStatusKOREA() throws Exception {
scriptTest("Status", Locale.KOREA);
}
-
+
public void testStringArgsKOREA() throws Exception {
scriptTest("StringArgs", Locale.KOREA);
}
-
+
public void testSubscribeKOREA() throws Exception {
scriptTest("Subscribe", Locale.KOREA);
}
-
+
public void testAppendKOREA() throws Exception {
scriptTest("Append", Locale.KOREA);
}
-
+
public void testDeleteKOREA() throws Exception {
scriptTest("Delete", Locale.KOREA);
}
-
+
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java Thu Sep 18 14:44:56 2008
@@ -21,7 +21,8 @@
import java.util.Locale;
-public abstract class AbstractTestSelectedState extends AbstractTestSelectedStateBase {
+public abstract class AbstractTestSelectedState extends
+ AbstractTestSelectedStateBase {
public AbstractTestSelectedState(HostSystem system) {
super(system);
@@ -30,109 +31,107 @@
public void testCheckUS() throws Exception {
scriptTest("Check", Locale.US);
}
-
+
public void testExpungeUS() throws Exception {
scriptTest("Expunge", Locale.US);
}
-
+
public void testSearchUS() throws Exception {
scriptTest("Search", Locale.US);
}
-
+
public void testFetchSingleMessageUS() throws Exception {
scriptTest("FetchSingleMessage", Locale.US);
}
-
+
public void testFetchMultipleMessagesUS() throws Exception {
scriptTest("FetchMultipleMessages", Locale.US);
}
-
+
public void testFetchPeekUS() throws Exception {
scriptTest("FetchPeek", Locale.US);
}
-
+
public void testStoreUS() throws Exception {
scriptTest("Store", Locale.US);
}
-
+
public void testCopyUS() throws Exception {
scriptTest("Copy", Locale.US);
}
-
+
public void testUidUS() throws Exception {
scriptTest("Uid", Locale.US);
}
-
public void testCheckITALY() throws Exception {
scriptTest("Check", Locale.ITALY);
}
-
+
public void testExpungeITALY() throws Exception {
scriptTest("Expunge", Locale.ITALY);
}
-
+
public void testSearchITALY() throws Exception {
scriptTest("Search", Locale.ITALY);
}
-
+
public void testFetchSingleMessageITALY() throws Exception {
scriptTest("FetchSingleMessage", Locale.ITALY);
}
-
+
public void testFetchMultipleMessagesITALY() throws Exception {
scriptTest("FetchMultipleMessages", Locale.ITALY);
}
-
+
public void testFetchPeekITALY() throws Exception {
scriptTest("FetchPeek", Locale.ITALY);
}
-
+
public void testStoreITALY() throws Exception {
scriptTest("Store", Locale.ITALY);
}
-
+
public void testCopyITALY() throws Exception {
scriptTest("Copy", Locale.ITALY);
}
-
+
public void testUidITALY() throws Exception {
scriptTest("Uid", Locale.ITALY);
}
-
public void testCheckKOREA() throws Exception {
scriptTest("Check", Locale.KOREA);
}
-
+
public void testExpungeKOREA() throws Exception {
scriptTest("Expunge", Locale.KOREA);
}
-
+
public void testSearchKOREA() throws Exception {
scriptTest("Search", Locale.KOREA);
}
-
+
public void testFetchSingleMessageKOREA() throws Exception {
scriptTest("FetchSingleMessage", Locale.KOREA);
}
-
+
public void testFetchMultipleMessagesKOREA() throws Exception {
scriptTest("FetchMultipleMessages", Locale.KOREA);
}
-
+
public void testFetchPeekKOREA() throws Exception {
scriptTest("FetchPeek", Locale.KOREA);
}
-
+
public void testStoreKOREA() throws Exception {
scriptTest("Store", Locale.KOREA);
}
-
+
public void testCopyKOREA() throws Exception {
scriptTest("Copy", Locale.KOREA);
}
-
+
public void testUidKOREA() throws Exception {
scriptTest("Uid", Locale.KOREA);
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedStateBase.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedStateBase.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedStateBase.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedStateBase.java Thu Sep 18 14:44:56 2008
@@ -17,17 +17,17 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
-
-
/**
- * <p>Runs tests for commands valid only in the SELECTED state. A login session
- * and setup of a "seleted" mailbox precedes the execution of the test elements.
- * </p><p>
+ * <p>
+ * Runs tests for commands valid only in the SELECTED state. A login session and
+ * setup of a "seleted" mailbox precedes the execution of the test elements.
+ * </p>
+ * <p>
* Recommended scripts:
- * </p><ul>
+ * </p>
+ * <ul>
* <li>Check"</li>
* <li>Expunge"</li>
* <li>Search"</li>
@@ -39,23 +39,22 @@
* <li>Uid"</li>
* </ul>
*/
-public abstract class AbstractTestSelectedStateBase
- extends AbstractTestForAuthenticatedState
-{
- public AbstractTestSelectedStateBase( HostSystem system )
- {
- super( system );
+public abstract class AbstractTestSelectedStateBase extends
+ AbstractTestForAuthenticatedState {
+ public AbstractTestSelectedStateBase(HostSystem system) {
+ super(system);
}
/**
- * Superclass sets up welcome message and login session in {@link #preElements}.
- * A "SELECT INBOX" session is then added to these elements.
+ * Superclass sets up welcome message and login session in
+ * {@link #preElements}. A "SELECT INBOX" session is then added to these
+ * elements.
+ *
* @throws Exception
*/
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- addTestFile( "SelectedStateSetup.test", preElements );
- addTestFile( "SelectedStateCleanup.test", postElements );
+ addTestFile("SelectedStateSetup.test", preElements);
+ addTestFile("SelectedStateCleanup.test", postElements);
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestUidSearch.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestUidSearch.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestUidSearch.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/AbstractTestUidSearch.java Thu Sep 18 14:44:56 2008
@@ -21,35 +21,34 @@
import java.util.Locale;
+abstract public class AbstractTestUidSearch extends
+ AbstractTestForAuthenticatedState {
-abstract public class AbstractTestUidSearch extends AbstractTestForAuthenticatedState {
-
- public AbstractTestUidSearch(HostSystem system) throws Exception
- {
+ public AbstractTestUidSearch(HostSystem system) throws Exception {
super(system);
}
-
+
public void testSearchAtomsUS() throws Exception {
- scriptTest("UidSearchAtoms", Locale.US);
+ scriptTest("UidSearchAtoms", Locale.US);
}
-
+
public void testSearchAtomsITALY() throws Exception {
- scriptTest("UidSearchAtoms", Locale.ITALY);
+ scriptTest("UidSearchAtoms", Locale.ITALY);
}
-
+
public void testSearchAtomsKOREA() throws Exception {
- scriptTest("UidSearchAtoms", Locale.KOREA);
+ scriptTest("UidSearchAtoms", Locale.KOREA);
}
-
+
public void testSearchCombinationsUS() throws Exception {
- scriptTest("UidSearchCombinations", Locale.US);
+ scriptTest("UidSearchCombinations", Locale.US);
}
-
+
public void testSearchCombinationsITALY() throws Exception {
- scriptTest("UidSearchCombinations", Locale.ITALY);
+ scriptTest("UidSearchCombinations", Locale.ITALY);
}
-
+
public void testSearchCombinationsKOREA() throws Exception {
- scriptTest("UidSearchCombinations", Locale.KOREA);
+ scriptTest("UidSearchCombinations", Locale.KOREA);
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/FileProtocolSessionBuilder.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/FileProtocolSessionBuilder.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/FileProtocolSessionBuilder.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/FileProtocolSessionBuilder.java Thu Sep 18 14:44:56 2008
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
import java.io.BufferedReader;
@@ -28,121 +27,128 @@
/**
* A builder which generates a ProtocolSession from a test file.
- *
- * @author Darrell DeBoer <da...@apache.org>
- *
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
* @version $Revision$
*/
-public class FileProtocolSessionBuilder
-{
+public class FileProtocolSessionBuilder {
private static final String SERVER_CONTINUATION_TAG = "S: \\+";
+
private static final String CLIENT_TAG = "C:";
+
private static final String SERVER_TAG = "S:";
+
private static final String OPEN_UNORDERED_BLOCK_TAG = "SUB {";
+
private static final String CLOSE_UNORDERED_BLOCK_TAG = "}";
+
private static final String COMMENT_TAG = "#";
+
private static final String SESSION_TAG = "SESSION:";
/**
- * Builds a ProtocolSession by reading lines from the test file
- * with the supplied name.
- * @param fileName The name of the protocol session file.
+ * Builds a ProtocolSession by reading lines from the test file with the
+ * supplied name.
+ *
+ * @param fileName
+ * The name of the protocol session file.
* @return The ProtocolSession
*/
- public ProtocolSession buildProtocolSession( String fileName )
- throws Exception
- {
+ public ProtocolSession buildProtocolSession(String fileName)
+ throws Exception {
ProtocolSession session = new ProtocolSession();
- addTestFile( fileName, session );
+ addTestFile(fileName, session);
return session;
}
/**
- * Adds all protocol elements from a test file to the ProtocolSession supplied.
- * @param fileName The name of the protocol session file.
- * @param session The ProtocolSession to add the elements to.
+ * Adds all protocol elements from a test file to the ProtocolSession
+ * supplied.
+ *
+ * @param fileName
+ * The name of the protocol session file.
+ * @param session
+ * The ProtocolSession to add the elements to.
*/
- public void addTestFile( String fileName, ProtocolSession session )
- throws Exception
- {
+ public void addTestFile(String fileName, ProtocolSession session)
+ throws Exception {
// Need to find local resource.
- InputStream is = this.getClass().getResourceAsStream( fileName );
- if ( is == null ) {
- throw new Exception( "Test Resource '" + fileName + "' not found." );
+ InputStream is = this.getClass().getResourceAsStream(fileName);
+ if (is == null) {
+ throw new Exception("Test Resource '" + fileName + "' not found.");
}
- addProtocolLinesFromStream( is, session, fileName );
+ addProtocolLinesFromStream(is, session, fileName);
}
/**
- * Reads ProtocolElements from the supplied InputStream and adds
- * them to the ProtocolSession.
- * @param is The input stream containing the protocol definition.
- * @param session The ProtocolSession to add elements to.
- * @param fileName The name of the source file, for error messages.
- */
- public void addProtocolLinesFromStream( InputStream is,
- ProtocolSession session,
- String fileName )
- throws Exception
- {
+ * Reads ProtocolElements from the supplied InputStream and adds them to the
+ * ProtocolSession.
+ *
+ * @param is
+ * The input stream containing the protocol definition.
+ * @param session
+ * The ProtocolSession to add elements to.
+ * @param fileName
+ * The name of the source file, for error messages.
+ */
+ public void addProtocolLinesFromStream(InputStream is,
+ ProtocolSession session, String fileName) throws Exception {
int sessionNumber = -1;
- BufferedReader reader = new BufferedReader( new InputStreamReader( is ) );
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String next;
int lineNumber = -1;
String lastClientMsg = "";
- while ( ( next = reader.readLine() ) != null ) {
+ while ((next = reader.readLine()) != null) {
String location = fileName + ":" + lineNumber;
if (SERVER_CONTINUATION_TAG.equals(next)) {
- session.CONT( sessionNumber );
- } else if ( next.startsWith( CLIENT_TAG ) ) {
+ session.CONT(sessionNumber);
+ } else if (next.startsWith(CLIENT_TAG)) {
String clientMsg = "";
- if ( next.length() > 3 ) {
- clientMsg = next.substring( 3 );
+ if (next.length() > 3) {
+ clientMsg = next.substring(3);
}
- session.CL( sessionNumber, clientMsg );
+ session.CL(sessionNumber, clientMsg);
lastClientMsg = clientMsg;
- }
- else if ( next.startsWith( SERVER_TAG ) ) {
+ } else if (next.startsWith(SERVER_TAG)) {
String serverMsg = "";
- if ( next.length() > 3 ) {
- serverMsg = next.substring( 3 );
+ if (next.length() > 3) {
+ serverMsg = next.substring(3);
}
- session.SL( sessionNumber, serverMsg, location, lastClientMsg );
- }
- else if ( next.startsWith( OPEN_UNORDERED_BLOCK_TAG ) ) {
- List unorderedLines = new ArrayList( 5 );
+ session.SL(sessionNumber, serverMsg, location, lastClientMsg);
+ } else if (next.startsWith(OPEN_UNORDERED_BLOCK_TAG)) {
+ List unorderedLines = new ArrayList(5);
next = reader.readLine();
- while ( !next.startsWith( CLOSE_UNORDERED_BLOCK_TAG ) ) {
- if (! next.startsWith( SERVER_TAG ) ) {
- throw new Exception( "Only 'S: ' lines are permitted inside a 'SUB {' block.");
+ while (!next.startsWith(CLOSE_UNORDERED_BLOCK_TAG)) {
+ if (!next.startsWith(SERVER_TAG)) {
+ throw new Exception(
+ "Only 'S: ' lines are permitted inside a 'SUB {' block.");
}
- String serverMsg = next.substring( 3 );
- unorderedLines.add( serverMsg );
+ String serverMsg = next.substring(3);
+ unorderedLines.add(serverMsg);
next = reader.readLine();
lineNumber++;
}
- session.SUB( sessionNumber, unorderedLines, location, lastClientMsg );
- }
- else if ( next.startsWith( COMMENT_TAG )
- || next.trim().length() == 0 ) {
+ session.SUB(sessionNumber, unorderedLines, location,
+ lastClientMsg);
+ } else if (next.startsWith(COMMENT_TAG)
+ || next.trim().length() == 0) {
// ignore these lines.
- }
- else if ( next.startsWith(SESSION_TAG)) {
+ } else if (next.startsWith(SESSION_TAG)) {
String number = next.substring(SESSION_TAG.length()).trim();
if (number.length() == 0) {
throw new Exception("No session number specified");
}
sessionNumber = Integer.parseInt(number);
- }
- else {
+ } else {
String prefix = next;
- if ( next.length() > 3 ) {
- prefix = next.substring( 0, 3 );
+ if (next.length() > 3) {
+ prefix = next.substring(0, 3);
}
- throw new Exception( "Invalid line prefix: " + prefix );
+ throw new Exception("Invalid line prefix: " + prefix);
}
lineNumber++;
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/HostSystem.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/HostSystem.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/HostSystem.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/HostSystem.java Thu Sep 18 14:44:56 2008
@@ -17,53 +17,60 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
/**
* Host system under test.
- *
+ *
*/
public interface HostSystem {
/**
* Resets host system to initial state.
+ *
* @throws Exception
*/
public void reset() throws Exception;
-
+
/**
* Add a user for testing.
- * @param user user name
- * @param password user password
+ *
+ * @param user
+ * user name
+ * @param password
+ * user password
* @throws Exception
*/
public boolean addUser(String user, String password) throws Exception;
-
+
/**
* Creates a new session for functional testing.
+ *
* @return <code>Session</code>, not null
* @throws Exception
*/
public Session newSession(Continuation continuation) throws Exception;
-
- public interface Session
- {
+
+ public interface Session {
public String readLine() throws Exception;
+
public void writeLine(String line) throws Exception;
+
/**
* Opens the session.
+ *
* @throws Exception
*/
public void start() throws Exception;
-
+
/**
* Closes the session.
+ *
* @throws Exception
*/
public void stop() throws Exception;
}
-
+
public interface Continuation {
public void doContinue();
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ImapTestConstants.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ImapTestConstants.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ImapTestConstants.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ImapTestConstants.java Thu Sep 18 14:44:56 2008
@@ -17,20 +17,22 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
/**
* Some constants to use when running Imap tests.
*/
-public interface ImapTestConstants
-{
+public interface ImapTestConstants {
int PORT = 143;
+
String HOST = "localhost";
String USER = "imapuser";
+
String PASSWORD = "password";
+
String FROM_ADDRESS = "sender@localhost";
+
String TO_ADDRESS = USER + "@" + HOST;
int TIMEOUT = 10000;
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ProtocolSession.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ProtocolSession.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ProtocolSession.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/ProtocolSession.java Thu Sep 18 14:44:56 2008
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.test.functional.imap;
import java.io.IOException;
@@ -30,26 +29,31 @@
/**
* A protocol session which can be run against a reader and writer, which checks
- * the server response against the expected values.
- * TODO make ProtocolSession itself be a permissible ProtocolElement,
- * so that we can nest and reuse sessions.
- * @author Darrell DeBoer <da...@apache.org>
- *
+ * the server response against the expected values. TODO make ProtocolSession
+ * itself be a permissible ProtocolElement, so that we can nest and reuse
+ * sessions.
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
* @version $Revision$
*/
-public class ProtocolSession
-{
+public class ProtocolSession {
private boolean continued = false;
+
private boolean continuationExpected = false;
+
private int maxSessionNumber;
+
protected List testElements = new ArrayList();
+
private Iterator elementsIterator;
+
private HostSystem.Session[] sessions;
+
private ProtocolElement nextTest;
+
private boolean continueAfterFailure = false;
-
-
-
+
public final boolean isContinueAfterFailure() {
return continueAfterFailure;
}
@@ -59,9 +63,9 @@
}
/**
- * Returns the number of sessions required to run this ProtocolSession.
- * If the number of readers and writers provided is less than this number,
- * an exception will occur when running the tests.
+ * Returns the number of sessions required to run this ProtocolSession. If
+ * the number of readers and writers provided is less than this number, an
+ * exception will occur when running the tests.
*/
public int getSessionCount() {
return maxSessionNumber + 1;
@@ -69,21 +73,24 @@
/**
* Executes the ProtocolSession in real time against the readers and writers
- * supplied, writing client requests and reading server responses in the order
- * that they appear in the test elements. The index of a reader/writer in the array
- * corresponds to the number of the session.
- * If an exception occurs, no more test elements are executed.
- * @param out The client requests are written to here.
- * @param in The server responses are read from here.
+ * supplied, writing client requests and reading server responses in the
+ * order that they appear in the test elements. The index of a reader/writer
+ * in the array corresponds to the number of the session. If an exception
+ * occurs, no more test elements are executed.
+ *
+ * @param out
+ * The client requests are written to here.
+ * @param in
+ * The server responses are read from here.
*/
public void runSessions(HostSystem.Session[] sessions) throws Exception {
this.sessions = sessions;
elementsIterator = testElements.iterator();
- while( elementsIterator.hasNext() ) {
+ while (elementsIterator.hasNext()) {
Object obj = elementsIterator.next();
- if ( obj instanceof ProtocolElement ) {
- ProtocolElement test = ( ProtocolElement ) obj;
- test.testProtocol( sessions, continueAfterFailure );
+ if (obj instanceof ProtocolElement) {
+ ProtocolElement test = (ProtocolElement) obj;
+ test.testProtocol(sessions, continueAfterFailure);
}
}
}
@@ -92,15 +99,15 @@
try {
if (continuationExpected) {
continued = true;
- while( elementsIterator.hasNext() ) {
+ while (elementsIterator.hasNext()) {
Object obj = elementsIterator.next();
- if ( obj instanceof ProtocolElement ) {
- nextTest = ( ProtocolElement ) obj;
-
+ if (obj instanceof ProtocolElement) {
+ nextTest = (ProtocolElement) obj;
+
if (!nextTest.isClient()) {
break;
}
- nextTest.testProtocol( sessions, continueAfterFailure );
+ nextTest.testProtocol(sessions, continueAfterFailure);
}
}
if (!elementsIterator.hasNext()) {
@@ -113,85 +120,85 @@
throw new RuntimeException(e);
}
}
-
+
/**
* adds a new Client request line to the test elements
*/
- public void CL( String clientLine )
- {
- testElements.add( new ClientRequest( clientLine ) );
+ public void CL(String clientLine) {
+ testElements.add(new ClientRequest(clientLine));
}
/**
- * adds a new Server Response line to the test elements, with the specified location.
+ * adds a new Server Response line to the test elements, with the specified
+ * location.
*/
- public void SL( String serverLine, String location )
- {
- testElements.add( new ServerResponse( serverLine, location ) );
+ public void SL(String serverLine, String location) {
+ testElements.add(new ServerResponse(serverLine, location));
}
/**
* adds a new Server Unordered Block to the test elements.
*/
- public void SUB( List serverLines, String location )
- {
- testElements.add( new ServerUnorderedBlockResponse( serverLines, location ) );
+ public void SUB(List serverLines, String location) {
+ testElements
+ .add(new ServerUnorderedBlockResponse(serverLines, location));
}
/**
* adds a new Client request line to the test elements
*/
- public void CL( int sessionNumber, String clientLine )
- {
+ public void CL(int sessionNumber, String clientLine) {
this.maxSessionNumber = Math.max(this.maxSessionNumber, sessionNumber);
- testElements.add( new ClientRequest( sessionNumber, clientLine ) );
+ testElements.add(new ClientRequest(sessionNumber, clientLine));
}
/**
- * Adds a continuation.
- * To allow one thread to be used for testing.
+ * Adds a continuation. To allow one thread to be used for testing.
*/
public void CONT(int sessionNumber) throws Exception {
this.maxSessionNumber = Math.max(this.maxSessionNumber, sessionNumber);
- testElements.add( new ContinuationElement(sessionNumber));
+ testElements.add(new ContinuationElement(sessionNumber));
}
-
+
/**
- * adds a new Server Response line to the test elements, with the specified location.
+ * adds a new Server Response line to the test elements, with the specified
+ * location.
*/
- public void SL( int sessionNumber, String serverLine, String location, String lastClientMessage )
- {
+ public void SL(int sessionNumber, String serverLine, String location,
+ String lastClientMessage) {
this.maxSessionNumber = Math.max(this.maxSessionNumber, sessionNumber);
- testElements.add( new ServerResponse( sessionNumber, serverLine, location, lastClientMessage ) );
+ testElements.add(new ServerResponse(sessionNumber, serverLine,
+ location, lastClientMessage));
}
/**
* adds a new Server Unordered Block to the test elements.
*/
- public void SUB( int sessionNumber, List serverLines, String location, String lastClientMessage )
- {
+ public void SUB(int sessionNumber, List serverLines, String location,
+ String lastClientMessage) {
this.maxSessionNumber = Math.max(this.maxSessionNumber, sessionNumber);
- testElements.add( new ServerUnorderedBlockResponse( sessionNumber, serverLines, location, lastClientMessage ) );
+ testElements.add(new ServerUnorderedBlockResponse(sessionNumber,
+ serverLines, location, lastClientMessage));
}
/**
* A client request, which write the specified message to a Writer.
*/
- private class ClientRequest implements ProtocolElement
- {
+ private class ClientRequest implements ProtocolElement {
private int sessionNumber;
+
private String message;
/**
* Initialises the ClientRequest with the supplied message.
*/
- public ClientRequest( String message )
- {
+ public ClientRequest(String message) {
this(-1, message);
}
/**
* Initialises the ClientRequest, with a message and session number.
+ *
* @param sessionNumber
* @param message
*/
@@ -201,20 +208,20 @@
}
/**
- * Writes the request message to the PrintWriters. If the sessionNumber == -1,
- * the request is written to *all* supplied writers, otherwise, only the
- * writer for this session is writted to.
- * @throws Exception
+ * Writes the request message to the PrintWriters. If the sessionNumber ==
+ * -1, the request is written to *all* supplied writers, otherwise, only
+ * the writer for this session is writted to.
+ *
+ * @throws Exception
*/
- public void testProtocol( HostSystem.Session[] sessions, boolean continueAfterFailure ) throws Exception
- {
+ public void testProtocol(HostSystem.Session[] sessions,
+ boolean continueAfterFailure) throws Exception {
if (sessionNumber < 0) {
for (int i = 0; i < sessions.length; i++) {
HostSystem.Session session = sessions[i];
writeMessage(session);
}
- }
- else {
+ } else {
HostSystem.Session session = sessions[sessionNumber];
writeMessage(session);
}
@@ -230,37 +237,45 @@
}
/**
- * Represents a single-line server response, which reads a line
- * from a reader, and compares it with the defined regular expression
- * definition of this line.
+ * Represents a single-line server response, which reads a line from a
+ * reader, and compares it with the defined regular expression definition of
+ * this line.
*/
- private class ServerResponse implements ProtocolElement
- {
+ private class ServerResponse implements ProtocolElement {
private String lastClientMessage;
+
private int sessionNumber;
+
private String expectedLine;
+
protected String location;
/**
* Sets up a server response.
- * @param expectedPattern A Perl regular expression pattern used to test
- * the line recieved.
- * @param location A descriptive value to use in error messages.
+ *
+ * @param expectedPattern
+ * A Perl regular expression pattern used to test the line
+ * recieved.
+ * @param location
+ * A descriptive value to use in error messages.
*/
- public ServerResponse( String expectedPattern, String location )
- {
+ public ServerResponse(String expectedPattern, String location) {
this(-1, expectedPattern, location, null);
}
/**
* Sets up a server response.
- * @param sessionNumber The number of session for a multi-session test
- * @param expectedPattern A Perl regular expression pattern used to test
- * the line recieved.
- * @param location A descriptive value to use in error messages.
+ *
+ * @param sessionNumber
+ * The number of session for a multi-session test
+ * @param expectedPattern
+ * A Perl regular expression pattern used to test the line
+ * recieved.
+ * @param location
+ * A descriptive value to use in error messages.
*/
- public ServerResponse( int sessionNumber, String expectedPattern, String location, String lastClientMessage )
- {
+ public ServerResponse(int sessionNumber, String expectedPattern,
+ String location, String lastClientMessage) {
this.sessionNumber = sessionNumber;
this.expectedLine = expectedPattern;
this.location = location;
@@ -268,71 +283,74 @@
}
/**
- * Reads a line from the supplied reader, and tests that it matches
- * the expected regular expression. If the sessionNumber == -1, then all
- * readers are tested, otherwise, only the reader for this session is tested.
- * @param out Is ignored.
- * @param in The server response is read from here.
- * @throws InvalidServerResponseException If the actual server response didn't
- * match the regular expression expected.
- */
- public void testProtocol( HostSystem.Session[] sessions, boolean continueAfterFailure)
- throws Exception
- {
+ * Reads a line from the supplied reader, and tests that it matches the
+ * expected regular expression. If the sessionNumber == -1, then all
+ * readers are tested, otherwise, only the reader for this session is
+ * tested.
+ *
+ * @param out
+ * Is ignored.
+ * @param in
+ * The server response is read from here.
+ * @throws InvalidServerResponseException
+ * If the actual server response didn't match the regular
+ * expression expected.
+ */
+ public void testProtocol(HostSystem.Session[] sessions,
+ boolean continueAfterFailure) throws Exception {
if (sessionNumber < 0) {
for (int i = 0; i < sessions.length; i++) {
HostSystem.Session session = sessions[i];
checkResponse(session, continueAfterFailure);
}
- }
- else {
+ } else {
HostSystem.Session session = sessions[sessionNumber];
checkResponse(session, continueAfterFailure);
}
}
- protected void checkResponse(HostSystem.Session session, boolean continueAfterFailure) throws Exception {
+ protected void checkResponse(HostSystem.Session session,
+ boolean continueAfterFailure) throws Exception {
String testLine = readLine(session);
- if ( ! match( expectedLine, testLine ) ) {
- String errMsg = "\nLocation: " + location +
- "\nLastClientMsg: " + lastClientMessage +
- "\nExpected: '" + expectedLine +
- "'\nActual : '" + testLine + "'";
+ if (!match(expectedLine, testLine)) {
+ String errMsg = "\nLocation: " + location + "\nLastClientMsg: "
+ + lastClientMessage + "\nExpected: '" + expectedLine
+ + "'\nActual : '" + testLine + "'";
if (continueAfterFailure) {
System.out.println(errMsg);
} else {
- throw new InvalidServerResponseException( errMsg );
+ throw new InvalidServerResponseException(errMsg);
}
}
}
/**
- * A convenience method which returns true if the actual string
- * matches the expected regular expression.
- * @param expected The regular expression used for matching.
- * @param actual The actual message to match.
+ * A convenience method which returns true if the actual string matches
+ * the expected regular expression.
+ *
+ * @param expected
+ * The regular expression used for matching.
+ * @param actual
+ * The actual message to match.
* @return <code>true</code> if the actual matches the expected.
*/
- protected boolean match( String expected, String actual )
- {
- final boolean result = Pattern.matches( expected, actual );
+ protected boolean match(String expected, String actual) {
+ final boolean result = Pattern.matches(expected, actual);
return result;
}
/**
* Grabs a line from the server and throws an error message if it
* doesn't work out
+ *
* @return String of the line from the server
*/
- protected String readLine( HostSystem.Session session )
- throws Exception
- {
+ protected String readLine(HostSystem.Session session) throws Exception {
try {
return session.readLine();
} catch (IOException e) {
- String errMsg = "\nLocation: " + location +
- "\nExpected: " + expectedLine +
- "\nReason: Server Timeout.";
+ String errMsg = "\nLocation: " + location + "\nExpected: "
+ + expectedLine + "\nReason: Server Timeout.";
throw new InvalidServerResponseException(errMsg);
}
}
@@ -343,36 +361,43 @@
}
/**
- * Represents a set of lines which must be recieved from the server,
- * in a non-specified order.
+ * Represents a set of lines which must be recieved from the server, in a
+ * non-specified order.
*/
- private class ServerUnorderedBlockResponse extends ServerResponse
- {
+ private class ServerUnorderedBlockResponse extends ServerResponse {
private List expectedLines = new ArrayList();
/**
- * Sets up a ServerUnorderedBlockResponse with the list of expected lines.
- * @param expectedLines A list containing a reqular expression for each
- * expected line.
- * @param location A descriptive location string for error messages.
+ * Sets up a ServerUnorderedBlockResponse with the list of expected
+ * lines.
+ *
+ * @param expectedLines
+ * A list containing a reqular expression for each expected
+ * line.
+ * @param location
+ * A descriptive location string for error messages.
*/
- public ServerUnorderedBlockResponse( List expectedLines, String location )
- {
+ public ServerUnorderedBlockResponse(List expectedLines, String location) {
this(-1, expectedLines, location, null);
}
/**
- * Sets up a ServerUnorderedBlockResponse with the list of expected lines.
- * @param sessionNumber The number of the session to expect this block,
- * for a multi-session test.
- * @param expectedLines A list containing a reqular expression for each
- * expected line.
- * @param location A descriptive location string for error messages.
- */
- public ServerUnorderedBlockResponse( int sessionNumber,
- List expectedLines, String location, String lastClientMessage)
- {
- super( sessionNumber, "<Unordered Block>", location, lastClientMessage);
+ * Sets up a ServerUnorderedBlockResponse with the list of expected
+ * lines.
+ *
+ * @param sessionNumber
+ * The number of the session to expect this block, for a
+ * multi-session test.
+ * @param expectedLines
+ * A list containing a reqular expression for each expected
+ * line.
+ * @param location
+ * A descriptive location string for error messages.
+ */
+ public ServerUnorderedBlockResponse(int sessionNumber,
+ List expectedLines, String location, String lastClientMessage) {
+ super(sessionNumber, "<Unordered Block>", location,
+ lastClientMessage);
this.expectedLines = expectedLines;
}
@@ -380,11 +405,15 @@
* Reads lines from the server response and matches them against the
* list of expected regular expressions. Each regular expression in the
* expected list must be matched by only one server response line.
- * @param reader Server responses are read from here.
- * @throws InvalidServerResponseException If a line is encountered which doesn't
- * match one of the expected lines.
+ *
+ * @param reader
+ * Server responses are read from here.
+ * @throws InvalidServerResponseException
+ * If a line is encountered which doesn't match one of the
+ * expected lines.
*/
- protected void checkResponse(HostSystem.Session session, boolean continueAfterFailure) throws Exception {
+ protected void checkResponse(HostSystem.Session session,
+ boolean continueAfterFailure) throws Exception {
List testLines = new ArrayList(expectedLines);
while (testLines.size() > 0) {
String actualLine = readLine(session);
@@ -400,51 +429,51 @@
}
if (!foundMatch) {
- StringBuffer errMsg = new StringBuffer()
- .append("\nLocation: ")
- .append(location)
- .append("\nExpected one of: ");
+ StringBuffer errMsg = new StringBuffer().append(
+ "\nLocation: ").append(location).append(
+ "\nExpected one of: ");
Iterator iter = expectedLines.iterator();
while (iter.hasNext()) {
errMsg.append("\n ");
errMsg.append(iter.next());
}
- errMsg.append("\nActual: ")
- .append(actualLine);
+ errMsg.append("\nActual: ").append(actualLine);
if (continueAfterFailure) {
System.out.println(errMsg.toString());
} else {
- throw new InvalidServerResponseException(errMsg.toString());
+ throw new InvalidServerResponseException(errMsg
+ .toString());
}
}
}
}
}
-
+
private class ContinuationElement implements ProtocolElement {
private final int sessionNumber;
-
+
public ContinuationElement(final int sessionNumber) throws Exception {
- this.sessionNumber = sessionNumber < 0 ? 0 : sessionNumber ;
+ this.sessionNumber = sessionNumber < 0 ? 0 : sessionNumber;
}
-
- public void testProtocol(Session[] sessions, boolean continueAfterFailure) throws Exception {
+
+ public void testProtocol(Session[] sessions,
+ boolean continueAfterFailure) throws Exception {
HostSystem.Session session = sessions[sessionNumber];
continuationExpected = true;
continued = false;
String testLine = session.readLine();
- if ( ! "+".equals(testLine) || ! continued) {
+ if (!"+".equals(testLine) || !continued) {
final String message = "Expected continuation";
if (continueAfterFailure) {
System.out.print(message);
} else {
- throw new InvalidServerResponseException( message );
+ throw new InvalidServerResponseException(message);
}
}
continuationExpected = false;
continued = false;
-
+
if (nextTest != null) {
nextTest.testProtocol(sessions, continueAfterFailure);
}
@@ -456,31 +485,32 @@
}
/**
- * Represents a generic protocol element, which may write requests to the server,
- * read responses from the server, or both. Implementations should test the server
- * response against an expected response, and throw an exception on mismatch.
+ * Represents a generic protocol element, which may write requests to the
+ * server, read responses from the server, or both. Implementations should
+ * test the server response against an expected response, and throw an
+ * exception on mismatch.
*/
- private interface ProtocolElement
- {
+ private interface ProtocolElement {
/**
* Executes the ProtocolElement against the supplied session.
- * @param continueAfterFailure TODO
- * @throws Exception
+ *
+ * @param continueAfterFailure
+ * TODO
+ * @throws Exception
*/
- void testProtocol( HostSystem.Session[] sessions, boolean continueAfterFailure) throws Exception;
-
+ void testProtocol(HostSystem.Session[] sessions,
+ boolean continueAfterFailure) throws Exception;
+
boolean isClient();
}
/**
- * An exception which is thrown when the actual response from a server
- * is different from that expected.
+ * An exception which is thrown when the actual response from a server is
+ * different from that expected.
*/
- public class InvalidServerResponseException extends Exception
- {
- public InvalidServerResponseException( String message )
- {
- super( message );
+ public class InvalidServerResponseException extends Exception {
+ public InvalidServerResponseException(String message) {
+ super(message);
}
}
}
Modified: james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/manual/ExternalHostSystem.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/manual/ExternalHostSystem.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/manual/ExternalHostSystem.java (original)
+++ james/protocols/imap/trunk/seda/src/test/java/org/apache/james/test/functional/imap/manual/ExternalHostSystem.java Thu Sep 18 14:44:56 2008
@@ -29,21 +29,25 @@
public class ExternalHostSystem implements HostSystem {
public static final HostSystem createLocalImap() {
- final ExternalHostSystem result = new ExternalHostSystem("localhost", 143, new SystemLoggingMonitor());
+ final ExternalHostSystem result = new ExternalHostSystem("localhost",
+ 143, new SystemLoggingMonitor());
return result;
}
-
+
private final InetSocketAddress address;
+
private final Monitor monitor;
-
- public ExternalHostSystem(final String host, final int port, final Monitor monitor) {
+
+ public ExternalHostSystem(final String host, final int port,
+ final Monitor monitor) {
super();
this.address = new InetSocketAddress(host, port);
this.monitor = monitor;
}
public boolean addUser(String user, String password) throws Exception {
- monitor.note("Please ensure user '"+ user + "' with password '" + password + "' exists.");
+ monitor.note("Please ensure user '" + user + "' with password '"
+ + password + "' exists.");
return true;
}
@@ -61,28 +65,32 @@
public interface Monitor {
void note(String message);
}
-
+
public static final class SystemLoggingMonitor implements Monitor {
public void note(String message) {
System.out.println(message);
}
-
+
}
-
+
private final static class SessionImpl implements Session {
- private static final byte[] CRLF = {'\r','\n'};
-
+ private static final byte[] CRLF = { '\r', '\n' };
+
private final SocketChannel socket;
+
private final Monitor monitor;
+
private final ByteBuffer readBuffer;
+
private final Charset ascii;
+
private final ByteBuffer lineEndBuffer;
-
+
private boolean first = true;
-
- public SessionImpl(final SocketChannel socket,final Monitor monitor) {
+
+ public SessionImpl(final SocketChannel socket, final Monitor monitor) {
super();
this.socket = socket;
this.monitor = monitor;
@@ -108,9 +116,11 @@
}
private void readlineInto(StringBuffer buffer) throws Exception {
- while (socket.read(readBuffer) == 0);
+ while (socket.read(readBuffer) == 0)
+ ;
readBuffer.flip();
- while (readOneMore(buffer));
+ while (readOneMore(buffer))
+ ;
readBuffer.compact();
}
@@ -133,7 +143,7 @@
}
return result;
}
-
+
public void start() throws Exception {
while (!socket.finishConnect()) {
monitor.note("connecting...");
Modified: james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java (original)
+++ james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java Thu Sep 18 14:44:56 2008
@@ -31,16 +31,18 @@
final class ByteContent implements MessageResult.Content {
private final byte[] contents;
+
private final long size;
+
public ByteContent(final byte[] contents) {
this.contents = contents;
size = contents.length + MessageUtils.countUnnormalLines(contents);
}
-
+
public long size() {
return size;
}
-
+
public void writeTo(StringBuffer buffer) {
MessageUtils.normalisedWriteTo(contents, buffer);
}
Modified: james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/CRLFOutputStream.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/CRLFOutputStream.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/CRLFOutputStream.java (original)
+++ james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/CRLFOutputStream.java Thu Sep 18 14:44:56 2008
@@ -44,20 +44,20 @@
protected final static int LAST_WAS_CR = 1;
protected final static int LAST_WAS_LF = 2;
-
+
protected boolean startOfLine = true;
/**
* Constructor that wraps an OutputStream.
*
* @param out
- * the OutputStream to be wrapped
+ * the OutputStream to be wrapped
*/
public CRLFOutputStream(OutputStream out) {
super(out);
statusLast = LAST_WAS_LF; // we already assume a CRLF at beginning
- // (otherwise TOP would not work correctly
- // !)
+ // (otherwise TOP would not work correctly
+ // !)
}
/**
@@ -65,10 +65,10 @@
* mandated CFLF pairing.
*
* @param b
- * the byte to write
+ * the byte to write
*
* @throws IOException
- * if an error occurs writing the byte
+ * if an error occurs writing the byte
*/
public void write(int b) throws IOException {
switch (b) {
@@ -94,14 +94,15 @@
break;
}
}
-
+
/**
- * Provides an extension point for ExtraDotOutputStream to be able to add dots
- * at the beginning of new lines.
+ * Provides an extension point for ExtraDotOutputStream to be able to add
+ * dots at the beginning of new lines.
*
* @see java.io.FilterOutputStream#write(byte[], int, int)
*/
- protected void writeChunk(byte buffer[], int offset, int length) throws IOException {
+ protected void writeChunk(byte buffer[], int offset, int length)
+ throws IOException {
out.write(buffer, offset, length);
}
@@ -113,29 +114,29 @@
/* optimized */
int lineStart = offset;
for (int i = offset; i < length + offset; i++) {
- switch(buffer[i]) {
- case '\r':
- // CR case. Write down the last line
- // and position the new lineStart at the next char
- writeChunk(buffer, lineStart, i - lineStart);
- out.write('\r');
- out.write('\n');
- startOfLine = true;
- lineStart = i + 1;
- statusLast = LAST_WAS_CR;
- break;
- case '\n':
- if (statusLast != LAST_WAS_CR) {
+ switch (buffer[i]) {
+ case '\r':
+ // CR case. Write down the last line
+ // and position the new lineStart at the next char
writeChunk(buffer, lineStart, i - lineStart);
out.write('\r');
out.write('\n');
startOfLine = true;
- }
- lineStart = i + 1;
- statusLast = LAST_WAS_LF;
- break;
- default:
- statusLast = LAST_WAS_OTHER;
+ lineStart = i + 1;
+ statusLast = LAST_WAS_CR;
+ break;
+ case '\n':
+ if (statusLast != LAST_WAS_CR) {
+ writeChunk(buffer, lineStart, i - lineStart);
+ out.write('\r');
+ out.write('\n');
+ startOfLine = true;
+ }
+ lineStart = i + 1;
+ statusLast = LAST_WAS_LF;
+ break;
+ default:
+ statusLast = LAST_WAS_OTHER;
}
}
if (length + offset > lineStart) {
@@ -144,12 +145,11 @@
}
}
-
/**
* Ensure that the stream is CRLF terminated.
*
* @throws IOException
- * if an error occurs writing the byte
+ * if an error occurs writing the byte
*/
public void checkCRLFTerminator() throws IOException {
if (statusLast == LAST_WAS_OTHER) {
Modified: james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java (original)
+++ james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java Thu Sep 18 14:44:56 2008
@@ -32,20 +32,24 @@
final class FullContent implements MessageResult.Content {
private final byte[] contents;
+
private final List headers;
+
private final long size;
-
+
public FullContent(final byte[] contents, final List headers) {
- this.contents = contents;
+ this.contents = contents;
this.headers = headers;
this.size = caculateSize();
}
private long caculateSize() {
- long result = contents.length + MessageUtils.countUnnormalLines(contents);
+ long result = contents.length
+ + MessageUtils.countUnnormalLines(contents);
result += 2;
- for (final Iterator it=headers.iterator(); it.hasNext();) {
- final MessageResult.Header header = (MessageResult.Header) it.next();
+ for (final Iterator it = headers.iterator(); it.hasNext();) {
+ final MessageResult.Header header = (MessageResult.Header) it
+ .next();
if (header != null) {
result += header.size();
result += 2;
@@ -55,8 +59,9 @@
}
public void writeTo(StringBuffer buffer) {
- for (final Iterator it=headers.iterator(); it.hasNext();) {
- final MessageResult.Header header = (MessageResult.Header) it.next();
+ for (final Iterator it = headers.iterator(); it.hasNext();) {
+ final MessageResult.Header header = (MessageResult.Header) it
+ .next();
if (header != null) {
header.writeTo(buffer);
}
@@ -74,8 +79,9 @@
public void writeTo(WritableByteChannel channel) throws IOException {
ByteBuffer newLine = ByteBuffer.wrap(MessageRowUtils.BYTES_NEW_LINE);
- for (final Iterator it=headers.iterator(); it.hasNext();) {
- final MessageResult.Header header = (MessageResult.Header) it.next();
+ for (final Iterator it = headers.iterator(); it.hasNext();) {
+ final MessageResult.Header header = (MessageResult.Header) it
+ .next();
if (header != null) {
header.writeTo(channel);
}
@@ -88,7 +94,8 @@
writeAll(channel, wrap);
}
- private void writeAll(WritableByteChannel channel, ByteBuffer buffer) throws IOException {
+ private void writeAll(WritableByteChannel channel, ByteBuffer buffer)
+ throws IOException {
while (channel.write(buffer) > 0) {
// write more
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org