Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
a27b80d8
Commit
a27b80d8
authored
Jan 08, 2016
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除单元测试对 GAE 的依赖
parent
04bb7815
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
131 deletions
+77
-131
pom.xml
pom.xml
+2
-26
src/main/resources/local.properties
src/main/resources/local.properties
+2
-4
src/test/java/org/b3log/solo/AbstractTestCase.java
src/test/java/org/b3log/solo/AbstractTestCase.java
+8
-27
src/test/java/org/b3log/solo/repository/impl/ArchiveDateRepositoryImplTestCase.java
...lo/repository/impl/ArchiveDateRepositoryImplTestCase.java
+4
-4
src/test/java/org/b3log/solo/repository/impl/TagArticleRepositoryImplTestCase.java
...olo/repository/impl/TagArticleRepositoryImplTestCase.java
+14
-15
src/test/java/org/b3log/solo/repository/impl/TagRepositoryImplTestCase.java
...b3log/solo/repository/impl/TagRepositoryImplTestCase.java
+13
-15
src/test/java/org/b3log/solo/service/UserQueryServiceTestCase.java
...java/org/b3log/solo/service/UserQueryServiceTestCase.java
+5
-5
src/test/java/org/b3log/solo/util/MarkdownsTestCase.java
src/test/java/org/b3log/solo/util/MarkdownsTestCase.java
+2
-2
src/test/resources/latke.properties
src/test/resources/latke.properties
+2
-32
src/test/resources/local.properties
src/test/resources/local.properties
+25
-1
No files found.
pom.xml
View file @
a27b80d8
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Solo POM.
Version:
2.9.1.16, Jan 7
, 2016
Version:
3.9.1.16, Jan 8
, 2016
Author: Liang Ding
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
...
...
@@ -105,7 +105,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<org.b3log.latke.version>
1.4.
9
</org.b3log.latke.version>
<org.b3log.latke.version>
1.4.
10-SNAPSHOT
</org.b3log.latke.version>
<servlet.version>
3.1.0
</servlet.version>
<slf4j.version>
1.7.5
</slf4j.version>
...
...
@@ -125,7 +125,6 @@
<maven-min-plugin.version>
1.0.0
</maven-min-plugin.version>
<!-- Unit Test -->
<testng.version>
6.1.1
</testng.version>
<gae.version>
1.8.1.1
</gae.version>
<!-- JDBC Drivers -->
<mysql-connector-java.version>
5.1.18
</mysql-connector-java.version>
</properties>
...
...
@@ -203,29 +202,6 @@
<artifactId>
commons-cli
</artifactId>
<version>
${commons-cli.version}
</version>
</dependency>
<!-- BEGIN: GAE related dependencies just for testing -->
<dependency>
<groupId>
org.b3log
</groupId>
<artifactId>
latke-gae
</artifactId>
<version>
${org.b3log.latke.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.appengine
</groupId>
<artifactId>
appengine-api-stubs
</artifactId>
<version>
${gae.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.appengine
</groupId>
<artifactId>
appengine-testing
</artifactId>
<version>
${gae.version}
</version>
<scope>
test
</scope>
</dependency>
<!-- END: GAE related dependencies just for testing -->
</dependencies>
<build>
...
...
src/main/resources/local.properties
View file @
a27b80d8
...
...
@@ -15,10 +15,8 @@
#
#
# Description: Solo local environment configurations. Configures this file
# if Solo runs on a standard Servlet container or Baidu App Engine,
# it is unnecessary to care this file if Solo runs on Google App Engine.
# Version: 1.1.2.7, Jan 7, 2016
# Description: Solo local environment configurations.
# Version: 1.1.2.8, Jan 8, 2016
# Author: Liang Ding
#
...
...
src/test/java/org/b3log/solo/AbstractTestCase.java
View file @
a27b80d8
...
...
@@ -15,14 +15,15 @@
*/
package
org
.
b3log
.
solo
;
import
com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
;
import
com.google.appengine.tools.development.testing.LocalServiceTestHelper
;
import
java.sql.Connection
;
import
java.util.Collection
;
import
java.util.Locale
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.ioc.config.Discoverer
;
import
org.b3log.latke.repository.jdbc.util.Connections
;
import
org.b3log.latke.repository.jdbc.util.JdbcRepositories
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
...
...
@@ -48,25 +49,18 @@ import org.b3log.solo.repository.impl.TagArticleRepositoryImpl;
import
org.b3log.solo.repository.impl.TagRepositoryImpl
;
import
org.b3log.solo.repository.impl.UserRepositoryImpl
;
import
org.b3log.solo.service.*
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
/**
* Abstract test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version
1.0.0.9, Dec 13, 2015
* @version
2.0.0.9, Jan 8, 2016
* @see #beforeClass()
* @see #afterClass()
*/
public
abstract
class
AbstractTestCase
{
/**
* Local service test helper.
*/
private
final
LocalServiceTestHelper
localServiceTestHelper
=
new
LocalServiceTestHelper
(
new
LocalDatastoreServiceTestConfig
());
/**
* Bean manager.
*/
...
...
@@ -76,7 +70,6 @@ public abstract class AbstractTestCase {
* Before class.
*
* <ol>
* <li>Sets up GAE unit test runtime environment</li>
* <li>Initializes Latke runtime</li>
* <li>Instantiates repositories</li>
* </ol>
...
...
@@ -85,30 +78,18 @@ public abstract class AbstractTestCase {
*/
@BeforeClass
public
void
beforeClass
()
throws
Exception
{
localServiceTestHelper
.
setUp
();
Latkes
.
initRuntimeEnv
();
Latkes
.
setLocale
(
Locale
.
SIMPLIFIED_CHINESE
);
final
Collection
<
Class
<?>>
classes
=
Discoverer
.
discover
(
"org.b3log.solo"
);
Lifecycle
.
startApplication
(
classes
);
beanManager
=
Lifecycle
.
getBeanManager
();
}
/**
* After class.
*
* <ol>
* <li>Tears down GAE unit test runtime environment</li>
* <li>Shutdowns Latke runtime</li>
* </ol>
*/
@AfterClass
public
void
afterClass
()
{
// XXX: NPE, localServiceTestHelper.tearDown();
final
Connection
connection
=
Connections
.
getConnection
();
connection
.
createStatement
().
execute
(
"DROP ALL OBJECTS"
);
connection
.
close
();
JdbcRepositories
.
initAllTables
();
Latkes
.
shutdown
();
}
/**
...
...
src/test/java/org/b3log/solo/repository/impl/ArchiveDateRepositoryImplTestCase.java
View file @
a27b80d8
...
...
@@ -37,7 +37,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
/**
* Adds successfully.
*
*
* @throws Exception exception
*/
@Test
...
...
@@ -46,7 +46,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
final
JSONObject
archiveDate
=
new
JSONObject
();
archiveDate
.
put
(
ArchiveDate
.
ARCHIVE_TIME
,
DateUtils
.
parseDate
(
"2011/12"
,
new
String
[]
{
"yyyy/MM"
}).
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_PUBLISHED_ARTICLE_COUNT
,
1
);
...
...
@@ -56,12 +56,12 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
final
List
<
JSONObject
>
archiveDates
=
archiveDateRepository
.
getArchiveDates
();
Assert
.
assertNotNull
(
archiveDates
);
Assert
.
assertEquals
(
archiveDates
.
size
(),
1
);
Assert
.
assertEquals
(
1
,
archiveDates
.
size
()
);
}
/**
* Get By ArchiveDate.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
...
...
src/test/java/org/b3log/solo/repository/impl/TagArticleRepositoryImplTestCase.java
View file @
a27b80d8
...
...
@@ -38,13 +38,12 @@ public class TagArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Add.
*
*
* @throws Exception exception
*/
@Test
public
void
add
()
throws
Exception
{
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
JSONObject
tagArticle
=
new
JSONObject
();
...
...
@@ -58,34 +57,34 @@ public class TagArticleRepositoryImplTestCase extends AbstractTestCase {
/**
* Get By ArticleId.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
public
void
getByArticleId
()
throws
Exception
{
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
List
<
JSONObject
>
tagArticle
=
tagArticleRepository
.
getByArticleId
(
"article1 id"
);
final
List
<
JSONObject
>
tagArticle
=
tagArticleRepository
.
getByArticleId
(
"article1 id"
);
Assert
.
assertNotNull
(
tagArticle
);
Assert
.
assertEquals
(
tagArticleRepository
.
getByArticleId
(
""
).
size
(),
0
);
Assert
.
assertEquals
(
0
,
tagArticleRepository
.
getByArticleId
(
""
).
size
()
);
}
/**
* Get By TagId.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
public
void
getByTagId
()
throws
Exception
{
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
JSONArray
results
=
tagArticleRepository
.
getByTagId
(
"tag1 id"
,
1
,
Integer
.
MAX_VALUE
).
final
JSONArray
results
=
tagArticleRepository
.
getByTagId
(
"tag1 id"
,
1
,
Integer
.
MAX_VALUE
).
getJSONArray
(
Keys
.
RESULTS
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
Assert
.
assertEquals
(
1
,
results
.
length
()
);
}
}
src/test/java/org/b3log/solo/repository/impl/TagRepositoryImplTestCase.java
View file @
a27b80d8
...
...
@@ -38,7 +38,7 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
/**
* Add.
*
*
* @throws Exception exception
*/
@Test
...
...
@@ -58,7 +58,7 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
/**
* Get By Title.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
...
...
@@ -69,9 +69,8 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
Assert
.
assertNotNull
(
found
);
Assert
.
assertEquals
(
found
.
getString
(
Tag
.
TAG_TITLE
),
"tag title1"
);
Assert
.
assertEquals
(
found
.
getInt
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
),
0
);
Assert
.
assertEquals
(
found
.
getInt
(
Tag
.
TAG_REFERENCE_COUNT
),
1
);
Assert
.
assertEquals
(
0
,
found
.
getInt
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
));
Assert
.
assertEquals
(
1
,
found
.
getInt
(
Tag
.
TAG_REFERENCE_COUNT
));
final
JSONObject
notFound
=
tagRepository
.
getByTitle
(
""
);
Assert
.
assertNull
(
notFound
);
...
...
@@ -79,7 +78,7 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
/**
* Get Most Used Tags.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
...
...
@@ -98,18 +97,17 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
List
<
JSONObject
>
mostUsedTags
=
tagRepository
.
getMostUsedTags
(
3
);
Assert
.
assertNotNull
(
mostUsedTags
);
Assert
.
assertEquals
(
mostUsedTags
.
size
(),
2
);
Assert
.
assertEquals
(
2
,
mostUsedTags
.
size
()
);
mostUsedTags
=
tagRepository
.
getMostUsedTags
(
1
);
Assert
.
assertNotNull
(
mostUsedTags
);
Assert
.
assertEquals
(
mostUsedTags
.
size
(),
1
);
Assert
.
assertEquals
(
mostUsedTags
.
get
(
0
).
getInt
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
),
3
);
Assert
.
assertEquals
(
1
,
mostUsedTags
.
size
());
Assert
.
assertEquals
(
3
,
mostUsedTags
.
get
(
0
).
getInt
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
));
}
/**
* Get By ArticleId.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"add"
)
...
...
@@ -120,16 +118,16 @@ public class TagRepositoryImplTestCase extends AbstractTestCase {
List
<
JSONObject
>
tags
=
tagRepository
.
getByArticleId
(
"article1 id"
);
Assert
.
assertNotNull
(
tags
);
Assert
.
assertEquals
(
tags
.
size
(),
1
);
Assert
.
assertEquals
(
1
,
tags
.
size
()
);
tags
=
tagRepository
.
getByArticleId
(
"not found"
);
Assert
.
assertNotNull
(
tags
);
Assert
.
assertEquals
(
tags
.
size
(),
0
);
Assert
.
assertEquals
(
0
,
tags
.
size
()
);
}
private
void
addTagArticle
()
throws
Exception
{
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
TagArticleRepository
tagArticleRepository
=
getTagArticleRepository
();
final
JSONObject
tagArticle
=
new
JSONObject
();
...
...
src/test/java/org/b3log/solo/service/UserQueryServiceTestCase.java
View file @
a27b80d8
...
...
@@ -34,7 +34,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
/**
* Add User.
*
*
* @throws Exception exception
*/
@Test
...
...
@@ -56,7 +56,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
/**
* Get User.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addUser"
)
...
...
@@ -67,7 +67,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
/**
* Get User By Email.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addUser"
)
...
...
@@ -80,7 +80,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
/**
* Get Users.
*
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addUser"
)
...
...
@@ -90,7 +90,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
final
JSONObject
paginationRequest
=
Requests
.
buildPaginationRequest
(
"1/20/10"
);
final
JSONObject
result
=
userQueryService
.
getUsers
(
paginationRequest
);
final
JSONArray
users
=
result
.
getJSONArray
(
User
.
USERS
);
Assert
.
assertEquals
(
users
.
length
(),
1
);
Assert
.
assertEquals
(
1
,
users
.
length
()
);
}
/**
...
...
src/test/java/org/b3log/solo/util/MarkdownsTestCase.java
View file @
a27b80d8
...
...
@@ -65,13 +65,13 @@ public final class MarkdownsTestCase {
}
markdownText
=
markdownTextBuilder
.
toString
();
System
.
out
.
println
(
markdownText
);
//
System.out.println(markdownText);
Stopwatchs
.
start
(
"Markdowning"
);
html
=
Markdowns
.
toHTML
(
markdownText
);
Stopwatchs
.
end
();
System
.
out
.
println
(
html
);
//
System.out.println(html);
System
.
out
.
println
(
"Stopwatch: "
);
System
.
out
.
println
(
Stopwatchs
.
getTimingStat
());
...
...
src/test/resources/latke.properties
View file @
a27b80d8
...
...
@@ -15,41 +15,11 @@
#
#
# Description:
B3log Latke configurations for test (GAE runtime)
.
# Version:
1.0.0.2, Apr 1, 2013
# Description:
Latke configurations for test
.
# Version:
2.0.0.2, Jan 8, 2016
# Author: Liang Ding
#
#### Server ####
# Configures the followings before deploy
serverScheme
=
http
serverHost
=
localhost
serverPort
=
8080
staticServerScheme
=
http
staticServerHost
=
localhost
staticServerPort
=
8080
# Note: The context path and static path should be "" if deploy app on ROOT. For other cases, starts with '/'
# and not ends with '/', for example, /blog
contextPath
=
staticPath
=
#### Runtime Environment ####
#runtimeEnv=LOCAL
runtimeEnv
=
GAE
#### Runtime Mode ####
runtimeMode
=
DEVELOPMENT
#runtimeMode=PRODUCTION
#### Cache Implementation ####
# Note: If the runtime environment is LOCAL, the cache will be LOCAL always
#cache=LOCAL
cache
=
GAE
#### User Service Implementation ####
# userService=GAE
userService
=
LOCAL
#### Static resource version ####
staticResourceVersion
=
201206280945
src/test/resources/local.properties
View file @
a27b80d8
...
...
@@ -14,4 +14,28 @@
# limitations under the License.
#
DO
NOT
REMOVE
THIS
FILE!
\ No newline at end of file
#### H2 runtime ####
runtimeDatabase
=
H2
jdbc.username
=
root
jdbc.password
=
jdbc.driver
=
org.h2.Driver
jdbc.URL
=
jdbc:h2:./target/solo_h2_test/db
jdbc.pool
=
h2
#### MySQL runtime ####
#runtimeDatabase=MYSQL
#jdbc.username=root
#jdbc.password=
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.URL=jdbc:mysql://localhost:3306/b3log?useUnicode=yes&characterEncoding=utf8
#jdbc.pool=druid
# The minConnCnt MUST larger or equal to 3
jdbc.minConnCnt
=
5
jdbc.maxConnCnt
=
10
# Be care to change the transaction isolation
jdbc.transactionIsolation
=
REPEATABLE_READ
# The specific table name prefix
jdbc.tablePrefix
=
b3_solo
\ No newline at end of file
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