Search in sources :

Example 1 with WarningImpl

use of com.mysql.cj.xdevapi.WarningImpl in project aws-mysql-jdbc by awslabs.

the class XProtocolTest method testWarnings.

@Test
public void testWarnings() {
    assumeTrue(this.isSetForXTests, PropertyDefinitions.SYSP_testsuite_url_mysqlx + " must be set to run this test.");
    this.protocol.send(this.messageBuilder.buildSqlStatement("explain select 1"), 0);
    this.protocol.readMetadata();
    this.protocol.drainRows();
    SqlResult res = this.protocol.readQueryResult(new SqlResultBuilder(this.protocol.getServerSession().getDefaultTimeZone(), this.protocol.getPropertySet()));
    Iterable<Warning> iterable = () -> res.getWarnings();
    List<Warning> warnings = StreamSupport.stream(iterable.spliterator(), false).map(w -> new WarningImpl(w)).collect(Collectors.toList());
    assertEquals(1, warnings.size());
    Warning w = warnings.get(0);
    assertEquals(1, w.getLevel());
    assertEquals(1003, w.getCode());
    // this message format might change over time and have to be loosened up
    assertEquals("/* select#1 */ select 1 AS `1`", w.getMessage());
}
Also used : MysqlErrorNumbers(com.mysql.cj.exceptions.MysqlErrorNumbers) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) XProtocolRowInputStream(com.mysql.cj.protocol.x.XProtocolRowInputStream) MysqlType(com.mysql.cj.MysqlType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) BiConsumer(java.util.function.BiConsumer) StreamSupport(java.util.stream.StreamSupport) XServerCapabilities(com.mysql.cj.protocol.x.XServerCapabilities) DocFilterParams(com.mysql.cj.xdevapi.DocFilterParams) SqlResultBuilder(com.mysql.cj.xdevapi.SqlResultBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StringValueFactory(com.mysql.cj.result.StringValueFactory) UpdateSpec(com.mysql.cj.xdevapi.UpdateSpec) UpdateType(com.mysql.cj.xdevapi.UpdateType) Warning(com.mysql.cj.xdevapi.Warning) Iterator(java.util.Iterator) ColumnDefinition(com.mysql.cj.protocol.ColumnDefinition) XMessageBuilder(com.mysql.cj.protocol.x.XMessageBuilder) Field(com.mysql.cj.result.Field) InsertParams(com.mysql.cj.xdevapi.InsertParams) IOException(java.io.IOException) TableFilterParams(com.mysql.cj.xdevapi.TableFilterParams) WarningImpl(com.mysql.cj.xdevapi.WarningImpl) Collectors(java.util.stream.Collectors) PropertyDefinitions(com.mysql.cj.conf.PropertyDefinitions) StatementExecuteOkBuilder(com.mysql.cj.protocol.x.StatementExecuteOkBuilder) XProtocolError(com.mysql.cj.protocol.x.XProtocolError) Test(org.junit.jupiter.api.Test) SqlResult(com.mysql.cj.xdevapi.SqlResult) Row(com.mysql.cj.result.Row) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) FilterParams(com.mysql.cj.xdevapi.FilterParams) XProtocol(com.mysql.cj.protocol.x.XProtocol) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Warning(com.mysql.cj.xdevapi.Warning) SqlResult(com.mysql.cj.xdevapi.SqlResult) SqlResultBuilder(com.mysql.cj.xdevapi.SqlResultBuilder) WarningImpl(com.mysql.cj.xdevapi.WarningImpl) Test(org.junit.jupiter.api.Test)

Aggregations

MysqlType (com.mysql.cj.MysqlType)1 PropertyDefinitions (com.mysql.cj.conf.PropertyDefinitions)1 MysqlErrorNumbers (com.mysql.cj.exceptions.MysqlErrorNumbers)1 ColumnDefinition (com.mysql.cj.protocol.ColumnDefinition)1 StatementExecuteOkBuilder (com.mysql.cj.protocol.x.StatementExecuteOkBuilder)1 XMessageBuilder (com.mysql.cj.protocol.x.XMessageBuilder)1 XProtocol (com.mysql.cj.protocol.x.XProtocol)1 XProtocolError (com.mysql.cj.protocol.x.XProtocolError)1 XProtocolRowInputStream (com.mysql.cj.protocol.x.XProtocolRowInputStream)1 XServerCapabilities (com.mysql.cj.protocol.x.XServerCapabilities)1 Field (com.mysql.cj.result.Field)1 Row (com.mysql.cj.result.Row)1 StringValueFactory (com.mysql.cj.result.StringValueFactory)1 DocFilterParams (com.mysql.cj.xdevapi.DocFilterParams)1 FilterParams (com.mysql.cj.xdevapi.FilterParams)1 InsertParams (com.mysql.cj.xdevapi.InsertParams)1 SqlResult (com.mysql.cj.xdevapi.SqlResult)1 SqlResultBuilder (com.mysql.cj.xdevapi.SqlResultBuilder)1 TableFilterParams (com.mysql.cj.xdevapi.TableFilterParams)1 UpdateSpec (com.mysql.cj.xdevapi.UpdateSpec)1