### Question:
JmsTransport implements BrokerTransport { @Override public void init(String configPath) throws EtiqetException { JmsConfigExtractor jmsConfigExtractor = new JmsConfigExtractor(new JmsConfigXmlParser()); JmsConfig configuration = jmsConfigExtractor.retrieveConfiguration(configPath); binaryMessageConverterDelegate = instantiateBinaryMessageConverterDelegate(configuration); connectionFactory = createConnectionFactory(configuration); defaultTopic = configuration.getDefaultTopic(); }  @Override void init(String configPath); @Override void start(); @Override void stop(); @Override void send(Cdr msg); @Override void send(Cdr msg, String topicName); @Override boolean isLoggedOn(); @Override String getDefaultSessionId(); @Override void setTransportDelegate(TransportDelegate<String, Cdr> transDel); @Override @SuppressWarnings("unchecked") void setCodec(Codec c); @Override Codec getCodec(); @Override void setDelegate(ClientDelegate delegate); @Override ClientDelegate getDelegate(); @Override void subscribeToTopic(Optional<String> topicName, final Consumer<Cdr> cdrListener); @Override void subscribeToQueue(String queueName, Consumer<Cdr> cdrListener); @Override void sendToTopic(Cdr cdr, Optional<String> maybeTopicName); @Override void sendToQueue(Cdr cdr, String queueName); @Override void clearQueue(String queueName); @Override Cdr subscribeAndConsumeFromTopic(final Optional<String> topicName, final Duration timeout); @Override Cdr subscribeAndConsumeFromQueue(final String queueName, final Duration timeout);  }### Answer:
@Test public void testInit() throws EtiqetException { transport.init("src/test/resources/config/jmsConfig.xml"); ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) transport.getConnectionFactory(); assertNotNull("Connection Factory should exist after transport is initialised", connectionFactory); assertEquals("vm: assertEquals("USERNAME", connectionFactory.getUserName()); assertEquals("PASSWORD", connectionFactory.getPassword()); assertEquals("testTopic", transport.getDefaultSessionId()); }
@Test public void testInit_PropertiesNotFound() { String configPath = "src/test/resources/config/jms_config_not_found.xml"; try { transport.init(configPath); fail("Should have failed because the above config file shouldn't exist"); } catch (Exception e) { assertTrue(e instanceof EtiqetException); assertEquals("Exception thrown while trying to read " + configPath, e.getMessage()); } }
@Test public void testInit_invalidXmlConfiguration() { String configPath = "src/test/resources/config/jmsConfig_invalid.xml"; try { transport.init(configPath); fail("Should have failed because the above config file is not valid"); } catch (Exception e) { assertTrue(e instanceof EtiqetException); assertEquals("Exception thrown while parsing " + configPath + " as com.neueda.etiqet.transport.jms.JmsConfiguration" , e.getMessage()); } }