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/04/22 10:33:13 UTC
[05/13] james-project git commit: JAMES-1717 Test vacation endpoints
JAMES-1717 Test vacation endpoints
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5619dbcd
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5619dbcd
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5619dbcd
Branch: refs/heads/master
Commit: 5619dbcd5ac06d942ded3d3d6c60213979e9d379
Parents: 847a81e
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Apr 19 11:19:35 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Apr 22 15:28:59 2016 +0700
----------------------------------------------------------------------
.../CassandraGetVacationResponseTest.java | 54 ++++++++++++
.../CassandraSetVacationResponseTest.java | 54 ++++++++++++
.../integration/GetVacationResponseTest.java | 88 ++++++++++++++++++
.../integration/SetVacationResponseTest.java | 93 ++++++++++++++++++++
.../MemoryGetVacationResponseMethodTest.java | 44 +++++++++
.../MemorySetVacationResponseMethodTest.java | 44 +++++++++
6 files changed, 377 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
new file mode 100644
index 0000000..717e8aa
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.GetVacationResponseTest;
+import org.apache.james.modules.CassandraJmapServerModule;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+public class CassandraGetVacationResponseTest extends GetVacationResponseTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(CassandraJamesServerMain.cassandraId)
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+ @Override
+ protected void await() {
+ embeddedElasticSearch.awaitForElasticSearch();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java
new file mode 100644
index 0000000..dc5e4a0
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.SetVacationResponseTest;
+import org.apache.james.modules.CassandraJmapServerModule;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+public class CassandraSetVacationResponseTest extends SetVacationResponseTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(CassandraJamesServerMain.cassandraId)
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+ @Override
+ protected void await() {
+ embeddedElasticSearch.awaitForElasticSearch();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
new file mode 100644
index 0000000..32190db
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.equalTo;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class GetVacationResponseTest {
+
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+ private static final String USERS_DOMAIN = "domain.tld";
+ public static final String USER = "username@" + USERS_DOMAIN;
+ public static final String PASSWORD = "password";
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ protected abstract void await();
+
+ private AccessToken accessToken;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ jmapServer.serverProbe().addDomain(USERS_DOMAIN);
+ jmapServer.serverProbe().addUser(USER, PASSWORD);
+ accessToken = JmapAuthentication.authenticateJamesUser(USER, PASSWORD);
+
+ await();
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void getVacationResponseIsNotImplementedYet() {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getVacationResponse\", {\"accountId\": \"1\"}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
new file mode 100644
index 0000000..5a77c55
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
@@ -0,0 +1,93 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.equalTo;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class SetVacationResponseTest {
+
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+ private static final String USERS_DOMAIN = "domain.tld";
+ public static final String USER = "username@" + USERS_DOMAIN;
+ public static final String PASSWORD = "password";
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ protected abstract void await();
+
+ private AccessToken accessToken;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ jmapServer.serverProbe().addDomain(USERS_DOMAIN);
+ jmapServer.serverProbe().addUser(USER, PASSWORD);
+ accessToken = JmapAuthentication.authenticateJamesUser(USER, PASSWORD);
+
+ await();
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void setVacationResponseIsNotImplementedYet() {
+ String bodyRequest = "[[\"setVacationResponse\", " +
+ "{\"accountId\": \"1\", " +
+ "\"update\":{\"idVacation\" : {" +
+ "\"id\": \"1\"," +
+ "\"isEnabled\": \"true\"," +
+ "\"textBody\": \"Message explaining my wonderful vacations\"" +
+ "}}}, \"#0\"]]";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(bodyRequest)
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
new file mode 100644
index 0000000..b0356bb
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.GetVacationResponseTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class MemoryGetVacationResponseMethodTest extends GetVacationResponseTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(MemoryJamesServerMain.inMemoryId)
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+ @Override
+ protected void await() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5619dbcd/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetVacationResponseMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetVacationResponseMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetVacationResponseMethodTest.java
new file mode 100644
index 0000000..3f42f7e
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetVacationResponseMethodTest.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.SetVacationResponseTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class MemorySetVacationResponseMethodTest extends SetVacationResponseTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(MemoryJamesServerMain.inMemoryId)
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+ @Override
+ protected void await() {
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org