SecurityManager securityManager = new SecurityManager(mock(Broker.class), false);
VirtualHost virtualHost = mock(VirtualHost.class);
when(virtualHost.getName()).thenReturn(hostName);
when(virtualHost.getSecurityManager()).thenReturn(securityManager);
when(virtualHost.getEventLogger()).thenReturn(eventLogger);
DefaultExchangeFactory factory = new DefaultExchangeFactory(virtualHost);
Map<String,Object> attributes = new HashMap<String, Object>();
attributes.put(org.apache.qpid.server.model.Exchange.ID, UUIDGenerator.generateExchangeUUID("amp.direct", virtualHost.getName()));
attributes.put(org.apache.qpid.server.model.Exchange.NAME, "amq.direct");
attributes.put(org.apache.qpid.server.model.Exchange.TYPE, "direct");
attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, durable);
return factory.createExchange(attributes);
}