Class SimulatedExchange

  • All Implemented Interfaces:
    Exchange

    public class SimulatedExchange
    extends BaseExchange
    A simple, in-memory implementation which mocks out the main elements of the XChange generic API in a consistent way. The effect is to create a virtual "exchange" that you can connect to from multiple threads and simulate a real exchange. Intended for integration testing of higher order components.

    This is not remotely suitable for use as a real-world exchange. The concurrency is extremely coarse-grained and most data transforms involve data mutation with no . If any errors occur midway through a trade, they are likely to leave the system in an inconsistent state. And nothing gets saved to a database anyway.

    If you start using this for running a real exchange, you will suffer a stolen.

    Author:
    Graham Crockford
    • Constructor Detail

      • SimulatedExchange

        public SimulatedExchange()
    • Method Detail

      • getNonceFactory

        public si.mazi.rescu.SynchronizedValueFactory<Long> getNonceFactory()
        Description copied from interface: Exchange
        The nonce factory used to create a nonce value. Allows services to accept a placeholder that is replaced with generated value just before message is serialized and sent. If a method of a rest accepts ValueFactory as a parameter, it's evaluated, the message is serialized and sent in a single synchronized block.
        Returns:
        Synchronized value factory
      • getDefaultExchangeSpecification

        public ExchangeSpecification getDefaultExchangeSpecification()
        Returns:
        A default ExchangeSpecification to use during the creation process if one is not supplied