diff --git a/apis/route53/src/main/java/org/jclouds/route53/domain/ResourceRecordSet.java b/apis/route53/src/main/java/org/jclouds/route53/domain/ResourceRecordSet.java index 97f76b6bf8..6dd9adede7 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/domain/ResourceRecordSet.java +++ b/apis/route53/src/main/java/org/jclouds/route53/domain/ResourceRecordSet.java @@ -103,7 +103,7 @@ public class ResourceRecordSet { private Weighted(String id, String name, String type, int weight, Optional ttl, List values, Optional aliasTarget) { super(id, name, type, ttl, values, aliasTarget); - this.weight = checkNotNull(weight, "weight"); + this.weight = weight; } /** diff --git a/apis/route53/src/main/java/org/jclouds/route53/functions/SerializeRRS.java b/apis/route53/src/main/java/org/jclouds/route53/functions/SerializeRRS.java index d747457c6b..5d95c07301 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/functions/SerializeRRS.java +++ b/apis/route53/src/main/java/org/jclouds/route53/functions/SerializeRRS.java @@ -20,7 +20,6 @@ package org.jclouds.route53.functions; import static com.google.common.base.Preconditions.checkNotNull; -import org.jclouds.rest.annotations.ParamParser; import org.jclouds.route53.domain.ResourceRecordSet; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Latency; @@ -30,7 +29,6 @@ import com.google.common.base.Function; /** * @author Adrian Cole - * @see ParamParser */ public class SerializeRRS implements Function { @Override @@ -41,7 +39,7 @@ public class SerializeRRS implements Function { builder.append("").append(rrs.getType()).append(""); if (rrs instanceof RecordSubset) { String id = RecordSubset.class.cast(rrs).getId(); - builder.append("").append(id).append(""); + builder.append("").append(id).append(""); } if (rrs instanceof Weighted) builder.append("").append(Weighted.class.cast(rrs).getWeight()).append(""); diff --git a/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiLiveTest.java b/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiLiveTest.java index b89b450410..bbcfc8d79a 100644 --- a/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiLiveTest.java +++ b/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiLiveTest.java @@ -135,33 +135,59 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest { @Test public void testCreateAndDeleteBulkRecords() { String name = System.getProperty("user.name").replace('.', '-') + ".bulk.route53test.jclouds.org."; + try { + String zoneId = recreateZone(name); + + ImmutableList records = ImmutableList. builder() + .add(ResourceRecordSet.builder().name("dom1." + name).type("TXT").add("\"somehow\" \" somewhere\"") + .build()) + .add(ResourceRecordSet.builder().name("dom2." + name).type("TXT").add("\"goodies\"").build()).build(); + + createAndDeleteRecordsInZone(records, zoneId); + } finally { + clearAndDeleteHostedZonesNamed(name); + } + } + + @Test + public void testCreateAndDeleteWeightedRecords() { + String name = System.getProperty("user.name").replace('.', '-') + ".weight.route53test.jclouds.org."; + try { + String zoneId = recreateZone(name); + + ImmutableList records = ImmutableList. builder() + .add(Weighted.builder().id("dom1").weight(1).name("dom." + name).type("CNAME").add("dom1." + name) + .build()) + .add(Weighted.builder().id("dom2").weight(1).name("dom." + name).type("CNAME").add("dom2." + name) + .build()).build(); + + createAndDeleteRecordsInZone(records, zoneId); + } finally { + clearAndDeleteHostedZonesNamed(name); + } + } + + private String recreateZone(String name) { clearAndDeleteHostedZonesNamed(name); - - ImmutableList records = ImmutableList. builder() - .add(ResourceRecordSet.builder().name("dom1." + name).type("TXT").add("\"somehow\" \" somewhere\"").build()) - .add(ResourceRecordSet.builder().name("dom2." + name).type("TXT").add("\"goodies\"").build()).build(); - String nonce = name + " @ " + new Date(); String comment = name + " for " + JcloudsVersion.get(); NewHostedZone newHostedZone = context.getApi().getHostedZoneApi() .createWithReferenceAndComment(name, nonce, comment); - String zoneId = newHostedZone.getZone().getId(); getAnonymousLogger().info("created zone: " + newHostedZone); - try { - assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone); - sync(api(zoneId).apply(createAll(records))); + assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone); + return newHostedZone.getZone().getId(); + } - checkAllRRs(zoneId); + private void createAndDeleteRecordsInZone(ImmutableList records, String zoneId) { + sync(api(zoneId).apply(createAll(records))); - sync(api(zoneId).apply(deleteAll(records))); + checkAllRRs(zoneId); - PagedIterable refreshed = refresh(zoneId); - assertTrue(refreshed.concat().filter(not(requiredRRTypes)).isEmpty(), "zone still has optional records: " - + refreshed); + sync(api(zoneId).apply(deleteAll(records))); - } finally { - clearAndDeleteHostedZonesNamed(name); - } + PagedIterable refreshed = refresh(zoneId); + assertTrue(refreshed.concat().filter(not(requiredRRTypes)).isEmpty(), "zone still has optional records: " + + refreshed); } private void clearAndDeleteHostedZonesNamed(String name) { diff --git a/apis/route53/src/test/java/org/jclouds/route53/filters/RestAuthenticationTest.java b/apis/route53/src/test/java/org/jclouds/route53/filters/RestAuthenticationTest.java deleted file mode 100644 index 63a1c215b5..0000000000 --- a/apis/route53/src/test/java/org/jclouds/route53/filters/RestAuthenticationTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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.route53.filters; - -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code RestAuthentication} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "RestAuthenticationTest") -public class RestAuthenticationTest { - - @Test - void test() { - } - -} diff --git a/apis/route53/src/test/java/org/jclouds/route53/functions/SerializeRRSTest.java b/apis/route53/src/test/java/org/jclouds/route53/functions/SerializeRRSTest.java new file mode 100644 index 0000000000..e0d6cedb00 --- /dev/null +++ b/apis/route53/src/test/java/org/jclouds/route53/functions/SerializeRRSTest.java @@ -0,0 +1,54 @@ +/** + * 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.route53.functions; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.route53.domain.ResourceRecordSet; +import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Weighted; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit") +public class SerializeRRSTest { + + @Test + void roundRobinRRSetToXML() { + assertEquals( + new SerializeRRS().apply(ResourceRecordSet.builder() + .name("dom1.foo.com.") + .type("A") + .add("1.2.3.4") + .add("5.6.7.8").build()), + "dom1.foo.com.A3001.2.3.45.6.7.8"); + } + + @Test + void roundWeightedRRSetToXML() { + assertEquals(new SerializeRRS().apply(Weighted.builder() + .id("dom1") + .weight(1) + .name("dom.foo.com.") + .type("CNAME") + .add("dom1.foo.com.").build()), + "dom.foo.com.CNAMEdom11300dom1.foo.com."); + } +}