Commit a05e4023 authored by Van's avatar Van

Merge remote-tracking branch 'origin/dev' into dev

parents 7f98642b b7144606
......@@ -272,6 +272,7 @@
<include>**/src/*/resources/plugins/*/*.properties</include>
<include>**/src/*/resources/js/admin/*.js</include>
<include>**/src/*/resources/*.properties</include>
<include>**/src/*/resources/*.xml</include>
<include>**/src/test/resources/**/*</include>
<include>**/src/*/resources/docker/*</include>
</includes>
......
......@@ -22,7 +22,7 @@ package org.b3log.solo.model;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @version 1.7.0.6, Sep 17, 2019
* @version 1.7.0.7, Jan 16, 2020
* @since 0.3.1
*/
public final class Common {
......@@ -97,26 +97,11 @@ public final class Common {
*/
public static final String MOST_USED_CATEGORIES = "mostUsedCategories";
/**
* Most comment count articles.
*/
public static final String MOST_COMMENT_ARTICLES = "mostCommentArticles";
/**
* Most view count articles.
*/
public static final String MOST_VIEW_COUNT_ARTICLES = "mostViewCountArticles";
/**
* Recent articles.
*/
public static final String RECENT_ARTICLES = "recentArticles";
/**
* Recent comments.
*/
public static final String RECENT_COMMENTS = "recentComments";
/**
* Previous article permalink.
*/
......
......@@ -153,7 +153,6 @@ public class BlogProcessor {
jsonObject.put("recentArticleTime", articleQueryService.getRecentArticleTime());
final JSONObject statistic = statisticQueryService.getStatistic();
jsonObject.put("articleCount", statistic.getLong(Option.ID_T_STATISTIC_PUBLISHED_ARTICLE_COUNT));
jsonObject.put("commentCount", statistic.getLong(Option.ID_T_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT));
jsonObject.put("tagCount", tagQueryService.getTagCount());
jsonObject.put("servePath", Latkes.getServePath());
jsonObject.put("staticServePath", Latkes.getStaticServePath());
......
......@@ -37,7 +37,7 @@ import java.util.List;
* Article repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.13, Jun 6, 2019
* @version 1.1.1.14, Jan 16, 2020
* @since 0.3.1
*/
@Repository
......@@ -212,40 +212,6 @@ public class ArticleRepository extends AbstractRepository {
return getList(query);
}
/**
* Gets most commented and published articles with the specified number.
*
* @param num the specified number
* @return a list of most comment articles, returns an empty list if not found
* @throws RepositoryException repository exception
*/
public List<JSONObject> getMostCommentArticles(final int num) throws RepositoryException {
final Query query = new Query().
addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).
setFilter(new PropertyFilter(Article.ARTICLE_STATUS, FilterOperator.EQUAL, Article.ARTICLE_STATUS_C_PUBLISHED)).
setPage(1, num).setPageCount(1);
return getList(query);
}
/**
* Gets most view count and published articles with the specified number.
*
* @param num the specified number
* @return a list of most view count articles, returns an empty list if not found
* @throws RepositoryException repository exception
*/
public List<JSONObject> getMostViewCountArticles(final int num) throws RepositoryException {
final Query query = new Query().
addSort(Article.ARTICLE_VIEW_COUNT, SortDirection.DESCENDING).
addSort(Article.ARTICLE_UPDATED, SortDirection.DESCENDING).
setFilter(new PropertyFilter(Article.ARTICLE_STATUS, FilterOperator.EQUAL, Article.ARTICLE_STATUS_C_PUBLISHED)).
setPage(1, num).setPageCount(1);
return getList(query);
}
/**
* Gets the previous article(by create date) by the specified article id.
*
......
......@@ -97,24 +97,6 @@ public class CommentRepository extends AbstractRepository {
commentCache.putComment(comment);
}
/**
* Gets post comments recently with the specified fetch.
*
* @param fetchSize the specified fetch size
* @return a list of comments recently, returns an empty list if not found
* @throws RepositoryException repository exception
*/
public List<JSONObject> getRecentComments(final int fetchSize) throws RepositoryException {
final Query query = new Query().
addSort(Keys.OBJECT_ID, SortDirection.DESCENDING).
setPage(1, fetchSize).setPageCount(1);
final List<JSONObject> ret = getList(query);
// Removes unpublished article related comments
removeForUnpublishedArticles(ret);
return ret;
}
/**
* Gets comments with the specified on id, current page number and
* page size.
......
......@@ -47,8 +47,6 @@ import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.Skins;
import org.b3log.solo.util.Solos;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import java.io.StringWriter;
import java.util.*;
......@@ -60,7 +58,7 @@ import static org.b3log.solo.model.Article.ARTICLE_CONTENT;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.7.0.13, Jan 9, 2020
* @version 1.7.0.14, Jan 16, 2020
* @since 0.3.1
*/
@Service
......@@ -431,60 +429,6 @@ public class DataModelService {
}
}
/**
* Fills most view count articles.
*
* @param dataModel data model
* @param preference the specified preference
* @throws ServiceException service exception
*/
public void fillMostViewCountArticles(final Map<String, Object> dataModel, final JSONObject preference) throws ServiceException {
Stopwatchs.start("Fill Most View Articles");
try {
LOGGER.debug("Filling the most view count articles....");
final int mostCommentArticleDisplayCnt = preference.getInt(Option.ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT);
final List<JSONObject> mostViewCountArticles = articleRepository.getMostViewCountArticles(mostCommentArticleDisplayCnt);
dataModel.put(Common.MOST_VIEW_COUNT_ARTICLES, mostViewCountArticles);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Fills most view count articles failed", e);
throw new ServiceException(e);
} finally {
Stopwatchs.end();
}
}
/**
* Fills most comments articles.
*
* @param dataModel data model
* @param preference the specified preference
* @throws ServiceException service exception
*/
public void fillMostCommentArticles(final Map<String, Object> dataModel, final JSONObject preference) throws ServiceException {
if (!preference.optBoolean(Option.ID_C_COMMENTABLE)) {
dataModel.put(Common.MOST_COMMENT_ARTICLES, Collections.emptyList());
return;
}
Stopwatchs.start("Fill Most CMMTs Articles");
try {
LOGGER.debug("Filling most comment articles....");
final int mostCommentArticleDisplayCnt = preference.getInt(Option.ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT);
final List<JSONObject> mostCommentArticles = articleRepository.getMostCommentArticles(mostCommentArticleDisplayCnt);
dataModel.put(Common.MOST_COMMENT_ARTICLES, mostCommentArticles);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Fills most comment articles failed", e);
throw new ServiceException(e);
} finally {
Stopwatchs.end();
}
}
/**
* Fills post articles recently.
*
......@@ -508,47 +452,6 @@ public class DataModelService {
}
}
/**
* Fills post comments recently.
*
* @param dataModel data model
* @param preference the specified preference
* @throws ServiceException service exception
*/
public void fillRecentComments(final Map<String, Object> dataModel, final JSONObject preference) throws ServiceException {
if (!preference.optBoolean(Option.ID_C_COMMENTABLE)) {
dataModel.put(Common.RECENT_COMMENTS, Collections.emptyList());
return;
}
Stopwatchs.start("Fill Recent Comments");
try {
LOGGER.debug("Filling recent comments....");
final int recentCommentDisplayCnt = preference.getInt(Option.ID_C_RECENT_COMMENT_DISPLAY_CNT);
final List<JSONObject> recentComments = commentRepository.getRecentComments(recentCommentDisplayCnt);
for (final JSONObject comment : recentComments) {
String commentContent = comment.optString(Comment.COMMENT_CONTENT);
commentContent = Markdowns.toHTML(commentContent);
commentContent = Jsoup.clean(commentContent, Whitelist.relaxed());
comment.put(Comment.COMMENT_CONTENT, commentContent);
comment.put(Comment.COMMENT_NAME, comment.getString(Comment.COMMENT_NAME));
comment.put(Comment.COMMENT_URL, comment.getString(Comment.COMMENT_URL));
comment.put(Common.IS_REPLY, false);
comment.put(Comment.COMMENT_T_DATE, new Date(comment.optLong(Comment.COMMENT_CREATED)));
comment.put("commentDate2", new Date(comment.optLong(Comment.COMMENT_CREATED)));
}
dataModel.put(Common.RECENT_COMMENTS, recentComments);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Fills recent comments failed", e);
throw new ServiceException(e);
} finally {
Stopwatchs.end();
}
}
/**
* Fills favicon URL. 可配置 favicon 图标路径 https://github.com/b3log/solo/issues/12706
*
......@@ -796,18 +699,6 @@ public class DataModelService {
if (Templates.hasExpression(template, "<#list links as link>")) {
fillLinks(dataModel);
}
if (Templates.hasExpression(template, "<#list recentComments as comment>")) {
fillRecentComments(dataModel, preference);
}
if (Templates.hasExpression(template, "<#list mostCommentArticles as article>")) {
fillMostCommentArticles(dataModel, preference);
}
if (Templates.hasExpression(template, "<#list mostViewCountArticles as article>")) {
fillMostViewCountArticles(dataModel, preference);
}
} catch (final ServiceException e) {
LOGGER.log(Level.ERROR, "Fills side failed", e);
throw new ServiceException(e);
......@@ -843,18 +734,6 @@ public class DataModelService {
fillCategories(dataModel);
}
if (Templates.hasExpression(template, "<#list recentComments as comment>")) {
fillRecentComments(dataModel, preference);
}
if (Templates.hasExpression(template, "<#list mostCommentArticles as article>")) {
fillMostCommentArticles(dataModel, preference);
}
if (Templates.hasExpression(template, "<#list mostViewCountArticles as article>")) {
fillMostViewCountArticles(dataModel, preference);
}
if (Templates.hasExpression(template, "<#include \"side.ftl\"/>")) {
fillSide(context, dataModel, preference);
}
......
......@@ -365,7 +365,6 @@ public class ExportService {
stat.put("recentArticleTime", articleQueryService.getRecentArticleTime());
final JSONObject statistic = statisticQueryService.getStatistic();
stat.put("articleCount", statistic.getLong(Option.ID_T_STATISTIC_PUBLISHED_ARTICLE_COUNT));
stat.put("commentCount", statistic.getLong(Option.ID_T_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT));
stat.put("tagCount", tagQueryService.getTagCount());
stat.put("skin", optionQueryService.getOptionById(Option.ID_C_SKIN_DIR_NAME).optString(Option.OPTION_VALUE));
stat.put("mobileSkin", optionQueryService.getOptionById(Option.ID_C_MOBILE_SKIN_DIR_NAME).optString(Option.OPTION_VALUE));
......
......@@ -83,8 +83,6 @@ public class StatisticQueryService {
final JSONObject ret = optionQueryService.getOptions(Option.CATEGORY_C_STATISTIC);
final long publishedArticleCount = articleRepository.count(new Query().setFilter(new PropertyFilter(Article.ARTICLE_STATUS, FilterOperator.EQUAL, Article.ARTICLE_STATUS_C_PUBLISHED)));
ret.put(Option.ID_T_STATISTIC_PUBLISHED_ARTICLE_COUNT, publishedArticleCount);
final long commentCount = commentRepository.count(new Query());
ret.put(Option.ID_T_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT, commentCount);
return ret;
} catch (final Exception e) {
......
#
# Solo - A small and beautiful blogging system written in Java.
# Copyright (c) 2010-present, b3log.org
#
# 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/>.
#
#
# Description: Solo logging configurations.
# Version: 1.1.0.11, Apr 1, 2019
# Author: <a href="http://88250.b3log.org">Liang Ding</a>
# Author: <a href="http://www.wanglay.com">Lei Wang</a>
#
log4j.rootLogger=INFO,stdout
log4j.logger.org.b3log.solo=INFO
log4j.logger.org.b3log.latke=WARN
log4j.logger.org.b3log.latke.util.freemarker.Templates=ERROR
log4j.logger.org.b3log.latke.repository.jdbc.util=WARN
log4j.logger.org.b3log.latke.util.Crypts=ERROR
log4j.logger.io.netty=WARN
log4j.logger.freemarker=WARN
log4j.logger.com.zaxxer=WARN
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=ERROR
# Console appender
log4j.appender.stdout.Encoding=UTF-8
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
# File appender
#log4j.appender.file=org.apache.log4j.RollingFileAppender
#log4j.appender.file.File=solo.log
#log4j.appender.file.MaxFileSize=50MB
#log4j.appender.file.MaxBackupIndex=5
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
<?xml version="1.0" encoding="UTF-8"?>
<!--
Solo - A small and beautiful blogging system written in Java.
Copyright (c) 2010-present, b3log.org
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/>.
-->
<!--
Description: log4j2 configuration.
Version: 1.0.0.0, Jan 16, 2020
Author: Liang Ding
-->
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<pattern>[%highlight{%-5p}]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n</pattern>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
<Root level="Info">
<AppenderRef ref="Console"/>
</Root>
<Logger name="org.b3log.solo" level="Info"/>
<Logger name="org.b3log.latke" level="Warn"/>
<Logger name="org.b3log.latke.util.freemarker.Templates" level="Error"/>
<Logger name="org.b3log.latke.repository.jdbc.util" level="WARN"/>
<Logger name="org.b3log.latke.util.Crypts" level="Error"/>
<Logger name="io.netty" level="Warn"/>
<Logger name="freemarker" level="Warn"/>
<Logger name="com.zaxxer" level="Warn"/>
</Loggers>
</Configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Solo - A small and beautiful blogging system written in Java.
Copyright (c) 2010-present, b3log.org
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/>.
-->
<!--
Description: OpenSearch definition.
Version: 1.0.0.0, May 26, 2018
......
......@@ -19,6 +19,7 @@ package org.b3log.solo.processor.console;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.repository.Query;
import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.MockRequest;
import org.b3log.solo.MockResponse;
......@@ -95,7 +96,7 @@ public class CommentConsoleTestCase extends AbstractTestCase {
*/
@Test(dependsOnMethods = "init")
public void removeArticleComment() throws Exception {
final List<JSONObject> recentComments = getCommentRepository().getRecentComments(1);
final List<JSONObject> recentComments = getCommentRepository().getList(new Query());
final JSONObject comment = recentComments.get(0);
final String commentId = comment.optString(Keys.OBJECT_ID);
......
......@@ -34,7 +34,7 @@ import java.util.List;
* {@link ArticleRepository} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Feb 25, 2019
* @version 1.0.0.6, Jan 16, 2020
*/
@Test(suiteName = "repository")
public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
......@@ -144,105 +144,12 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
Assert.assertEquals(nextArticle.getString(Article.ARTICLE_TITLE), "article title2");
}
/**
* Get Most Comment Articles.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "previousAndNext"})
public void getMostCommentArticles() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
final JSONObject article = new JSONObject();
article.put(Article.ARTICLE_TITLE, "article title3");
article.put(Article.ARTICLE_ABSTRACT, "article abstract");
article.put(Article.ARTICLE_ABSTRACT_TEXT, "article abstract text");
article.put(Article.ARTICLE_TAGS_REF, "tag1, tag2");
article.put(Article.ARTICLE_AUTHOR_ID, "1");
article.put(Article.ARTICLE_COMMENT_COUNT, 2);
article.put(Article.ARTICLE_VIEW_COUNT, 2);
article.put(Article.ARTICLE_CONTENT, "article content");
article.put(Article.ARTICLE_PERMALINK, "article permalink3");
article.put(Article.ARTICLE_STATUS, Article.ARTICLE_STATUS_C_PUBLISHED);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
article.put(Article.ARTICLE_IMG1_URL, Article.getArticleImg1URL(article));
final Transaction transaction = articleRepository.beginTransaction();
articleRepository.add(article);
transaction.commit();
List<JSONObject> mostCommentArticles = articleRepository.getMostCommentArticles(2);
Assert.assertNotNull(mostCommentArticles);
Assert.assertEquals(mostCommentArticles.size(), 2);
Assert.assertEquals(mostCommentArticles.get(0).getInt(Article.ARTICLE_COMMENT_COUNT), 2);
Assert.assertEquals(mostCommentArticles.get(1).getInt(Article.ARTICLE_COMMENT_COUNT), 1);
mostCommentArticles = articleRepository.getMostCommentArticles(1);
Assert.assertNotNull(mostCommentArticles);
Assert.assertEquals(mostCommentArticles.size(), 1);
Assert.assertEquals(mostCommentArticles.get(0).getInt(Article.ARTICLE_COMMENT_COUNT), 2);
}
/**
* Get Most View Count Articles
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "previousAndNext", "getMostCommentArticles"})
public void getMostViewCountArticles() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
final JSONObject article = new JSONObject();
article.put(Article.ARTICLE_TITLE, "article title4");
article.put(Article.ARTICLE_ABSTRACT, "article abstract");
article.put(Article.ARTICLE_ABSTRACT_TEXT, "article abstract text");
article.put(Article.ARTICLE_TAGS_REF, "tag1, tag2");
article.put(Article.ARTICLE_AUTHOR_ID, "1");
article.put(Article.ARTICLE_COMMENT_COUNT, 3);
article.put(Article.ARTICLE_VIEW_COUNT, 3);
article.put(Article.ARTICLE_CONTENT, "article content");
article.put(Article.ARTICLE_PERMALINK, "article permalink4");
article.put(Article.ARTICLE_STATUS, Article.ARTICLE_STATUS_C_DRAFT);
article.put(Article.ARTICLE_PUT_TOP, false);
article.put(Article.ARTICLE_CREATED, new Date().getTime());
article.put(Article.ARTICLE_UPDATED, new Date().getTime());
article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
article.put(Article.ARTICLE_IMG1_URL, Article.getArticleImg1URL(article));
final Transaction transaction = articleRepository.beginTransaction();
articleRepository.add(article);
transaction.commit();
List<JSONObject> mostViewCountArticles = articleRepository.getMostViewCountArticles(2);
Assert.assertNotNull(mostViewCountArticles);
Assert.assertEquals(mostViewCountArticles.size(), 2);
Assert.assertEquals(mostViewCountArticles.get(0).getInt(Article.ARTICLE_VIEW_COUNT), 2);
Assert.assertEquals(mostViewCountArticles.get(1).getInt(Article.ARTICLE_VIEW_COUNT), 1);
mostViewCountArticles = articleRepository.getMostViewCountArticles(1);
Assert.assertNotNull(mostViewCountArticles);
Assert.assertEquals(mostViewCountArticles.size(), 1);
Assert.assertEquals(mostViewCountArticles.get(0).getInt(Article.ARTICLE_VIEW_COUNT), 2);
}
/**
* Get Randomly.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "previousAndNext", "getMostCommentArticles", "getMostViewCountArticles"})
@Test(dependsOnMethods = {"add", "previousAndNext"})
public void getRandomly() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
......@@ -255,19 +162,18 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "previousAndNext", "getMostCommentArticles", "getMostViewCountArticles"})
@Test(dependsOnMethods = {"add", "previousAndNext"})
public void getRecentArticles() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
Assert.assertEquals(articleRepository.count(), 4);
Assert.assertEquals(articleRepository.count(), 2);
List<JSONObject> recentArticles = articleRepository.getRecentArticles(3);
Assert.assertNotNull(recentArticles);
Assert.assertEquals(recentArticles.size(), 3);
Assert.assertEquals(recentArticles.size(), 2);
Assert.assertEquals(recentArticles.get(0).getString(Article.ARTICLE_TITLE), "article title3");
Assert.assertEquals(recentArticles.get(1).getString(Article.ARTICLE_TITLE), "article title2");
Assert.assertEquals(recentArticles.get(2).getString(Article.ARTICLE_TITLE), "article title1");
Assert.assertEquals(recentArticles.get(0).getString(Article.ARTICLE_TITLE), "article title2");
Assert.assertEquals(recentArticles.get(1).getString(Article.ARTICLE_TITLE), "article title1");
}
/**
......@@ -275,7 +181,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "getMostViewCountArticles"})
@Test(dependsOnMethods = {"add"})
public void isPublished() throws Exception {
final ArticleRepository articleRepository = getArticleRepository();
......@@ -285,9 +191,9 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
final JSONObject article = all.getJSONObject(0);
Assert.assertTrue(articleRepository.isPublished(article.getString(Keys.OBJECT_ID)));
final JSONObject notPublished = articleRepository.getByPermalink("article permalink4");
Assert.assertNotNull(notPublished);
Assert.assertEquals(Article.ARTICLE_STATUS_C_DRAFT, notPublished.optInt(Article.ARTICLE_STATUS));
final JSONObject published = articleRepository.getByPermalink("article permalink1");
Assert.assertNotNull(published);
Assert.assertEquals(Article.ARTICLE_STATUS_C_PUBLISHED, published.optInt(Article.ARTICLE_STATUS));
Assert.assertFalse(articleRepository.isPublished("not found"));
}
......
#
# Solo - A small and beautiful blogging system written in Java.
# Copyright (c) 2010-present, b3log.org
#
# 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/>.
#
#
# Description: Solo logging configurations for test.
# Version: 1.0.0.0, Mar 3, 2019
# Author: <a href="http://88250.b3log.org">Liang Ding</a>
#
log4j.rootLogger=INFO,stdout
log4j.logger.org.b3log.solo=INFO
log4j.logger.org.b3log.latke=WARN
log4j.logger.org.b3log.latke.util.freemarker.Templates=ERROR
log4j.logger.org.b3log.latke.repository.jdbc.util=WARN
log4j.logger.io.netty=WARN
log4j.logger.freemarker=WARN
log4j.logger.com.zaxxer=WARN
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=ERROR
# Console appender
log4j.appender.stdout.Encoding=UTF-8
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment