mirror of https://github.com/apache/activemq.git
NO-JIRA Allow validation points to use asserts, adds a new test in idle
test.
This commit is contained in:
parent
9ddd162d25
commit
7c06d8d683
|
@ -507,12 +507,20 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
|
|||
|
||||
@Override
|
||||
protected void doOpenInspection() {
|
||||
getStateInspector().inspectOpenedResource(getConnection());
|
||||
try {
|
||||
getStateInspector().inspectOpenedResource(getConnection());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClosedInspection() {
|
||||
getStateInspector().inspectClosedResource(getConnection());
|
||||
try {
|
||||
getStateInspector().inspectClosedResource(getConnection());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireClientException(Throwable ex) {
|
||||
|
|
|
@ -512,17 +512,29 @@ public class AmqpReceiver extends AmqpAbstractResource<Receiver> {
|
|||
|
||||
@Override
|
||||
protected void doOpenInspection() {
|
||||
getStateInspector().inspectOpenedResource(getReceiver());
|
||||
try {
|
||||
getStateInspector().inspectOpenedResource(getReceiver());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClosedInspection() {
|
||||
getStateInspector().inspectClosedResource(getReceiver());
|
||||
try {
|
||||
getStateInspector().inspectClosedResource(getReceiver());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDetachedInspection() {
|
||||
getStateInspector().inspectDetachedResource(getReceiver());
|
||||
try {
|
||||
getStateInspector().inspectDetachedResource(getReceiver());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void configureSource(Source source) {
|
||||
|
|
|
@ -278,17 +278,29 @@ public class AmqpSender extends AmqpAbstractResource<Sender> {
|
|||
|
||||
@Override
|
||||
protected void doOpenInspection() {
|
||||
getStateInspector().inspectOpenedResource(getSender());
|
||||
try {
|
||||
getStateInspector().inspectOpenedResource(getSender());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClosedInspection() {
|
||||
getStateInspector().inspectClosedResource(getSender());
|
||||
try {
|
||||
getStateInspector().inspectClosedResource(getSender());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDetachedInspection() {
|
||||
getStateInspector().inspectDetachedResource(getSender());
|
||||
try {
|
||||
getStateInspector().inspectDetachedResource(getSender());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -381,12 +381,20 @@ public class AmqpSession extends AmqpAbstractResource<Session> {
|
|||
|
||||
@Override
|
||||
protected void doOpenInspection() {
|
||||
getStateInspector().inspectOpenedResource(getSession());
|
||||
try {
|
||||
getStateInspector().inspectOpenedResource(getSession());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClosedInspection() {
|
||||
getStateInspector().inspectClosedResource(getSession());
|
||||
try {
|
||||
getStateInspector().inspectClosedResource(getSession());
|
||||
} catch (Throwable error) {
|
||||
getStateInspector().markAsInvalid(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNextSenderId() {
|
||||
|
|
|
@ -54,7 +54,8 @@ public class AmqpBrokerReuqestedHearbeatsTest extends AmqpClientTestSupport {
|
|||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
@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)
|
||||
public void testClientWithoutHeartbeatsGetsDropped() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue