Skip to content

Commit

Permalink
Merge pull request Azure#923 from andrerod/release-0.5.0
Browse files Browse the repository at this point in the history
Apply remaining review comments
  • Loading branch information
André Rodrigues committed Apr 16, 2014
2 parents 663ed4a + f54931e commit d23cdee
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.junit.Test;

public class ClientRootCertificateOperationsTests extends NetworkManagementIntegrationTestBase {

@BeforeClass
public static void setup() throws Exception {
testNetworkName = testNetworkPrefix + randomString(10);;
Expand All @@ -42,17 +41,13 @@ public static void setup() throws Exception {

@AfterClass
public static void cleanup() throws Exception {
try
{
try {
ClientRootCertificateListResponse ClientRootCertificateListResponse = clientRootCertificateOperations.list(testNetworkName);
ArrayList<ClientRootCertificateListResponse.ClientRootCertificate> clientRootCertificatelist = ClientRootCertificateListResponse.getClientRootCertificates();
for (ClientRootCertificateListResponse.ClientRootCertificate clientRootCertificate : clientRootCertificatelist)
{
for (ClientRootCertificateListResponse.ClientRootCertificate clientRootCertificate : clientRootCertificatelist) {
clientRootCertificateOperations.delete(testNetworkName, clientRootCertificate.getThumbprint());
}
}
catch (ServiceException e) {
e.printStackTrace();
} catch (ServiceException e) {
}
}

Expand Down Expand Up @@ -85,19 +80,15 @@ public void getClientRootCertificates() throws Exception {

@Test
public void listClientRootCertificatesSuccess() throws Exception {
try
{
ClientRootCertificateListResponse ClientRootCertificateListResponse = networkManagementClient.getClientRootCertificatesOperations().list(testNetworkName);
ArrayList<ClientRootCertificateListResponse.ClientRootCertificate> clientRootCertificatelist = ClientRootCertificateListResponse.getClientRootCertificates();
for (ClientRootCertificateListResponse.ClientRootCertificate clientRootCertificate : clientRootCertificatelist)
{
assertNotNull(clientRootCertificate.getThumbprint());
assertNotNull(clientRootCertificate.getExpirationTime());
assertNotNull(clientRootCertificate.getSubject());
}
try {
ClientRootCertificateListResponse ClientRootCertificateListResponse = networkManagementClient.getClientRootCertificatesOperations().list(testNetworkName);
ArrayList<ClientRootCertificateListResponse.ClientRootCertificate> clientRootCertificatelist = ClientRootCertificateListResponse.getClientRootCertificates();
for (ClientRootCertificateListResponse.ClientRootCertificate clientRootCertificate : clientRootCertificatelist) {
assertNotNull(clientRootCertificate.getThumbprint());
assertNotNull(clientRootCertificate.getExpirationTime());
assertNotNull(clientRootCertificate.getSubject());
}
} catch (ServiceException e) {
}
catch (ServiceException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.xml.sax.SAXException;

public class GatewayOperationsTests extends NetworkManagementIntegrationTestBase {
@BeforeClass
public static void setup() throws Exception {
createService();
Expand Down Expand Up @@ -84,7 +84,7 @@ public void createGatewayOnEmptyNetworkFailed() throws Exception {
@Test
public void getGatewaySuccess() throws Exception {
// Act
GatewayGetResponse gatewayGetResponse = gatewayOperations.get(testNetworkName);
GatewayGetResponse gatewayGetResponse = gatewayOperations.get(testNetworkName);
// Assert
Assert.assertEquals(200, gatewayGetResponse.getStatusCode());
Assert.assertNotNull(gatewayGetResponse.getRequestId());
Expand All @@ -103,6 +103,6 @@ public void listGatewayFailedWithInsufficientPermission() throws Exception {
assertNotNull(gatewayConnection.getLastConnectionEstablished());
assertNotNull(gatewayConnection.getLastEvent());
assertNotNull(gatewayConnection.getLocalNetworkSiteName());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

public abstract class NetworkManagementIntegrationTestBase {

protected static NetworkManagementClient networkManagementClient;
protected static NetworkManagementClient networkManagementClient;
protected static NetworkOperations networkOperations;
protected static ReservedIPOperations reservedIPOperations;
protected static GatewayOperations gatewayOperations;
Expand All @@ -68,13 +68,13 @@ protected static void createService() throws Exception {
}

protected static Configuration createConfiguration() throws Exception {
String baseUri = System.getenv(ManagementConfiguration.URI);
return ManagementConfiguration.configure(
baseUri != null ? new URI(baseUri) : null,
System.getenv(ManagementConfiguration.SUBSCRIPTION_ID),
System.getenv(ManagementConfiguration.KEYSTORE_PATH),
System.getenv(ManagementConfiguration.KEYSTORE_PASSWORD),
KeyStoreType.fromString(System.getenv(ManagementConfiguration.KEYSTORE_TYPE)));
String baseUri = System.getenv(ManagementConfiguration.URI);
return ManagementConfiguration.configure(
baseUri != null ? new URI(baseUri) : null,
System.getenv(ManagementConfiguration.SUBSCRIPTION_ID),
System.getenv(ManagementConfiguration.KEYSTORE_PATH),
System.getenv(ManagementConfiguration.KEYSTORE_PASSWORD),
KeyStoreType.fromString(System.getenv(ManagementConfiguration.KEYSTORE_TYPE)));
}

protected static void createNetwork(String networkName) throws Exception {
Expand Down Expand Up @@ -127,17 +127,14 @@ protected static void createNetwork(String networkName) throws Exception {
}
}

protected static void deleteNetwork(String networkName)
{
protected static void deleteNetwork(String networkName) {
NetworkGetConfigurationResponse operationResponse = null ;
boolean exist = false;

try {
operationResponse = networkManagementClient.getNetworksOperations().getConfiguration();
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}

//Assert
Expand All @@ -155,11 +152,8 @@ protected static void deleteNetwork(String networkName)
try {
responseDoc = documentBuilder.parse(new BOMInputStream(new ByteArrayInputStream(operationResponse.getConfiguration().getBytes())));
} catch (NullPointerException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

NodeList virtualNetworkSitelist = responseDoc.getElementsByTagNameNS("http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration", "VirtualNetworkSite");
Expand Down Expand Up @@ -197,13 +191,9 @@ protected static void deleteNetwork(String networkName)
try {
networkOperations.setConfiguration(parameters);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ public void setConfiguration() throws Exception {
@Test
public void listNetworksSuccess() throws Exception {
// Arrange
NetworkListResponse NetworkListResponse = networkOperations.list();
ArrayList<NetworkListResponse.VirtualNetworkSite> virtualnetwoksitelist = NetworkListResponse.getVirtualNetworkSites();
for (NetworkListResponse.VirtualNetworkSite networksite : virtualnetwoksitelist)
{
assertNotNull(networksite.getName());
assertNotNull(networksite.getAffinityGroup());
assertNotNull(networksite.getId());
assertNotNull(networksite.getState());
assertNotNull(networksite.getAddressSpace());
assertNotNull(networksite.getSubnets());

}
NetworkListResponse NetworkListResponse = networkOperations.list();
ArrayList<NetworkListResponse.VirtualNetworkSite> virtualnetwoksitelist = NetworkListResponse.getVirtualNetworkSites();
for (NetworkListResponse.VirtualNetworkSite networksite : virtualnetwoksitelist) {
assertNotNull(networksite.getName());
assertNotNull(networksite.getAffinityGroup());
assertNotNull(networksite.getId());
assertNotNull(networksite.getState());
assertNotNull(networksite.getAddressSpace());
assertNotNull(networksite.getSubnets());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ public void checkIllegalIPAddressFailed() throws Exception {

// Act
staticIPOperations.check(testNetworkName, ipAddress);

}
}
}

0 comments on commit d23cdee

Please sign in to comment.