Commit b61c81ee authored by Liang Ding's avatar Liang Ding

#169 测试用例修改漏提

parent 29fd5c49
...@@ -17,8 +17,10 @@ package org.b3log.solo.repository.impl; ...@@ -17,8 +17,10 @@ package org.b3log.solo.repository.impl;
import java.util.List; import java.util.List;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.commons.lang.time.DateUtils;
import org.b3log.latke.repository.Transaction; import org.b3log.latke.repository.Transaction;
import org.b3log.solo.AbstractTestCase; import org.b3log.solo.AbstractTestCase;
import org.b3log.solo.SoloServletListener;
import org.b3log.solo.model.ArchiveDate; import org.b3log.solo.model.ArchiveDate;
import org.b3log.solo.repository.ArchiveDateRepository; import org.b3log.solo.repository.ArchiveDateRepository;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -28,7 +30,7 @@ import org.testng.annotations.Test; ...@@ -28,7 +30,7 @@ import org.testng.annotations.Test;
* {@link ArchiveDateRepositoryImpl} test case. * {@link ArchiveDateRepositoryImpl} test case.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, Dec 31, 2011 * @version 1.0.0.1, Jan 18, 2013
*/ */
@Test(suiteName = "repository") @Test(suiteName = "repository")
public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase { public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
...@@ -44,7 +46,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase { ...@@ -44,7 +46,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
final JSONObject archiveDate = new JSONObject(); final JSONObject archiveDate = new JSONObject();
archiveDate.put(ArchiveDate.ARCHIVE_TIME, ArchiveDate.DATE_FORMAT.parse("2011/12").getTime()); archiveDate.put(ArchiveDate.ARCHIVE_TIME, DateUtils.parseDate("2011/12", new String[] {"yyyy/MM"}).getTime());
archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 1); archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 1);
archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 1); archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 1);
...@@ -68,5 +70,6 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase { ...@@ -68,5 +70,6 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
final JSONObject archiveDate = archiveDateRepository.getByArchiveDate("2011/12"); final JSONObject archiveDate = archiveDateRepository.getByArchiveDate("2011/12");
Assert.assertNotNull(archiveDate); Assert.assertNotNull(archiveDate);
System.out.println(archiveDate.toString(SoloServletListener.JSON_PRINT_INDENT_FACTOR));
} }
} }
...@@ -17,7 +17,8 @@ package org.b3log.solo.service; ...@@ -17,7 +17,8 @@ package org.b3log.solo.service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.solo.AbstractTestCase; import org.b3log.solo.AbstractTestCase;
...@@ -80,10 +81,10 @@ public class ArchiveDateQueryServiceTestCase extends AbstractTestCase { ...@@ -80,10 +81,10 @@ public class ArchiveDateQueryServiceTestCase extends AbstractTestCase {
public void getByArchiveDateString() throws Exception { public void getByArchiveDateString() throws Exception {
final ArchiveDateQueryService archiveDateQueryService = ArchiveDateQueryService.getInstance(); final ArchiveDateQueryService archiveDateQueryService = ArchiveDateQueryService.getInstance();
final String archiveDateString = ArchiveDate.DATE_FORMAT.format(new Date()); final String archiveDateString = DateFormatUtils.format(new Date(), "yyyy/MM");
final JSONObject result = archiveDateQueryService.getByArchiveDateString(archiveDateString); final JSONObject result = archiveDateQueryService.getByArchiveDateString(archiveDateString);
Assert.assertNotNull(result); Assert.assertNotNull(result);
Assert.assertEquals(result.getJSONObject(ArchiveDate.ARCHIVE_DATE).getLong(ArchiveDate.ARCHIVE_TIME), Assert.assertEquals(result.getJSONObject(ArchiveDate.ARCHIVE_DATE).getLong(ArchiveDate.ARCHIVE_TIME),
ArchiveDate.DATE_FORMAT.parse(archiveDateString).getTime()); DateUtils.parseDate(archiveDateString, new String[] {"yyyy/MM"}).getTime());
} }
} }
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