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 2017/12/18 06:17:10 UTC
[1/3] james-project git commit: JAMES-2259 Add minimal integration
test regarding MODSEQ search
Repository: james-project
Updated Branches:
refs/heads/master a7959458f -> 8d5c53b12
JAMES-2259 Add minimal integration test regarding MODSEQ search
These tests are hard to write with MPT as we can not access the MODSEQ value. Hence I believe a minimum strategy can be adopted:
- Pick a very high modseq
- Ensure nothing is returned.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8d5c53b1
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8d5c53b1
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8d5c53b1
Branch: refs/heads/master
Commit: 8d5c53b123a3e6e1248d42052a042b4ba01f1ec9
Parents: 452e1a1
Author: benwa <bt...@linagora.com>
Authored: Fri Dec 15 11:07:06 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Dec 18 13:16:21 2017 +0700
----------------------------------------------------------------------
.../org/apache/james/imap/scripts/SearchAtoms.test | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8d5c53b1/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/SearchAtoms.test
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/SearchAtoms.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/SearchAtoms.test
index 1ce099c..99374eb 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/SearchAtoms.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/SearchAtoms.test
@@ -1916,5 +1916,12 @@ S: A148 OK SEARCH completed\.
C: A149 SEARCH UNSEEN
S: \* SEARCH 3 4 8 9 13 14 18 19
S: A149 OK SEARCH completed\.
-C: A150 DELETE testmailbox
-S: A150 OK DELETE completed\.
+
+C: A150 SEARCH MODSEQ 150000
+S: \* OK \[HIGHESTMODSEQ .*\] Highest
+S: \* SEARCH
+S: A150 OK SEARCH completed\.
+# We expect no modseq to be over 1500, hence we expect an empty result.
+
+C: A151 DELETE testmailbox
+S: A151 OK DELETE completed\.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/3] james-project git commit: JAMES-2259 SearchKey should match
bean contract
Posted by bt...@apache.org.
JAMES-2259 SearchKey should match bean contract
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1695b0a2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1695b0a2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1695b0a2
Branch: refs/heads/master
Commit: 1695b0a2a75161fa043f8158c7bc71d22a4d3c6f
Parents: a795945
Author: benwa <bt...@linagora.com>
Authored: Fri Dec 15 10:46:08 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Dec 18 13:16:21 2017 +0700
----------------------------------------------------------------------
.../imap/api/message/request/SearchKey.java | 75 ++++++--------------
.../imap/api/message/request/SearchKeyTest.java | 32 +++++++++
2 files changed, 54 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/1695b0a2/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java b/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
index 374efba..810817a 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
@@ -22,6 +22,7 @@ package org.apache.james.imap.api.message.request;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import org.apache.james.imap.api.message.IdRange;
@@ -455,62 +456,30 @@ public final class SearchKey {
public long getModSeq() {
return modSeq;
}
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((date == null) ? 0 : date.hashCode());
- result = PRIME * result + ((name == null) ? 0 : name.hashCode());
- if (sequence != null) {
- result = PRIME * result + sequence.length;
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof SearchKey) {
+ SearchKey searchKey = (SearchKey) o;
+
+ return Objects.equals(this.type, searchKey.type)
+ && Objects.equals(this.size, searchKey.size)
+ && Objects.equals(this.seconds, searchKey.seconds)
+ && Objects.equals(this.modSeq, searchKey.modSeq)
+ && Objects.equals(this.date, searchKey.date)
+ && Objects.equals(this.keys, searchKey.keys)
+ && Objects.equals(this.name, searchKey.name)
+ && Objects.equals(this.value, searchKey.value)
+ && Arrays.equals(this.sequence, searchKey.sequence)
+ && Arrays.equals(this.uids, searchKey.uids);
}
- result = PRIME * result + (int) (size ^ (size >>> 32));
- result = PRIME * result + ((keys == null) ? 0 : keys.hashCode());
- result = PRIME * result + type;
- result = PRIME * result + ((value == null) ? 0 : value.hashCode());
- return result;
+ return false;
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final SearchKey other = (SearchKey) obj;
- if (date == null) {
- if (other.date != null)
- return false;
- } else if (!date.equals(other.date))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (!Arrays.equals(sequence, other.sequence))
- return false;
- if (size != other.size)
- return false;
- if (keys == null) {
- if (other.keys != null)
- return false;
- } else if (!keys.equals(other.keys))
- return false;
- if (type != other.type)
- return false;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
+ @Override
+ public final int hashCode() {
+ return Objects.hash(type, date, keys, size, name, value,
+ Arrays.hashCode(sequence), Arrays.hashCode(uids), seconds, modSeq);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/1695b0a2/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java b/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
new file mode 100644
index 0000000..6ea9da7
--- /dev/null
+++ b/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.imap.api.message.request;
+
+import org.junit.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class SearchKeyTest {
+ @Test
+ public void shouldMatchBeanContract() {
+ EqualsVerifier.forClass(SearchKey.class)
+ .verify();
+ }
+}
\ 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
[2/3] james-project git commit: JAMES-2259 Correct search key for
modseq in IMAP protocol
Posted by bt...@apache.org.
JAMES-2259 Correct search key for modseq in IMAP protocol
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/452e1a1a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/452e1a1a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/452e1a1a
Branch: refs/heads/master
Commit: 452e1a1a84348d35d7443bc725e407573e1bacfa
Parents: 1695b0a
Author: Pedro Henrique Lopes Martins <pe...@wit-software.com>
Authored: Thu Dec 14 11:10:24 2017 +0000
Committer: benwa <bt...@linagora.com>
Committed: Mon Dec 18 13:16:21 2017 +0700
----------------------------------------------------------------------
.../apache/james/imap/api/message/request/SearchKey.java | 4 ++--
.../james/imap/api/message/request/SearchKeyTest.java | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/452e1a1a/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java b/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
index 810817a..a476a5d 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
@@ -330,7 +330,7 @@ public final class SearchKey {
}
public static SearchKey buildModSeq(long modSeq) {
- return new SearchKey(TYPE_ANSWERED, null, null, 0, null, null, null, null, -1, modSeq);
+ return new SearchKey(TYPE_MODSEQ, null, null, 0, null, null, null, null, -1, modSeq);
}
private final int type;
@@ -496,4 +496,4 @@ public final class SearchKey {
.add("keys", Optional.ofNullable(keys).map(ImmutableList::copyOf))
.toString();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/452e1a1a/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java b/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
index 6ea9da7..9630f7b 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/api/message/request/SearchKeyTest.java
@@ -19,6 +19,8 @@
package org.apache.james.imap.api.message.request;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -29,4 +31,11 @@ public class SearchKeyTest {
EqualsVerifier.forClass(SearchKey.class)
.verify();
}
+
+ @Test
+ public void modSeqSearchKeyShouldBeOfTypeModSeq() {
+ SearchKey searchKey = SearchKey.buildModSeq(36);
+
+ assertThat(searchKey.getType()).isEqualTo(SearchKey.TYPE_MODSEQ);
+ }
}
\ 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