@Test
  public void testContentRequest_root_with_content_key() {
    SitePath sitePath = new SitePath(siteKey, "/contentName--123");
    final ContentKey contentKey = new ContentKey(123);
    ContentPath contentPath = new ContentPath(contentKey, "contentName", new Path("/"));
    sitePath.setContentPath(contentPath);

    SectionContentEntity sectionContent = createSectionContent(contentKey, "contentName");
    MenuItemEntity menuItem = new MenuItemEntity();
    addSectionContentToMenuItem(menuItem, sectionContent);

    injectContentIntoContentDao(contentKey, "contentName");
    injectMenuItemToSiteEntityResolver("/", menuItem);

    PageRequestContextResolver pageRequestContextResolver =
        new PageRequestContextResolver(contentDao);
    PageRequestContext resolvedContext =
        pageRequestContextResolver.resolvePageRequestContext(site, sitePath);

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNotNull(resolvedContentPath);
    assertEquals("123", resolvedContentPath.getContentKey().toString());
    assertNotNull(resolvedContext.getRequestedMenuItem());
    assertTrue(resolvedContext.getPageRequestType().equals(PageRequestType.CONTENT));
  }
Beispiel #2
0
  public void testResolveLongSitePath1() {

    httpServletRequest.setRequestURI("/site/1/About/Jobs/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/About/Jobs/", sitePath.getLocalPath().toString());
  }
Beispiel #3
0
  public void testResolveSimpleSitePath1() {

    httpServletRequest.setRequestURI("/site/1/Frontpage");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/Frontpage", sitePath.getLocalPath().toString());
  }
Beispiel #4
0
  public void testResolveSimpleSitePath123() {

    httpServletRequest.setCharacterEncoding("ISO-8859-1");
    httpServletRequest.setRequestURI("/site/123/Frontpage/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_123, sitePath.getSiteKey());
    assertEquals("/Frontpage/", sitePath.getLocalPath().toString());
  }
Beispiel #5
0
  public void testResolveSimpleSitePathWithNoLocalPathAndNoEndSlash() {

    httpServletRequest.setCharacterEncoding("ISO-8859-1");
    httpServletRequest.setRequestURI("/site/123");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_123, sitePath.getSiteKey());
    assertEquals("", sitePath.getLocalPath().toString());
  }
Beispiel #6
0
  public void testResolveIncludePath() {

    httpServletRequest.setAttribute("javax.servlet.include.request_uri", "/site/1/About/Jobs/");
    httpServletRequest.setRequestURI("/About/Jobs/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/About/Jobs/", sitePath.getLocalPath().toString());
  }
Beispiel #7
0
  public void testResolveSitePathWithNoPrefix() {

    sitePathResolver.setSitePathPrefix("");
    httpServletRequest.setRequestURI("/1/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/", sitePath.getLocalPath().toString());
  }
Beispiel #8
0
  public void testGetParamWithMultipleValues() {

    httpServletRequest.setRequestURI("/site/1/Frontpage");
    httpServletRequest.setParameter("param1", new String[] {"value0", "value1"});

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/Frontpage", sitePath.getLocalPath().toString());
    assertEquals("value0", sitePath.getParam("param1"));
  }
Beispiel #9
0
  public void xtestRussianSitePath_WithDefaultCharacterEncoding_UTF_8() {

    sitePropertiesService.setProperty(
        siteKey_1, SitePropertyNames.URL_DEFAULT_CHARACTER_ENCODING, "UTF-8");
    httpServletRequest.setRequestURI("/site/1/Services%D0%BB/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/Servicesл/", sitePath.getLocalPath().toString());
  }
Beispiel #10
0
  public void xtestSweedishSitePath_With_ISO_8859_1() {

    sitePropertiesService.setProperty(
        siteKey_1, SitePropertyNames.URL_DEFAULT_CHARACTER_ENCODING, "ISO-8859-1");
    httpServletRequest.setRequestURI("/site/1/B%F6t/");

    SitePath sitePath = sitePathResolver.resolveSitePath(httpServletRequest);

    assertEquals(siteKey_1, sitePath.getSiteKey());
    assertEquals("/Böt/", sitePath.getLocalPath().toString());
  }