james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From man...@apache.org
Subject svn commit: r909996 - in /james/hupa/trunk: ./ client/ client/src/main/java/org/apache/hupa/client/mvp/ client/src/test/java/org/apache/hupa/ client/src/test/java/org/apache/hupa/client/ client/src/test/java/org/apache/hupa/client/guice/ client/src/tes...
Date Sun, 14 Feb 2010 10:26:53 GMT
Author: manolo
Date: Sun Feb 14 10:26:52 2010
New Revision: 909996

URL: http://svn.apache.org/viewvc?rev=909996&view=rev
Log:
Added common classes for testing presenters and client code.
Client pom.xml modifications to include easymock stuff and to run GwtTestCase cases.
Little refactoring in server side tests.
Tests for ContactsPresenter.

Added:
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaGwtTestCase.java
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaMvpTestCase.java
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/GuiceMvpTestModule.java
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/ContactsPresenterTest.java
    james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/GuiceServerTestModule.java
      - copied, changed from r909175, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/guice/GuiceTestModule.java
    james/hupa/trunk/server/src/main/java/org/apache/hupa/server/mock/MockHttpSession.java
      - copied unchanged from r908044, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockHttpSession.java
    james/hupa/trunk/server/src/main/java/org/apache/hupa/server/mock/MockLog.java
      - copied unchanged from r908044, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockLog.java
    james/hupa/trunk/server/src/main/java/org/apache/hupa/server/mock/MockLogProvider.java
      - copied unchanged from r908044, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockLogProvider.java
Removed:
    james/hupa/trunk/client/src/test/java/org/apache/hupa/HupaTest.gwt.xml
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/guice/GuiceTestModule.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockHttpSession.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockIMAPStoreCache.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockLog.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockLogProvider.java
Modified:
    james/hupa/trunk/client/pom.xml
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsPresenter.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsView.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
    james/hupa/trunk/client/src/test/java/org/apache/hupa/client/validation/EmailListValidatorTest.java
    james/hupa/trunk/pom.xml
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/HupaGuiceTestCase.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/AbtractSendMessageHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/CreateFolderHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteFolderHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteMessageByUidHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FetchFoldersHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FowardMessageHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/GetMessageDetailsHandlerTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/HandlersTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorageTest.java
    james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InSessionUserPreferencesStorageTest.java

Modified: james/hupa/trunk/client/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/pom.xml?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/client/pom.xml (original)
+++ james/hupa/trunk/client/pom.xml Sun Feb 14 10:26:52 2010
@@ -21,7 +21,9 @@
                 <artifactId>gwt-maven-plugin</artifactId>
                 <configuration>
                      <runTarget>Hupa.html</runTarget>
-                     <extraJvmArgs>-Dhupa.config.file=${project.parent.basedir}/server/src/main/webapp/WEB-INF/conf/config.properties</extraJvmArgs>
+                     <extraJvmArgs>
+                         -Dhupa.config.file=${project.parent.basedir}/server/src/main/webapp/WEB-INF/conf/config.properties
+                     </extraJvmArgs>
                 </configuration>
                 <executions>
                     <execution>
@@ -34,6 +36,17 @@
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <additionalClasspathElements>
+                        <additionalClasspathElement>${basedir}/src/test/java</additionalClasspathElement>
+                        <additionalClasspathElement>${basedir}/src/main/java</additionalClasspathElement>
+                    </additionalClasspathElements>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <configuration>
                     <webXml>src/main/webapp/WEB-INF/web.xml
@@ -57,8 +70,6 @@
         </plugins>
     </build>
 
-
-
     <dependencies>
         <dependency>
             <groupId>org.apache.hupa</groupId>
@@ -114,9 +125,19 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>com.google.gwt</groupId>
+            <artifactId>gwt-dev</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsPresenter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsPresenter.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsPresenter.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsPresenter.java Sun Feb 14 10:26:52 2010
@@ -33,6 +33,7 @@
 public class ContactsPresenter extends WidgetPresenter<ContactsPresenter.Display>{
 
     DispatchAsync dispatcher;
+    protected Contact[] contacts;
     
     @Inject
     public ContactsPresenter(Display display, EventBus eventBus, DispatchAsync dispatcher) {
@@ -42,6 +43,7 @@
 
     public interface Display extends NameAwareWidgetDisplay, WidgetDisplay {
         public void setContacts(Contact[] contacts);
+        public Contact[] getContacts();
     }
     
     @Override
@@ -52,15 +54,14 @@
     protected void onRevealDisplay() {
         dispatcher.execute(new Contacts(),  new HupaCallback<ContactsResult>(dispatcher, eventBus) {
             public void callback(ContactsResult result) {
-                display.setContacts(result.getContacts());
+                contacts = result.getContacts();
+                display.setContacts(contacts);
             }
         }); 
     }
 
     @Override
     protected void onUnbind() {
-        // TODO Auto-generated method stub
-        
     }
 
 }

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsView.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsView.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ContactsView.java Sun Feb 14 10:26:52 2010
@@ -30,6 +30,8 @@
 import org.apache.hupa.client.HupaConstants;
 import org.apache.hupa.shared.rpc.ContactsResult.Contact;
 
+import java.util.ArrayList;
+
 public class ContactsView extends Composite implements ContactsPresenter.Display{
 
     private VerticalPanel panel = new VerticalPanel();
@@ -69,5 +71,13 @@
             ctable.setText(i, 1, contacts[i].mail);
         }
     }
