Java Code Examples for com.rabbitmq.client.impl.LongStringHelper

The following examples show how to use com.rabbitmq.client.impl.LongStringHelper. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rabbitmq-mock   Source File: MockConnectionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void connectionParams_are_default_ones() {
    Connection connection = new MockConnectionFactory().newConnection();

    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(connection.getAddress().getHostAddress()).isEqualTo("127.0.0.1");
    softly.assertThat(connection.getPort()).isEqualTo(ConnectionFactory.DEFAULT_AMQP_PORT);
    softly.assertThat(connection.getChannelMax()).isEqualTo(0);
    softly.assertThat(connection.getFrameMax()).isEqualTo(0);
    softly.assertThat(connection.getHeartbeat()).isEqualTo(0);
    softly.assertThat(connection.getClientProperties()).isEqualTo(AMQConnection.defaultClientProperties());
    softly.assertThat(connection.getClientProvidedName()).isNull();
    softly.assertThat(connection.getServerProperties().get("version"))
        .isEqualTo(LongStringHelper.asLongString(new Version(AMQP.PROTOCOL.MAJOR, AMQP.PROTOCOL.MINOR).toString()));
    softly.assertThat(connection.getExceptionHandler()).isExactlyInstanceOf(DefaultExceptionHandler.class);
    softly.assertAll();
}
 
Example 2
Source Project: pinpoint   Source File: RabbitMQTestConstants.java    License: Apache License 2.0 5 votes vote down vote up
public SaslMechanism getSaslMechanism(String[] mechanisms) {
    return new SaslMechanism() {
        public String getName() {
            return "ANONYMOUS";
        }

        public LongString handleChallenge(LongString challenge, String username, String password) {
            return LongStringHelper.asLongString("");
        }
    };
}
 
Example 3
Source Project: rabbitmq-mock   Source File: MockConnection.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Object> getServerProperties() {
    return Collections.singletonMap("version",
        LongStringHelper.asLongString(new Version(AMQP.PROTOCOL.MAJOR, AMQP.PROTOCOL.MINOR).toString()));
}
 
Example 4
Source Project: vertx-rabbitmq-client   Source File: UtilsTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testConvertWithHeaders() {

  Map<String, Object> customListMap = new HashMap<>();
  customListMap.put( "count", 4L);
  customListMap.put( "exchange", LongStringHelper.asLongString( "exchange1" ) );
  customListMap.put( "reason", LongStringHelper.asLongString( "expired" ) );
  customListMap.put( "routing-keys", Arrays.asList(
    LongStringHelper.asLongString( "key1" ),
    LongStringHelper.asLongString( "key2" )
  ));
  customListMap.put( "time", Date.from( Instant.ofEpochSecond( 1570140666 ) ) );

  List<Map<String, Object>> customList = new ArrayList<>();
  customList.add(customListMap);

  Map<String, Object> headers = new HashMap<>();
  headers.put( "customId", 123 );
  headers.put( "customQualifier", "qualifier1" );
  headers.put( "customQualifierLongString", LongStringHelper.asLongString( "qualifier2" ) );
  headers.put( "customList", customList );

  JsonObject result = Utils.toJson( new BasicPropertiesTestBuilder().setHeaders( headers ).build() );
  Map<String, Object> headersConverted = result.getJsonObject( "headers" ).getMap();
  assertNotNull( headersConverted );
  assertEquals( 4, headersConverted.entrySet().size() );
  assertEquals( 123, headersConverted.get( "customId" ) );
  assertEquals( "qualifier1", headersConverted.get( "customQualifier" ) );
  assertEquals( "qualifier2", headersConverted.get( "customQualifierLongString" ) );
  assertNotNull( headersConverted.get( "customList" ) );

  List<Map<String, Object>> headersConvertedCustomList = (List<Map<String, Object>>) headersConverted.get( "customList");
  assertEquals( 1, headersConvertedCustomList.size() );
  assertEquals( 4L, headersConvertedCustomList.get(0).get("count") );
  assertEquals( "exchange1", headersConvertedCustomList.get(0).get("exchange") );
  assertEquals( "expired", headersConvertedCustomList.get(0).get("reason") );
  assertEquals( Instant.parse("2019-10-03T22:11:06Z"), headersConvertedCustomList.get(0).get("time") );

  List<String> headersConvertedCustomListMapRoutingKeys = (List<String>) headersConvertedCustomList.get(0).get("routing-keys");

  assertNotNull( headersConvertedCustomListMapRoutingKeys );
  assertEquals( 2, headersConvertedCustomListMapRoutingKeys.size() );
  assertEquals( "key1", headersConvertedCustomListMapRoutingKeys.get(0) );
  assertEquals( "key2", headersConvertedCustomListMapRoutingKeys.get(1) );
}