### Question:
Route { public StompletActivator match(String destination) { Matcher routeMatcher = this.regexp.matcher( destination ); if (routeMatcher.matches()) { Map<String, String> matches = new HashMap<String, String>(); for (int i = 0; i < this.segmentNames.length; ++i) { matches.put( segmentNames[i], routeMatcher.group( i + 1 ) ); } return new StompletActivator( this, destination, matches ); } return null; } Route(String pattern, Stomplet stomplet); StompletActivator match(String destination); String getPatternString(); Stomplet getStomplet(); String toString();  }### Answer:
@Test public void testStraightMatch() throws Exception { Route route = new Route( "/queues/foo", null ); StompletActivator match = route.match( "/queues/bar" ); assertNull( match ); match = route.match( "/queues/foo" ); assertNotNull( match ); }
@Test public void testMatchWithSegments() throws Exception { Route route = new Route( "/stocks/:stock", null ); StompletActivator match = route.match( "/stocks/AAPL" ); assertNotNull( match ); assertEquals( "AAPL", match.get( "stock" ) ); match = route.match( "/stocks/RHT" ); assertNotNull( match ); assertEquals( "RHT", match.get( "stock" ) ); match = route.match( "/bonds/AAPL" ); assertNull( match ); }
@Test public void testMatchWithSeveralSegments() throws Exception { Route route = new Route( "/stocks/:exchange/:stock", null ); StompletActivator match = route.match( "/stocks/NASDAQ/AAPL" ); assertNotNull( match ); assertEquals( "NASDAQ", match.get( "exchange" ) ); assertEquals( "AAPL", match.get( "stock" ) ); match = route.match( "/stocks/NYSE/RHT" ); assertNotNull( match ); assertEquals( "NYSE", match.get( "exchange" ) ); assertEquals( "RHT", match.get( "stock" ) ); match = route.match( "/bonds/AAPL" ); assertNull( match ); match = route.match( "/bonds/whut/AAPL" ); assertNull( match ); }