mirror of https://github.com/apache/jclouds.git
Issue 942: NPE + Missing data when calling getVAppExtendedInfo on Terremark eCloud
This commit is contained in:
parent
5123195eec
commit
2d60a72ddd
|
@ -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.trmk.vcloud_0_8.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ComputePoolReference implements Comparable<ComputePoolReference> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromComputePoolReference(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private URI href;
|
||||
private String name;
|
||||
|
||||
public Builder href(URI href) {
|
||||
this.href = href;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComputePoolReference build() {
|
||||
return new ComputePoolReference(href, name);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolReference(ComputePoolReference in) {
|
||||
return href(in.getHref()).name(in.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final URI href;
|
||||
private final String name;
|
||||
|
||||
public ComputePoolReference(URI href, String name) {
|
||||
this.href = href;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int compareTo(ComputePoolReference that) {
|
||||
return (this == that) ? 0 : getHref().compareTo(that.getHref());
|
||||
}
|
||||
|
||||
public URI getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ComputePoolReference that = ComputePoolReference.class.cast(o);
|
||||
return equal(this.href, that.href) && equal(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(href, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("").add("href", href).add("name", name).toString();
|
||||
}
|
||||
}
|
|
@ -18,10 +18,52 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* @author Seshu Pasam
|
||||
*/
|
||||
public class NetworkAdapter implements Comparable<NetworkAdapter> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromNetworkAdapter(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String macAddress;
|
||||
private String name;
|
||||
private Subnet subnet;
|
||||
|
||||
public Builder macAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder subnet(Subnet subnet) {
|
||||
this.subnet = subnet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NetworkAdapter build() {
|
||||
return new NetworkAdapter(macAddress, name, subnet);
|
||||
}
|
||||
|
||||
public Builder fromNetworkAdapter(NetworkAdapter in) {
|
||||
return macAddress(in.getMacAddress()).name(in.getName()).subnet(in.getSubnet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String macAddress;
|
||||
private final String name;
|
||||
private final Subnet subnet;
|
||||
|
@ -49,44 +91,23 @@ public class NetworkAdapter implements Comparable<NetworkAdapter> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((macAddress== null) ? 0 : macAddress.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
|
||||
return result;
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
NetworkAdapter that = NetworkAdapter.class.cast(o);
|
||||
return equal(this.macAddress, that.macAddress) && equal(this.name, that.name) && equal(this.subnet, that.subnet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NetworkAdapter other = (NetworkAdapter) obj;
|
||||
if (macAddress == null) {
|
||||
if (other.macAddress != null)
|
||||
return false;
|
||||
} else if (!macAddress.equals(other.macAddress))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (subnet == null) {
|
||||
if (other.subnet != null)
|
||||
return false;
|
||||
} else if (!subnet.equals(other.subnet))
|
||||
return false;
|
||||
return true;
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(macAddress, name, subnet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[MAC address=" + macAddress + ", name=" + name + ", subnet=" + subnet + "]";
|
||||
return Objects.toStringHelper("").add("macAddress", macAddress).add("name", name).add("subnet", subnet)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,48 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* @author Seshu Pasam
|
||||
*/
|
||||
public class Subnet implements Comparable<Subnet> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromSubnet(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private URI href;
|
||||
private String name;
|
||||
|
||||
public Builder href(URI href) {
|
||||
this.href = href;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Subnet build() {
|
||||
return new Subnet(href, name);
|
||||
}
|
||||
|
||||
public Builder fromSubnet(Subnet in) {
|
||||
return href(in.getHref()).name(in.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final URI href;
|
||||
private final String name;
|
||||
|
||||
|
@ -45,38 +81,22 @@ public class Subnet implements Comparable<Subnet> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
Subnet that = Subnet.class.cast(o);
|
||||
return equal(this.href, that.href) && equal(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Subnet other = (Subnet) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(href, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[href=" + href + ", name=" + name + "]";
|
||||
return Objects.toStringHelper("").add("href", href).add("name", name).toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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
|
||||
* regarding copyright ownershhref. 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
|
||||
|
@ -18,28 +18,103 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* @author Seshu Pasam
|
||||
* @author Seshu Pasam, Adrian Cole
|
||||
*/
|
||||
public class VAppExtendedInfo implements Comparable<VAppExtendedInfo> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromVAppExtendedInfo(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private URI href;
|
||||
private String name;
|
||||
private String longName;
|
||||
private List<String> tags = Lists.newArrayList();
|
||||
private List<NetworkAdapter> networkAdapters = Lists.newArrayList();
|
||||
private ComputePoolReference computePoolReference;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder href(URI href) {
|
||||
this.href = href;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder longName(String longName) {
|
||||
this.longName = longName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder tags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder networkAdapters(List<NetworkAdapter> networkAdapters) {
|
||||
this.networkAdapters = networkAdapters;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder networkAdapter(NetworkAdapter networkAdapter) {
|
||||
this.networkAdapters.add(networkAdapter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder computePoolReference(ComputePoolReference computePoolReference) {
|
||||
this.computePoolReference = computePoolReference;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VAppExtendedInfo build() {
|
||||
return new VAppExtendedInfo(id, href, name, tags, longName, networkAdapters, computePoolReference);
|
||||
}
|
||||
|
||||
public Builder fromVAppExtendedInfo(VAppExtendedInfo in) {
|
||||
return id(in.getId()).href(in.getHref()).name(in.getName()).longName(in.getLongName()).tags(in.getTags())
|
||||
.networkAdapters(in.getNetworkAdapters()).computePoolReference(in.getComputePoolReference());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final URI href;
|
||||
private final String name;
|
||||
private final List<String> tags;
|
||||
private final String longName;
|
||||
private final List<String> tags;
|
||||
private final List<NetworkAdapter> networkAdapters;
|
||||
private final ComputePoolReference computePoolReference;
|
||||
|
||||
public VAppExtendedInfo(String id, URI href, String name, List<String> tags, String longName,
|
||||
List<NetworkAdapter> networkAdapters) {
|
||||
List<NetworkAdapter> networkAdapters, ComputePoolReference computePoolReference) {
|
||||
this.id = id;
|
||||
this.href = href;
|
||||
this.name = name;
|
||||
this.tags = tags;
|
||||
this.longName = longName;
|
||||
this.networkAdapters = networkAdapters;
|
||||
this.computePoolReference = computePoolReference;
|
||||
}
|
||||
|
||||
public int compareTo(VAppExtendedInfo that) {
|
||||
|
@ -58,71 +133,44 @@ public class VAppExtendedInfo implements Comparable<VAppExtendedInfo> {
|
|||
return name;
|
||||
}
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getLongName() {
|
||||
return longName;
|
||||
}
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<NetworkAdapter> getNetworkAdapters() {
|
||||
return networkAdapters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((longName == null) ? 0 : longName.hashCode());
|
||||
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
|
||||
result = prime * result + ((networkAdapters == null) ? 0 : networkAdapters.hashCode());
|
||||
return result;
|
||||
public ComputePoolReference getComputePoolReference() {
|
||||
return computePoolReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (obj == null)
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VAppExtendedInfo other = (VAppExtendedInfo) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (tags == null) {
|
||||
if (other.tags != null)
|
||||
return false;
|
||||
} else if (!tags.equals(other.tags))
|
||||
return false;
|
||||
if (networkAdapters == null) {
|
||||
if (other.networkAdapters != null)
|
||||
return false;
|
||||
} else if (!networkAdapters.equals(other.networkAdapters))
|
||||
return false;
|
||||
return true;
|
||||
VAppExtendedInfo that = VAppExtendedInfo.class.cast(o);
|
||||
return equal(this.id, that.id) && equal(this.href, that.href) && equal(this.name, that.name)
|
||||
&& equal(this.longName, that.longName) && equal(this.tags, that.tags)
|
||||
&& equal(this.networkAdapters, that.networkAdapters)
|
||||
&& equal(this.computePoolReference, that.computePoolReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, href, name, longName, tags, networkAdapters, computePoolReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[href=" + href + ", id=" + id + ", name=" + name + ", long name=" + longName
|
||||
+ ", tags=" + tags.toString() + ", network adapters=" + networkAdapters.toString() + "]";
|
||||
return Objects.toStringHelper("").add("id", id).add("href", href).add("name", name).add("longName", longName)
|
||||
.add("tags", tags).add("networkAdapters", networkAdapters).add("computePoolReference",
|
||||
computePoolReference).toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,53 +18,39 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.xml;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.ComputePoolReference;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.NetworkAdapter;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.Subnet;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.VAppExtendedInfo;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Seshu Pasam
|
||||
* @author Seshu Pasam, Adrian Cole
|
||||
*/
|
||||
public class VAppExtendedInfoHandler extends HandlerWithResult<VAppExtendedInfo> {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
private String id;
|
||||
private URI href;
|
||||
private String name;
|
||||
private String longName;
|
||||
private List<String> tags;
|
||||
private List<NetworkAdapter> networkAdapters = Lists.newArrayList();
|
||||
private VAppExtendedInfo.Builder builder = VAppExtendedInfo.builder();
|
||||
private NetworkAdapter.Builder adapterBuilder = NetworkAdapter.builder();
|
||||
private Subnet.Builder subnetBuilder = Subnet.builder();
|
||||
private ComputePoolReference.Builder poolBuilder = ComputePoolReference.builder();
|
||||
private boolean inAdapters;
|
||||
private String macAddress;
|
||||
private String adapterName;
|
||||
private boolean inSubnet;
|
||||
private Subnet subnet;
|
||||
private URI subnetLocation;
|
||||
private String subnetName;
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
private boolean inComputePool;
|
||||
|
||||
@Override
|
||||
public VAppExtendedInfo getResult() {
|
||||
return new VAppExtendedInfo(id, href, name, tags, longName, networkAdapters);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,47 +59,55 @@ public class VAppExtendedInfoHandler extends HandlerWithResult<VAppExtendedInfo>
|
|||
inAdapters = true;
|
||||
} else if (qName.equals("Subnet")) {
|
||||
inSubnet = true;
|
||||
} else if (qName.equals("ComputePoolReference")) {
|
||||
inComputePool = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
String current = currentOrNull();
|
||||
String current = currentOrNull(currentText);
|
||||
if (current != null) {
|
||||
if (qName.equals("Id")) {
|
||||
this.id = current;
|
||||
builder.id(current);
|
||||
} else if (qName.equals("Tags")) {
|
||||
this.tags = Arrays.asList(current.split(","));
|
||||
builder.tags(ImmutableList.copyOf(Splitter.on(',').split(current)));
|
||||
} else if (qName.equals("LongName")) {
|
||||
this.longName = current;
|
||||
builder.longName(current);
|
||||
} else if (qName.equals("Href")) {
|
||||
URI href = URI.create(current);
|
||||
if (inSubnet) {
|
||||
this.subnetLocation = URI.create(current);
|
||||
subnetBuilder.href(href);
|
||||
} else if (inComputePool) {
|
||||
poolBuilder.href(href);
|
||||
} else {
|
||||
this.href = URI.create(current);
|
||||
builder.href(href);
|
||||
}
|
||||
} else if (qName.equals("Name")) {
|
||||
if (inSubnet) {
|
||||
this.subnetName = current;
|
||||
subnetBuilder.name(current);
|
||||
} else if (inAdapters) {
|
||||
this.adapterName = current;
|
||||
adapterBuilder.name(current);
|
||||
} else if (inComputePool) {
|
||||
poolBuilder.name(current);
|
||||
} else {
|
||||
this.name = current;
|
||||
builder.name(current);
|
||||
}
|
||||
} else if (qName.equals("NetworkAdapters")) {
|
||||
inAdapters = false;
|
||||
} else if (qName.equals("NetworkAdapter")) {
|
||||
networkAdapters.add(new NetworkAdapter(macAddress, adapterName, subnet));
|
||||
macAddress = null;
|
||||
adapterName = null;
|
||||
subnet = null;
|
||||
} else if (qName.equals("MacAddress")) {
|
||||
macAddress = current;
|
||||
} else if (qName.equals("Subnet")) {
|
||||
subnet = new Subnet(subnetLocation, subnetName);
|
||||
subnetLocation = null;
|
||||
subnetName = null;
|
||||
inSubnet = false;
|
||||
adapterBuilder.macAddress(current);
|
||||
}
|
||||
} else if (qName.equals("NetworkAdapters")) {
|
||||
inAdapters = false;
|
||||
} else if (qName.equals("NetworkAdapter")) {
|
||||
builder.networkAdapter(adapterBuilder.build());
|
||||
adapterBuilder = NetworkAdapter.builder();
|
||||
} else if (qName.equals("Subnet")) {
|
||||
adapterBuilder.subnet(subnetBuilder.build());
|
||||
subnetBuilder = Subnet.builder();
|
||||
inSubnet = false;
|
||||
} else if (qName.equals("ComputePoolReference")) {
|
||||
builder.computePoolReference(poolBuilder.build());
|
||||
poolBuilder = ComputePoolReference.builder();
|
||||
inComputePool = false;
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* 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.trmk.vcloud_0_8.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.ComputePoolReference;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.NetworkAdapter;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.Subnet;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.VAppExtendedInfo;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VAppExtendedInfoHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "VAppExtendedInfoHandlerTest")
|
||||
public class VAppExtendedInfoHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/vapp-ext.xml");
|
||||
|
||||
VAppExtendedInfo result = factory.create(injector.getInstance(VAppExtendedInfoHandler.class)).parse(is);
|
||||
assertEquals(
|
||||
result,
|
||||
VAppExtendedInfo
|
||||
.builder()
|
||||
.id("392992")
|
||||
.href(
|
||||
URI
|
||||
.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/vapp/392992"))
|
||||
.name("instance01")
|
||||
.networkAdapter(
|
||||
NetworkAdapter
|
||||
.builder()
|
||||
.macAddress("00:50:56:95:12:96")
|
||||
.name("Network adapter 1")
|
||||
.subnet(
|
||||
Subnet
|
||||
.builder()
|
||||
.href(
|
||||
URI
|
||||
.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/network/43781"))
|
||||
.name("10.122.213.192/27").build()).build())
|
||||
.computePoolReference(
|
||||
ComputePoolReference
|
||||
.builder()
|
||||
.href(
|
||||
URI
|
||||
.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/computePool/692"))
|
||||
.name(
|
||||
|
||||
"Resource Pool 692").build()).build());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<VApp xmlns="urn:tmrk:eCloudExtensions-2.8" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Id>392992</Id>
|
||||
<Href>https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/vapp/392992</Href>
|
||||
<Name>instance01</Name>
|
||||
<Tags></Tags>
|
||||
<LongName></LongName>
|
||||
<NetworkAdapters>
|
||||
<NetworkAdapter>
|
||||
<MacAddress>00:50:56:95:12:96</MacAddress>
|
||||
<Name>Network adapter 1</Name>
|
||||
<Subnet>
|
||||
<Href>https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/network/43781</Href>
|
||||
<Name>10.122.213.192/27</Name>
|
||||
</Subnet>
|
||||
</NetworkAdapter>
|
||||
</NetworkAdapters>
|
||||
<ComputePoolReference>
|
||||
<Href>https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/computePool/692</Href>
|
||||
<Name>Resource Pool 692</Name>
|
||||
</ComputePoolReference>
|
||||
</VApp>
|
Loading…
Reference in New Issue