forked from mmlewis/twuFunctionalTesting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Molly
committed
Jul 4, 2012
0 parents
commit b34315f
Showing
25 changed files
with
3,969 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.idea | ||
*.class | ||
target/ | ||
out/ | ||
*.iml | ||
.vagrant | ||
*.log | ||
*.ipr | ||
*.iws | ||
*.metadata/ | ||
*.DS_Store | ||
*swp | ||
Functional Test/reports/ | ||
.gradle | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'jetty' | ||
apply plugin: 'war' | ||
apply plugin: 'idea' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile 'org.hibernate:hibernate-core:4.0.1.Final', | ||
'javax.servlet:servlet-api:2.5', | ||
'org.springframework:spring-core:3.1.1.RELEASE', | ||
'org.springframework:spring-webmvc:3.1.1.RELEASE', | ||
'org.springframework:spring-web:3.1.1.RELEASE', | ||
'commons-dbcp:commons-dbcp:1.4', | ||
'org.springframework:spring-orm:3.1.0.RELEASE', | ||
'com.h2database:h2:1.2.145', | ||
'cglib:cglib:2.2.2', | ||
'org.freemarker:freemarker:2.3+', | ||
'ch.qos.logback:logback-classic:1.0.0', | ||
'commons-lang:commons-lang:2.6', | ||
'org.jasig.cas:cas-client-core:3.1.10', | ||
'hsqldb:hsqldb:1.8.0.10', | ||
'mysql:mysql-connector-java:5.1.18', | ||
'org.springframework.security:spring-security-core:3.1.0.RELEASE', | ||
'org.springframework.security:spring-security-cas:3.1.0.RELEASE', | ||
'org.springframework.security:spring-security-config:3.1.0.RELEASE', | ||
'org.springframework.security:spring-security-web:3.1.0.RELEASE' | ||
|
||
testCompile 'junit:junit:4.8.1', | ||
'org.springframework:spring-test:3.1.1.RELEASE', | ||
'org.mockito:mockito-all:1.9.0' | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kabbadi.controller; | ||
|
||
import kabbadi.domain.User; | ||
import kabbadi.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
public class HomeController { | ||
private UserService userService; | ||
|
||
@Autowired | ||
public HomeController(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
@RequestMapping(value = "/home", method = RequestMethod.GET) | ||
public ModelAndView homepage(@RequestParam(value = "username", defaultValue = "") String username) { | ||
ModelAndView modelAndView = new ModelAndView("home"); | ||
if (!username.isEmpty()) { | ||
User user = userService.getUser(username); | ||
modelAndView.addObject("user", user) | ||
.addObject("username", username); | ||
} | ||
return modelAndView; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package kabbadi.domain; | ||
|
||
import org.hsqldb.Library; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
import javax.persistence.*; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
@Entity | ||
public class User { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private int id; | ||
|
||
public static final String NAME_PROPERTY = "name"; | ||
|
||
private String name; | ||
|
||
@Deprecated | ||
public User() { | ||
} | ||
|
||
public User(String name) { | ||
this.name = name; | ||
} | ||
|
||
public User(int id, String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package kabbadi.domain.db; | ||
|
||
import org.hibernate.Session; | ||
import org.hibernate.SessionFactory; | ||
import org.hibernate.criterion.Restrictions; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public class GenericRepository<T> { | ||
protected SessionFactory sessionFactory; | ||
private Class<T> type; | ||
|
||
private GenericRepository() { | ||
} | ||
|
||
public GenericRepository(SessionFactory sessionFactory, Class<T> type) { | ||
this.sessionFactory = sessionFactory; | ||
this.type = type; | ||
} | ||
|
||
public T save(T o) { | ||
int id = (Integer) getSession().save(o); | ||
return get(id); | ||
} | ||
|
||
public T get(int id) { | ||
return (T) getSession().get(type, id); | ||
} | ||
|
||
public List<T> list() { | ||
return (List<T>) getSession().createCriteria(type).list(); | ||
} | ||
|
||
public void update( T o) { | ||
getSession().update(o); | ||
} | ||
|
||
public void delete(T o) { | ||
getSession().delete(o); | ||
} | ||
|
||
public List<T> findAll(String field, Object param) { | ||
return getSession().createCriteria(type).add(Restrictions.eq(field, param)).list(); | ||
} | ||
|
||
protected Session getSession() { | ||
return sessionFactory.getCurrentSession(); | ||
} | ||
|
||
public T findBy(String propertyName, String value) { | ||
return (T) this.sessionFactory.getCurrentSession().createCriteria(type).add( | ||
Restrictions.eq(propertyName, value)).uniqueResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kabbadi.service; | ||
|
||
import kabbadi.domain.User; | ||
import kabbadi.domain.db.GenericRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
public class UserService { | ||
|
||
private GenericRepository<User> userRepository; | ||
|
||
@Deprecated | ||
public UserService() {} | ||
|
||
@Autowired | ||
public UserService(@Qualifier("userRepository") GenericRepository<User> userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
|
||
@Transactional | ||
public User getUser(String userName) { | ||
return userRepository.findBy(User.NAME_PROPERTY, userName); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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:tx="http://www.springframework.org/schema/tx" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:security="http://www.springframework.org/schema/security" | ||
xmlns:mvc="http://www.springframework.org/schema/mvc" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | ||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd | ||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd | ||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> | ||
|
||
<context:annotation-config/> | ||
<mvc:annotation-driven/> | ||
<context:component-scan base-package="kabbadi"/> | ||
|
||
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> | ||
<property name="driverClassName" value="org.h2.Driver"/> | ||
<property name="url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/> | ||
<property name="username" value="sa"/> | ||
<property name="password" value=""/> | ||
</bean> | ||
|
||
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> | ||
<property name="dataSource" ref="myDataSource"/> | ||
<property name="configLocation" value="classpath:hibernate.cfg.xml"/> | ||
</bean> | ||
|
||
<bean id="transactionManager" | ||
class="org.springframework.orm.hibernate4.HibernateTransactionManager"> | ||
<property name="sessionFactory" ref="sessionFactory"/> | ||
</bean> | ||
|
||
<bean id="userRepository" class="kabbadi.domain.db.GenericRepository"> | ||
<constructor-arg value="kabbadi.domain.User"/> | ||
<constructor-arg ref="sessionFactory"/> | ||
</bean> | ||
|
||
<tx:annotation-driven/> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<!DOCTYPE hibernate-configuration PUBLIC | ||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> | ||
|
||
<hibernate-configuration> | ||
|
||
<session-factory> | ||
|
||
<!-- SQL dialect --> | ||
<property name="dialect">org.hibernate.dialect.H2Dialect</property> | ||
|
||
<!-- Disable the second-level cache --> | ||
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property> | ||
|
||
<!-- Echo all executed SQL to stdout --> | ||
<property name="show_sql">true</property> | ||
|
||
<!-- Drop and re-save the database schema on startup --> | ||
<property name="hbm2ddl.auto">create</property> | ||
|
||
<property name="hibernate.id.new_generator_mappings">true</property> | ||
|
||
<mapping class="kabbadi.domain.User"/> | ||
|
||
</session-factory> | ||
|
||
</hibernate-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
insert into user (id, name) values (1, 'bill'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<pattern>%date{ISO8601} %logger %method%n%level: %message%n</pattern> | ||
</layout> | ||
</appender> | ||
|
||
|
||
<root> | ||
<level value="INFO" /> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" | ||
xmlns:mvc="http://www.springframework.org/schema/mvc"> | ||
|
||
<context:component-scan base-package="kabbadi.controller"/> | ||
|
||
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> | ||
<property name="templateLoaderPath" value="/WEB-INF/freemarker/"/> | ||
</bean> | ||
|
||
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> | ||
<property name="cache" value="true"/> | ||
<property name="prefix" value=""/> | ||
<property name="suffix" value=".ftl"/> | ||
<property name="exposeSpringMacroHelpers" value="true"/> | ||
</bean> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>kabaddi</title> | ||
</head> | ||
|
||
<body> | ||
<#if user??> | ||
<h1>Hallo ${user.name}</a> | ||
<#else> | ||
<#if username??> | ||
<h1>Sorry, didn't find a user called "${username}"</h1> | ||
</#if> | ||
<p><a href="?username=bill">Try me</a></p> | ||
</#if> | ||
</h1> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?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:mvc="http://www.springframework.org/schema/mvc" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd | ||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> | ||
|
||
<mvc:resources mapping="/**" location="/static/"/> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
id="WebApp_ID" version="2.5"> | ||
<display-name>JMSpace</display-name> | ||
|
||
<servlet> | ||
<servlet-name>dispatcher</servlet-name> | ||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>static</servlet-name> | ||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>dispatcher</servlet-name> | ||
<url-pattern>/</url-pattern> | ||
</servlet-mapping> | ||
|
||
<servlet-mapping> | ||
<servlet-name>static</servlet-name> | ||
<url-pattern>/static/*</url-pattern> | ||
</servlet-mapping> | ||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>classpath:/applicationContext.xml</param-value> | ||
</context-param> | ||
|
||
</web-app> |
Oops, something went wrong.