Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<suppress checks="FinalClass" files="RequestResponseLink.java"/>
<suppress checks="FinalClass" files="Util.java"/>

<!-- star imports are ok in unit tests - it makes it easier to import all assertions, etc -->
<suppress checks="AvoidStarImport" files=".*[/\\]src[/\\]test[/\\]java[/\\].*\.java"/>

<!-- All auto generated files need to exclude from checkstyle -->
<suppress checks="[a-zA-Z0-9]*" files=".*[/\\]storage[/\\].*[/\\](models|implementation)[/\\].*\.java"/>
<suppress checks="UnusedImports" files=".*[/\\]storage[/\\].*Generated.*.java"/>
Expand Down
20 changes: 18 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
<wiremock-standalone.version>2.15.0</wiremock-standalone.version>
<jetty-http.version>9.4.11.v20180605</jetty-http.version>
<jetty-server.version>9.4.11.v20180605</jetty-server.version>
<junit.version>4.12</junit.version>
<junit4.version>4.12</junit4.version>
<junit5.version>5.5.0</junit5.version>
<commons-io.version>2.4</commons-io.version>

<!-- Maven Tool Versions -->
Expand Down Expand Up @@ -286,7 +287,22 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<version>${junit4.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit5.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit5.version}</version>
</dependency>

<dependency>
Expand Down
18 changes: 15 additions & 3 deletions pom.client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</pluginManagement>

Expand All @@ -473,9 +485,9 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<headerLocation>checkstyle/java.header</headerLocation>
<configLocation>eng/code-quality-reports/src/main/resources/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<headerLocation>eng/code-quality-reports/src/main/resources/checkstyle/java.header</headerLocation>
<propertyExpansion>samedir=</propertyExpansion>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure-core-amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

package com.azure.core.amqp;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

public class AmqpShutdownSignalTest {

Expand All @@ -19,11 +19,11 @@ public void constructor() {

AmqpShutdownSignal shutdownSignal = new AmqpShutdownSignal(isTransient, isInitiatedByClient, message);

Assert.assertTrue(shutdownSignal.isTransient());
Assert.assertTrue(shutdownSignal.isInitiatedByClient());
assertTrue(shutdownSignal.isTransient());
assertTrue(shutdownSignal.isInitiatedByClient());

String contents = shutdownSignal.toString();
Assert.assertNotNull(contents);
Assert.assertTrue(contents.contains(message));
assertNotNull(contents);
assertTrue(contents.contains(message));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.azure.core.amqp.exception.AmqpException;
import com.azure.core.amqp.exception.ErrorCondition;
import com.azure.core.amqp.exception.ErrorContext;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

import java.time.Duration;

Expand All @@ -30,15 +30,15 @@ public void retryDurationIncreases() {
// Act
retry.incrementRetryCount();
final Duration firstRetryInterval = retry.getNextRetryInterval(exception, remainingTime);
Assert.assertNotNull(firstRetryInterval);
assertNotNull(firstRetryInterval);

retry.incrementRetryCount();
final Duration leftoverTime = remainingTime.minus(firstRetryInterval);
final Duration secondRetryInterval = retry.getNextRetryInterval(exception, leftoverTime);

// Assert
Assert.assertNotNull(secondRetryInterval);
Assert.assertTrue(secondRetryInterval.toNanos() > firstRetryInterval.toNanos());
assertNotNull(secondRetryInterval);
assertTrue(secondRetryInterval.toNanos() > firstRetryInterval.toNanos());
}

/**
Expand All @@ -61,12 +61,12 @@ public void retryCloneBehavesSame() {
final Duration cloneRetryInterval = clone.getNextRetryInterval(exception, remainingTime);

// Assert
Assert.assertNotNull(retryInterval);
Assert.assertNotNull(cloneRetryInterval);
assertNotNull(retryInterval);
assertNotNull(cloneRetryInterval);

// The retry interval for the clone will be larger because we've incremented the retry count, so it should
// calculate a longer waiting period.
Assert.assertTrue(cloneRetryInterval.toNanos() > retryInterval.toNanos());
assertTrue(cloneRetryInterval.toNanos() > retryInterval.toNanos());
}

@Test
Expand All @@ -84,12 +84,12 @@ public void retryClone() {
final Duration cloneRetryInterval = clone.getNextRetryInterval(exception, remainingTime);

// Assert
Assert.assertNotSame(retry, clone);
Assert.assertEquals(retry, clone);
Assert.assertEquals(retry.hashCode(), clone.hashCode());
assertNotSame(retry, clone);
assertEquals(retry, clone);
assertEquals(retry.hashCode(), clone.hashCode());

Assert.assertNotNull(retryInterval);
Assert.assertNotNull(cloneRetryInterval);
Assert.assertEquals(retryInterval, cloneRetryInterval);
assertNotNull(retryInterval);
assertNotNull(cloneRetryInterval);
assertEquals(retryInterval, cloneRetryInterval);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

package com.azure.core.amqp;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

public class MessageConstantTest {

Expand All @@ -16,7 +16,7 @@ public void createFromString() {
String header = "absolute-expiry-time";
MessageConstant actual = MessageConstant.fromString(header);

Assert.assertEquals(MessageConstant.ABSOLUTE_EXPIRY_TIME, actual);
assertEquals(MessageConstant.ABSOLUTE_EXPIRY_TIME, actual);
}

/**
Expand All @@ -27,6 +27,6 @@ public void getHeaderValue() {
String expected = "x-opt-enqueued-time";
String actual = MessageConstant.ENQUEUED_TIME_UTC_ANNOTATION_NAME.getValue();

Assert.assertEquals(expected, actual);
assertEquals(expected, actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.azure.core.amqp.exception.AmqpException;
import com.azure.core.amqp.exception.ErrorCondition;
import com.azure.core.amqp.exception.ErrorContext;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

import java.time.Duration;

Expand All @@ -27,15 +27,15 @@ public void defaultRetryPolicy() {
// Act
retry.incrementRetryCount();
final Duration firstRetryInterval = retry.getNextRetryInterval(exception, remainingTime);
Assert.assertNotNull(firstRetryInterval);
assertNotNull(firstRetryInterval);

retry.incrementRetryCount();
final Duration leftoverTime = remainingTime.minus(firstRetryInterval);
final Duration secondRetryInterval = retry.getNextRetryInterval(exception, leftoverTime);

// Assert
Assert.assertNotNull(secondRetryInterval);
Assert.assertTrue(secondRetryInterval.toNanos() > firstRetryInterval.toNanos());
assertNotNull(secondRetryInterval);
assertTrue(secondRetryInterval.toNanos() > firstRetryInterval.toNanos());
}

/**
Expand All @@ -44,39 +44,39 @@ public void defaultRetryPolicy() {
@Test
public void canIncrementRetryCount() {
Retry retry = Retry.getDefaultRetry();
Assert.assertEquals(0, retry.getRetryCount());
Assert.assertEquals(0, retry.incrementRetryCount());
assertEquals(0, retry.getRetryCount());
assertEquals(0, retry.incrementRetryCount());

Assert.assertEquals(1, retry.getRetryCount());
Assert.assertEquals(1, retry.incrementRetryCount());
assertEquals(1, retry.getRetryCount());
assertEquals(1, retry.incrementRetryCount());

Assert.assertEquals(2, retry.getRetryCount());
Assert.assertEquals(2, retry.incrementRetryCount());
assertEquals(2, retry.getRetryCount());
assertEquals(2, retry.incrementRetryCount());

retry.resetRetryInterval();

Assert.assertEquals(0, retry.getRetryCount());
Assert.assertEquals(0, retry.incrementRetryCount());
assertEquals(0, retry.getRetryCount());
assertEquals(0, retry.incrementRetryCount());

Assert.assertEquals(1, retry.getRetryCount());
assertEquals(1, retry.getRetryCount());
}

@Test
public void isRetriableException() {
final Exception exception = new AmqpException(true, "error message", errorContext);
Assert.assertTrue(Retry.isRetriableException(exception));
assertTrue(Retry.isRetriableException(exception));
}

@Test
public void notRetriableException() {
final Exception invalidException = new RuntimeException("invalid exception");
Assert.assertFalse(Retry.isRetriableException(invalidException));
assertFalse(Retry.isRetriableException(invalidException));
}

@Test
public void notRetriableExceptionNotTransient() {
final Exception invalidException = new AmqpException(false, "Some test exception", errorContext);
Assert.assertFalse(Retry.isRetriableException(invalidException));
assertFalse(Retry.isRetriableException(invalidException));
}

/**
Expand All @@ -94,8 +94,8 @@ public void noRetryPolicy() {
int retryCount = noRetry.incrementRetryCount();

// Assert
Assert.assertEquals(0, retryCount);
Assert.assertNull(nextRetryInterval);
assertEquals(0, retryCount);
assertNull(nextRetryInterval);
}

/**
Expand All @@ -118,7 +118,7 @@ public void excessMaxRetry() {
final Duration nextRetryInterval = retry.getNextRetryInterval(exception, sixtySec);

// Assert
Assert.assertEquals(Retry.DEFAULT_MAX_RETRY_COUNT, retry.getRetryCount());
Assert.assertNull(nextRetryInterval);
assertEquals(Retry.DEFAULT_MAX_RETRY_COUNT, retry.getRetryCount());
assertNull(nextRetryInterval);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

package com.azure.core.amqp;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

public class TransportTypeTest {

Expand All @@ -16,16 +17,18 @@ public void createFromString() {
String socketString = "Amqpwebsockets";
TransportType actual = TransportType.fromString(socketString);

Assert.assertEquals(TransportType.AMQP_WEB_SOCKETS, actual);
assertEquals(TransportType.AMQP_WEB_SOCKETS, actual);
}

/**
* Verifies that an exception is thrown when an unknown transport type string is passed.
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void illegalTransportTypeString() {
String socketString = "AmqpNonExistent";
final String socketString = "AmqpNonExistent";

TransportType actual = TransportType.fromString(socketString);
assertThrows(IllegalArgumentException.class, () -> {
TransportType actual = TransportType.fromString(socketString);
});
}
}
Loading