PageRenderTime 27ms CodeModel.GetById 19ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

/core/src/test/java/org/b3log/solo/util/PermalinksTestCase.java

http://github.com/b3log/b3log-solo
Java | 72 lines | 40 code | 5 blank | 27 comment | 0 complexity | 7e20564677c6315ffae8f7ab292b3f87 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
 1/*
 2 * Copyright (c) 2009, 2010, 2011, 2012, B3log Team
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *     http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.b3log.solo.util;
17
18import org.testng.annotations.Test;
19import org.testng.Assert;
20
21/**
22 * {@link org.b3log.solo.util.Permalinks} test case.
23 *
24 * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
25 * @version 1.0.0.0, Jun 29, 2011
26 */
27public final class PermalinksTestCase {
28
29    /**
30     * Test method for {@linkplain Permalinks#matchDefaultArticlePermalinkFormat(java.lang.String)}.
31     */
32    @Test
33    public void matchDefaultArticlePermalinkFormat() {
34        Assert.assertTrue(
35                Permalinks.matchDefaultArticlePermalinkFormat(
36                "/articles/1986/08/25/1234567890.html"));
37        Assert.assertFalse(
38                Permalinks.matchDefaultArticlePermalinkFormat(
39                "/articles/1986/0/25/1234567890.html"));
40        Assert.assertFalse(
41                Permalinks.matchDefaultArticlePermalinkFormat(
42                "/articles/1.html"));
43        Assert.assertFalse(
44                Permalinks.matchDefaultArticlePermalinkFormat(
45                "/articles/1986/08/25/a.html"));
46        Assert.assertFalse(
47                Permalinks.matchDefaultArticlePermalinkFormat(
48                "/articles/1986/aa/25/1234567890.html"));
49        Assert.assertFalse(
50                Permalinks.matchDefaultArticlePermalinkFormat(
51                "/1986/aa/25/1234567890.html"));
52        Assert.assertFalse(
53                Permalinks.matchDefaultArticlePermalinkFormat(
54                "/articles/1986/08/25/1234567890html"));
55
56    }
57
58    /**
59     * Test method for {@linkplain Permalinks#matchDefaultPagePermalinkFormat(java.lang.String)}.
60     */
61    @Test
62    public void matchDefaultPagePermalinkFormat() {
63        Assert.assertTrue(Permalinks.matchDefaultPagePermalinkFormat(
64                "/pages/1234567890.html"));
65        Assert.assertFalse(Permalinks.matchDefaultPagePermalinkFormat(
66                "/pages.html"));
67        Assert.assertFalse(Permalinks.matchDefaultPagePermalinkFormat(
68                "/1234567890.html"));
69        Assert.assertFalse(Permalinks.matchDefaultPagePermalinkFormat(
70                "/pages/a1234567890.html"));
71    }
72}