@Before
  public void startBroker() throws Exception {
    brokerService = new BrokerService();
    TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice);
    brokerService.setDeleteAllMessagesOnStartup(true);
    brokerService.setUseJmx(false);

    PolicyMap policyMap = new PolicyMap();
    PolicyEntry defaultEntry = new PolicyEntry();
    defaultEntry.setUseConsumerPriority(
        false); // java.lang.IllegalArgumentException: Comparison method violates its general
                // contract!
    defaultEntry.setMaxAuditDepth(publisherThreadCount);
    defaultEntry.setEnableAudit(true);
    defaultEntry.setUseCache(useCache);
    defaultEntry.setMaxPageSize(1000);
    defaultEntry.setOptimizedDispatch(optimizeDispatch);
    defaultEntry.setMemoryLimit(destMemoryLimit);
    defaultEntry.setExpireMessagesPeriod(0);
    policyMap.setDefaultEntry(defaultEntry);
    brokerService.setDestinationPolicy(policyMap);

    brokerService.getSystemUsage().getMemoryUsage().setLimit(512 * 1024 * 1024);

    TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0");
    brokerService.start();
    activemqURL = transportConnector.getPublishableConnectString();
  }
 @Override
 protected void tearDown() throws Exception {
   stopBroker();
   super.tearDown();
 }