Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webmagic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
沈俊林
webmagic
Commits
31698097
Commit
31698097
authored
Mar 16, 2014
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
invite h2 as test and standalone db, add spring profile for switch
parent
9a4eab44
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
140 additions
and
129 deletions
+140
-129
pom.xml
webmagic-avalon/webmagic-avalon-common/pom.xml
+14
-0
DynamicClassDao.java
.../main/java/us/codecraft/webmagic/dao/DynamicClassDao.java
+0
-2
DynamicClass.xml
...-avalon-common/src/main/resources/mapper/DynamicClass.xml
+32
-0
applicationContext-datasource.xml
...c/main/resources/spring/applicationContext-datasource.xml
+41
-0
applicationContext-myBatis.xml
.../src/main/resources/spring/applicationContext-myBatis.xml
+20
-10
applicationContext-tx.xml
...ommon/src/main/resources/spring/applicationContext-tx.xml
+0
-0
applicationContext.xml
...n-common/src/main/resources/spring/applicationContext.xml
+4
-0
schema.sql
...bmagic-avalon-common/src/main/resources/sql/h2/schema.sql
+8
-0
schema.sql
...gic-avalon-common/src/main/resources/sql/mysql/schema.sql
+0
-0
AbstractTest.java
...mon/src/test/java/us/codecraft/webmagic/AbstractTest.java
+17
-0
DynamicClassDaoTest.java
...t/java/us/codecraft/webmagic/dao/DynamicClassDaoTest.java
+2
-9
DynamicClassServiceImplTest.java
...decraft/webmagic/service/DynamicClassServiceImplTest.java
+2
-6
applicationContext-freemarker.xml
...c/test/resources/spring/applicationContext-freemarker.xml
+0
-34
applicationContext-myBatis.xml
.../src/test/resources/spring/applicationContext-myBatis.xml
+0
-23
applicationContext.xml
...n-common/src/test/resources/spring/applicationContext.xml
+0
-45
No files found.
webmagic-avalon/webmagic-avalon-common/pom.xml
View file @
31698097
...
...
@@ -11,6 +11,7 @@
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
us.codecraft
</groupId>
<artifactId>
webmagic-extension
</artifactId>
...
...
@@ -75,19 +76,28 @@
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjrt
</artifactId>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
1.3.175
</version>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-all
</artifactId>
...
...
@@ -97,18 +107,22 @@
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
</dependencies>
<build>
...
...
webmagic-avalon/webmagic-avalon-common/src/main/java/us/codecraft/webmagic/dao/DynamicClassDao.java
View file @
31698097
package
us
.
codecraft
.
webmagic
.
dao
;
import
org.apache.ibatis.annotations.Insert
;
import
us.codecraft.webmagic.model.DynamicClass
;
/**
...
...
@@ -8,6 +7,5 @@ import us.codecraft.webmagic.model.DynamicClass;
*/
public
interface
DynamicClassDao
{
@Insert
(
"insert into DynamicClass (`ClassName`,`SourceCode`,`AddTime`,`UpdateTime`) values (#{className},#{sourceCode},now(),now())"
)
public
int
add
(
DynamicClass
dynamicClass
);
}
webmagic-avalon/webmagic-avalon-common/src/main/resources/mapper/DynamicClass.xml
0 → 100644
View file @
31698097
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2010-2013 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"us.codecraft.webmagic.dao.DynamicClassDao"
>
<insert
id=
"add"
parameterType=
"us.codecraft.webmagic.model.DynamicClass"
databaseId=
"mysql"
>
insert into DynamicClass (`ClassName`,`SourceCode`,`AddTime`,`UpdateTime`)
values (#{className},#{sourceCode},now(),now())
</insert>
<insert
id=
"add"
parameterType=
"us.codecraft.webmagic.model.DynamicClass"
databaseId=
"h2"
>
insert into DynamicClass (`ClassName`,`SourceCode`,`AddTime`,`UpdateTime`)
values (#{className},#{sourceCode},now(),now())
</insert>
</mapper>
\ No newline at end of file
webmagic-avalon/webmagic-avalon-common/src/main/resources/spring/applicationContext-datasource.xml
0 → 100644
View file @
31698097
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc=
"http://www.springframework.org/schema/jdbc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"
>
<bean
id=
"dataSource"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"url"
value=
"jdbc:mysql://127.0.0.1:3306/WebMagic?characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"webmagic"
/>
<property
name=
"password"
value=
"webmagic"
/>
</bean>
<beans
profile=
"test"
>
<bean
id=
"dataSource"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"org.h2.Driver"
/>
<property
name=
"url"
value=
"jdbc:h2:mem:WebMagic;DB_CLOSE_DELAY=-1"
/>
</bean>
<!--Refer to https://github.com/springside/springside4/wiki/H2-Database -->
<jdbc:initialize-database
data-source=
"dataSource"
ignore-failures=
"ALL"
>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<!--<jdbc:script location="classpath:data/h2/import-data.sql" encoding="UTF-8"/>-->
</jdbc:initialize-database>
</beans>
<beans
profile=
"standalone"
>
<bean
id=
"dataSource"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"org.h2.Driver"
/>
<property
name=
"url"
value=
"jdbc:h2:file:~/.h2/WebMagic;AUTO_SERVER=TRUE"
/>
</bean>
<!--Refer to https://github.com/springside/springside4/wiki/H2-Database -->
<jdbc:initialize-database
data-source=
"dataSource"
ignore-failures=
"ALL"
>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<!--<jdbc:script location="classpath:data/h2/import-data.sql" encoding="UTF-8"/>-->
</jdbc:initialize-database>
</beans>
</beans>
\ No newline at end of file
webmagic-avalon/webmagic-avalon-common/src/main/resources/spring/applicationContext-myBatis.xml
View file @
31698097
...
...
@@ -4,20 +4,30 @@
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean
id=
"sqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
</bean>
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"us.codecraft.webmagic.dao"
/>
</bean>
<bean
id=
"dataSource"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"url"
value=
"jdbc:mysql://127.0.0.1:3306/WebMagic?characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"webmagic"
/>
<property
name=
"password"
value=
"webmagic"
/>
<bean
id=
"vendorProperties"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<property
name=
"properties"
>
<props>
<prop
key=
"SQL Server"
>
sqlserver
</prop>
<prop
key=
"DB2"
>
db2
</prop>
<prop
key=
"Oracle"
>
oracle
</prop>
<prop
key=
"MySQL"
>
mysql
</prop>
<prop
key=
"H2"
>
h2
</prop>
</props>
</property>
</bean>
<bean
id=
"databaseIdProvider"
class=
"org.apache.ibatis.mapping.VendorDatabaseIdProvider"
>
<property
name=
"properties"
ref=
"vendorProperties"
/>
</bean>
<bean
id=
"sqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
<property
name=
"databaseIdProvider"
ref=
"databaseIdProvider"
/>
<property
name=
"mapperLocations"
value=
"classpath*:/mapper/**/*.xml"
/>
</bean>
</beans>
\ No newline at end of file
webmagic-avalon/webmagic-avalon-common/src/
test
/resources/spring/applicationContext-tx.xml
→
webmagic-avalon/webmagic-avalon-common/src/
main
/resources/spring/applicationContext-tx.xml
View file @
31698097
File moved
webmagic-avalon/webmagic-avalon-common/src/main/resources/spring/applicationContext.xml
View file @
31698097
...
...
@@ -11,6 +11,10 @@
http://www.springframework.org/schema/context/spring-context-4.0.xsd"
>
<context:annotation-config/>
<context:property-placeholder
ignore-resource-not-found=
"true"
location=
"classpath*:/applicationContext.properties,
classpath*:/applicationContext.test.properties"
/>
<bean
id=
"messageSource"
class=
"org.springframework.context.support.ResourceBundleMessageSource"
>
<property
name=
"basenames"
>
<list>
...
...
webmagic-avalon/webmagic-avalon-common/src/main/resources/sql/h2/schema.sql
0 → 100644
View file @
31698097
CREATE
TABLE
DynamicClass
(
Id
int
(
11
)
NOT
NULL
AUTO_INCREMENT
PRIMARY
KEY
,
`ClassName`
varchar
(
200
)
NOT
NULL
,
`SourceCode`
text
NOT
NULL
,
`AddTime`
datetime
NOT
NULL
,
`UpdateTime`
datetime
NOT
NULL
,
UNIQUE
INDEX
`un_class_name`
(
`ClassName`
)
);
\ No newline at end of file
webmagic-avalon/
sql/create-tables
.sql
→
webmagic-avalon/
webmagic-avalon-common/src/main/resources/sql/mysql/schema
.sql
View file @
31698097
File moved
webmagic-avalon/webmagic-avalon-common/src/test/java/us/codecraft/webmagic/AbstractTest.java
0 → 100644
View file @
31698097
package
us
.
codecraft
.
webmagic
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @author code4crafter@gmail.com
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath*:/spring/applicationContext*.xml"
})
@ActiveProfiles
(
"test"
)
@Transactional
public
abstract
class
AbstractTest
{
}
webmagic-avalon/webmagic-avalon-common/src/test/java/us/codecraft/webmagic/dao/DynamicClassDaoTest.java
View file @
31698097
package
us
.
codecraft
.
webmagic
.
dao
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
us.codecraft.webmagic.AbstractTest
;
import
us.codecraft.webmagic.model.DynamicClass
;
/**
* @author code4crafter@gmail.com
*/
@Ignore
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:/spring/applicationContext-*.xml"
})
@Transactional
public
class
DynamicClassDaoTest
{
public
class
DynamicClassDaoTest
extends
AbstractTest
{
@Autowired
private
DynamicClassDao
dynamicClassDao
;
...
...
webmagic-avalon/webmagic-avalon-common/src/test/java/us/codecraft/webmagic/service/DynamicClassServiceImplTest.java
View file @
31698097
...
...
@@ -2,15 +2,13 @@ package us.codecraft.webmagic.service;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.Spy
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
us.codecraft.forger.ForgerFactory
;
import
us.codecraft.webmagic.AbstractTest
;
import
us.codecraft.webmagic.Foo
;
import
us.codecraft.webmagic.dao.DynamicClassDao
;
import
us.codecraft.webmagic.exception.DynamicClassCompileException
;
...
...
@@ -22,9 +20,7 @@ import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
/**
* @author code4crafter@gmail.com
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath*:/spring/applicationContext*.xml"
})
public
class
DynamicClassServiceImplTest
{
public
class
DynamicClassServiceImplTest
extends
AbstractTest
{
@Before
public
void
setUp
()
{
...
...
webmagic-avalon/webmagic-avalon-common/src/test/resources/spring/applicationContext-freemarker.xml
deleted
100644 → 0
View file @
9a4eab44
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean
id=
"freemarkerConfigurer"
class=
"org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
>
<property
name=
"templateLoaderPath"
value=
"/WEB-INF/pages/"
/>
<property
name=
"defaultEncoding"
value=
"utf-8"
/>
<property
name=
"freemarkerSettings"
>
<props>
<prop
key=
"template_update_delay"
>
0
</prop>
<prop
key=
"locale"
>
zh_CN
</prop>
<prop
key=
"datetime_format"
>
yyyy-MM-dd HH:mm:ss
</prop>
<prop
key=
"date_format"
>
yyyy-MM-dd
</prop>
<prop
key=
"number_format"
>
#.##
</prop>
</props>
</property>
</bean>
<bean
id=
"viewResolver"
class=
"org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
>
<property
name=
"viewClass"
value=
"org.springframework.web.servlet.view.freemarker.FreeMarkerView"
/>
<property
name=
"suffix"
value=
".ftl"
/>
<property
name=
"contentType"
value=
"text/html;charset=utf-8"
/>
<property
name=
"exposeRequestAttributes"
value=
"true"
/>
<property
name=
"exposeSessionAttributes"
value=
"true"
/>
<property
name=
"exposeSpringMacroHelpers"
value=
"true"
/>
</bean>
</beans>
\ No newline at end of file
webmagic-avalon/webmagic-avalon-common/src/test/resources/spring/applicationContext-myBatis.xml
deleted
100644 → 0
View file @
9a4eab44
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean
id=
"sqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
</bean>
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"us.codecraft.webmagic.dao"
/>
</bean>
<bean
id=
"dataSource"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"url"
value=
"jdbc:mysql://127.0.0.1:3306/WebMagic?characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"webmagic"
/>
<property
name=
"password"
value=
"webmagic"
/>
</bean>
</beans>
\ No newline at end of file
webmagic-avalon/webmagic-avalon-common/src/test/resources/spring/applicationContext.xml
deleted
100644 → 0
View file @
9a4eab44
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xsi:schemaLocation=
"http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd"
>
<context:annotation-config/>
<bean
id=
"messageSource"
class=
"org.springframework.context.support.ResourceBundleMessageSource"
>
<property
name=
"basenames"
>
<list>
<value>
web_messages
</value>
</list>
</property>
</bean>
<context:component-scan
base-package=
"us.codecraft.webmagic"
/>
<bean
class=
"org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"
>
<property
name=
"messageConverters"
>
<list>
<bean
id=
"fastJsonHttpMessageConverter"
class=
"com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"
>
<property
name=
"supportedMediaTypes"
>
<list>
<value>
text/html;charset=UTF-8
</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
<mvc:annotation-driven>
</mvc:annotation-driven>
</beans>
\ 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