Repository: incubator-brooklyn Updated Branches: refs/heads/master 2556b29ab -> ced5e15a5
Fix GeoscalingWebClient create primary domain REST call and update test Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a51db37a Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a51db37a Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a51db37a Branch: refs/heads/master Commit: a51db37ad3b82fb4dcc3d90cabd1e24386c0fe69 Parents: 9c9a866 Author: Mike Zaccardo <[email protected]> Authored: Fri Jun 19 11:12:32 2015 -0400 Committer: Mike Zaccardo <[email protected]> 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/incubator-brooklyn/blob/a51db37a/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/incubator-brooklyn/blob/a51db37a/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));
