Permalink
Browse files

initial commit to Google Code

  • Loading branch information...
ipolevoy committed Apr 3, 2011
1 parent fbb52b9 commit b6b0b25e494e2518b81f27754874b544e15a14d2
Showing 352 changed files with 18,722 additions and 0 deletions.
View
619 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,44 @@
========1. Story:
(09:14:45 PM) ipolevoy@gmail.com/102ED2CB: ...I should probably think it over
(09:14:55 PM) ipolevoy@gmail.com/102ED2CB: maybe a better solution is necessary
(09:15:13 PM) ipolevoy@gmail.com/102ED2CB: something like a FreeMarkerConfig.init() - in tests this needs to be called automatically in cases where integrateViews() is set.
(09:15:21 PM) ipolevoy@gmail.com/102ED2CB: where you register all your tags
(09:15:28 PM) ipolevoy@gmail.com/102ED2CB: and this is called in SpecHelper
(09:15:31 PM) ipolevoy@gmail.com/102ED2CB: always
(09:15:58 PM) ipolevoy@gmail.com/102ED2CB: do that you had the same tags available in tests, as at runtime, even if you do not have filters
(09:16:09 PM) ipolevoy@gmail.com/102ED2CB: this is because pages can/do have tags
========2. Story:
Implement getLastModified():
MyController extends AppController{
public void index(){...}
public long indexLastModified(){...}
it is up to application logic to tell server when it was last modified ...:
see this: http://docstore.mik.ua/orelly/java-ent/servlet/ch03_06.htm
========7. Story:
implement addGlobalFilters(new TimingFilter()).except(MyController.class, BooksController.class, etc.);
========9. Story:
Implement FreeMarker exception handler
========10. Bug:
Prevent view(), assign(), render(), redirect(), etc. inside ControllerFilter.after() this is because the controller already
rendered.
========10. Story:
Add HttpSupport.println() with this implementaiton: System.out.println()
========11. Bug:
WARN ParamCopy - found 'session' value set by controller. It is reserved by ActiveWeb and will be overwritten
View
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: javalite:javalite-common:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: jaxen:jaxen:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.8.1" level="project" />
<orderEntry type="module" module-name="activeweb" />
<orderEntry type="library" name="Maven: activejdbc:activejdbc:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.5.10" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.16" level="project" />
<orderEntry type="library" name="Maven: com.google.inject:guice:2.0" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:2.5.6" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:2.5.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-simple:1.5.10" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
</component>
</module>
View
@@ -0,0 +1,63 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>activeweb</groupId>
<artifactId>activeweb-testing</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ActiveWeb - Testing</name>
<description>Testing dependency for building controller, view and integration specs.</description>
<developers>
<developer>
<name>Igor Polevoy</name>
<email>igor at polevoy.org</email>
</developer>
</developers>
<parent>
<groupId>activeweb</groupId>
<artifactId>activeweb-root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javalite</groupId>
<artifactId>javalite-common</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>activeweb</groupId>
<artifactId>activeweb</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,81 @@
/*
Copyright 2009-2010 Igor Polevoy
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.
*/
package activeweb;
import org.junit.After;
import org.junit.Before;
/**
*
* Bootstraps entire application, including AppConfig class, which sets up all filters exactly as at run time.
* If a {@link activeweb.controller_filters.DBConnectionFilter} is used in the application, it is bypassed.
* Instead, the DB connection to a test DB is made from a super class. A connection is opened to
* a test DB, transaction is started before each test. After each test, a connection is closed and a transaction
* is rolled back.
*
*
* @author Igor Polevoy
*/
public abstract class AppIntegrationSpec extends IntegrationSpec{
private boolean suppressDb = false;
@Before
public void beforeAppIntegrationSpec(){
Bootstrap.initApp();
if(!suppressDb){
Configuration.instance().setTesting(true);
DBSpecHelper.openTestConnections();
}
}
@After
public void afterAppIntegrationSpec() {
if(!suppressDb){
DBSpecHelper.closeTestConnections();
DBSpecHelper.clearConnectionWrappers();
}
}
/**
* Takes controller path. A controller path is a full path to controller starting from context and ending in a
* name of a controller on URI. Example: <code>/admin/permissions</code> where "admin" is a sub-package of controller
* and "permissions" is a name of controller. Such path implies a name of a controller class:
* <code>app.controllers.admin.PermissionsController</code>.
* Controller path always starts with a slash: "/".
*
* @param controllerPath
* @return
*/
@Override
protected RequestBuilder controller(String controllerPath){
RequestBuilder requestBuilder = new RequestBuilder(controllerPath, session());
requestBuilder.integrateViews();
return requestBuilder;
}
/**
* Call this method from a constructor of your spec in cases you do not need DB connections.
* Calling from a "before" method will not work.
*/
protected void suppressDb(){
suppressDb = true;
}
}
@@ -0,0 +1,68 @@
/*
Copyright 2009-2010 Igor Polevoy
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.
*/
package activeweb;
import javalite.common.Inflector;
import javalite.common.Util;
import javalite.test.jspec.TestException;
/**
* Super class for controller tests. This class will not open a connection to a test DB.
*
* @see {@link activeweb.DBControllerSpec}.
* @author Igor Polevoy
*/
public class ControllerSpec extends SpecHelper {
/**
* Use this DSL-ish method to send requests to controllers from specs.
* <strong>Attention</strong>: this method always returns a new object, please string methods one after another - fluent interfaces
* approach.
*
* @return instance of <code>RequestBuilder</code> with convenience methods.
*/
protected RequestBuilder request() {
return new RequestBuilder(getControllerPath(), session());
}
protected final String getControllerPath() {
String packageName = getClass().getPackage().getName();
if(!packageName.startsWith("app.controllers")){
throw new SpecException("controller specs must be located in package 'app.controllers' or sub-packages");
}
if (!getClass().getSimpleName().endsWith("ControllerSpec"))
throw new SpecException("Descendant of activeweb.ControllerSpec must be named with: controller name + 'Spec', " +
"and because controllers have to have a suffix 'Controller'," +
" controller spec classes must have a suffix: 'ControllerSpec' ");
String temp = getClass().getName();//full name
temp = temp.substring(16);
if(temp.contains(".")){
temp = temp.substring(0, temp.lastIndexOf("."));// this is sub-package
}else{
temp = "";
}
String specClassName = getClass().getSimpleName();
String controllerName = specClassName.substring(0, specClassName.lastIndexOf("ControllerSpec"));
controllerName = Inflector.underscore(controllerName);
return "/" + (Util.blank(temp)? "": temp + "/") + controllerName;
}
}
@@ -0,0 +1,51 @@
/*
Copyright 2009-2010 Igor Polevoy
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.
*/
package activeweb;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
/**
* Super class for controllers requiring a DB connection to the test DB.
* Connection is opened before a test, closed after a test and a transaction is rolled back.
*
* @author Igor Polevoy
*/
public class DBControllerSpec extends ControllerSpec {
@BeforeClass
public static void initDBConfig() {
DBSpecHelper.initDBConfig();
}
@Before
public final void open(){
DBSpecHelper.openTestConnections();
}
@After
public final void close(){
DBSpecHelper.closeTestConnections();
}
@AfterClass
public static void tearDown() {
DBSpecHelper.clearConnectionWrappers();
}
}
Oops, something went wrong.

0 comments on commit b6b0b25

Please sign in to comment.