+    
+    public Contact[] getContacts() {
+        ArrayList<Contact> contacts = new ArrayList<Contact>();
+        for (int i=0; i < ctable.getRowCount(); i++) {
+            contacts.add(new Contact(ctable.getText(i, 0), ctable.getText(i, 1)));
+        }
+        return contacts.toArray(new Contact[contacts.size()]);
+    }
 
 }

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java Sun Feb 14 10:26:52 2010
@@ -366,8 +366,9 @@
             if (!oldmessage.getSubject().toLowerCase().startsWith("fwd:"))
                 display.getSubjectText().setText("Fwd: " + oldmessage.getSubject());
         } else if (type.equals(Type.REPLY) || type.equals(Type.REPLY_ALL)) {
-            if (!oldmessage.getSubject().toLowerCase().startsWith("re:"))
+            if (!oldmessage.getSubject().toLowerCase().startsWith("re:")) {
                 display.getSubjectText().setText("Re: " + oldmessage.getSubject());
+            }
             if (oldmessage.getReplyto() != null) {
                 display.getToText().setText(oldmessage.getReplyto());
             } else if (type.equals(Type.REPLY)) {

Added: james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaGwtTestCase.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaGwtTestCase.java?rev=909996&view=auto
==============================================================================
--- james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaGwtTestCase.java (added)
+++ james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaGwtTestCase.java Sun Feb 14 10:26:52 2010
@@ -0,0 +1,46 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.hupa.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Base class for testing hupa in client side.
+ * 
+ * @author manolo
+ *
+ */
+public abstract class HupaGwtTestCase extends GWTTestCase {
+
+    /**
+     * Although tests extending this class should work in either the jvm or the browser,
+     * it is better to run them in the jvm because of performance reasons.
+     * 
+     * Change the return value if you what to run them in browser, but
+     * be sure to commit this class returning null
+     * 
+     *   TODO: put some code to return the adequate value based on an external
+     *   property. System.getProperty doesn't work because the test
+     *   is compiled to javascript when not returning null
+     */
+    public String getModuleName() {
+        //return "org.apache.hupa.Hupa";
+        return null;
+    }
+}

Added: james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaMvpTestCase.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaMvpTestCase.java?rev=909996&view=auto
==============================================================================
--- james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaMvpTestCase.java (added)
+++ james/hupa/trunk/client/src/test/java/org/apache/hupa/client/HupaMvpTestCase.java Sun Feb 14 10:26:52 2010
@@ -0,0 +1,68 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.hupa.client;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import com.sun.mail.imap.IMAPStore;
+
+import junit.framework.TestCase;
+
+import org.apache.hupa.client.guice.GuiceMvpTestModule;
+import org.apache.hupa.server.IMAPStoreCache;
+import org.apache.hupa.server.guice.GuiceServerTestModule;
+import org.apache.hupa.server.preferences.UserPreferencesStorage;
+import org.apache.hupa.shared.SConsts;
+import org.apache.hupa.shared.data.User;
+
+import javax.mail.Session;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Base class for testing presenters in hupa
+ * 
+ * @author manolo
+ *
+ */
+public abstract class HupaMvpTestCase extends TestCase {
+
+    // Create an injector containing both, the server and the client modules.
+    protected Injector injector = Guice.createInjector(new GuiceServerTestModule(), new GuiceMvpTestModule());
+
+    protected HttpSession httpSession = injector.getInstance(HttpSession.class);
+    protected Session session = injector.getInstance(Session.class);
+
+    protected UserPreferencesStorage userPreferences = injector.getInstance(UserPreferencesStorage.class);
+    protected IMAPStoreCache storeCache = injector.getInstance(IMAPStoreCache.class);
+
+    protected User testUser;
+    protected IMAPStore store;
+
+    @Override
+    protected void setUp() throws Exception {
+        try {
+            testUser = injector.getInstance(User.class);
+            store = storeCache.get(testUser);
+            httpSession.setAttribute(SConsts.USER_SESS_ATTR, testUser);
+        } catch (Exception e) {
+        }
+    }
+
+}

Added: james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/GuiceMvpTestModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/GuiceMvpTestModule.java?rev=909996&view=auto
==============================================================================
--- james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/GuiceMvpTestModule.java (added)
+++ james/hupa/trunk/client/src/test/java/org/apache/hupa/client/guice/GuiceMvpTestModule.java Sun Feb 14 10:26:52 2010
@@ -0,0 +1,96 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.hupa.client.guice;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.dispatch.client.service.DispatchService;
+import net.customware.gwt.dispatch.server.Dispatch;
+import net.customware.gwt.dispatch.shared.Action;
+import net.customware.gwt.dispatch.shared.ActionException;
+import net.customware.gwt.dispatch.shared.Result;
+import net.customware.gwt.presenter.client.Display;
+import net.customware.gwt.presenter.client.EventBus;
+
+import static org.easymock.EasyMock.createStrictMock;
+
+import org.apache.hupa.client.mvp.ContactsPresenter;
+import org.easymock.EasyMock;
+
+/**
+ * Guice module used to test the presenter
+ * 
+ * @author manolo
+ *
+ */
+public class GuiceMvpTestModule extends AbstractModule {
+    
+    @Override
+    protected void configure() {
+
+        bind(DispatchService.class).to(DispatchTestService.class).in(Singleton.class);
+        bind(DispatchAsync.class).to(DispatchTestAsync.class).in(Singleton.class);
+
+        final EventBus eventBus = createStrictMock(EventBus.class);
+        bind(EventBus.class).toInstance(eventBus);
+
+        bindDisplay(ContactsPresenter.Display.class);
+    }
+
+    public <D extends Display> void bindDisplay(final Class<D> display) {
+        final D mockDisplay = EasyMock.createNiceMock(display);
+        bind(display).toInstance(mockDisplay);
+    }
+
+    static class DispatchTestService implements DispatchService {
+        private Dispatch dispatch;
+
+        @Inject
+        public DispatchTestService(Dispatch dispatch) {
+            this.dispatch = dispatch;
+        }
+
+        public Result execute(Action<?> action) throws Exception {
+            Result result = dispatch.execute(action);
+            return result;
+        }
+    }
+
+    static class DispatchTestAsync implements DispatchAsync {
+        private Dispatch dispatch;
+
+        @Inject
+        public DispatchTestAsync(Dispatch dispatch) {
+            this.dispatch = dispatch;
+        }
+
+        public <A extends Action<R>, R extends Result> void execute(A action, AsyncCallback<R> callback) {
+            try {
+                R result = dispatch.execute(action);
+                callback.onSuccess(result);
+            } catch (ActionException e) {
+                callback.onFailure(e);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/ContactsPresenterTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/ContactsPresenterTest.java?rev=909996&view=auto
==============================================================================
--- james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/ContactsPresenterTest.java (added)
+++ james/hupa/trunk/client/src/test/java/org/apache/hupa/client/mvp/ContactsPresenterTest.java Sun Feb 14 10:26:52 2010
@@ -0,0 +1,61 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.hupa.client.mvp;
+
+import org.apache.hupa.client.HupaMvpTestCase;
+import org.apache.hupa.shared.rpc.ContactsResult.Contact;
+import org.easymock.EasyMock;
+
+public class ContactsPresenterTest extends HupaMvpTestCase {
+
+    ContactsPresenter presenter = injector.getInstance(ContactsPresenter.class);
+    ContactsPresenter.Display display = presenter.getDisplay();
+    
+    public void testRevealDisplayWhenListIsEmpty() throws Exception {
+        Contact[] contacts = new Contact[]{};
+        
+        display.setContacts(EasyMock.aryEq(contacts));
+        EasyMock.replay(display);
+        // get the contacts list from the server
+        presenter.onRevealDisplay();
+        assertNotNull(presenter.contacts);
+        assertEquals(0, presenter.contacts.length);
+        EasyMock.verify(display);
+        EasyMock.reset(display);
+    }
+
+    public void testRevealDisplayWhenListHasData() throws Exception {
+        Contact c = new Contact("Somebody <somebody@foo.com>");
+        assertEquals("Somebody", c.realname);
+        assertEquals("somebody@foo.com", c.mail);
+        Contact[] contacts = new Contact[]{c};
+        
+        // add the contact list to the server
+        userPreferences.addContact(contacts);
+        
+        display.setContacts(EasyMock.aryEq(contacts));
+        EasyMock.replay(display);
+        // get the contacts list from the server
+        presenter.onRevealDisplay();
+        assertEquals(1, presenter.contacts.length);
+        EasyMock.verify(display);
+        EasyMock.reset(display);
+    }
+}
+

Modified: james/hupa/trunk/client/src/test/java/org/apache/hupa/client/validation/EmailListValidatorTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/test/java/org/apache/hupa/client/validation/EmailListValidatorTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/client/src/test/java/org/apache/hupa/client/validation/EmailListValidatorTest.java (original)
+++ james/hupa/trunk/client/src/test/java/org/apache/hupa/client/validation/EmailListValidatorTest.java Sun Feb 14 10:26:52 2010
@@ -1,12 +1,27 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
 package org.apache.hupa.client.validation;
 
-import junit.framework.TestCase;
+import org.apache.hupa.client.HupaGwtTestCase;
 
-import org.apache.hupa.client.validation.EmailListValidator;
+public class EmailListValidatorTest extends HupaGwtTestCase {
 
-
-public class EmailListValidatorTest extends TestCase{
-    
     public void testEmailValidator() {
         assertTrue(EmailListValidator.isValidAddressList("abc@abc.def"));
         assertTrue(EmailListValidator.isValidAddressList(" abc@abc.def"));

Modified: james/hupa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/pom.xml?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/pom.xml (original)
+++ james/hupa/trunk/pom.xml Sun Feb 14 10:26:52 2010
@@ -344,11 +344,23 @@
                 <scope>provided</scope>
             </dependency>
             <dependency>
+                <groupId>com.google.gwt</groupId>
+                <artifactId>gwt-dev</artifactId>
+                <version>${gwtVersion}</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.1</version>
                 <scope>test</scope>
             </dependency>
+            <dependency>
+                <groupId>org.easymock</groupId>
+                <artifactId>easymock</artifactId>
+                <version>2.5.2</version>
+                <scope>test</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 </project>

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/GuiceServerTestModule.java (from r909175, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/guice/GuiceTestModule.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/GuiceServerTestModule.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/GuiceServerTestModule.java&p1=james/hupa/trunk/server/src/test/java/org/apache/hupa/server/guice/GuiceTestModule.java&r1=909175&r2=909996&rev=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/guice/GuiceTestModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/GuiceServerTestModule.java Sun Feb 14 10:26:52 2010
@@ -19,7 +19,6 @@
 
 package org.apache.hupa.server.guice;
 
-import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
@@ -28,6 +27,8 @@
 
 import com.sun.mail.imap.IMAPStore;
 
+import net.customware.gwt.dispatch.server.guice.ActionHandlerModule;
+
 import org.apache.commons.logging.Log;
 import org.apache.hupa.server.IMAPStoreCache;
 import org.apache.hupa.server.InMemoryIMAPStoreCache;
@@ -67,7 +68,7 @@
  * @author manolo
  *
  */
-public class GuiceTestModule extends AbstractModule {
+public class GuiceServerTestModule extends ActionHandlerModule {
         
     protected Class<? extends Provider<Session>> sessionClass = SessionProvider.class;
     protected Class<? extends HttpSession> httpSessionClass = MockHttpSession.class;
@@ -79,7 +80,7 @@
     protected Properties properties = DemoModeConstants.demoProperties;
 
     @Override
-    protected void configure() {
+    protected void configureHandlers() {
         Names.bindProperties(binder(), properties);
         
         bind(Session.class).toProvider(sessionClass);
@@ -104,7 +105,7 @@
         bind(SendMessageHandler.class);
         bind(ReplyMessageHandler.class);
         bind(ForwardMessageHandler.class);
-        bind(ContactsHandler.class);
+        bindHandler(ContactsHandler.class);
         
         bind(UserPreferencesStorage.class).to(userPreferencesClass);
         

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/HupaGuiceTestCase.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/HupaGuiceTestCase.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/HupaGuiceTestCase.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/HupaGuiceTestCase.java Sun Feb 14 10:26:52 2010
@@ -29,7 +29,7 @@
 import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
-import org.apache.hupa.server.guice.GuiceTestModule;
+import org.apache.hupa.server.guice.GuiceServerTestModule;
 import org.apache.hupa.server.handler.AbstractSendMessageHandler;
 import org.apache.hupa.server.handler.ContactsHandler;
 import org.apache.hupa.server.handler.CreateFolderHandler;
@@ -62,21 +62,21 @@
 
     protected IdleHandler idleHandler = injector.getInstance(IdleHandler.class);
 
-    protected CreateFolderHandler createFHandler = injector.getInstance(CreateFolderHandler.class);
+    protected CreateFolderHandler createFolderHandler = injector.getInstance(CreateFolderHandler.class);
     
-    protected DeleteFolderHandler deleteFHandler = injector.getInstance(DeleteFolderHandler.class);
+    protected DeleteFolderHandler deleteFolderHandler = injector.getInstance(DeleteFolderHandler.class);
     
-    protected FetchFoldersHandler fetchFHandler = injector.getInstance(FetchFoldersHandler.class);
+    protected FetchFoldersHandler fetchFoldersHandler = injector.getInstance(FetchFoldersHandler.class);
     
     protected FetchMessagesHandler fetchMessagesHandler = injector.getInstance(FetchMessagesHandler.class);
     
-    protected DeleteMessageByUidHandler deleteMByUid = injector.getInstance(DeleteMessageByUidHandler.class);
+    protected DeleteMessageByUidHandler deleteMessageByUidHandler = injector.getInstance(DeleteMessageByUidHandler.class);
     
-    protected AbstractSendMessageHandler<SendMessage> abstSendMsgHndl = injector.getInstance(SendMessageHandler.class);
+    protected AbstractSendMessageHandler<SendMessage> sendMessageHandler = injector.getInstance(SendMessageHandler.class);
     
-    protected ForwardMessageHandler fwdMsgHndl = injector.getInstance(ForwardMessageHandler.class);
+    protected ForwardMessageHandler forwardMessageHandler = injector.getInstance(ForwardMessageHandler.class);
     
-    protected GetMessageDetailsHandler getDetailsMsgHndl = injector.getInstance(GetMessageDetailsHandler.class);
+    protected GetMessageDetailsHandler getDetailsHandler = injector.getInstance(GetMessageDetailsHandler.class);
     
     protected Log logger = injector.getInstance(Log.class);
     
@@ -96,7 +96,9 @@
     
     protected IMAPStore store;
     
-    public HupaGuiceTestCase() {
+    
+    @Override
+    protected void setUp() throws Exception {
         try {
             testUser = injector.getInstance(User.class);
             store = storeCache.get(testUser);
@@ -104,8 +106,8 @@
         } catch (Exception e) {
         }
     }
-    
+
     protected Module getModule() {
-        return new GuiceTestModule();
+        return new GuiceServerTestModule();
     }
 }

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/AbtractSendMessageHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/AbtractSendMessageHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/AbtractSendMessageHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/AbtractSendMessageHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -84,14 +84,14 @@
     public void testRestoreInlineLinks() {
         String txt, res;
         txt = ".. <img\nsrc='...&name=abcd' name='cid:abcd'\nwhatever=/> ..";
-        res = abstSendMsgHndl.restoreInlineLinks(txt);
+        res = sendMessageHandler.restoreInlineLinks(txt);
         assertEquals(".. <img\nsrc='cid:abcd'\nwhatever=/> ..", res);
     }
 
     public void testHtmlmessageToText() {
         String txt, res;
         txt = "<div>Hola:</div>Como \n estas<br/>Adios\n\n";
-        res = abstSendMsgHndl.htmlToText(txt);
+        res = sendMessageHandler.htmlToText(txt);
         assertEquals("Hola:\nComo estas\nAdios ", res);
     }
     
@@ -102,19 +102,19 @@
         SMTPMessage smtpmsg = TestUtils.createMockSMTPMessage(SessionUtils.getSessionRegistry(logger, httpSession), 2);
         SendMessage action = new SendMessage(smtpmsg);
         
-        Message message = abstSendMsgHndl.createMessage(session, action);
-        message =  abstSendMsgHndl.fillBody(message, action);
+        Message message = sendMessageHandler.createMessage(session, action);
+        message =  sendMessageHandler.fillBody(message, action);
         
         assertEquals(contentTwoAttach, TestUtils.summaryzeContent(message).toString());
 
-        abstSendMsgHndl.sendMessage(session, testUser, message);
+        sendMessageHandler.sendMessage(session, testUser, message);
         
         // The reported size is wrong before the message has been saved
         Part part = MessageUtils.handleMultiPart(logger, message.getContent(), "uploadedFile_1.bin");
         assertTrue(part.getSize() < 0);
 
         assertTrue(sentbox.getMessages().length == 0);
-        abstSendMsgHndl.saveSentMessage(session, testUser, message);
+        sendMessageHandler.saveSentMessage(session, testUser, message);
         assertTrue(sentbox.getMessages().length == 1);
         
         message = sentbox.getMessage(0);
@@ -134,7 +134,7 @@
         SendMessage action = new SendMessage(smtpmsg);
         
         assertTrue(sentbox.getMessages().length == 0);
-        abstSendMsgHndl.execute(action, null);
+        sendMessageHandler.execute(action, null);
         Message message = sentbox.getMessage(0);
         assertNotNull(message);
         assertEquals(contentTwoAttach, TestUtils.summaryzeContent(message).toString());

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/CreateFolderHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/CreateFolderHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/CreateFolderHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/CreateFolderHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -40,7 +40,7 @@
         assertFalse("not exists",f1.exists());
         
         try {
-            createFHandler.execute(new CreateFolder(folder), null);
+            createFolderHandler.execute(new CreateFolder(folder), null);
             Folder f = store.getFolder(folder.getFullName());
             assertTrue("exists",f.exists());
         } catch (ActionException e) {
@@ -55,7 +55,7 @@
         Folder f1 = store.getFolder(folder.getFullName());
         f1.create(Folder.HOLDS_FOLDERS);
         try {
-            createFHandler.execute(new CreateFolder(folder), null);
+            createFolderHandler.execute(new CreateFolder(folder), null);
             fail("Folder already exists");
         } catch (ActionException e) {
         }
@@ -65,7 +65,7 @@
         httpSession.removeAttribute(SConsts.USER_SESS_ATTR);
         IMAPFolder folder = createFolder();
         try {
-            createFHandler.execute(new CreateFolder(folder), null);
+            createFolderHandler.execute(new CreateFolder(folder), null);
             fail("Invalid session");
         } catch (InvalidSessionException e) {
         } catch (ActionException e) {

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteFolderHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteFolderHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteFolderHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteFolderHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -39,7 +39,7 @@
         Folder f1 = store.getFolder(folder.getFullName());
         f1.create(Folder.HOLDS_FOLDERS);
         try {
-            deleteFHandler.execute(new DeleteFolder(folder), null);
+            deleteFolderHandler.execute(new DeleteFolder(folder), null);
             Folder f = store.getFolder(folder.getFullName());
             assertFalse("not exists",f.exists());
         } catch (ActionException e) {
@@ -51,7 +51,7 @@
     public void testDeleteNonExistFolder() throws MessagingException {
         IMAPFolder folder = createFolder();
         try {
-            deleteFHandler.execute(new DeleteFolder(folder), null);
+            deleteFolderHandler.execute(new DeleteFolder(folder), null);
             fail("Folder should not exist");
         } catch (ActionException e) {
         }    
@@ -61,7 +61,7 @@
         httpSession.removeAttribute(SConsts.USER_SESS_ATTR);
         IMAPFolder folder = createFolder();
         try {
-            deleteFHandler.execute(new DeleteFolder(folder), null);
+            deleteFolderHandler.execute(new DeleteFolder(folder), null);
             fail("Invalid session");
         } catch (InvalidSessionException e) {
         } catch (ActionException e) {

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteMessageByUidHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteMessageByUidHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteMessageByUidHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/DeleteMessageByUidHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -41,7 +41,7 @@
         folder.setFullName("NOT_EXISTS");
         DeleteMessageByUid action = new DeleteMessageByUid(folder,new ArrayList<Long>());
         try {
-            deleteMByUid.execute(action, null);
+            deleteMessageByUidHandler.execute(action, null);
             fail("Folder should not exists!");
         } catch (ActionException e) {
         }
@@ -64,7 +64,7 @@
         MockIMAPFolder f3 = (MockIMAPFolder) store.getFolder(testUser.getSettings().getTrashFolderName());
         assertFalse("Trash folder already exists", f3.exists());
         try {
-            deleteMByUid.execute(action, null);
+            deleteMessageByUidHandler.execute(action, null);
             assertEquals("Only 1 message left", 1, f.getMessageCount());
             
             MockIMAPFolder f2 = (MockIMAPFolder) store.getFolder(testUser.getSettings().getTrashFolderName());
@@ -88,7 +88,7 @@
         uids.add(2l);
         DeleteMessageByUid action = new DeleteMessageByUid(folder, uids);
         try {
-            deleteMByUid.execute(action, null);
+            deleteMessageByUidHandler.execute(action, null);
             assertEquals("Only 1 message left", 1, f.getMessageCount());
         } catch (ActionException e) {
             e.printStackTrace();

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FetchFoldersHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FetchFoldersHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FetchFoldersHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FetchFoldersHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -39,6 +39,7 @@
     
 
     public void setUp() throws Exception {
+        super.setUp();
         MockIMAPStore store = (MockIMAPStore) storeCache.get(testUser);
         store.clear();
     }
@@ -46,7 +47,7 @@
     public void testInvalidSessionId() {
         httpSession.removeAttribute(SConsts.USER_SESS_ATTR);
         try {
-            fetchFHandler.execute(new FetchFolders(), null);
+            fetchFoldersHandler.execute(new FetchFolders(), null);
             fail("Invalid session");
         } catch (InvalidSessionException e) {
         } catch (ActionException e) {
@@ -58,7 +59,7 @@
     public void testNoFolders() {
         httpSession.setAttribute(SConsts.USER_SESS_ATTR, testUser);
         try {
-            FetchFoldersResult result = fetchFHandler.execute(new FetchFolders(), null);
+            FetchFoldersResult result = fetchFoldersHandler.execute(new FetchFolders(), null);
             assertTrue(result.getFolders().isEmpty());
         } catch (ActionException e) {
             e.printStackTrace();
@@ -72,7 +73,7 @@
         store.getFolder("WHATEVER1").create(Folder.HOLDS_FOLDERS);
         store.getFolder("WHATEVER.XXX").create(Folder.HOLDS_FOLDERS);
         try {
-            FetchFoldersResult result = fetchFHandler.execute(new FetchFolders(), null);
+            FetchFoldersResult result = fetchFoldersHandler.execute(new FetchFolders(), null);
             ArrayList<IMAPFolder> folders = result.getFolders();
             assertFalse(folders.isEmpty());
             assertEquals(3, folders.size());

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FowardMessageHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FowardMessageHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FowardMessageHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/FowardMessageHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -55,8 +55,8 @@
         SMTPMessage smtpmsg = TestUtils.createMockSMTPMessage(registry, 2);
         ForwardMessage action = new ForwardMessage(smtpmsg, ifolder, msgUid);
         
-        message = fwdMsgHndl.createMessage(session, action);
-        message = fwdMsgHndl.fillBody(message, action);
+        message = forwardMessageHandler.createMessage(session, action);
+        message = forwardMessageHandler.fillBody(message, action);
         
         String expected = "multipart/mixed\n"
             + " multipart/alternative\n"

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/GetMessageDetailsHandlerTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/GetMessageDetailsHandlerTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/GetMessageDetailsHandlerTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/GetMessageDetailsHandlerTest.java Sun Feb 14 10:26:52 2010
@@ -35,42 +35,42 @@
     
     public void testTextDocumentToHtml() throws Exception {
         String msg = "...\nhttp://www.example.com/path/action.do;s=1;a=2?p=abcd\n...";
-        String res = getDetailsMsgHndl.txtDocumentToHtml(msg, "aFolder", 9999l);
+        String res = getDetailsHandler.txtDocumentToHtml(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertTrue(res.contains("onClick=\"openLink('http://"));
         
         msg = "...\nnobody@subdomain.the-domain.org\n...";
-        res = getDetailsMsgHndl.txtDocumentToHtml(msg, "aFolder", 9999l);
+        res = getDetailsHandler.txtDocumentToHtml(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertTrue(res.contains("onClick=\"mailTo('nobody@"));
         
-        res = getDetailsMsgHndl.txtDocumentToHtml("", "aFolder", 9999l);
+        res = getDetailsHandler.txtDocumentToHtml("", "aFolder", 9999l);
         assertTrue(res.length()==0);
         
         msg = "...<atag>...";
-        res = getDetailsMsgHndl.txtDocumentToHtml(msg, "aFolder", 9999l);
+        res = getDetailsHandler.txtDocumentToHtml(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertEquals("...&lt;atag&gt;...", res);
     }
 
     public void testFilterHtmlDocument() throws Exception {
         String msg = "<div>...\nhttp://whatever\n...</div>";
-        String res = getDetailsMsgHndl.txtDocumentToHtml(msg, "aFolder", 9999l);
+        String res = getDetailsHandler.txtDocumentToHtml(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertTrue(res.contains("onClick=\"openLink('http://whatever"));
         
         msg = "...\n<a\nhref=https://www.example.com/path/action.do;s=1;a=2?p=abcd\n...";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertTrue(res.contains("onClick=\"openLink('https://"));
 
         msg = "...\n<a\nhref=mailTo:nobody@subdomain.the-domain.org\n...";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertTrue(res.contains("onClick=\"mailTo('nobody@"));
 
         msg = "...\n...<img   \n   src=\"cid:1.1934304663@web28309.mail.ukl.yahoo.com\" width=200\n....";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         assertEquals("...\n...<img   \n   src='" + 
                 SConsts.HUPA + SConsts.SERVLET_DOWNLOAD + "?" 
@@ -79,46 +79,46 @@
                 + SConsts.PARAM_NAME + "=1.1934304663@web28309.mail.ukl.yahoo.com' name='cid:1.1934304663@web28309.mail.ukl.yahoo.com' width=200\n....", res);
         
         msg = "\n\n.... <Script \ntype=\"whatever\"\n>\nalert('hello');\n</script > ---\n\n";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
 
         msg = "\n\n.... <a \nid=\"whatever\"\nonclick=\"alert('hello');\"\n</a > ---\n\n";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
 
         msg = "\n\n.... <style \ntype=\"whatever\"\n>\n.a{};\n</Style > ---\n\n";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertNotSame(msg, res);
         
-        res = getDetailsMsgHndl.filterHtmlDocument("", "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument("", "aFolder", 9999l);
         assertTrue(res.length()==0);
     }
 
     public void testRegexEmailsInsideTagAttributes() {
         String msg, res;
         msg = ".. <a href=\"http://whatever?param1=whatever&email= dock@example.com&param3\">..</a> ..";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertFalse(res.contains("mailTo("));
 
         msg = ".. <a href=bla > http://whatever?param1=whatever&email=dock@example.com&param3 </a> ..";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertFalse(res.contains("mailTo("));
         assertFalse(res.contains("openLink("));
 
         msg = ".. <div > http://whatever?param1=whatever&email=dock@example.com&param3 <p> ..";
-        res = getDetailsMsgHndl.filterHtmlDocument(msg, "aFolder", 9999l);
+        res = getDetailsHandler.filterHtmlDocument(msg, "aFolder", 9999l);
         assertFalse(res.contains("mailTo("));
         assertTrue(res.contains("openLink("));
         
         msg = "http://accounts.myspace.com.deaaaf.me.uk/msp/index.php?fuseaction=update&code=78E2BL6-EKY5L893K4MHSA-74ESO-D743U41GYB18J-FA18EI698V4M&email=somehone@somewere.com";
-        res = getDetailsMsgHndl.txtDocumentToHtml(msg, "aFolder", 9999l);
+        res = getDetailsHandler.txtDocumentToHtml(msg, "aFolder", 9999l);
         assertFalse(res.contains("mailTo("));
         assertTrue(res.contains("openLink("));
         
     }
 
     private MessageDetails loadMessageDetails(String msgFile) throws Exception {
-        return getDetailsMsgHndl.mimeToDetails(TestUtils.loadMessageFromFile(session,msgFile), "theFolder", 9999l);
+        return getDetailsHandler.mimeToDetails(TestUtils.loadMessageFromFile(session,msgFile), "theFolder", 9999l);
     }
     
     public void testMessageDetails_textPlain() throws Exception {
@@ -169,7 +169,7 @@
         serverfolder.addMessages(new Message[]{msg});
         
         org.apache.hupa.shared.data.IMAPFolder clientfolder = new org.apache.hupa.shared.data.IMAPFolder("WHATEVER");
-        MessageDetails details = getDetailsMsgHndl.exposeMessage(testUser, clientfolder, 0);
+        MessageDetails details = getDetailsHandler.exposeMessage(testUser, clientfolder, 0);
         
         // inline images have to be downloaded from the server
         assertTrue(details.getText().contains("img src=\'" + 
@@ -186,7 +186,7 @@
     public void testMessageDetails_links() throws Exception {
         MessageDetails details = loadMessageDetails("2.msg");
 
-        String html = getDetailsMsgHndl.filterHtmlDocument(details.getText(), "foldername", 111l);
+        String html = getDetailsHandler.filterHtmlDocument(details.getText(), "foldername", 111l);
         assertFalse(html.contains("<script>"));
         assertFalse(html.contains("<style>"));
         assertTrue(html.contains("<a onClick=\"openLink('http://code.google.com/intl/es/webtoolkit/');return false;\" href=\"http://code.google.com/intl/es/webtoolkit/\""));

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/HandlersTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/HandlersTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/HandlersTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/handler/HandlersTest.java Sun Feb 14 10:26:52 2010
@@ -25,7 +25,7 @@
 import net.customware.gwt.dispatch.shared.ActionException;
 
 import org.apache.hupa.server.HupaGuiceTestCase;
-import org.apache.hupa.server.guice.GuiceTestModule;
+import org.apache.hupa.server.guice.GuiceServerTestModule;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.rpc.CreateFolder;
 import org.apache.hupa.shared.rpc.DeleteFolder;
@@ -44,7 +44,7 @@
         // If you want to run these tests against your IMAP server do this:
         //    1.- Change properties and classes to do integration tests and
         //    2.- Be sure the user and password are set correctly
-        class MyModule extends GuiceTestModule {
+        class MyModule extends GuiceServerTestModule {
             public MyModule() {
                 // properties = courierProperties;
                 // properties = gmailProperties;
@@ -58,7 +58,7 @@
         try {
             org.apache.hupa.shared.rpc.LoginUser l = new org.apache.hupa.shared.rpc.LoginUser(testUser.getName(),testUser.getPassword());
             loginUser.execute(l, null);
-            FetchFoldersResult result = fetchFHandler.execute(new FetchFolders(), null);
+            FetchFoldersResult result = fetchFoldersHandler.execute(new FetchFolders(), null);
             assertNotNull(result);
         } catch (ActionException e) {
             e.printStackTrace();
@@ -77,7 +77,7 @@
         assertFalse("not exists", f1.exists());
         
         try {
-            createFHandler.execute(new CreateFolder(sFolder), null);
+            createFolderHandler.execute(new CreateFolder(sFolder), null);
             Folder f = store.getFolder(sFolder.getFullName());
             assertTrue("exists", f.exists());
             assertFalse("Not opened", f.isOpen());
@@ -87,7 +87,7 @@
             Message[] msgs = f.getMessages();
             assertEquals(0, msgs.length);
             
-            deleteFHandler.execute(new DeleteFolder(sFolder), null);
+            deleteFolderHandler.execute(new DeleteFolder(sFolder), null);
             f = store.getFolder(sFolder.getFullName());
             assertFalse("not exists",f.exists());
 

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorageTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorageTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorageTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorageTest.java Sun Feb 14 10:26:52 2010
@@ -5,7 +5,7 @@
 import com.sun.mail.imap.IMAPStore;
 
 import org.apache.hupa.server.HupaGuiceTestCase;
-import org.apache.hupa.server.guice.GuiceTestModule;
+import org.apache.hupa.server.guice.GuiceServerTestModule;
 import org.apache.hupa.server.utils.SessionUtils;
 import org.apache.hupa.server.utils.TestUtils;
 import org.apache.hupa.shared.data.IMAPFolder;
@@ -29,7 +29,7 @@
      *   - Be sure the user and password are set correctly
      *   - Comment the delay
      */
-    static class MyModule extends GuiceTestModule {
+    static class MyModule extends GuiceServerTestModule {
         public MyModule() {
             // properties = courierProperties;
             // properties = gmailProperties;
@@ -49,6 +49,7 @@
      * Delete contacts from session and all messages in user's dratfs folder
      */
     public void setUp() throws Exception {
+        super.setUp();
         httpSession.removeAttribute(InImapUserPreferencesStorage.CONTACTS_ATTR);
         Folder f = storeCache.get(testUser).getFolder(testUser.getSettings().getDraftsFolderName());
         if (f.exists() && f.getMessageCount() > 0) {
@@ -143,7 +144,7 @@
         smtpmsg.setCc(new ArrayList<String>());
         smtpmsg.setBcc(new ArrayList<String>());
         SendMessage action = new SendMessage(smtpmsg);
-        abstSendMsgHndl.execute(action, null);
+        sendMessageHandler.execute(action, null);
 
         // The email has to be added to the contact list 
         assertEquals(1, userPreferences.getContacts().length);

Modified: james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InSessionUserPreferencesStorageTest.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InSessionUserPreferencesStorageTest.java?rev=909996&r1=909995&r2=909996&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InSessionUserPreferencesStorageTest.java (original)
+++ james/hupa/trunk/server/src/test/java/org/apache/hupa/server/preferences/InSessionUserPreferencesStorageTest.java Sun Feb 14 10:26:52 2010
@@ -15,6 +15,7 @@
 public class InSessionUserPreferencesStorageTest extends HupaGuiceTestCase {
 
     public void setUp() throws Exception {
+        super.setUp();
         httpSession.removeAttribute(InImapUserPreferencesStorage.CONTACTS_ATTR);
     }
     
@@ -36,7 +37,7 @@
         
         SMTPMessage smtpmsg = TestUtils.createMockSMTPMessage(SessionUtils.getSessionRegistry(logger, httpSession), 2);
         SendMessage action = new SendMessage(smtpmsg);
-        abstSendMsgHndl.execute(action, null);
+        sendMessageHandler.execute(action, null);
         
         assertEquals(3, userPreferences.getContacts().length);
     }    



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message