diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncClient.java
index 913b9fae9f..2249c4d641 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncClient.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncClient.java
@@ -18,10 +18,7 @@
*/
package org.jclouds.glesys;
-import org.jclouds.glesys.features.ArchiveAsyncClient;
-import org.jclouds.glesys.features.DomainAsyncClient;
-import org.jclouds.glesys.features.IpAsyncClient;
-import org.jclouds.glesys.features.ServerAsyncClient;
+import org.jclouds.glesys.features.*;
import org.jclouds.rest.annotations.Delegate;
/**
@@ -58,4 +55,10 @@ public interface GleSYSAsyncClient {
@Delegate
DomainAsyncClient getDomainClient();
+ /**
+ * Provides asynchronous access to E-Mail features.
+ */
+ @Delegate
+ EmailAsyncClient getEmailClient();
+
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSClient.java
index 91b9a6d2d1..65e0d61d46 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSClient.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/GleSYSClient.java
@@ -19,10 +19,7 @@
package org.jclouds.glesys;
import org.jclouds.concurrent.Timeout;
-import org.jclouds.glesys.features.ArchiveClient;
-import org.jclouds.glesys.features.DomainClient;
-import org.jclouds.glesys.features.IpClient;
-import org.jclouds.glesys.features.ServerClient;
+import org.jclouds.glesys.features.*;
import org.jclouds.rest.annotations.Delegate;
import java.util.concurrent.TimeUnit;
@@ -60,5 +57,12 @@ public interface GleSYSClient {
* Provides synchronous access to DNS features.
*/
@Delegate
- DomainClient getDomainClient();
+ DomainClient getDomainClient();
+
+ /**
+ * Provides synchronous access to E-Mail features.
+ */
+ @Delegate
+ EmailClient getEmailClient();
+
}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
index e9a5879dea..e9d9236104 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
@@ -50,6 +50,7 @@ public class GleSYSRestClientModule extends RestClientModule
+ * @see
*/
public class Archive implements Comparable {
public static Builder builder() {
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java
index 1b77fee3f1..bdee0df871 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java
@@ -27,6 +27,7 @@ import java.util.Date;
* Domain data for a Glesys account.
*
* @author Adam Lowe
+ * @see
*/
public class Domain implements Comparable {
public static Builder builder() {
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java
index 4ee0422e82..86b4fe6487 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java
@@ -24,6 +24,7 @@ import com.google.common.base.Objects;
* DNS record data.
*
* @author Adam Lowe
+ * @see
*/
public class DomainRecord implements Comparable {
public static Builder builder() {
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java
new file mode 100644
index 0000000000..3846c4e197
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java
@@ -0,0 +1,213 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Date;
+
+/**
+ * Detailed information on an Email Account
+ *
+ * @author Adam Lowe
+ * @see
+ */
+public class Email implements Comparable {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String account;
+ private String quota;
+ private String usedQuota;
+ private int antispamLevel;
+ private boolean antiVirus;
+ private boolean autoRespond;
+ private String autoRespondMessage;
+ private boolean autoRespondSaveEmail;
+ private Date created;
+ private Date modified;
+
+ public Builder account(String account) {
+ this.account = account;
+ return this;
+ }
+
+ public Builder quota(String quota) {
+ this.quota = quota;
+ return this;
+ }
+
+ public Builder usedQuota(String usedQuota) {
+ this.usedQuota = usedQuota;
+ return this;
+ }
+
+ public Builder antispamLevel(int antispamLevel) {
+ this.antispamLevel = antispamLevel;
+ return this;
+ }
+
+ public Builder antiVirus(boolean antiVirus) {
+ this.antiVirus = antiVirus;
+ return this;
+ }
+
+ public Builder autoRespond(boolean autoRespond) {
+ this.autoRespond = autoRespond;
+ return this;
+ }
+
+ public Builder autoRespondMessage(String autoRespondMessage) {
+ this.autoRespondMessage = autoRespondMessage;
+ return this;
+ }
+
+ public Builder autoRespondSaveEmail(boolean autoRespondSaveEmail) {
+ this.autoRespondSaveEmail = autoRespondSaveEmail;
+ return this;
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder modified(Date modified) {
+ this.modified = modified;
+ return this;
+ }
+
+ public Email build() {
+ return new Email(account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
+ autoRespondSaveEmail, created, modified);
+ }
+
+ public Builder fromEmail(Email in) {
+ return account(in.getAccount()).quota(in.getQuota()).usedQuota(in.getUsedQuota()).antispamLevel(in.getAntispamLevel()).
+ antiVirus(in.getAntiVirus()).autoRespond(in.getAutoRespond()).autoRespondMessage(in.getAutoRespondMessage()).
+ autoRespondSaveEmail(in.getAutoRespondSaveEmail()).created(in.getCreated()).modified(in.getModified());
+ }
+ }
+
+ @SerializedName("emailaccount")
+ private final String account;
+ private final String quota;
+ @SerializedName("usedquota")
+ private final String usedQuota;
+ @SerializedName("antispamlevel")
+ private final int antispamLevel;
+ @SerializedName("antivirus")
+ private final boolean antiVirus;
+ @SerializedName("autorespond")
+ private final boolean autoRespond;
+ @SerializedName("autorespondmessage")
+ private final String autoRespondMessage;
+ @SerializedName("autorespondsaveemail")
+ private final boolean autoRespondSaveEmail;
+ private final Date created;
+ private final Date modified;
+
+ public Email(String account, String quota, String usedQuota, int antispamLevel, boolean antiVirus, boolean autoRespond, String autoRespondMessage, boolean autoRespondSaveEmail, Date created, Date modified) {
+ this.account = account;
+ this.quota = quota;
+ this.usedQuota = usedQuota;
+ this.antispamLevel = antispamLevel;
+ this.antiVirus = antiVirus;
+ this.autoRespond = autoRespond;
+ this.autoRespondMessage = autoRespondMessage;
+ this.autoRespondSaveEmail = autoRespondSaveEmail;
+ this.created = created;
+ this.modified = modified;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public String getQuota() {
+ return quota;
+ }
+
+ public String getUsedQuota() {
+ return usedQuota;
+ }
+
+ public int getAntispamLevel() {
+ return antispamLevel;
+ }
+
+ public boolean getAntiVirus() {
+ return antiVirus;
+ }
+
+ public boolean getAutoRespond() {
+ return autoRespond;
+ }
+
+ public String getAutoRespondMessage() {
+ return autoRespondMessage;
+ }
+
+ public boolean getAutoRespondSaveEmail() {
+ return autoRespondSaveEmail;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getModified() {
+ return modified;
+ }
+
+ @Override
+ public int compareTo(Email other) {
+ return account.compareTo(other.getAccount());
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof Email) {
+ Email other = (Email) object;
+ return Objects.equal(account, other.account);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(account);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("account=%s, quota=%s, usedquota=%s, antispamLevel=%d, " +
+ "antiVirus=%b, autoRespond=%b, autoRespondMessage=%s, autoRespondSaveEmail=%b, " +
+ "created=%s, modified=%s", account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
+ autoRespondSaveEmail, created.toString(), modified.toString());
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java
new file mode 100644
index 0000000000..5db99d0a22
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java
@@ -0,0 +1,86 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import java.util.Set;
+
+/**
+ * @author Adam Lowe
+ * @see
+ */
+public class EmailOverview {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private EmailOverviewSummary summary;
+ private Set domains;
+
+ public Builder summary(EmailOverviewSummary summary) {
+ this.summary = summary;
+ return this;
+ }
+
+ public Builder domains(Set domains) {
+ this.domains = domains;
+ return this;
+ }
+
+ public Builder domains(EmailOverviewDomain... domains) {
+ return domains(ImmutableSet.copyOf(domains));
+ }
+
+ public EmailOverview build() {
+ return new EmailOverview(summary, domains);
+ }
+
+ public Builder fromEmailOverview(EmailOverview in) {
+ return summary(in.getSummary()).domains(in.getDomains());
+ }
+ }
+
+ private EmailOverviewSummary summary;
+ private Set domains;
+
+ public EmailOverview(EmailOverviewSummary summary, Set domains) {
+ this.summary = summary;
+ this.domains = domains;
+ }
+
+ public EmailOverviewSummary getSummary() {
+ return summary;
+ }
+
+ public Set getDomains() {
+ return domains == null ? ImmutableSet.of() : domains;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(summary, domains);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (object instanceof EmailOverview) {
+ EmailOverview other = (EmailOverview) object;
+ return Objects.equal(summary, other.summary)
+ && Objects.equal(domains, other.domains);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ Joiner commaJoiner = Joiner.on(", ");
+ return String.format("summary=%s, domains=[%s]", summary, commaJoiner.join(getDomains()));
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java
new file mode 100644
index 0000000000..1dbe48523c
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java
@@ -0,0 +1,88 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Objects;
+
+/**
+ * @author Adam Lowe
+ * @see
+ */
+public class EmailOverviewDomain {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String domain;
+ private int accounts;
+ private int aliases;
+
+ public Builder domain(String domain) {
+ this.domain = domain;
+ return this;
+ }
+
+ public Builder accounts(int accounts) {
+ this.accounts = accounts;
+ return this;
+ }
+
+ public Builder aliases(int aliases) {
+ this.aliases = aliases;
+ return this;
+ }
+
+ public EmailOverviewDomain build() {
+ return new EmailOverviewDomain(domain, accounts, aliases);
+ }
+
+ public Builder fromEmailOverview(EmailOverviewDomain in) {
+ return domain(domain).accounts(in.getAccounts()).aliases(in.getAliases());
+ }
+ }
+
+ private final String domain;
+ private final int accounts;
+ private final int aliases;
+
+ public EmailOverviewDomain(String domain, int accounts, int aliases) {
+ this.domain = domain;
+ this.accounts = accounts;
+ this.aliases = aliases;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public int getAccounts() {
+ return accounts;
+ }
+
+ public int getAliases() {
+ return aliases;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(domain);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (object instanceof EmailOverviewDomain) {
+ EmailOverviewDomain other = (EmailOverviewDomain) object;
+ return Objects.equal(domain, other.domain);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("domain=%s, accounts=%d, aliases=%d", domain, accounts, aliases);
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java
new file mode 100644
index 0000000000..9d41458022
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java
@@ -0,0 +1,108 @@
+package org.jclouds.glesys.domain;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * @author Adam Lowe
+ * @see
+ */
+public class EmailOverviewSummary {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private int accounts;
+ private int maxAccounts;
+ private int aliases;
+ private int maxAliases;
+
+ public Builder accounts(int accounts) {
+ this.accounts = accounts;
+ return this;
+ }
+
+ public Builder maxAccounts(int maxAccounts) {
+ this.maxAccounts = maxAccounts;
+ return this;
+ }
+
+ public Builder aliases(int aliases) {
+ this.aliases = aliases;
+ return this;
+ }
+
+ public Builder maxAliases(int maxAliases) {
+ this.maxAliases = maxAliases;
+ return this;
+ }
+
+ public EmailOverviewSummary build() {
+ return new EmailOverviewSummary(accounts, maxAccounts, aliases, maxAliases);
+ }
+
+ public Builder fromEmailOverview(EmailOverviewSummary in) {
+ return accounts(in.getAccounts()).maxAccounts(in.getMaxAccounts()).aliases(in.getAliases()).maxAliases(in.getMaxAliases());
+ }
+ }
+
+ private final int accounts;
+ @SerializedName("maxaccounts")
+ private final int maxAccounts;
+ private final int aliases;
+ @SerializedName("maxaliases")
+ private final int maxAliases;
+
+ public EmailOverviewSummary(int accounts, int maxAccounts, int aliases, int maxAliases) {
+ this.accounts = accounts;
+ this.maxAccounts = maxAccounts;
+ this.aliases = aliases;
+ this.maxAliases = maxAliases;
+ }
+
+ public int getAccounts() {
+ return accounts;
+ }
+
+ public int getMaxAccounts() {
+ return maxAccounts;
+ }
+
+ public int getAliases() {
+ return aliases;
+ }
+
+ public int getMaxAliases() {
+ return maxAliases;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(accounts, maxAccounts, aliases, maxAliases);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (object instanceof EmailOverviewSummary) {
+ EmailOverviewSummary other = (EmailOverviewSummary) object;
+ return Objects.equal(accounts, other.accounts)
+ && Objects.equal(maxAccounts, other.maxAccounts)
+ && Objects.equal(aliases, other.aliases)
+ && Objects.equal(maxAliases, other.maxAliases);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ Joiner commaJoiner = Joiner.on(", ");
+ return String.format("accounts=%d, maxAccounts=%d, aliases=%d, maxAliases=%d", accounts, maxAccounts, aliases, maxAliases);
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java
index 3117f8f746..19332cc5ef 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java
@@ -15,7 +15,7 @@ import org.jclouds.javax.annotation.Nullable;
* Connection information to connect to a server with VNC.
*
* @author Adam Lowe
- * @see
+ * @see
*/
public class ServerCreated {
public static Builder builder() {
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java
index f8c210185b..464355f5bb 100644
--- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreatedIp.java
@@ -38,11 +38,19 @@ public class ServerCreatedIp {
protected int version;
protected double cost;
- public Builder version(int version) {
+ protected Builder version(int version) {
this.version = version;
return this;
}
+ public Builder version4() {
+ return version(4);
+ }
+
+ public Builder version6() {
+ return version(6);
+ }
+
public Builder ip(String ip) {
this.ip = ip;
return this;
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java
new file mode 100644
index 0000000000..267f5ad08d
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.features;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.jclouds.glesys.domain.*;
+import org.jclouds.glesys.options.EmailCreateOptions;
+import org.jclouds.glesys.options.EmailEditOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.ExceptionParser;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
+import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.Set;
+
+/**
+ * Provides asynchronous access to E-Mail data via the Glesys REST API.
+ *
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.glesys.features.EmailClient
+ * @see
+ */
+@RequestFilters(BasicAuthentication.class)
+public interface EmailAsyncClient {
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#emailOverview
+ */
+ @POST
+ @Path("/email/overview/format/json")
+ @SelectJson("response")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
+ ListenableFuture emailOverview();
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#listAccounts
+ */
+ @POST
+ @Path("/email/list/format/json")
+ @SelectJson("emailaccounts")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
+ ListenableFuture> listAccounts(@FormParam("domain") String domain);
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#createAccount
+ */
+ @POST
+ @Path("/email/createaccount/format/json")
+ ListenableFuture createAccount(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, EmailCreateOptions... options);
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#createAlias
+ */
+ @POST
+ @Path("/email/createalias/format/json")
+ ListenableFuture createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#editAccount
+ */
+ @POST
+ @Path("/email/editaccount/format/json")
+ ListenableFuture editAccount(@FormParam("emailaccount") String accountAddress, EmailEditOptions... options);
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#editAlias
+ */
+ @POST
+ @Path("/email/editalias/format/json")
+ ListenableFuture editAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
+
+ /**
+ * @see org.jclouds.glesys.features.EmailClient#delete
+ */
+ @POST
+ @Path("/email/delete/format/json")
+ ListenableFuture delete(@FormParam("email") String accountAddress);
+
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java
new file mode 100644
index 0000000000..2fc29e6b29
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.features;
+
+import org.jclouds.concurrent.Timeout;
+import org.jclouds.glesys.domain.Email;
+import org.jclouds.glesys.domain.EmailOverview;
+import org.jclouds.glesys.options.EmailCreateOptions;
+import org.jclouds.glesys.options.EmailEditOptions;
+
+import javax.ws.rs.FormParam;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Provides synchronous access to E-Mail requests.
+ *
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.glesys.features.DomainAsyncClient
+ * @see
+ */
+@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
+public interface EmailClient {
+
+ /**
+ * Get a summary of e-mail accounts associated with this Glesys account
+ *
+ * @return the relevant summary data
+ */
+ EmailOverview emailOverview();
+
+ /**
+ *
+ * @return
+ */
+ Set listAccounts(String domain);
+
+ void createAccount(String accountAddress, String password, EmailCreateOptions... options);
+
+ void createAlias(String aliasAddress, String toEmailAddress);
+
+ void editAccount(String accountAddress, EmailEditOptions... options);
+
+ void editAlias(String aliasAddress, String toEmailAddress);
+
+ void delete(String accountAddress);
+
+}
\ No newline at end of file
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java
new file mode 100644
index 0000000000..e6b42b662c
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java
@@ -0,0 +1,76 @@
+package org.jclouds.glesys.options;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+import java.util.Date;
+
+/**
+ * @author Adam Lowe
+ * @see
+ */
+public class EmailCreateOptions extends BaseHttpRequestOptions {
+ public static class Builder {
+ /**
+ * @see EmailCreateOptions#antispamLevel
+ */
+ public static EmailCreateOptions antispamLevel(int antispamLevel) {
+ return new EmailCreateOptions().antispamLevel(antispamLevel);
+ }
+
+ /**
+ * @see EmailCreateOptions#antiVirus
+ */
+ public static EmailCreateOptions antiVirus(boolean antiVirus) {
+ return new EmailCreateOptions().antiVirus(antiVirus);
+ }
+
+ /**
+ * @see EmailCreateOptions#autorespond
+ */
+ public static EmailCreateOptions autorespond(boolean autorespond) {
+ return new EmailCreateOptions().autorespond(autorespond);
+ }
+
+ /**
+ * @see EmailCreateOptions#autorespondSaveEmail
+ */
+ public static EmailCreateOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
+ return new EmailCreateOptions().autorespondSaveEmail(autorespondSaveEmail);
+ }
+
+ /**
+ * @see EmailCreateOptions#autorespondMessage
+ */
+ public static EmailCreateOptions autorespondMessage(boolean autorespondMessage) {
+ return new EmailCreateOptions().autorespondMessage(autorespondMessage);
+ }
+ }
+
+ public EmailCreateOptions antispamLevel(int antispamLevel) {
+ formParameters.put("antispamlevel", Integer.toString(antispamLevel));
+ return this;
+ }
+
+ public EmailCreateOptions antiVirus(boolean antiVirus) {
+ formParameters.put("antivirus", Integer.toString(antiVirus ? 1 : 0));
+ return this;
+ }
+
+ public EmailCreateOptions autorespond(boolean autorespond) {
+ formParameters.put("autorespond", Integer.toString(autorespond ? 1 : 0));
+ return this;
+ }
+
+ public EmailCreateOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
+ formParameters.put("autorespondsaveemail", Integer.toString(autorespondSaveEmail ? 1 : 0));
+ return this;
+ }
+
+ public EmailCreateOptions autorespondMessage(boolean autorespondMessage) {
+ formParameters.put("autorespondmessage", Integer.toString(autorespondMessage ? 1 : 0));
+ return this;
+ }
+}
diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java
new file mode 100644
index 0000000000..b741f61a18
--- /dev/null
+++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java
@@ -0,0 +1,41 @@
+package org.jclouds.glesys.options;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+/**
+ * @author Adam Lowe
+ * @see
+ */
+public class EmailEditOptions extends EmailCreateOptions {
+
+ public static class Builder {
+ public static EmailEditOptions antispamLevel(int antispamLevel) {
+ return EmailEditOptions.class.cast(new EmailEditOptions().antispamLevel(antispamLevel));
+ }
+
+ public static EmailEditOptions antiVirus(boolean antiVirus) {
+ return EmailEditOptions.class.cast(new EmailEditOptions().antiVirus(antiVirus));
+ }
+
+ public static EmailEditOptions autorespond(boolean autorespond) {
+ return EmailEditOptions.class.cast(new EmailEditOptions().autorespond(autorespond));
+ }
+
+ public static EmailEditOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
+ return EmailEditOptions.class.cast(new EmailEditOptions().autorespondSaveEmail(autorespondSaveEmail));
+ }
+
+ public static EmailEditOptions autorespondMessage(boolean autorespondMessage) {
+ return EmailEditOptions.class.cast(new EmailEditOptions().autorespondMessage(autorespondMessage));
+ }
+
+ public static EmailEditOptions autorespondMessage(String password) {
+ return new EmailEditOptions().password(password);
+ }
+ }
+
+ public EmailEditOptions password(String password) {
+ formParameters.put("password", password);
+ return this;
+ }
+}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSAsyncClientTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSAsyncClientTest.java
index a481233325..69fe8b45ed 100644
--- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSAsyncClientTest.java
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSAsyncClientTest.java
@@ -30,6 +30,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
+import org.jclouds.util.Strings2;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -66,8 +67,6 @@ public abstract class BaseGleSYSAsyncClientTest extends RestClientTest {
/**
* Test that a method call is annotated correctly.
*
- * TODO de-code ampersands and spaces in args properly
- *
* @param localMethod the method to call in asyncClientClass
* @param remoteCall the name of the expected call on the remote server
* @param httpMethod "GET" or "POST"
@@ -87,7 +86,7 @@ public abstract class BaseGleSYSAsyncClientTest extends RestClientTest {
argValues.add(arg);
} else {
Map.Entry entry = (Map.Entry) arg;
- argStrings.add(entry.getKey() + "=" + entry.getValue());
+ argStrings.add(entry.getKey() + "=" + Strings2.urlEncode(entry.getValue()));
argValues.add(entry.getValue());
}
}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSClientLiveTest.java
index 206ca54f95..6973b908d6 100644
--- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSClientLiveTest.java
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/BaseGleSYSClientLiveTest.java
@@ -19,10 +19,17 @@
package org.jclouds.glesys.features;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.testng.Assert.*;
+import com.google.common.base.Predicate;
import org.jclouds.glesys.GleSYSAsyncClient;
import org.jclouds.glesys.GleSYSClient;
+import org.jclouds.glesys.domain.ServerCreated;
+import org.jclouds.glesys.domain.ServerState;
+import org.jclouds.glesys.domain.ServerStatus;
+import org.jclouds.glesys.options.ServerStatusOptions;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.sshj.config.SshjSshClientModule;
@@ -33,10 +40,12 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
+import java.util.concurrent.TimeUnit;
+
/**
* Tests behavior of {@code GleSYSClient}
*
- * @author Adrian Cole
+ * @author Adrian Cole, Adam Lowe
*/
@Test(groups = "live")
public class BaseGleSYSClientLiveTest {
@@ -45,18 +54,67 @@ public class BaseGleSYSClientLiveTest {
@BeforeGroups(groups = { "live" })
public void setupClient() {
- String identity = checkNotNull(System.getProperty("test.glesys.identity"), "test.glesys.identity");
- String credential = checkNotNull(System.getProperty("test.glesys.credential"), "test.glesys.credential");
-
- context = new RestContextFactory().createContext("glesys", identity, credential,
- ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()));
-
+ if (context == null) {
+ String identity = checkNotNull(System.getProperty("test.glesys.identity"), "test.glesys.identity");
+ String credential = checkNotNull(System.getProperty("test.glesys.credential"), "test.glesys.credential");
+
+ context = new RestContextFactory().createContext("glesys", identity, credential,
+ ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()));
+ }
}
@AfterGroups(groups = "live")
protected void tearDown() {
- if (context != null)
+ if (context != null) {
context.close();
+ context = null;
+ }
}
+ protected void createDomain(String domain) {
+ final DomainClient client = context.getApi().getDomainClient();
+ int before = client.listDomains().size();
+ client.addDomain(domain);
+ RetryablePredicate result = new RetryablePredicate(
+ new Predicate() {
+ public boolean apply(Integer value) {
+ return client.listDomains().size() == value;
+ }
+ }, 30, 1, TimeUnit.SECONDS);
+
+ assertTrue(result.apply(before + 1));
+ }
+
+
+ protected ServerStatusChecker createServer(String hostName) {
+ ServerClient client = context.getApi().getServerClient();
+ ServerCreated testServer = client.createServer("Falkenberg", "OpenVZ", hostName, "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
+
+ assertNotNull(testServer.getId());
+ assertEquals(testServer.getHostname(), hostName);
+ assertFalse(testServer.getIps().isEmpty());
+
+ ServerStatusChecker runningServerCounter = new ServerStatusChecker(client, testServer.getId(), 300, 10, TimeUnit.SECONDS);
+
+ assertTrue(runningServerCounter.apply(ServerState.RUNNING));
+ return runningServerCounter;
+ }
+
+ public static class ServerStatusChecker extends RetryablePredicate {
+ private final String serverId;
+ public String getServerId() {
+ return serverId;
+ }
+ public ServerStatusChecker(final ServerClient client, final String serverId, long maxWait, long period, TimeUnit unit) {
+ super(new Predicate() {
+
+ public boolean apply(ServerState value) {
+ ServerStatus status = client.getServerStatus(serverId, ServerStatusOptions.Builder.state());
+ return status.getState() == value;
+ }
+
+ }, maxWait, period, unit);
+ this.serverId = serverId;
+ }
+ }
}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java
index 14459ae6ef..58d3dff335 100644
--- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java
@@ -37,6 +37,7 @@ import static org.testng.Assert.assertTrue;
*/
@Test(groups = "live", testName = "DomainClientLiveTest")
public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
+ public final String testDomain = "glesystest.jclouds.org";
@BeforeGroups(groups = {"live"})
public void setupClient() {
@@ -55,6 +56,13 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
return client.listRecords(testDomain).size() == value;
}
}, 30, 1, TimeUnit.SECONDS);
+
+ try {
+ client.deleteDomain(testDomain);
+ } catch (Exception ex) {
+ }
+
+ createDomain(testDomain);
}
@AfterGroups(groups = {"live"})
@@ -67,24 +75,11 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
}
private DomainClient client;
- private String testDomain = "glesystest.jclouds.org";
private String testRecordId;
private RetryablePredicate domainCounter;
private RetryablePredicate recordCounter;
@Test
- public void testCreateDomain() throws Exception {
- try {
- client.deleteDomain(testDomain);
- } catch (Exception ex) {
- }
-
- int before = client.listDomains().size();
- client.addDomain(testDomain);
- assertTrue(domainCounter.apply(before + 1));
- }
-
- @Test(dependsOnMethods = "testCreateDomain")
public void testCreateRecord() throws Exception {
int before = client.listRecords(testDomain).size();
@@ -93,7 +88,7 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
assertTrue(recordCounter.apply(before + 1));
}
- @Test(dependsOnMethods = "testCreateRecord")
+ @Test
public void testDeleteRecord() throws Exception {
Set domainRecords = client.listRecords(testDomain);
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailAsyncClientTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailAsyncClientTest.java
new file mode 100644
index 0000000000..6ba5679b76
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailAsyncClientTest.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.features;
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
+import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
+import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
+import org.jclouds.rest.internal.RestAnnotationProcessor;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+/**
+ * Tests annotation parsing of {@code ArchiveAsyncClient}
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "EmailAsyncClientTest")
+public class EmailAsyncClientTest extends BaseGleSYSAsyncClientTest {
+ public EmailAsyncClientTest() {
+ asyncClientClass = EmailAsyncClient.class;
+ remoteServicePrefix = "email";
+ }
+
+ public void testList() throws Exception {
+ testMethod("listAccounts", "list", "POST", true, ReturnEmptySetOnNotFoundOr404.class, newEntry("domain","test"));
+ }
+
+ public void testOverview() throws Exception {
+ testMethod("emailOverview", "overview", "POST", true, ReturnEmptySetOnNotFoundOr404.class);
+ }
+
+ public void testCreateAccount() throws Exception {
+ testMethod("createAccount", "createaccount", "POST", false, MapHttp4xxCodesToExceptions.class,
+ newEntry("emailaccount", "jclouds.org"), newEntry("password", "test@jclouds.org"));
+ }
+
+ public void testCreateAlias() throws Exception {
+ testMethod("createAlias", "createalias", "POST", false, MapHttp4xxCodesToExceptions.class,
+ newEntry("emailalias", "test2@jclouds.org"), newEntry("goto", "test@jclouds.org"));
+ }
+
+ public void testEditAlias() throws Exception {
+ testMethod("editAlias", "editalias", "POST", false, MapHttp4xxCodesToExceptions.class,
+ newEntry("emailalias", "test2@jclouds.org"), newEntry("goto", "test1@jclouds.org"));
+ }
+
+ @Override
+ protected TypeLiteral> createTypeLiteral() {
+ return new TypeLiteral>() {
+ };
+ }
+}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java
new file mode 100644
index 0000000000..3c0b74eb62
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java
@@ -0,0 +1,119 @@
+/**
+* Licensed to jclouds, Inc. (jclouds) under one or more
+* contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. jclouds 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.jclouds.glesys.features;
+
+import com.google.common.base.Predicate;
+import org.jclouds.glesys.domain.*;
+import org.jclouds.glesys.options.EmailEditOptions;
+import org.jclouds.predicates.RetryablePredicate;
+import org.testng.annotations.AfterGroups;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import static org.testng.Assert.*;
+
+/**
+* Tests behavior of {@code EmailClient}
+*
+* @author Adam Lowe
+*/
+@Test(groups = "live", testName = "EmailClientLiveTest")
+public class EmailClientLiveTest extends BaseGleSYSClientLiveTest {
+
+ @BeforeGroups(groups = {"live"})
+ public void setupClient() {
+ super.setupClient();
+ client = context.getApi().getEmailClient();
+
+ try {
+ client.delete("test@" + testDomain);
+ context.getApi().getDomainClient().deleteDomain(testDomain);
+
+ } catch(Exception e) {
+ }
+
+ serverId = createServer("test-email-jclouds").getServerId();
+ createDomain(testDomain);
+
+ domainCounter = new RetryablePredicate(
+ new Predicate() {
+ public boolean apply(Integer value) {
+ return client.listAccounts(testDomain).size() == value;
+ }
+ }, 30, 1, TimeUnit.SECONDS);
+
+ }
+
+
+ @AfterGroups(groups = {"live"})
+ public void tearDown() {
+ client.delete("test@" + testDomain);
+ context.getApi().getDomainClient().deleteDomain(testDomain);
+ context.getApi().getServerClient().destroyServer(serverId, 0);
+ super.tearDown();
+ }
+
+ private EmailClient client;
+ private String serverId;
+ private final String testDomain = "email-test.jclouds.org";
+ private RetryablePredicate domainCounter;
+
+ @Test
+ public void createEmail() {
+ int before = client.listAccounts(testDomain).size();
+ client.createAccount("test@" + testDomain, "password");
+ assertTrue(domainCounter.apply(before + 1));
+ }
+
+ @Test(dependsOnMethods = "createEmail")
+ public void testOverview() throws Exception {
+ EmailOverview overview = client.emailOverview();
+ assertNotNull(overview.getSummary());
+ assertTrue(overview.getSummary().getAccounts() >= 1);
+ assertTrue(overview.getSummary().getAliases() == 0);
+ assertTrue(overview.getSummary().getMaxAccounts() > 0);
+ assertTrue(overview.getSummary().getMaxAliases() > 0);
+ assertNotNull(overview.getDomains());
+ assertFalse(overview.getDomains().isEmpty());
+
+ EmailOverviewDomain domain = EmailOverviewDomain.builder().domain(testDomain).accounts(1).build();
+ assertTrue(overview.getDomains().contains(domain));
+ }
+
+ @Test(dependsOnMethods = "createEmail")
+ public void testListAccounts() throws Exception {
+ Set accounts = client.listAccounts(testDomain);
+ assertTrue(accounts.size() >= 1);
+ }
+
+ @Test(dependsOnMethods = "createEmail")
+ public void testEditAccount() throws Exception {
+ client.editAccount("test@" + testDomain, EmailEditOptions.Builder.antiVirus(false));
+ Set accounts = client.listAccounts(testDomain);
+ for(Email account : accounts) {
+ if (account.getAccount().equals("test@" + testDomain)) {
+ assertFalse(account.getAntiVirus());
+ }
+ }
+ }
+}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java
index 38e61c33a6..bd570ff728 100644
--- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java
@@ -41,41 +41,31 @@ import static org.testng.Assert.*;
*/
@Test(groups = "live", testName = "ServerClientLiveTest")
public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
-
+ public static final String testHostName1 = "jclouds-test";
+ public static final String testHostName2 = "jclouds-test2";
+
@BeforeGroups(groups = {"live"})
public void setupClient() {
super.setupClient();
client = context.getApi().getServerClient();
+ runningServerCounter = createServer(testHostName1);
+ testServerId = runningServerCounter.getServerId();
}
@AfterGroups(groups = {"live"})
public void tearDown() {
- client.destroyServer(testServer.getId(), 0);
- if (testServer2 != null) {
- client.destroyServer(testServer2.getId(), 0);
+ client.destroyServer(testServerId, 0);
+ if (testServerId2 != null) {
+ client.destroyServer(testServerId2, 0);
}
super.tearDown();
}
private ServerClient client;
- private ServerCreated testServer;
- private ServerCreated testServer2;
- // note this is initialized by testCreateServer()
- private RetryablePredicate runningServerCounter;
+ private ServerStatusChecker runningServerCounter;
+ private String testServerId;
+ private String testServerId2;
- @Test
- public void testCreateServer() throws Exception {
- testServer = client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
-
- assertNotNull(testServer.getId());
- assertEquals(testServer.getHostname(), "jclouds-test");
- assertFalse(testServer.getIps().isEmpty());
-
- runningServerCounter = new ServerStatusChecker(testServer.getId(), 120, 2, TimeUnit.SECONDS);
-
- assertTrue(runningServerCounter.apply(ServerState.RUNNING));
- }
-
@Test
public void testAllowedArguments() throws Exception {
Map templates = client.getServerAllowedArguments();
@@ -125,7 +115,7 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
assert t.getMinMemSize() > 0 : t;
}
- @Test(dependsOnMethods = "testCreateServer")
+ @Test
public void testListServers() throws Exception {
Set response = client.listServers();
assertNotNull(response);
@@ -141,35 +131,46 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
}
}
- @Test(dependsOnMethods = "testCreateServer")
+ @Test
public void testServerDetails() throws Exception {
- ServerStatus newStatus = client.getServerStatus(testServer.getId());
+ ServerStatus newStatus = client.getServerStatus(testServerId);
checkStatus(newStatus);
}
- @Test(dependsOnMethods = "testCreateServer")
+ @Test(enabled=false) // TODO tricksy
public void testRebootServer() throws Exception {
- client.rebootServer(testServer.getId());
+ long uptime = 0;
+
+ while(uptime < 20) {
+ uptime = client.getServerStatus(testServerId).getUptime();
+ }
+
+ assertTrue(uptime > 19);
+
+ client.rebootServer(testServerId);
- assertTrue(runningServerCounter.apply(ServerState.STOPPED));
+ uptime = client.getServerStatus(testServerId).getUptime();
+
+ assertTrue(uptime < 20);
+
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
}
- @Test(dependsOnMethods = "testCreateServer")
+ @Test
public void testStopAndStartServer() throws Exception {
- client.stopServer(testServer.getId());
+ client.stopServer(testServerId);
assertTrue(runningServerCounter.apply(ServerState.STOPPED));
- client.startServer(testServer.getId());
+ client.startServer(testServerId);
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
}
- @Test(dependsOnMethods = "testCreateServer")
+ @Test
public void testServerLimits() throws Exception {
- Map limits = client.getServerLimits(testServer.getId());
+ Map limits = client.getServerLimits(testServerId);
assertNotNull(limits);
for (Map.Entry entry : limits.entrySet()) {
assertNotNull(entry.getKey());
@@ -184,9 +185,9 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
}
// TODO in progress
- @Test(enabled=false, dependsOnMethods = "testCreateServer")
+ @Test(enabled=false)
public void testServerConsole() throws Exception {
- ServerConsole console = client.getServerConsole(testServer.getId());
+ ServerConsole console = client.getServerConsole(testServerId);
assertNotNull(console);
assertNotNull(console.getHost());
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
@@ -194,15 +195,17 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
}
// takes a few minutes
- @Test(enabled=false, dependsOnMethods = "testCreateServer")
+ @Test(enabled=false)
public void testCloneServer() throws Exception {
- testServer2 = client.cloneServer(testServer.getId(), "jclouds-test2", ServerCloneOptions.Builder.cpucores(1));
+ ServerCreated testServer2 = client.cloneServer(testServerId, testHostName2, ServerCloneOptions.Builder.cpucores(1));
assertNotNull(testServer2.getId());
assertEquals(testServer2.getHostname(), "jclouds-test2");
assertTrue(testServer2.getIps().isEmpty());
+
+ testServerId2 = testServer2.getId();
- RetryablePredicate cloneChecker = new ServerStatusChecker(testServer2.getId(), 300, 10, TimeUnit.SECONDS);
+ RetryablePredicate cloneChecker = new ServerStatusChecker(client, testServerId2, 300, 10, TimeUnit.SECONDS);
assertTrue(cloneChecker.apply(ServerState.STOPPED));
@@ -213,12 +216,12 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
new Predicate() {
public boolean apply(ServerState value) {
- ServerStatus status = client.getServerStatus(testServer2.getId(), ServerStatusOptions.Builder.state());
+ ServerStatus status = client.getServerStatus(testServerId2, ServerStatusOptions.Builder.state());
if (status.getState() == value) {
return true;
}
-
- client.startServer(testServer2.getId());
+
+ client.startServer(testServerId2);
return false;
}
@@ -265,17 +268,4 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
assert status.getMemory().getUsage() >= 0 : status;
assertNotNull(status.getMemory().getUnit());
}
-
- private class ServerStatusChecker extends RetryablePredicate {
- public ServerStatusChecker(final String serverId, long maxWait, long period, TimeUnit unit) {
- super(new Predicate() {
-
- public boolean apply(ServerState value) {
- ServerStatus status = client.getServerStatus(serverId, ServerStatusOptions.Builder.state());
- return status.getState() == value;
- }
-
- }, maxWait, period, unit);
- }
- }
}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailListTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailListTest.java
new file mode 100644
index 0000000000..4503371efa
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailListTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.parse;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import org.jclouds.glesys.config.GleSYSParserModule;
+import org.jclouds.glesys.domain.Email;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Set;
+
+/**
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "ParseEmailListTest")
+public class ParseEmailListTest extends BaseSetParserTest {
+
+ @Override
+ public String resource() {
+ return "/email_list.json";
+ }
+
+ @Override
+ @SelectJson("emailaccounts")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set expected() {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ Email.Builder builder = Email.builder().quota("200 MB").usedQuota("0 MB").antispamLevel(3).antiVirus(true).autoRespond(false).autoRespondSaveEmail(true).autoRespondMessage("false");
+ try {
+ return ImmutableSet.of(
+ builder.account("test@adamlowe.net").created(dateFormat.parse("2011-12-22T12:13:14")).modified(dateFormat.parse("2011-12-22T12:13:35")).build(),
+ builder.account("test2@adamlowe.net").created(dateFormat.parse("2011-12-22T12:14:29")).modified(dateFormat.parse("2011-12-22T12:14:31")).build()
+ );
+ } catch(ParseException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailOverviewTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailOverviewTest.java
new file mode 100644
index 0000000000..afc53f1641
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseEmailOverviewTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.jclouds.glesys.parse;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import org.jclouds.glesys.config.GleSYSParserModule;
+import org.jclouds.glesys.domain.EmailOverview;
+import org.jclouds.glesys.domain.EmailOverviewDomain;
+import org.jclouds.glesys.domain.EmailOverviewSummary;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "ParseEmailListTest")
+public class ParseEmailOverviewTest extends BaseItemParserTest {
+
+ @Override
+ public String resource() {
+ return "/email_overview.json";
+ }
+
+ @Override
+ @SelectJson("response")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public EmailOverview expected() {
+ return EmailOverview.builder().summary(EmailOverviewSummary.builder().accounts(2).aliases(0).maxAccounts(50).maxAliases(1000).build()).domains(EmailOverviewDomain.builder().accounts(2).aliases(0).domain("adamlowe.net").build()).build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
+ }
+
+}
diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java
index cd1b64812c..f08739f1d2 100644
--- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java
+++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/parse/ParseServerCreatedTest.java
@@ -47,7 +47,7 @@ public class ParseServerCreatedTest extends BaseItemParserTest {
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
public ServerCreated expected() {
- return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(ServerCreatedIp.builder().ip("109.74.10.27").version(4).cost(2.00).build()).build();
+ return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(ServerCreatedIp.builder().ip("109.74.10.27").version4().cost(2.00).build()).build();
}
diff --git a/sandbox-providers/glesys/src/test/resources/email_list.json b/sandbox-providers/glesys/src/test/resources/email_list.json
new file mode 100644
index 0000000000..b970ad8068
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/resources/email_list.json
@@ -0,0 +1 @@
+{"response":{"status":{"code":"200","text":"OK"},"list":{"emailaccounts":[{"emailaccount":"test2@adamlowe.net","quota":"200 MB","usedquota":"0 MB","antispamlevel":3,"antivirus":true,"autorespond":false,"autorespondmessage":false,"autorespondsaveemail":true,"created":"2011-12-22 12:14:29","modified":"2011-12-22 12:14:31"},{"emailaccount":"test@adamlowe.net","quota":"200 MB","usedquota":"0 MB","antispamlevel":3,"antivirus":true,"autorespond":false,"autorespondmessage":false,"autorespondsaveemail":true,"created":"2011-12-22 12:13:14","modified":"2011-12-22 12:13:35"}]},"debug":{"input":{"domain":"adamlowe.net"}}}}
\ No newline at end of file
diff --git a/sandbox-providers/glesys/src/test/resources/email_overview.json b/sandbox-providers/glesys/src/test/resources/email_overview.json
new file mode 100644
index 0000000000..d98a8c852e
--- /dev/null
+++ b/sandbox-providers/glesys/src/test/resources/email_overview.json
@@ -0,0 +1 @@
+{"response":{"status":{"code":"200","text":"OK"},"summary":{"accounts":2,"maxaccounts":"50","aliases":0,"maxaliases":1000},"domains":[{"domain":"adamlowe.net","accounts":2,"aliases":0}],"debug":{"input":[]}}}
\ No newline at end of file