Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
2eb64965
Unverified
Commit
2eb64965
authored
Dec 11, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
#12593
parent
f76eaa2d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
24 deletions
+105
-24
src/main/java/org/b3log/solo/processor/CategoryProcessor.java
...main/java/org/b3log/solo/processor/CategoryProcessor.java
+0
-16
src/test/java/org/b3log/solo/MockHttpServletRequest.java
src/test/java/org/b3log/solo/MockHttpServletRequest.java
+18
-8
src/test/java/org/b3log/solo/processor/CategoryProcessorTestCase.java
...a/org/b3log/solo/processor/CategoryProcessorTestCase.java
+87
-0
No files found.
src/main/java/org/b3log/solo/processor/CategoryProcessor.java
View file @
2eb64965
...
...
@@ -103,22 +103,6 @@ public class CategoryProcessor {
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Gets category URI from the specified URI.
*
* @param requestURI the specified request URI
* @return category URI
*/
private
static
String
getCategoryURI
(
final
String
requestURI
)
{
final
String
path
=
requestURI
.
substring
((
Latkes
.
getContextPath
()
+
"/category/"
).
length
());
if
(
path
.
contains
(
"/"
))
{
return
path
.
substring
(
0
,
path
.
indexOf
(
"/"
));
}
else
{
return
path
.
substring
(
0
);
}
}
/**
* Shows articles related with a category with the specified context.
*
...
...
src/test/java/org/b3log/solo/MockHttpServletRequest.java
View file @
2eb64965
...
...
@@ -95,7 +95,17 @@ public class MockHttpServletRequest implements HttpServletRequest {
@Override
public
Enumeration
getHeaderNames
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
return
new
Enumeration
()
{
@Override
public
boolean
hasMoreElements
()
{
return
false
;
}
@Override
public
Object
nextElement
()
{
return
null
;
}
};
}
@Override
...
...
@@ -221,7 +231,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
@Override
public
String
getCharacterEncoding
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
"mock character encoding"
;
}
@Override
...
...
@@ -236,7 +246,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
@Override
public
String
getContentType
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
"mock content type"
;
}
@Override
...
...
@@ -315,7 +325,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
@Override
public
String
getRemoteHost
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
"mock remote host"
;
}
@Override
...
...
@@ -355,22 +365,22 @@ public class MockHttpServletRequest implements HttpServletRequest {
@Override
public
int
getRemotePort
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
0
;
}
@Override
public
String
getLocalName
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
"mock local name"
;
}
@Override
public
String
getLocalAddr
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
"mock local addr"
;
}
@Override
public
int
getLocalPort
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
)
;
return
0
;
}
@Override
...
...
src/test/java/org/b3log/solo/processor/CategoryProcessorTestCase.java
0 → 100644
View file @
2eb64965
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
processor
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.MockHttpServletRequest
;
import
org.b3log.solo.MockHttpServletResponse
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.io.BufferedReader
;
import
java.io.StringReader
;
/**
* {@link CategoryProcessor} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Dec 11, 2018
* @since 2.9.8
*/
@Test
(
suiteName
=
"processor"
)
public
class
CategoryProcessorTestCase
extends
AbstractTestCase
{
/**
* Init.
*
* @throws Exception exception
*/
@Test
public
void
init
()
throws
Exception
{
super
.
init
();
}
/**
* showCategoryArticles.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
showCategoryArticles
()
throws
Exception
{
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/category/"
);
request
.
setMethod
(
"POST"
);
final
JSONObject
requestJSON
=
new
JSONObject
();
requestJSON
.
put
(
Category
.
CATEGORY_T_TAGS
,
"Solo"
);
requestJSON
.
put
(
Category
.
CATEGORY_TITLE
,
"分类1"
);
requestJSON
.
put
(
Category
.
CATEGORY_URI
,
"cate1"
);
final
BufferedReader
reader
=
new
BufferedReader
(
new
StringReader
(
requestJSON
.
toString
()));
request
.
setReader
(
reader
);
mockAdminLogin
(
request
);
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
request
=
mockRequest
();
request
.
setRequestURI
(
"/category/cate1"
);
request
.
setMethod
(
"GET"
);
request
.
setAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
,
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
);
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"<title>分类1 - Admin 的个人博客</title>"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment