@Test
public void testRetrieveId() {

  SessionConfiguration sc = new SessionConfiguration();
  sc.setSessionIdName("somesession");
  sc.setAttribute("com.amadeus.session.id", "uuid");
  urlSessionTracking.configure(sc);
  RequestWithSession request = mock(RequestWithSession.class, withSettings().extraInterfaces(HttpServletRequest.class));
  HttpServletRequest hsr = (HttpServletRequest)request;
  UUID uuid = UUID.randomUUID();
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+uuid);
  SessionTracking.IdAndSource id = urlSessionTracking.retrieveId(request);
  assertNotNull(id);
  assertEquals(uuid.toString(), id.id);
  
  // Also test case in-sensitivity
  when(hsr.getRequestURI()).thenReturn("/url;SomeSession="+uuid);
  id = urlSessionTracking.retrieveId(request);
  assertNotNull("URL parameter case sensitivity test", id);
  assertEquals("URL parameter case sensitivity test", uuid.toString(), id.id);
  String sessionIdWithTimestamp = uuid.toString() + BaseSessionTracking.SESSION_ID_TIMESTAMP_SEPARATOR + System.currentTimeMillis();
  String invalidSessionIdWithTimestamp = uuid.toString() + "-abcdefgh" + BaseSessionTracking.SESSION_ID_TIMESTAMP_SEPARATOR + System.currentTimeMillis();
  String sessionIdWithoutTimestamp = uuid.toString();
  when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithTimestamp);
  assertNull(urlSessionTracking.retrieveId(request));
  when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithoutTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithoutTimestamp);
  assertEquals(sessionIdWithoutTimestamp, urlSessionTracking.retrieveId(request).id);
  when(hsr.getPathInfo()).thenReturn(";somesession="+invalidSessionIdWithTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+invalidSessionIdWithTimestamp);
  assertNull(urlSessionTracking.retrieveId(request));
  sc.setTimestampSufix(true);
  urlSessionTracking.configure(sc);
  when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithTimestamp);
  assertEquals(sessionIdWithTimestamp, urlSessionTracking.retrieveId(request).id);
  when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithoutTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithoutTimestamp);
  assertEquals(sessionIdWithoutTimestamp, urlSessionTracking.retrieveId(request).id);
  when(hsr.getPathInfo()).thenReturn(";somesession="+invalidSessionIdWithTimestamp);
  when(hsr.getRequestURI()).thenReturn("/url;somesession="+invalidSessionIdWithTimestamp);
  assertNull(urlSessionTracking.retrieveId(request));
}