You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:47:16 UTC
[24/50] [abbrv] brooklyn-library git commit: Fix GeoscalingWebClient
create primary domain REST call and update test
Fix GeoscalingWebClient create primary domain REST call and update test
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/59d1dcd9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/59d1dcd9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/59d1dcd9
Branch: refs/heads/0.7.0-incubating
Commit: 59d1dcd928dc2cda86333870220330c9e2678537
Parents: b575ad7
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Authored: Fri Jun 19 11:12:32 2015 -0400
Committer: Mike Zaccardo <mi...@cloudsoftcorp.com>
Committed: Fri Jun 19 11:12:32 2015 -0400
----------------------------------------------------------------------
.../dns/geoscaling/GeoscalingWebClient.java | 4 +-
.../dns/geoscaling/GeoscalingWebClientTest.java | 48 +++++++++++++++-----
2 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/59d1dcd9/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClient.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClient.java b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClient.java
index 290d16a..7ce10cc 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClient.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClient.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.io.FilenameUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@@ -248,7 +249,8 @@ public class GeoscalingWebClient {
HttpPost request = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("MAX_FILE_SIZE", "65536"));
- nameValuePairs.add(new BasicNameValuePair("domain", name));
+ nameValuePairs.add(new BasicNameValuePair("domain", FilenameUtils.removeExtension(name)));
+ nameValuePairs.add(new BasicNameValuePair("tld", FilenameUtils.getExtension(name)));
request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
sendRequest(request, true);
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/59d1dcd9/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClientTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClientTest.java b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClientTest.java
index c045c39..73584b2 100644
--- a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClientTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingWebClientTest.java
@@ -26,26 +26,55 @@ import static brooklyn.entity.dns.geoscaling.GeoscalingWebClient.PROVIDE_UPTIME_
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
-import javax.net.ssl.SSLSocketFactory;
-
import org.apache.http.client.HttpClient;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import brooklyn.entity.dns.geoscaling.GeoscalingWebClient.Domain;
import brooklyn.entity.dns.geoscaling.GeoscalingWebClient.SmartSubdomain;
import brooklyn.util.http.HttpTool;
+import brooklyn.util.text.Strings;
/**
* {@link GeoscalingWebClient} unit tests.
*/
public class GeoscalingWebClientTest {
+ private final static String GEOSCALING_URL = "https://www.geoscaling.com";
private final static String USERNAME = "cloudsoft";
private final static String PASSWORD = "cl0uds0ft";
- private final static String PRIMARY_DOMAIN = "domain"+((int)(Math.random()*10000))+".test.org";
- private final static String SUBDOMAIN = "subdomain"+((int)(Math.random()*10000));
+
+ private final static String PRIMARY_DOMAIN = "domain-" + Strings.makeRandomId(5) + ".test.org";
+ private final static String SUBDOMAIN = "subdomain-" + Strings.makeRandomId(5);
+
private final static String DEFAULT_SCRIPT = "output[] = array(\"fail\");";
+ private GeoscalingWebClient geoscaling;
+
+ private Domain domain;
+ private SmartSubdomain smartSubdomain;
+
+ @BeforeMethod(alwaysRun=true)
+ public void setUp() {
+ // Insecurely use "trustAll" so that don't need to import signature into trust store
+ // before test will work on jenkins machine.
+ HttpClient httpClient = HttpTool.httpClientBuilder().uri(GEOSCALING_URL).trustAll().build();
+ geoscaling = new GeoscalingWebClient(httpClient);
+ geoscaling.login(USERNAME, PASSWORD);
+ }
+
+ @AfterMethod(alwaysRun=true)
+ public void tearDown() {
+ if (smartSubdomain != null)
+ smartSubdomain.delete();
+
+ if (domain != null)
+ domain.delete();
+
+ if (geoscaling != null)
+ geoscaling.logout();
+ }
@Test(groups = "Integration")
public void testSimpleNames() {
@@ -58,20 +87,14 @@ public class GeoscalingWebClientTest {
}
public void testWebClient(String primaryDomainName, String smartSubdomainName) {
- // Insecurely use "trustAll" so that don't need to import signature into trust store
- // before test will work on jenkins machine.
- HttpClient httpClient = HttpTool.httpClientBuilder().uri("https://www.geoscaling.com").trustAll().build();
- GeoscalingWebClient geoscaling = new GeoscalingWebClient(httpClient);
- geoscaling.login(USERNAME, PASSWORD);
-
assertNull(geoscaling.getPrimaryDomain(primaryDomainName));
geoscaling.createPrimaryDomain(primaryDomainName);
- Domain domain = geoscaling.getPrimaryDomain(primaryDomainName);
+ domain = geoscaling.getPrimaryDomain(primaryDomainName);
assertNotNull(domain);
assertNull(domain.getSmartSubdomain(smartSubdomainName));
domain.createSmartSubdomain(smartSubdomainName);
- SmartSubdomain smartSubdomain = domain.getSmartSubdomain(smartSubdomainName);
+ smartSubdomain = domain.getSmartSubdomain(smartSubdomainName);
assertNotNull(smartSubdomain);
smartSubdomain.configure(
@@ -84,6 +107,7 @@ public class GeoscalingWebClientTest {
smartSubdomain.delete();
assertNull(domain.getSmartSubdomain(smartSubdomainName));
+
domain.delete();
assertNull(geoscaling.getPrimaryDomain(primaryDomainName));