use of com.mysql.cj.protocol.PacketReceivedTimeHolder in project JavaSegundasQuintas by ecteruel.
the class ConnectionRegressionTest method testBug45419.
/**
* Tests fix for BUG#45419, ensure that time is not converted to seconds before being reported as milliseconds.
*
* @throws Exception
*/
@Test
public void testBug45419() throws Exception {
Exception e = null;
String msg = ExceptionFactory.createLinkFailureMessageBasedOnHeuristics(((MysqlConnection) this.conn).getPropertySet(), ((MysqlConnection) this.conn).getSession().getServerSession(), new PacketSentTimeHolder() {
@Override
public long getPreviousPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
@Override
public long getLastPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
}, new PacketReceivedTimeHolder() {
@Override
public long getLastPacketReceivedTime() {
return System.currentTimeMillis() - 2000;
}
}, e);
Matcher m = Pattern.compile("\\d.?\\d{3}", Pattern.MULTILINE).matcher(msg);
assertTrue(m.find());
assertTrue(Long.parseLong(m.group().replaceAll("[^\\d]", "")) >= 2000);
assertTrue(m.find());
assertTrue(Long.parseLong(m.group().replaceAll("[^\\d]", "")) >= 1000);
}
use of com.mysql.cj.protocol.PacketReceivedTimeHolder in project JavaSegundasQuintas by ecteruel.
the class ConnectionRegressionTest method testBug44587.
/**
* Tests fix for BUG#44587, provide last packet sent/received timing in all connection failure errors.
*
* @throws Exception
*/
@Test
public void testBug44587() throws Exception {
Exception e = null;
String msg = ExceptionFactory.createLinkFailureMessageBasedOnHeuristics(((MysqlConnection) this.conn).getPropertySet(), ((MysqlConnection) this.conn).getSession().getServerSession(), new PacketSentTimeHolder() {
@Override
public long getPreviousPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
@Override
public long getLastPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
}, new PacketReceivedTimeHolder() {
@Override
public long getLastPacketReceivedTime() {
return System.currentTimeMillis() - 2000;
}
}, e);
assertTrue(containsMessage(msg, "CommunicationsException.ServerPacketTimingInfo"));
}
use of com.mysql.cj.protocol.PacketReceivedTimeHolder in project ABC by RuiPinto96274.
the class ConnectionRegressionTest method testBug44587.
/**
* Tests fix for BUG#44587, provide last packet sent/received timing in all connection failure errors.
*
* @throws Exception
*/
@Test
public void testBug44587() throws Exception {
Exception e = null;
String msg = ExceptionFactory.createLinkFailureMessageBasedOnHeuristics(((MysqlConnection) this.conn).getPropertySet(), ((MysqlConnection) this.conn).getSession().getServerSession(), new PacketSentTimeHolder() {
@Override
public long getPreviousPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
@Override
public long getLastPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
}, new PacketReceivedTimeHolder() {
@Override
public long getLastPacketReceivedTime() {
return System.currentTimeMillis() - 2000;
}
}, e);
assertTrue(containsMessage(msg, "CommunicationsException.ServerPacketTimingInfo"));
}
use of com.mysql.cj.protocol.PacketReceivedTimeHolder in project aws-mysql-jdbc by awslabs.
the class ConnectionRegressionTest method testBug44587.
/**
* Tests fix for BUG#44587, provide last packet sent/received timing in all connection failure errors.
*
* @throws Exception
*/
@Test
public void testBug44587() throws Exception {
Exception e = null;
String msg = ExceptionFactory.createLinkFailureMessageBasedOnHeuristics(((MysqlConnection) this.conn).getPropertySet(), ((MysqlConnection) this.conn).getSession().getServerSession(), new PacketSentTimeHolder() {
@Override
public long getPreviousPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
@Override
public long getLastPacketSentTime() {
return System.currentTimeMillis() - 1000;
}
}, new PacketReceivedTimeHolder() {
@Override
public long getLastPacketReceivedTime() {
return System.currentTimeMillis() - 2000;
}
}, e);
assertTrue(containsMessage(msg, "CommunicationsException.ServerPacketTimingInfo"));
}
use of com.mysql.cj.protocol.PacketReceivedTimeHolder in project aws-mysql-jdbc by awslabs.
the class ExceptionsTest method testConstructors.
@Test
public void testConstructors() {
new CommunicationsException(TEST_MESSAGE, new Throwable());
new CommunicationsException((JdbcConnection) this.conn, new PacketSentTimeHolder() {
}, new PacketReceivedTimeHolder() {
}, new Exception());
new ConnectionFeatureNotAvailableException(TEST_MESSAGE, new Throwable());
new ConnectionFeatureNotAvailableException((JdbcConnection) this.conn, new PacketSentTimeHolder() {
}, new Exception());
new MysqlDataTruncation(TEST_MESSAGE, 0, false, false, 0, 0, 0);
new MySQLQueryInterruptedException();
new MySQLQueryInterruptedException(TEST_MESSAGE);
new MySQLQueryInterruptedException(TEST_MESSAGE, TEST_SQL_STATE);
new MySQLQueryInterruptedException(TEST_MESSAGE, TEST_SQL_STATE, 0);
new MySQLStatementCancelledException();
new MySQLStatementCancelledException(TEST_MESSAGE);
new MySQLStatementCancelledException(TEST_MESSAGE, TEST_SQL_STATE);
new MySQLStatementCancelledException(TEST_MESSAGE, TEST_SQL_STATE, 0);
new MySQLTimeoutException();
new MySQLTimeoutException(TEST_MESSAGE);
new MySQLTimeoutException(TEST_MESSAGE, TEST_SQL_STATE);
new MySQLTimeoutException(TEST_MESSAGE, TEST_SQL_STATE, 0);
new MySQLTransactionRollbackException();
new MySQLTransactionRollbackException(TEST_MESSAGE);
new MySQLTransactionRollbackException(TEST_MESSAGE, TEST_SQL_STATE);
new MySQLTransactionRollbackException(TEST_MESSAGE, TEST_SQL_STATE, 0);
new NotUpdatable(TEST_MESSAGE);
new OperationNotSupportedException();
new OperationNotSupportedException(TEST_MESSAGE);
new PacketTooBigException(TEST_MESSAGE);
new PacketTooBigException(0, 100);
new SQLError();
}
Aggregations