interconnect/test/src/main/java/de/taimos/dvalin/interconnect/core/spring/test/BrokerMock.java
/**
     * @param destination the destination name
     * @param topic       <code>true</code> for topic; <code>false</code> for queue
     * @param ico         the object to send
     * @param headers     optional headers
     */
@param destination the destination name
@param topic       true for topic; false for queue
@param ico         the object to send
@param headers     optional headers
@param destination the destination name @param topic true for topic ; false for queue @param ico the object to send @param headers optional headers
public void send(final String destination, final boolean topic, final InterconnectObject ico, final DaemonMessageSenderHeader... headers) {
        if (this.requestMock.hasHandler(destination)) {
            UUID uuid = null;
            for (DaemonMessageSenderHeader head : headers) {
                if (head.getField() == DaemonMessageSenderHeader.Field.RequestUUID) {
                    uuid = UUID.fromString((String) head.getValue());
                }
            }
            this.requestMock.receive(uuid == null ? UUID.randomUUID() : uuid, destination, ico);
            return;
        }
        final String destName = (topic ? "topic://" : "queue://") + destination;
        if (!BrokerMock.this.listeners.containsKey(destName)) {
            BrokerMock.LOGGER.error("Missing destination {}", destName);
            throw new RuntimeException();
        }
        this.exec.execute(() -> {
            try {
                final ActiveMQDestination dest;
                if (topic) {
                    dest = new ActiveMQTopic(destination);
                } else {
                    dest = new ActiveMQQueue(destination);
                }
                ActiveMQTextMessage msg = new ActiveMQTextMessage();
                msg.setDestination(dest);
                msg.setText(InterconnectMapper.toJson(ico));
                msg.setObjectProperty(InterconnectConnector.HEADER_ICO_CLASS, ico.getClass().getName());
                if (headers != null) {
                    for (DaemonMessageSenderHeader header : headers) {
                        msg.setObjectProperty(header.getField().getName(), header.getValue());
                    }
                }
                BrokerMock.this.listeners.get(destName).onMessage(msg);
            } catch (Exception e) {
                BrokerMock.LOGGER.error("Failed to send message", e);
            }
        });
    }
public void send ( final String destination , final boolean topic , final InterconnectObject ico , final DaemonMessageSenderHeader ... headers ) { if ( this . requestMock . hasHandler ( destination ) ) { UUID uuid = null ; for ( DaemonMessageSenderHeader head : headers ) { if ( head . getField ( ) == DaemonMessageSenderHeader . Field . RequestUUID ) { uuid = UUID . fromString ( ( String ) head . getValue ( ) ) ; } } this . requestMock . receive ( uuid == null ? UUID . randomUUID ( ) : uuid , destination , ico ) ; return ; } final String destName = ( topic ? "topic://" : "queue://" ) + destination ; if ( ! BrokerMock . this . listeners . containsKey ( destName ) ) { BrokerMock . LOGGER . error ( "Missing destination {}" , destName ) ; throw new RuntimeException ( ) ; } this . exec . execute ( ( ) -> { try { final ActiveMQDestination dest ; if ( topic ) { dest = new ActiveMQTopic ( destination ) ; } else { dest = new ActiveMQQueue ( destination ) ; } ActiveMQTextMessage msg = new ActiveMQTextMessage ( ) ; msg . setDestination ( dest ) ; msg . setText ( InterconnectMapper . toJson ( ico ) ) ; msg . setObjectProperty ( InterconnectConnector . HEADER_ICO_CLASS , ico . getClass ( ) . getName ( ) ) ; if ( headers != null ) { for ( DaemonMessageSenderHeader header : headers ) { msg . setObjectProperty ( header . getField ( ) . getName ( ) , header . getValue ( ) ) ; } } BrokerMock . this . listeners . get ( destName ) . onMessage ( msg ) ; } catch ( Exception e ) { BrokerMock . LOGGER . error ( "Failed to send message" , e ) ; } } ) ; }
@param destination the destination name
 @param topic       <code>true</code> for topic; <code>false</code> for queue
 @param ico         the object to send
 @param headers     optional headers
@param destination the destination name @param topic <code > true< / code > for topic ; <code > false< / code > for queue @param ico the object to send @param headers optional headers
// Check registered RequestMocks