NO-JIRA Allow validation points to use asserts, adds a new test in idle

test.
This commit is contained in:
Timothy Bish 2015-10-22 10:17:41 -04:00
parent 9ddd162d25
commit 7c06d8d683
5 changed files with 75 additions and 11 deletions

View File

@ -507,12 +507,20 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
@Override @Override
protected void doOpenInspection() { protected void doOpenInspection() {
try {
getStateInspector().inspectOpenedResource(getConnection()); getStateInspector().inspectOpenedResource(getConnection());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doClosedInspection() { protected void doClosedInspection() {
try {
getStateInspector().inspectClosedResource(getConnection()); getStateInspector().inspectClosedResource(getConnection());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
protected void fireClientException(Throwable ex) { protected void fireClientException(Throwable ex) {

View File

@ -512,17 +512,29 @@ public class AmqpReceiver extends AmqpAbstractResource<Receiver> {
@Override @Override
protected void doOpenInspection() { protected void doOpenInspection() {
try {
getStateInspector().inspectOpenedResource(getReceiver()); getStateInspector().inspectOpenedResource(getReceiver());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doClosedInspection() { protected void doClosedInspection() {
try {
getStateInspector().inspectClosedResource(getReceiver()); getStateInspector().inspectClosedResource(getReceiver());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doDetachedInspection() { protected void doDetachedInspection() {
try {
getStateInspector().inspectDetachedResource(getReceiver()); getStateInspector().inspectDetachedResource(getReceiver());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
protected void configureSource(Source source) { protected void configureSource(Source source) {

View File

@ -278,17 +278,29 @@ public class AmqpSender extends AmqpAbstractResource<Sender> {
@Override @Override
protected void doOpenInspection() { protected void doOpenInspection() {
try {
getStateInspector().inspectOpenedResource(getSender()); getStateInspector().inspectOpenedResource(getSender());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doClosedInspection() { protected void doClosedInspection() {
try {
getStateInspector().inspectClosedResource(getSender()); getStateInspector().inspectClosedResource(getSender());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doDetachedInspection() { protected void doDetachedInspection() {
try {
getStateInspector().inspectDetachedResource(getSender()); getStateInspector().inspectDetachedResource(getSender());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override

View File

@ -381,12 +381,20 @@ public class AmqpSession extends AmqpAbstractResource<Session> {
@Override @Override
protected void doOpenInspection() { protected void doOpenInspection() {
try {
getStateInspector().inspectOpenedResource(getSession()); getStateInspector().inspectOpenedResource(getSession());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
@Override @Override
protected void doClosedInspection() { protected void doClosedInspection() {
try {
getStateInspector().inspectClosedResource(getSession()); getStateInspector().inspectClosedResource(getSession());
} catch (Throwable error) {
getStateInspector().markAsInvalid(error.getMessage());
}
} }
private String getNextSenderId() { private String getNextSenderId() {

View File

@ -54,7 +54,8 @@ public class AmqpBrokerReuqestedHearbeatsTest extends AmqpClientTestSupport {
@Override @Override
public void inspectOpenedResource(Connection connection) { public void inspectOpenedResource(Connection connection) {
assertEquals(TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout()); assertEquals("Broker did not send half the idle timeout",
TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout());
} }
}); });
@ -65,6 +66,29 @@ public class AmqpBrokerReuqestedHearbeatsTest extends AmqpClientTestSupport {
connection.close(); connection.close();
} }
@Test(timeout = 60000)
public void testBrokerSendsHalfConfiguredIdleTimeoutWhenClientSendsTimeout() throws Exception {
AmqpClient client = createAmqpClient();
assertNotNull(client);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Connection connection) {
assertEquals("Broker did not send half the idle timeout",
TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout());
}
});
AmqpConnection connection = client.createConnection();
connection.setIdleTimeout(TEST_IDLE_TIMEOUT * 4);
assertNotNull(connection);
connection.connect();
connection.getStateInspector().assertValid();
connection.close();
}
@Test(timeout = 60000) @Test(timeout = 60000)
public void testClientWithoutHeartbeatsGetsDropped() throws Exception { public void testClientWithoutHeartbeatsGetsDropped() throws Exception {