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 bt...@apache.org on 2016/03/24 06:46:50 UTC
[1/7] james-project git commit: JAMES-1704 junit,
assertj and hamcrest are needed to play Memory Guice tests
Repository: james-project
Updated Branches:
refs/heads/master f89a2abd2 -> 4e92aefcc
JAMES-1704 junit, assertj and hamcrest are needed to play Memory Guice tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f1f50560
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f1f50560
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f1f50560
Branch: refs/heads/master
Commit: f1f505608e658eaf82881b986830a91c21d2345e
Parents: f89a2ab
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Mar 24 11:41:43 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 11:42:18 2016 +0700
----------------------------------------------------------------------
.../memory-jmap-integration-testing/pom.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f1f50560/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index e6d15cc..6404f9c 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -170,6 +170,22 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[7/7] james-project git commit: JAMES-1704 InMemory should support
user flags operation
Posted by bt...@apache.org.
JAMES-1704 InMemory should support user flags operation
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4e92aefc
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4e92aefc
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4e92aefc
Branch: refs/heads/master
Commit: 4e92aefccb24badcb187e30d1cf35cf392e50942
Parents: f1b3318
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Mar 24 09:57:20 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:34 2016 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/MailboxManager.java | 3 +-
.../cassandra/CassandraMailboxManager.java | 2 +-
.../inmemory/InMemoryMailboxManager.java | 19 ++++++++++++-
.../inmemory/InMemoryMessageManager.java | 30 ++++++++++++++++++++
4 files changed, 51 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e92aefc/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index 22cad9d..1375d1d 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -71,7 +71,8 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport {
enum Capabilities {
Basic,
- Move
+ Move,
+ UserFlags
}
List<Capabilities> getSupportedCapabilities();
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e92aefc/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
index 369a928..d404a76 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
@@ -65,7 +65,7 @@ public class CassandraMailboxManager extends StoreMailboxManager<CassandraId> {
@Override
public List<Capabilities> getSupportedCapabilities() {
- return Lists.newArrayList(Capabilities.Basic, Capabilities.Move);
+ return Lists.newArrayList(Capabilities.Basic, Capabilities.Move, Capabilities.UserFlags);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e92aefc/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index a1683c9..c8cf946 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -23,11 +23,15 @@ import java.util.List;
import javax.inject.Inject;
import org.apache.james.mailbox.MailboxPathLocker;
+import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMailboxManager;
+import org.apache.james.mailbox.store.StoreMessageManager;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
import com.google.common.collect.Lists;
@@ -40,6 +44,19 @@ public class InMemoryMailboxManager extends StoreMailboxManager<InMemoryId> {
@Override
public List<Capabilities> getSupportedCapabilities() {
- return Lists.newArrayList(Capabilities.Basic, Capabilities.Move);
+ return Lists.newArrayList(Capabilities.Basic, Capabilities.Move, Capabilities.UserFlags);
+ }
+
+ @Override
+ protected StoreMessageManager<InMemoryId> createMessageManager(Mailbox<InMemoryId> mailbox, MailboxSession session) throws MailboxException {
+ return new InMemoryMessageManager(getMapperFactory(),
+ getMessageSearchIndex(),
+ getEventDispatcher(),
+ getLocker(),
+ mailbox,
+ getAclResolver(),
+ getGroupMembershipResolver(),
+ getQuotaManager(),
+ getQuotaRootResolver());
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e92aefc/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageManager.java
new file mode 100644
index 0000000..101ca55
--- /dev/null
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageManager.java
@@ -0,0 +1,30 @@
+package org.apache.james.mailbox.inmemory;
+
+import javax.mail.Flags;
+
+import org.apache.james.mailbox.MailboxPathLocker;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.StoreMessageManager;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
+import org.apache.james.mailbox.store.mail.MessageMapperFactory;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.search.MessageSearchIndex;
+
+public class InMemoryMessageManager extends StoreMessageManager<InMemoryId> {
+
+ public InMemoryMessageManager(MessageMapperFactory<InMemoryId> mapperFactory, MessageSearchIndex<InMemoryId> index, MailboxEventDispatcher<InMemoryId> dispatcher, MailboxPathLocker locker, Mailbox<InMemoryId> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver) throws MailboxException {
+ super(mapperFactory, index, dispatcher, locker, mailbox, aclResolver, groupMembershipResolver, quotaManager, quotaRootResolver);
+ }
+
+ @Override
+ protected Flags getPermanentFlags(MailboxSession session) {
+ Flags permanentFlags = new Flags(super.getPermanentFlags(session));
+ permanentFlags.add(Flags.Flag.USER);
+ return permanentFlags;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/7] james-project git commit: JAMES-1704 InMemoryMailboxMapper
should validate mapper unit tests
Posted by bt...@apache.org.
JAMES-1704 InMemoryMailboxMapper should validate mapper unit tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5a21b6b2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5a21b6b2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5a21b6b2
Branch: refs/heads/master
Commit: 5a21b6b224d36d0cbbbfa08073d802bc64e9e034
Parents: f1f5056
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Mar 11 13:46:11 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:21 2016 +0700
----------------------------------------------------------------------
.../inmemory/mail/InMemoryMailboxMapper.java | 18 ++++++++----
.../mail/InMemoryMailboxMapperTest.java | 30 ++++++++++++++++++++
2 files changed, 42 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5a21b6b2/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
index 7dc9a19..17dd2f4 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
@@ -33,6 +33,8 @@ import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
+import com.google.common.base.Objects;
+
public class InMemoryMailboxMapper implements MailboxMapper<InMemoryId> {
private static final int INITIAL_SIZE = 128;
@@ -57,7 +59,7 @@ public class InMemoryMailboxMapper implements MailboxMapper<InMemoryId> {
/**
* @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByPath(org.apache.james.mailbox.model.MailboxPath)
*/
- public synchronized Mailbox<InMemoryId> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
+ public synchronized Mailbox<InMemoryId> findMailboxByPath(MailboxPath path) throws MailboxException {
Mailbox<InMemoryId> result = null;
for (Mailbox<InMemoryId> mailbox:mailboxesById.values()) {
MailboxPath mp = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
@@ -88,8 +90,8 @@ public class InMemoryMailboxMapper implements MailboxMapper<InMemoryId> {
}
private boolean mailboxMatchesRegex(Mailbox<InMemoryId> mailbox, MailboxPath path, String regex) {
- return mailbox.getNamespace().equals(path.getNamespace())
- && mailbox.getUser().equals(path.getUser())
+ return Objects.equal(mailbox.getNamespace(), path.getNamespace())
+ && Objects.equal(mailbox.getUser(), path.getUser())
&& mailbox.getName().matches(regex);
}
@@ -115,17 +117,21 @@ public class InMemoryMailboxMapper implements MailboxMapper<InMemoryId> {
/**
* @see org.apache.james.mailbox.store.mail.MailboxMapper#hasChildren(org.apache.james.mailbox.store.mail.model.Mailbox, char)
*/
- public boolean hasChildren(Mailbox<InMemoryId> mailbox, char delimiter) throws MailboxException,
- MailboxNotFoundException {
+ public boolean hasChildren(Mailbox<InMemoryId> mailbox, char delimiter) throws MailboxException {
String mailboxName = mailbox.getName() + delimiter;
for (Mailbox<InMemoryId> box:mailboxesById.values()) {
- if (box.getName().startsWith(mailboxName)) {
+ if (belongsToSameUser(mailbox, box) && box.getName().startsWith(mailboxName)) {
return true;
}
}
return false;
}
+ private boolean belongsToSameUser(Mailbox<InMemoryId> mailbox, Mailbox<InMemoryId> otherMailbox) {
+ return Objects.equal(mailbox.getNamespace(), otherMailbox.getNamespace())
+ && Objects.equal(mailbox.getUser(), otherMailbox.getUser());
+ }
+
/**
* @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
*/
http://git-wip-us.apache.org/repos/asf/james-project/blob/5a21b6b2/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
new file mode 100644
index 0000000..fc1711d
--- /dev/null
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.james.mailbox.inmemory.mail;
+
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.store.mail.model.AbstractMailboxMapperTest;
+
+public class InMemoryMailboxMapperTest extends AbstractMailboxMapperTest<InMemoryId> {
+
+ public InMemoryMailboxMapperTest() {
+ super(new InMemoryMapperProvider());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[6/7] james-project git commit: JAMES-1704 Add elasticsearch to java
8 build profiles
Posted by bt...@apache.org.
JAMES-1704 Add elasticsearch to java 8 build profiles
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f1b33189
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f1b33189
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f1b33189
Branch: refs/heads/master
Commit: f1b33189c5b97d949f78a399090d57a08c9dd986
Parents: aae4a09
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Mar 11 14:41:26 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:33 2016 +0700
----------------------------------------------------------------------
dockerfiles/compilation/java-8/compile.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f1b33189/dockerfiles/compilation/java-8/compile.sh
----------------------------------------------------------------------
diff --git a/dockerfiles/compilation/java-8/compile.sh b/dockerfiles/compilation/java-8/compile.sh
index c7d8733..a9f6da2 100755
--- a/dockerfiles/compilation/java-8/compile.sh
+++ b/dockerfiles/compilation/java-8/compile.sh
@@ -44,9 +44,9 @@ git checkout $SHA1
# Compilation
if [ "$SKIPTESTS" = "skipTests" ]; then
- mvn package -DskipTests -Pcassandra,inmemory,exclude-lucene,with-assembly,with-jetm
+ mvn package -DskipTests -Pcassandra,elasticsearch,inmemory,exclude-lucene,with-assembly,with-jetm
else
- mvn package -Pcassandra,inmemory,exclude-lucene,with-assembly,with-jetm
+ mvn package -Pcassandra,inmemory,elasticsearch,exclude-lucene,with-assembly,with-jetm
fi
# Retrieve result
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[5/7] james-project git commit: JAMES-1704 Add inmemory to java 8
build profiles
Posted by bt...@apache.org.
JAMES-1704 Add inmemory to java 8 build profiles
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/aae4a09e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/aae4a09e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/aae4a09e
Branch: refs/heads/master
Commit: aae4a09e3a7748ef4e0b4da6717218b2f5719595
Parents: a435f4e
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Mar 11 14:36:36 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:33 2016 +0700
----------------------------------------------------------------------
dockerfiles/compilation/java-8/compile.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/aae4a09e/dockerfiles/compilation/java-8/compile.sh
----------------------------------------------------------------------
diff --git a/dockerfiles/compilation/java-8/compile.sh b/dockerfiles/compilation/java-8/compile.sh
index 696f4db..c7d8733 100755
--- a/dockerfiles/compilation/java-8/compile.sh
+++ b/dockerfiles/compilation/java-8/compile.sh
@@ -44,9 +44,9 @@ git checkout $SHA1
# Compilation
if [ "$SKIPTESTS" = "skipTests" ]; then
- mvn package -DskipTests -Pcassandra,exclude-lucene,with-assembly,with-jetm
+ mvn package -DskipTests -Pcassandra,inmemory,exclude-lucene,with-assembly,with-jetm
else
- mvn package -Pcassandra,exclude-lucene,with-assembly,with-jetm
+ mvn package -Pcassandra,inmemory,exclude-lucene,with-assembly,with-jetm
fi
# Retrieve result
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/7] james-project git commit: JAMES-1704 SimpleMailboxMessage
should have textualLineCount well copied
Posted by bt...@apache.org.
JAMES-1704 SimpleMailboxMessage should have textualLineCount well copied
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7fb157bc
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7fb157bc
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7fb157bc
Branch: refs/heads/master
Commit: 7fb157bc78a2d4d2cde0ca4492dedd99b45b2772
Parents: 5a21b6b
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Mar 11 14:30:14 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:25 2016 +0700
----------------------------------------------------------------------
.../mail/model/impl/SimpleMailboxMessage.java | 1 +
.../model/impl/SimpleMailboxMessageTest.java | 58 ++++++++++++--------
2 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/7fb157bc/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
index ee15e79..0ae7aee 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
@@ -44,6 +44,7 @@ public class SimpleMailboxMessage<Id extends MailboxId> extends DelegatingMailbo
SharedByteArrayInputStream content = copyFullContent(original);
int bodyStartOctet = Ints.checkedCast(original.getFullContentOctets() - original.getBodyOctets());
PropertyBuilder pBuilder = new PropertyBuilder(original.getProperties());
+ pBuilder.setTextualLineCount(original.getTextualLineCount());
return new SimpleMailboxMessage<Id>(internalDate, size, bodyStartOctet, content, flags, pBuilder, mailboxId);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7fb157bc/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
index cabf6bf..17761a3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
@@ -19,18 +19,17 @@
package org.apache.james.mailbox.store.mail.model.impl;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Calendar;
+import java.util.Date;
import javax.mail.Flags;
import javax.mail.util.SharedByteArrayInputStream;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.james.mailbox.FlagsBuilder;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.store.TestId;
@@ -42,6 +41,8 @@ public class SimpleMailboxMessageTest {
private static final Charset MESSAGE_CHARSET = Charset.forName("UTF-8");
private static final String MESSAGE_CONTENT = "Simple message content without special characters";
private static final String MESSAGE_CONTENT_SPECIAL_CHAR = "Simple message content with special characters: \"'(§è!çà$*`";
+ public static final TestId TEST_ID = TestId.of(1L);
+ public static final int BODY_START_OCTET = 0;
private SimpleMailboxMessage<TestId> MESSAGE;
private SimpleMailboxMessage<TestId> MESSAGE_SPECIAL_CHAR;
@@ -53,35 +54,27 @@ public class SimpleMailboxMessageTest {
@Test
public void testSize() {
- assertEquals(MESSAGE_CONTENT.length(), MESSAGE.getFullContentOctets());
+ assertThat(MESSAGE.getFullContentOctets()).isEqualTo(MESSAGE_CONTENT.length());
}
@Test
public void testInputStreamSize() throws IOException {
- InputStream is = MESSAGE.getFullContent();
- int byteCount = 0;
- while (is.read() != -1) {
- byteCount++;
- }
- assertEquals(MESSAGE_CONTENT.length(), byteCount);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ byteArrayOutputStream.write(MESSAGE.getFullContent());
+ assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT.getBytes().length);
}
@Test
public void testInputStreamSizeSpecialCharacters() throws IOException {
- InputStream is = MESSAGE_SPECIAL_CHAR.getFullContent();
- int byteCount = 0;
- while (is.read() != -1) {
- byteCount++;
- }
- assertFalse(MESSAGE_CONTENT_SPECIAL_CHAR.length() == byteCount);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ byteArrayOutputStream.write(MESSAGE_SPECIAL_CHAR.getFullContent());
+ assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR.getBytes().length);
}
@Test
public void testFullContent() throws IOException {
- assertEquals(MESSAGE_CONTENT,
- new String(IOUtils.toByteArray(MESSAGE.getFullContent()),MESSAGE_CHARSET));
- assertEquals(MESSAGE_CONTENT_SPECIAL_CHAR,
- new String(IOUtils.toByteArray(MESSAGE_SPECIAL_CHAR.getFullContent()),MESSAGE_CHARSET));
+ assertThat(new String(IOUtils.toByteArray(MESSAGE.getFullContent()),MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT);
+ assertThat(new String(IOUtils.toByteArray(MESSAGE_SPECIAL_CHAR.getFullContent()),MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR);
}
@Test
@@ -92,17 +85,36 @@ public class SimpleMailboxMessageTest {
@Test
public void copyShouldReturnFieldByFieldEqualsObject() throws MailboxException {
- SimpleMailboxMessage<TestId> original = buildMessage("my content");
+ long textualLineCount = 42L;
+ String text = "text";
+ String plain = "plain";
+ PropertyBuilder propertyBuilder = new PropertyBuilder();
+ propertyBuilder.setTextualLineCount(textualLineCount);
+ propertyBuilder.setMediaType(text);
+ propertyBuilder.setSubType(plain);
+ SimpleMailboxMessage<TestId> original = new SimpleMailboxMessage<TestId>(new Date(),
+ MESSAGE_CONTENT.length(),
+ BODY_START_OCTET,
+ new SharedByteArrayInputStream(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET)),
+ new Flags(),
+ propertyBuilder,
+ TEST_ID);
+
SimpleMailboxMessage<TestId> copy = SimpleMailboxMessage.copy(TestId.of(1337), original);
+
assertThat((Object)copy).isEqualToIgnoringGivenFields(original, "message", "mailboxId").isNotSameAs(original);
assertThat(copy.getMessage()).usingComparator(new FieldByFieldComparator()).isEqualTo(original.getMessage());
+ assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getTextualLineCount()).isEqualTo(textualLineCount);
+ assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getMediaType()).isEqualTo(text);
+ assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getSubType()).isEqualTo(plain);
+
}
private static SimpleMailboxMessage<TestId> buildMessage(String content) {
return new SimpleMailboxMessage<TestId>(Calendar.getInstance().getTime(),
- content.length(), 0, new SharedByteArrayInputStream(
+ content.length(), BODY_START_OCTET, new SharedByteArrayInputStream(
content.getBytes(MESSAGE_CHARSET)), new Flags(),
- new PropertyBuilder(), TestId.of(1L));
+ new PropertyBuilder(), TEST_ID);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[4/7] james-project git commit: JAMES-1704 InMemoryMessageMapper
should succeed unit tests
Posted by bt...@apache.org.
JAMES-1704 InMemoryMessageMapper should succeed unit tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a435f4e8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a435f4e8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a435f4e8
Branch: refs/heads/master
Commit: a435f4e8de988de500debd3e405a26da9a416177
Parents: 7fb157b
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Mar 11 14:31:34 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Mar 24 12:44:29 2016 +0700
----------------------------------------------------------------------
.../inmemory/mail/InMemoryMessageMapper.java | 2 +-
.../mail/InMemoryMessageMapperTest.java | 30 +++++++++++++++
.../mail/model/AbstractMessageMapperTest.java | 12 +++++-
.../mailbox/store/mail/model/MessageAssert.java | 39 ++++++++++----------
4 files changed, 61 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/a435f4e8/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
index 1986946..931d399 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
@@ -148,7 +148,7 @@ public class InMemoryMessageMapper extends AbstractMessageMapper<InMemoryId> {
Collections.sort(results);
if (max > 0 && results.size() > max) {
- results = results.subList(0, max - 1);
+ results = results.subList(0, max);
}
return results.iterator();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a435f4e8/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
new file mode 100644
index 0000000..6d70e8f
--- /dev/null
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.james.mailbox.inmemory.mail;
+
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.store.mail.model.AbstractMessageMapperTest;
+
+public class InMemoryMessageMapperTest extends AbstractMessageMapperTest<InMemoryId> {
+
+ public InMemoryMessageMapperTest() {
+ super(new InMemoryMapperProvider());
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a435f4e8/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
index 3198507..30e261d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
@@ -442,8 +442,16 @@ public abstract class AbstractMessageMapperTest<Id extends MailboxId> {
MailboxMessage<Id> message7 = SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6);
messageMapper.copy(benwaInboxMailbox, message7);
message7.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
- MessageAssert.assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message7.getUid()), MessageMapper.FetchType.Full, LIMIT).next())
- .isEqualTo(message7, MessageMapper.FetchType.Full);
+ assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isGreaterThan(message6.getUid());
+
+ MailboxMessage result = messageMapper.findInMailbox(benwaInboxMailbox,
+ MessageRange.one(messageMapper.getLastUid(benwaInboxMailbox)),
+ MessageMapper.FetchType.Full,
+ LIMIT)
+ .next();
+
+ MessageAssert.assertThat(result).isEqualToWithoutUid(message7, MessageMapper.FetchType.Full);
+ assertThat(result.getUid()).isEqualTo(messageMapper.getLastUid(benwaInboxMailbox));
}
@Test
http://git-wip-us.apache.org/repos/asf/james-project/blob/a435f4e8/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssert.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssert.java
index 7b0ddc0..1135763 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssert.java
@@ -26,6 +26,8 @@ import org.assertj.core.api.AbstractAssert;
import javax.mail.Flags;
import java.io.IOException;
+import com.google.common.base.Objects;
+
public class MessageAssert extends AbstractAssert<MessageAssert, MailboxMessage<?>> {
public MessageAssert(MailboxMessage<?> actual) {
@@ -36,47 +38,52 @@ public class MessageAssert extends AbstractAssert<MessageAssert, MailboxMessage<
return new MessageAssert(actual);
}
- public MessageAssert isEqualTo(MailboxMessage<?> expected, MessageMapper.FetchType usedFetchType) throws IOException {
+ public MessageAssert isEqualToWithoutUid(MailboxMessage<?> expected, MessageMapper.FetchType usedFetchType) throws IOException {
isNotNull();
- if (!equals(actual.getMailboxId(), expected.getMailboxId())) {
+ if (!Objects.equal(actual.getMailboxId(), expected.getMailboxId())) {
failWithMessage("Expected Mailbox ID to be <%s> but was <%s>", expected.getMailboxId().toString(), actual.getMailboxId().toString());
}
- if (!equals(actual.getUid(), expected.getUid())) {
- failWithMessage("Expected UID to be <%s> but was <%s>", expected.getUid(), actual.getUid());
- }
- if (!equals(actual.getInternalDate(), expected.getInternalDate())) {
+ if (!Objects.equal(actual.getInternalDate(), expected.getInternalDate())) {
failWithMessage("Expected Internal Date to be <%s> but was <%s>", expected.getInternalDate(), actual.getInternalDate());
}
- if (!equals(actual.getBodyOctets(), expected.getBodyOctets())) {
+ if (!Objects.equal(actual.getBodyOctets(), expected.getBodyOctets())) {
failWithMessage("Expected Body octet to be <%s> but was <%s>", expected.getBodyOctets(), actual.getBodyOctets());
}
- if (!equals(actual.getMediaType(), expected.getMediaType())) {
+ if (!Objects.equal(actual.getMediaType(), expected.getMediaType())) {
failWithMessage("Expected Media type to be <%s> but was <%s>", expected.getBodyOctets(), actual.getBodyOctets());
}
- if (!equals(actual.getSubType(), expected.getSubType())) {
+ if (!Objects.equal(actual.getSubType(), expected.getSubType())) {
failWithMessage("Expected Sub type to be <%s> but was <%s>", expected.getBodyOctets(), actual.getBodyOctets());
}
if (usedFetchType == MessageMapper.FetchType.Full) {
- if (!equals(actual.getFullContentOctets(), expected.getFullContentOctets())) {
+ if (!Objects.equal(actual.getFullContentOctets(), expected.getFullContentOctets())) {
failWithMessage("Expected MailboxMessage size to be <%s> but was <%s>", expected.getFullContentOctets(), actual.getFullContentOctets());
}
- if (!equals(IOUtils.toString(actual.getFullContent()), IOUtils.toString(expected.getFullContent()))) {
+ if (!Objects.equal(IOUtils.toString(actual.getFullContent()), IOUtils.toString(expected.getFullContent()))) {
failWithMessage("Expected Full content to be <%s> but was <%s>", IOUtils.toString(actual.getFullContent()), IOUtils.toString(expected.getFullContent()));
}
}
if (usedFetchType == MessageMapper.FetchType.Full || usedFetchType == MessageMapper.FetchType.Headers) {
- if (!equals(IOUtils.toString(actual.getHeaderContent()), IOUtils.toString(expected.getHeaderContent()))) {
+ if (!Objects.equal(IOUtils.toString(actual.getHeaderContent()), IOUtils.toString(expected.getHeaderContent()))) {
failWithMessage("Expected Header content to be <%s> but was <%s>", IOUtils.toString(actual.getHeaderContent()), IOUtils.toString(expected.getHeaderContent()));
}
}
if (usedFetchType == MessageMapper.FetchType.Full || usedFetchType == MessageMapper.FetchType.Body) {
- if (!equals(IOUtils.toString(actual.getBodyContent()), IOUtils.toString(expected.getBodyContent()))) {
+ if (!Objects.equal(IOUtils.toString(actual.getBodyContent()), IOUtils.toString(expected.getBodyContent()))) {
failWithMessage("Expected Body content to be <%s> but was <%s>", IOUtils.toString(actual.getBodyContent()), IOUtils.toString(expected.getBodyContent()));
}
}
return this;
}
+ public MessageAssert isEqualTo(MailboxMessage<?> expected, MessageMapper.FetchType usedFetchType) throws IOException {
+ isNotNull();
+ if (!Objects.equal(actual.getUid(), expected.getUid())) {
+ failWithMessage("Expected UID to be <%s> but was <%s>", expected.getUid(), actual.getUid());
+ }
+ return isEqualToWithoutUid(expected, usedFetchType);
+ }
+
public MessageAssert hasFlags(Flags flags) {
if (flags.contains(Flags.Flag.ANSWERED) != actual.isAnswered()) {
failWithMessage("Expected ANSWERED flag to be <%s> but was <%>", flags.contains(Flags.Flag.ANSWERED), actual.isAnswered());
@@ -99,10 +106,4 @@ public class MessageAssert extends AbstractAssert<MessageAssert, MailboxMessage<
return this;
}
- private boolean equals(Object object1, Object object2) {
- if ( object1 == null && object2 == null ) {
- return true;
- }
- return ( object1 != null ) && object1.equals(object2);
- }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org