diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index 5d8f04727b04..e5e3e865f67c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed 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 + * 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. + * 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 com.microsoft.windowsazure.serviceruntime; @@ -50,7 +50,6 @@ public final class RoleEnvironment { JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName()); } catch (JAXBException e) { - // TODO Auto-generated catch block e.printStackTrace(); } clientId = UUID.randomUUID().toString(); @@ -93,6 +92,7 @@ private static synchronized void initialize() { lastState = new AtomicReference(); runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() { + @Override public void goalStateChanged(GoalState newGoalState) { switch (newGoalState.getExpectedState()) { case STARTED: diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ConnectionStringSyntaxException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ConnectionStringSyntaxException.java index 5f6a24c8f0ce..4b611302e2ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ConnectionStringSyntaxException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ConnectionStringSyntaxException.java @@ -1,22 +1,24 @@ /** * Copyright Microsoft Corporation - * + * * Licensed 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. + * 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 com.microsoft.windowsazure.services.core.utils; public class ConnectionStringSyntaxException extends Exception { + private static final long serialVersionUID = 9074252127254835859L; + public ConnectionStringSyntaxException(String message) { super(message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 2efac14c00b0..2d7a029c30c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -28,7 +28,7 @@ public static ServiceException process(String serviceName, ServiceException exce Throwable cause = exception.getCause(); for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - Class scanClass = scan.getClass(); + Class scanClass = scan.getClass(); if (ServiceException.class.isAssignableFrom(scanClass)) { return populate(exception, serviceName, (ServiceException) scan); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index 826ea46fd63e..e67717853055 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java @@ -19,7 +19,7 @@ import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonWriteNullProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; // // members of this class defined per specification at @@ -27,7 +27,7 @@ // @JsonIgnoreProperties(ignoreUnknown = true) -@JsonWriteNullProperties(false) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) public class BrokerProperties { @JsonProperty("CorrelationId") diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index 5a8dda45f9ba..a01aa2aed43b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed 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 + * 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. + * 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 com.microsoft.windowsazure.services.serviceBus.implementation; @@ -31,18 +31,12 @@ public BrokerProperties fromString(String value) throws IllegalArgumentException return mapper.readValue(value.getBytes(), BrokerProperties.class); } catch (JsonParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } } @@ -54,18 +48,12 @@ public String toString(BrokerProperties value) { mapper.writeValue(writer, value); } catch (JsonGenerationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } return writer.toString(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index fbda9c3f7f5e..3edfc51d87c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed 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 + * 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. + * 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 com.microsoft.windowsazure.services.serviceBus.implementation; @@ -30,19 +30,16 @@ public class MarshallerProvider implements ContextResolver { @Context private ContextResolver jaxbContextResolver; + @Override public Marshaller getContext(Class type) { Marshaller marshaller; try { marshaller = getJAXBContext(type).createMarshaller(); } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); @@ -50,8 +47,6 @@ public Marshaller getContext(Class type) { marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); } catch (PropertyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } return marshaller; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index df43072ce8cc..5255b4ec25cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed 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 + * 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. + * 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 com.microsoft.windowsazure.services.serviceBus.implementation; @@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; -import javax.inject.Named; import javax.management.timer.Timer; import com.microsoft.windowsazure.services.core.ServiceException; @@ -41,7 +40,7 @@ public class WrapTokenManager { @Inject public WrapTokenManager(WrapContract contract, DateFactory dateFactory, - ServiceBusConnectionSettings connectionSettings) { + ServiceBusConnectionSettings connectionSettings) { this.contract = contract; this.dateFactory = dateFactory; this.uri = connectionSettings.getWrapUri(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java index 6b5e12695101..924ab0fead22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java @@ -202,6 +202,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } @@ -232,6 +234,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java index d14843554216..352115a45dba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java @@ -55,8 +55,6 @@ public void sign(ClientRequest cr) { if (log.isDebugEnabled()) { log.debug(String.format("String to sign: \"%s\"", stringToSign)); } - //TODO: Remove or comment the following line - //System.out.println(String.format("String to sign: \"%s\"", stringToSign)); String signature = this.getSigner().sign(stringToSign); cr.getHeaders().putSingle("Authorization", "SharedKey " + this.getAccountName() + ":" + signature); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java index 043032a474ab..0daec9926c02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java @@ -260,6 +260,8 @@ else if (value.getClass() == byte[].class) { for (byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else if (value.getClass() == Byte[].class) { @@ -269,6 +271,8 @@ else if (value.getClass() == Byte[].class) { for (Byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index 42f4d4acab31..00a669a080ff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -2,25 +2,26 @@ * Copyright Microsoft Corporation * * Licensed 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 + * 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. + * 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 com.microsoft.windowsazure.serviceruntime; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.LinkedList; import java.util.List; import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; /** * @@ -88,7 +89,7 @@ public void goalStateClientRestartsThread() { Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { - private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); + private final ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); @Override public void initialize(InputStream inputStream) { @@ -148,7 +149,6 @@ public RoleEnvironmentData deserialize(InputStream stream) { client.getCurrentGoalState(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index 81ac9334d8dc..cba0245c4270 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -40,13 +40,6 @@ public class BlobTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/ParsedConnectionStringTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/ParsedConnectionStringTest.java index 6da2023a2ef9..68c5972d1d7f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/ParsedConnectionStringTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/ParsedConnectionStringTest.java @@ -1,11 +1,11 @@ /** * Copyright Microsoft Corporation - * + * * Licensed 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. @@ -15,12 +15,13 @@ package com.microsoft.windowsazure.services.core.utils; -import com.microsoft.windowsazure.services.core.utils.pipeline.ConnectionStringField; +import static org.junit.Assert.*; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import static org.junit.Assert.*; +import com.microsoft.windowsazure.services.core.utils.pipeline.ConnectionStringField; public class ParsedConnectionStringTest { @@ -35,6 +36,7 @@ public String getAField() { return aField; } + @SuppressWarnings("unused") protected void setAField(String aField) { this.aField = aField; } @@ -52,7 +54,6 @@ private static class ThreeFields extends ParsedConnectionString { private String fieldTwo; private int fieldThree; - public ThreeFields(String connectionString) throws ConnectionStringSyntaxException { super(connectionString); } @@ -61,6 +62,7 @@ public String getFieldOne() { return fieldOne; } + @SuppressWarnings("unused") protected void setFieldOne(String fieldOne) { this.fieldOne = fieldOne; } @@ -69,6 +71,7 @@ public String getFieldTwo() { return fieldTwo; } + @SuppressWarnings("unused") protected void setFieldTwo(String fieldTwo) { this.fieldTwo = fieldTwo; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index b3c266fac5ae..fd3a57a7f1f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -67,6 +67,7 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int initialCount = 0; for (CloudQueue queue : qClient.listQueues()) { + Assert.assertNotNull(queue); initialCount++; } @@ -82,6 +83,7 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int count = 0; for (CloudQueue queue : qClient.listQueues()) { + Assert.assertNotNull(queue); count++; } @@ -111,6 +113,7 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxException, StorageException { int count = 0; for (CloudQueue queue : qClient.listQueues()) { + Assert.assertNotNull(queue); count++; } @@ -130,6 +133,7 @@ public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxEx count = 0; for (CloudQueue queue : qClient.listQueues()) { + Assert.assertNotNull(queue); count++; } } @@ -181,16 +185,19 @@ public void testListQueuesSegmented() throws URISyntaxException, StorageExceptio public void testListQueuesEqual() throws URISyntaxException, StorageException { int count1 = 0; for (CloudQueue queue : qClient.listQueues()) { + Assert.assertNotNull(queue); count1++; } int count2 = 0; for (CloudQueue queue : qClient.listQueues("")) { + Assert.assertNotNull(queue); count2++; } int count3 = 0; for (CloudQueue queue : qClient.listQueues(null)) { + Assert.assertNotNull(queue); count3++; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index d97bb4bdc7b4..9258e5931787 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -487,6 +487,7 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns int count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { + Assert.assertNotNull(m); count++; } @@ -498,6 +499,7 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { + Assert.assertNotNull(m); count++; } @@ -674,7 +676,7 @@ public void testAddMessageLargeMessageInput() throws URISyntaxException, Storage @Test public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, StorageException, - UnsupportedEncodingException { + UnsupportedEncodingException, InterruptedException { final String queueName = UUID.randomUUID().toString().toLowerCase(); final CloudQueue queue = qClient.getQueueReference(queueName); queue.create(); @@ -683,13 +685,7 @@ public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, Sto Date d1 = m1.getExpirationTime(); queue.deleteMessage(m1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + Thread.sleep(2000); queue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage m2 = queue.retrieveMessage(); @@ -818,7 +814,8 @@ public void testDeleteMessageNullMessage() throws URISyntaxException, StorageExc } @Test - public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -833,13 +830,7 @@ public void testRetrieveMessage() throws URISyntaxException, StorageException, U newQueue.deleteMessage(message1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + Thread.sleep(2000); newQueue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage message2 = newQueue.retrieveMessage(); @@ -917,7 +908,8 @@ public void testRetrieveMessagesNonFound() throws URISyntaxException, StorageExc } @Test - public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -926,14 +918,7 @@ public void testDequeueCountIncreases() throws URISyntaxException, StorageExcept Assert.assertTrue(message1.getDequeueCount() == 1); for (int i = 2; i < 5; i++) { - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + Thread.sleep(2000); CloudQueueMessage message2 = newQueue.retrieveMessage(1, null, null); Assert.assertTrue(message2.getDequeueCount() == i); } @@ -1147,7 +1132,8 @@ public void testUpdateMessage() throws URISyntaxException, StorageException, Uns } @Test - public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -1162,13 +1148,7 @@ public void testUpdateMessageFullPass() throws URISyntaxException, StorageExcept Assert.assertTrue(popreceipt2 != popreceipt1); Assert.assertTrue(NextVisibleTim1.before(NextVisibleTim2)); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + Thread.sleep(2000); String newMesage = message.getMessageContentAsString() + "updated"; message.setMessageContent(newMesage); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index ead279ce3dbd..e44acb2a2100 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -41,13 +41,6 @@ public class QueueTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index bd86d9b7abf9..c09af13305b8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -128,7 +128,7 @@ public void getNonExistQueueFail() throws Exception { String queuePath = "testGetNonExistQueueFail"; // Act - GetQueueResult getQueueResult = service.getQueue(queuePath); + service.getQueue(queuePath); // Assert } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 7bec262714c0..d8818dddc09c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -334,7 +334,7 @@ public void tableInvalidQuery() throws StorageException, IOException, URISyntaxE } @Test - public void testQueryOnSupportedTypes() throws StorageException { + public void testQueryOnSupportedTypes() throws StorageException, InterruptedException { // Setup TableBatchOperation batch = new TableBatchOperation(); String pk = UUID.randomUUID().toString(); @@ -359,14 +359,8 @@ public void testQueryOnSupportedTypes() throws StorageException { ent.setGuid(UUID.randomUUID()); ent.setString(String.format("%04d", j)); - try { - // Add delay to make times unique - Thread.sleep(100); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + // Add delay to make times unique + Thread.sleep(100); batch.insert(ent); if (j == 50) { middleRef = ent; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index b5c68c6df876..80c7ce30738a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -176,12 +176,13 @@ public void assertEquality(ComplexEntity other) { Assert.assertEquals(this.getPartitionKey(), other.getPartitionKey()); Assert.assertEquals(this.getRowKey(), other.getRowKey()); - Assert.assertEquals(this.getDateTime(), other.getDateTime()); + assertDateApproxEquals(this.getDateTime(), other.getDateTime(), 100); + Assert.assertEquals(this.getGuid(), other.getGuid()); Assert.assertEquals(this.getString(), other.getString()); - Assert.assertEquals(this.getDouble(), other.getDouble()); - Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive()); + Assert.assertEquals(this.getDouble(), other.getDouble(), 1.0e-10); + Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive(), 1.0e-10); Assert.assertEquals(this.getInt32(), other.getInt32()); Assert.assertEquals(this.getIntegerPrimitive(), other.getIntegerPrimitive()); Assert.assertEquals(this.getBool(), other.getBool()); @@ -192,6 +193,18 @@ public void assertEquality(ComplexEntity other) { Assert.assertTrue(Arrays.equals(this.getBinaryPrimitive(), other.getBinaryPrimitive())); } + protected void assertDateApproxEquals(Date expected, Date actual, int deltaInMs) { + if (expected == null || actual == null) { + Assert.assertEquals(expected, actual); + } + else { + long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + if (diffInMilliseconds > deltaInMs) { + Assert.assertEquals(expected, actual); + } + } + } + /** * @return the binary */ @@ -567,12 +580,6 @@ public static class1 generateRandomEnitity(String pk) { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - //UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); }