コード例 #1
0
  @Test
  public void testMultipleInvalidFriendlyURLMapperURL() throws Exception {
    Map<Locale, String> friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.SPAIN, "/tags/dos");
    friendlyURLMap.put(LocaleUtil.US, "/tags/two");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);
    } catch (LayoutFriendlyURLsException lfurlse) {
      Map<Locale, Exception> localizedExceptionsMap = lfurlse.getLocalizedExceptionsMap();

      List<Exception> layoutFriendlyURLExceptions =
          ListUtil.fromCollection(localizedExceptionsMap.values());

      Assert.assertEquals(2, layoutFriendlyURLExceptions.size());

      for (Exception e : layoutFriendlyURLExceptions) {
        String keywordsConflict = ((LayoutFriendlyURLException) e).getKeywordConflict();

        Assert.assertEquals(keywordsConflict, "tags");
      }
    }
  }
コード例 #2
0
  @Test
  public void testInvalidFriendlyURLMapperURLInDefaultLocale() throws Exception {

    Map<Locale, String> friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.US, "/tags");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);

      Assert.fail();
    } catch (LayoutFriendlyURLsException lfurlse) {
      Map<Locale, Exception> localizedExceptionsMap = lfurlse.getLocalizedExceptionsMap();

      List<Exception> layoutFriendlyURLExceptions =
          ListUtil.fromCollection(localizedExceptionsMap.values());

      Assert.assertEquals(1, layoutFriendlyURLExceptions.size());

      LayoutFriendlyURLException lfurle =
          (LayoutFriendlyURLException) layoutFriendlyURLExceptions.get(0);

      Assert.assertEquals(lfurle.getKeywordConflict(), "tags");
    }

    friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.US, "/home/tags");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);

      Assert.fail();
    } catch (LayoutFriendlyURLsException lfurlse) {
      Map<Locale, Exception> localizedExceptionsMap = lfurlse.getLocalizedExceptionsMap();

      List<Exception> layoutFriendlyURLExceptions =
          ListUtil.fromCollection(localizedExceptionsMap.values());

      Assert.assertEquals(1, layoutFriendlyURLExceptions.size());

      LayoutFriendlyURLException lfurle =
          (LayoutFriendlyURLException) layoutFriendlyURLExceptions.get(0);

      Assert.assertEquals(lfurle.getKeywordConflict(), "tags");
    }

    friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.US, "/tags/home");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);

      Assert.fail();
    } catch (LayoutFriendlyURLsException lfurlse) {
      Map<Locale, Exception> localizedExceptionsMap = lfurlse.getLocalizedExceptionsMap();

      List<Exception> layoutFriendlyURLExceptions =
          ListUtil.fromCollection(localizedExceptionsMap.values());

      Assert.assertEquals(1, layoutFriendlyURLExceptions.size());

      LayoutFriendlyURLException lfurle =
          (LayoutFriendlyURLException) layoutFriendlyURLExceptions.get(0);

      Assert.assertEquals(lfurle.getKeywordConflict(), "tags");
    }

    friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.US, "/blogs/-/home");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);

      Assert.fail();
    } catch (LayoutFriendlyURLsException lfurlse) {
      Map<Locale, Exception> localizedExceptionsMap = lfurlse.getLocalizedExceptionsMap();

      List<Exception> layoutFriendlyURLExceptions =
          ListUtil.fromCollection(localizedExceptionsMap.values());

      Assert.assertEquals(1, layoutFriendlyURLExceptions.size());

      LayoutFriendlyURLException lfurle =
          (LayoutFriendlyURLException) layoutFriendlyURLExceptions.get(0);

      Assert.assertEquals(lfurle.getKeywordConflict(), "/-/");
    }
  }