Permalink
Browse files

Got the controller tests working again and implemented the # route tag

  • Loading branch information...
1 parent 0e7fe3a commit c61345f6dac0e1f45ce72b232deaeecbfc0ecd74 @ajselvig ajselvig committed Dec 29, 2012
View
9 .idea/libraries/javassist_3_12_1_GA.xml
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+ <library name="javassist-3.12.1.GA">
+ <CLASSES>
+ <root url="jar://$PROJECT_DIR$/lib/javassist-3.12.1.GA.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+</component>
View
252 .idea/workspace.xml
@@ -2,27 +2,40 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="2d472f65-4e1f-4bcf-9336-59340b03091d" name="Default" comment="">
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/kotlin-runtime.jar" afterPath="$PROJECT_DIR$/lib/kotlin-runtime.jar" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" afterPath="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" />
+ <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt" />
+ <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/javassist_3_12_1_GA.xml" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" afterPath="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/KaraTests.iml" afterPath="$PROJECT_DIR$/KaraTests/KaraTests.iml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraExec/src/Main.kt" afterPath="$PROJECT_DIR$/KaraExec/src/Main.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
</list>
<ignored path="Kara.iws" />
<ignored path=".idea/workspace.xml" />
<file path="/Dimensions.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352565087547" ignored="false" />
<file path="/a.dummy" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352565409553" ignored="false" />
- <file path="/Dispatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785029397" ignored="false" />
+ <file path="/Dispatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356759341306" ignored="false" />
<file path="/BaseTags.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785526099" ignored="false" />
<file path="/Enums.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352569691890" ignored="false" />
<file path="/Element.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355435684785" ignored="false" />
<file path="/MockHttpServletResponse.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352571599397" ignored="false" />
- <file path="/FooController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352574853407" ignored="false" />
+ <file path="/FooController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756115012" ignored="false" />
<file path="/Application.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355786586928" ignored="false" />
<file path="/AppLoader.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355899016243" ignored="false" />
<file path="/Main.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356733173848" ignored="false" />
<file path="$USER_HOME$/Library/Application Support/IdeaIC12/Kotlin/lib/kotlin-plugin.jar!/jet/Unit.jet" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356732799951" ignored="false" />
<file path="/FileWatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354993061099" ignored="false" />
- <file path="/HomeController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355462965216" ignored="false" />
+ <file path="/HomeController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356736561555" ignored="false" />
<file path="/JettyRunner.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355896378428" ignored="false" />
<file path="/Index.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354990519488" ignored="false" />
<file path="/fragment.java" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354852259600" ignored="false" />
@@ -119,10 +132,10 @@
<file path="/Show.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355291672775" ignored="false" />
<file path="/Exceptions.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355627624427" ignored="false" />
<file path="/Error.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355428502830" ignored="false" />
- <file path="/ActionInfo.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785186368" ignored="false" />
+ <file path="/ActionInfo.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356755296782" ignored="false" />
<file path="/Util.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355460410532" ignored="false" />
<file path="/ErrorView.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355464388567" ignored="false" />
- <file path="/RouteParams.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355461329295" ignored="false" />
+ <file path="/RouteParams.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356736392377" ignored="false" />
<file path="/BaseController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355463443372" ignored="false" />
<file path="/AppConfig.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355898964207" ignored="false" />
<file path="/Generator.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356734885202" ignored="false" />
@@ -142,8 +155,8 @@
<file path="/Servlet.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355788085682" ignored="false" />
<file path="/Stylesheet.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785331005" ignored="false" />
<file path="/a.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355804316991" ignored="false" />
- <file path="/DispatchTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355805407591" ignored="false" />
- <file path="/MockDispatch.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355806220044" ignored="false" />
+ <file path="/DispatchTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356752507487" ignored="false" />
+ <file path="/MockDispatch.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356752592438" ignored="false" />
<file path="/Templates.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355860908482" ignored="false" />
<file path="/GeneralTemplates.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355895976591" ignored="false" />
<file path="/Json.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355863127844" ignored="false" />
@@ -175,7 +188,11 @@
<file path="$USER_HOME$/tmp/karaexample/src/com/karaexample/styles/DefaultStyles.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355961191801" ignored="false" />
<file path="$USER_HOME$/tmp/karaexample/.idea/ant.xml" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355943788020" ignored="false" />
<file path="$USER_HOME$/tmp/karaexample/src/com/karaexample/Application.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355961191801" ignored="false" />
- <file path="/README.md" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355988305514" ignored="false" />
+ <file path="/README.md" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356762706749" ignored="false" />
+ <file path="/MockHttpServletRequest.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356753941172" ignored="false" />
+ <file path="/ActionTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756177707" ignored="false" />
+ <file path="/MockHttpSession.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356753902745" ignored="false" />
+ <file path="/Annotations.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756350271" ignored="false" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -235,10 +252,19 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="README.md" pinned="false" current="false" current-in-tab="false">
+ <file leaf-file-name="README.md" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
- <state line="113" column="0" selection-start="6294" selection-end="6294" vertical-scroll-proportion="0.0">
+ <state line="355" column="0" selection-start="15908" selection-end="15908" vertical-scroll-proportion="0.5840555">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="DefaultLayout.kt" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/DefaultLayout.kt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="14" column="27" selection-start="397" selection-end="397" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -247,25 +273,34 @@
<file leaf-file-name="Main.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="96" column="29" selection-start="3236" selection-end="3236" vertical-scroll-proportion="0.0">
+ <state line="35" column="60" selection-start="901" selection-end="901" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Generator.kt" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/Generator.kt">
+ <file leaf-file-name="HomeController.kt" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="241" column="0" selection-start="8545" selection-end="8545" vertical-scroll-proportion="0.86259544">
+ <state line="15" column="0" selection-start="375" selection-end="375" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="AppConfig.kt" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt">
+ <file leaf-file-name="RouteParams.kt" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="46" column="49" selection-start="1418" selection-end="1418" vertical-scroll-proportion="0.0">
+ <state line="45" column="31" selection-start="1212" selection-end="1212" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="ActionInfo.kt" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="95" column="13" selection-start="3482" selection-end="3482" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -296,32 +331,32 @@
<component name="IdeDocumentHistory">
<option name="changedFiles">
<list>
- <option value="$PROJECT_DIR$/KaraLib/src/kara/views/Json.kt" />
- <option value="$PROJECT_DIR$/KaraDemo/config/appconfig.json" />
- <option value="$PROJECT_DIR$/KaraLib/src/kara/config/Config.kt" />
- <option value="$PROJECT_DIR$/KaraExec/src/server/JettyRunner.kt" />
- <option value="$PROJECT_DIR$/KaraLib/src/kara/config/ConfigReader.kt" />
- <option value="$PROJECT_DIR$/kara" />
- <option value="$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt" />
- <option value="$PROJECT_DIR$/KaraExec/src/server/AppLoader.kt" />
- <option value="$PROJECT_DIR$/KaraDemo/config/appconfig.development.json" />
- <option value="$PROJECT_DIR$/KaraExec/src/generators/templates/GeneralTemplates.kt" />
- <option value="$PROJECT_DIR$/ivy.xml" />
- <option value="$PROJECT_DIR$/KaraExec/src/generators/templates/ProjectTemplates.kt" />
<option value="$PROJECT_DIR$/KaraExec/src/generators/templates/ViewTemplates.kt" />
- <option value="$PROJECT_DIR$/README.md" />
- <option value="$PROJECT_DIR$/KaraExec/src/Main.kt" />
<option value="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" />
+ <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" />
+ <option value="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" />
+ <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" />
+ <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" />
+ <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" />
+ <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" />
+ <option value="$PROJECT_DIR$/KaraExec/src/Main.kt" />
+ <option value="$PROJECT_DIR$/README.md" />
</list>
</option>
</component>
<component name="MavenProjectNavigator">
<treeState />
</component>
<component name="ProjectFrameBounds">
- <option name="x" value="212" />
+ <option name="x" value="157" />
<option name="y" value="22" />
- <option name="width" value="1468" />
+ <option name="width" value="1523" />
<option name="height" value="968" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
@@ -384,16 +419,38 @@
<option name="myItemId" value="Kara" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="Kara" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
<PATH_ELEMENT>
- <option name="myItemId" value="External Libraries" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
+ <option name="myItemId" value="KaraTests" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="Kara" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="KaraTests" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="karatests" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="views" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -404,6 +461,14 @@
<option name="myItemId" value="KaraTests" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="karatests" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -422,6 +487,10 @@
<option name="myItemId" value="karatests" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="mock" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -872,7 +941,7 @@
<property name="options.lastSelected" value="appearance" />
<property name="MemberChooser.sorted" value="false" />
<property name="recentsLimit" value="5" />
- <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/guava-11.0.2.jar!/" />
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/javassist-3.12.1.GA.jar!/" />
<property name="project.structure.side.proportion" value="0.1946387" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
@@ -898,7 +967,7 @@
<recent name="$PROJECT_DIR$/KaraTests/src" />
</key>
</component>
- <component name="RunManager" selected="Kotlin.kara demo server">
+ <component name="RunManager" selected="Kotlin.karatests.controllers">
<configuration default="false" name="kara demo server" type="JetRunConfigurationType" factoryName="Kotlin" temporary="true">
<option name="MAIN_CLASS_NAME" value="kara.namespace" />
<option name="VM_PARAMETERS" value="" />
@@ -1098,8 +1167,9 @@
<item index="5" class="java.lang.String" itemvalue="Kotlin.karatests.views" />
</list>
<recent_temporary>
- <list size="1">
- <item index="0" class="java.lang.String" itemvalue="Kotlin.kara demo server" />
+ <list size="2">
+ <item index="0" class="java.lang.String" itemvalue="Kotlin.karatests.controllers" />
+ <item index="1" class="java.lang.String" itemvalue="Kotlin.kara demo server" />
</list>
</recent_temporary>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
@@ -1156,7 +1226,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
- <frame x="212" y="22" width="1468" height="968" extended-state="0" />
+ <frame x="157" y="22" width="1523" height="968" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -1168,13 +1238,13 @@
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Kotlin" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.20253165" sideWeight="0.69729096" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
- <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19457547" sideWeight="0.7995781" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.19457547" sideWeight="0.99661475" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32979977" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.1728142" sideWeight="0.16843346" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32991803" sideWeight="0.7632509" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.17229255" sideWeight="0.8054245" order="0" side_tool="false" content_ui="combo" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.28386337" sideWeight="0.6557377" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.1943128" sideWeight="0.7287736" order="0" side_tool="false" content_ui="combo" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2712264" sideWeight="0.6557377" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32744405" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@@ -1254,92 +1324,114 @@
</buildFile>
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/KaraDemo/KaraDemo.iml">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="7" column="73" selection-start="401" selection-end="401" vertical-scroll-proportion="0.16613925" />
+ <state line="52" column="31" selection-start="1656" selection-end="1656" vertical-scroll-proportion="1.4661654">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/build.xml">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/HomeController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="6" column="0" selection-start="184" selection-end="184" vertical-scroll-proportion="0.14263074" />
+ <state line="9" column="20" selection-start="258" selection-end="258" vertical-scroll-proportion="0.22881356">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/ivy.xml">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="16" selection-start="100" selection-end="100" vertical-scroll-proportion="0.0">
+ <state line="45" column="31" selection-start="1212" selection-end="1212" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/ProjectTemplates.kt">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="9" column="0" selection-start="142" selection-end="142" vertical-scroll-proportion="0.0" />
+ <state line="6" column="8" selection-start="128" selection-end="128" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/server/JettyRunner.kt">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/BaseController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="68" column="0" selection-start="2297" selection-end="2297" vertical-scroll-proportion="1.5572519" />
+ <state line="17" column="15" selection-start="519" selection-end="519" vertical-scroll-proportion="0.44973546">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/ViewTemplates.kt">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="30" column="49" selection-start="723" selection-end="723" vertical-scroll-proportion="0.0" />
+ <state line="10" column="0" selection-start="186" selection-end="186" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/home/Index.kt">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="20" column="25" selection-start="507" selection-end="703" vertical-scroll-proportion="0.0" />
+ <state line="7" column="33" selection-start="197" selection-end="197" vertical-scroll-proportion="0.18518518">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/home/Forms.kt">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="0" selection-start="78" selection-end="965" vertical-scroll-proportion="0.0" />
+ <state line="4" column="28" selection-start="115" selection-end="115" vertical-scroll-proportion="0.105820104">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/styles/DefaultStyles.kt">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="6" column="0" selection-start="104" selection-end="965" vertical-scroll-proportion="0.0" />
+ <state line="85" column="34" selection-start="3271" selection-end="3271" vertical-scroll-proportion="0.35978836">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
+ <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="10" column="5" selection-start="267" selection-end="267" vertical-scroll-proportion="0.0" />
+ <state line="95" column="13" selection-start="3482" selection-end="3482" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="7" column="36" selection-start="139" selection-end="139" vertical-scroll-proportion="0.0" />
+ <state line="7" column="28" selection-start="168" selection-end="168" vertical-scroll-proportion="0.1779661">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/GeneralTemplates.kt">
+ <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/CrudController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="70" column="13" selection-start="1173" selection-end="1173" vertical-scroll-proportion="0.0" />
+ <state line="17" column="5" selection-start="367" selection-end="367" vertical-scroll-proportion="0.43220338">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt">
+ <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="46" column="49" selection-start="1418" selection-end="1418" vertical-scroll-proportion="0.0">
+ <state line="15" column="0" selection-start="375" selection-end="375" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/README.md">
+ <entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="113" column="0" selection-start="6294" selection-end="6294" vertical-scroll-proportion="0.0">
+ <state line="35" column="60" selection-start="901" selection-end="901" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
+ <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/DefaultLayout.kt">
<provider selected="true" editor-type-id="text-editor">
- <state line="96" column="29" selection-start="3236" selection-end="3236" vertical-scroll-proportion="0.0">
+ <state line="14" column="27" selection-start="397" selection-end="397" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/Generator.kt">
+ <entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
- <state line="241" column="0" selection-start="8545" selection-end="8545" vertical-scroll-proportion="0.86259544">
+ <state line="355" column="0" selection-start="15908" selection-end="15908" vertical-scroll-proportion="0.5840555">
<folding />
</state>
</provider>
@@ -1351,8 +1443,8 @@
<settings>
<artifact-editor>
<show-content>
- <type id="artifact" />
<type id="library" />
+ <type id="artifact" />
</show-content>
</artifact-editor>
<last-edited>KaraExec:jar</last-edited>
@@ -1403,7 +1495,7 @@
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
- <last-edited>KaraExec</last-edited>
+ <last-edited>KaraTests</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
@@ -1427,7 +1519,7 @@
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
- <last-edited>guava-11.0.2</last-edited>
+ <last-edited>javassist-3.12.1.GA</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
View
4 KaraDemo/src/karademo/controllers/HomeController.kt
@@ -15,6 +15,8 @@ class HomeController() : BaseController(DefaultLayout()) {
}
Post("/updatebook") fun update() : ActionResult {
+ println("parameters:")
+ println(params.getHash("book").toString())
return RedirectResult("/forms")
}
@@ -24,8 +26,6 @@ class HomeController() : BaseController(DefaultLayout()) {
isPublished = true
}
//(this.session).setAttribute("hello", "world")
- if (book.isPublished)
- throw RuntimeException("This is an exception!")
return Forms(book)
}
View
2 KaraExec/src/Main.kt
@@ -35,7 +35,6 @@ Commands:
c, config Show the application's configuration for the current environment
g, generate Generates a new project or file (see below)
h, help Show this help message
- u, update Updates the application's Kara dependency to the latest version
s, server Run the Kara server on the current directory
Options:
@@ -48,6 +47,7 @@ Generators:
project <name> Generates a new Kara project with the given name.
Use the --package=<package> option to specify a package
that's different than the project name.
+ update Updates the application's Kara dependency to the latest version
controller <name> Generates a new controller with the given name.
"Controller" will be automatically appended to the name)
view <controller> <view> Generate a new view for the given controller.
View
15 KaraLib/src/kara/controllers/ActionInfo.kt
@@ -33,8 +33,9 @@ class ActionInfo(val route : String, val controller : BaseController, val method
return true
}
- public fun getParams(url : String, query : String?) : RouteParams {
-
+ public fun getParams(request : HttpServletRequest) : RouteParams {
+ val url = request.getRequestURI()!!
+ val query = request.getQueryString()
val params = RouteParams()
// parse the query string
@@ -58,11 +59,19 @@ class ActionInfo(val route : String, val controller : BaseController, val method
val routeComp = routeComps[i]
routeComp.getParam(params, comp)
}
+
+ // parse the form parameters
+ for (name in request.getParameterNames()) {
+ val value = request.getParameter(name)!!
+ params[name] = value
+ }
+
return params
}
+ /** Execute the action based on the given request and populate the response. */
public fun exec(val appConfig: AppConfig, request: HttpServletRequest, response : HttpServletResponse) {
- val params = getParams(request.getRequestURI()!!, request.getQueryString())
+ val params = getParams(request)
controller.beforeRequest(request, response, params)
val context = ActionContext(appConfig, request, response, params)
View
8 KaraLib/src/kara/controllers/Annotations.kt
@@ -4,16 +4,16 @@ import java.lang.annotation.*
/** Used to annotate actions that respond to GET requests.
*/
-Retention(RetentionPolicy.RUNTIME) annotation class Get(val route : String = "[default]")
+Retention(RetentionPolicy.RUNTIME) annotation class Get(val route : String = "")
/** Used to annotate actions that respond to POST requests.
*/
-Retention(RetentionPolicy.RUNTIME) annotation class Post(val route : String = "[default]")
+Retention(RetentionPolicy.RUNTIME) annotation class Post(val route : String = "")
/** Used to annotate actions that respond to PUT requests.
*/
-Retention(RetentionPolicy.RUNTIME) annotation class Put(val route : String = "[default]")
+Retention(RetentionPolicy.RUNTIME) annotation class Put(val route : String = "")
/** Used to annotate actions that respond to DELETE requests.
*/
-Retention(RetentionPolicy.RUNTIME) annotation class Delete(val route : String = "[default]")
+Retention(RetentionPolicy.RUNTIME) annotation class Delete(val route : String = "")
View
9 KaraLib/src/kara/controllers/Dispatcher.kt
@@ -82,13 +82,16 @@ class Dispatcher() {
fun parseAction(annString : String, controller : BaseController, method : Method) {
// get the route based on the annotation and the controller
var route = annString.substring(annString.indexOf('=')+1, annString.indexOf(')'))
- if (!annString.contains("=") || route == "[default]") {
- route = method.getName()?.toLowerCase() as String
- }
+// if (!annString.contains("=") || route.length() == 0) {
+// route = method.getName()?.toLowerCase() as String
+// }
+ route = route.replace("#", method.getName()?.toLowerCase()!!)
val root = controller.root
if (!route.startsWith("/")) {
route = root + route
}
+ if (route.length() > 1 && route.endsWith("/"))
+ route = route.substring(0, route.length()-1)
val actionInfo = ActionInfo(route, controller, method)
logger.debug("adding action: " + actionInfo.toString());
View
15 KaraLib/src/kara/controllers/RouteParams.kt
@@ -40,6 +40,21 @@ class RouteParams() {
return _list.size()
}
+ /** Gets a hash with the nested values of the given name. */
+ fun getHash(name : String) : HashMap<String,String> {
+ val map = HashMap<String,String>()
+ val prefix = name + "["
+ for (key in _map.keySet()) {
+ if (key.startsWith(prefix)) {
+ var subkey = key.replace(prefix, "")
+ subkey = subkey.substring(0, subkey.length()-1)
+ val value = _map[key]!!
+ map[subkey] = value
+ }
+ }
+ return map
+ }
+
public fun toString() : String {
val pairs = _map.iterator().map { it ->
"${it.getKey()}: ${it.getValue()}"
View
6 KaraTests/KaraTests.iml
@@ -10,6 +10,12 @@
<orderEntry type="module" module-name="KaraLib" />
<orderEntry type="library" name="KotlinRuntime" level="project" />
<orderEntry type="library" name="javax.servlet-3.0.0.v201112011016" level="project" />
+ <orderEntry type="library" name="slf4j-log4j12-1.6.6" level="project" />
+ <orderEntry type="library" name="log4j-1.2.17" level="project" />
+ <orderEntry type="library" name="guava-11.0.2" level="project" />
+ <orderEntry type="library" name="slf4j-api-1.6.6" level="project" />
+ <orderEntry type="library" name="reflections-0.9.8" level="project" />
+ <orderEntry type="library" name="javassist-3.12.1.GA" level="project" />
</component>
</module>
View
5 KaraTests/src/karatests/controllers/ActionTests.kt
@@ -9,7 +9,7 @@ import kara.config.AppConfig
/** Tests for executing actions */
-fun runActionTests(args : Array<String>) {
+fun runActionTests() {
initMockDispatchWithReflection()
@@ -18,6 +18,9 @@ fun runActionTests(args : Array<String>) {
assertTrue(output?.contains("Default Layout") as Boolean, "Home view contains layout")
assertTrue(output?.contains("Welcome Home") as Boolean, "Home view contains view")
+ response = mockDispatch("GET", "/foo/blank")
+ assertEquals("blank", response.stringOutput())
+
response = mockDispatch("GET", "/foo/bar")
assertEquals("bar", response.stringOutput())
View
33 KaraTests/src/karatests/controllers/DispatchTests.kt
@@ -3,9 +3,10 @@ package karatests.controllers
import kara.controllers.Dispatcher
import kotlin.test.*
import kara.config.AppConfig
+import karatests.mock.mockRequest
/** Tests for dispatching routes to get action info. */
-fun runDispatchTests(args : Array<String>) {
+fun runDispatchTests() {
val appConfig = AppConfig("", "development")
appConfig["kara.appPackage"] = "karatests.controllers"
@@ -27,33 +28,39 @@ fun runDispatchTests(args : Array<String>) {
dispatcher.match("GET", "/foo/foobar") // default action name
- actionInfo = dispatcher.match("GET", "/foo/bar/list")!! // unnamed param
- var params = actionInfo.getParams("/foo/bar/list", "")
+ var request = mockRequest("GET", "/foo/bar/list")
+ actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // unnamed param
+ var params = actionInfo.getParams(request)
assertEquals("bar", params[0])
- actionInfo = dispatcher.match("GET", "/foo/complex/bar/list/42")!! // named and unnamed params
- params = actionInfo.getParams("/foo/complex/bar/list/42", "")
+ request = mockRequest("GET", "/foo/complex/bar/list/42")
+ actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // named and unnamed params
+ params = actionInfo.getParams(request)
assertEquals("bar", params[0])
assertEquals("42", params["id"])
assertEquals(2, params.size())
// crud controller
- actionInfo = dispatcher.match("GET", "/crud?name=value")!! // empty route with parameters
+ request = mockRequest("GET", "/crud?name=value")
+ actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // empty route with parameters
assertEquals(CrudController().javaClass, actionInfo.controller.javaClass)
- params = actionInfo.getParams("/crud?name=value", "")
+ params = actionInfo.getParams(request)
assertEquals("value", params["name"])
- actionInfo = dispatcher.match("GET", "/crud/42")!! // named parameter
- params = actionInfo.getParams("/crud/42", "")
+ request = mockRequest("GET", "/crud/42")
+ actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // named parameter
+ params = actionInfo.getParams(request)
assertEquals("42", params["id"])
dispatcher.match("POST", "/crud") // models
- actionInfo = dispatcher.match("PUT", "/crud/42")!! // put
- params = actionInfo.getParams("/crud/42", "")
+ request = mockRequest("PUT", "/crud/42")
+ actionInfo = dispatcher.match("PUT", request.getRequestURI()!!)!! // put
+ params = actionInfo.getParams(request)
assertEquals("42", params["id"])
- actionInfo = dispatcher.match("DELETE", "/crud/42")!! // delete
- params = actionInfo.getParams("/crud/42", "")
+ request = mockRequest("DELETE", "/crud/42")
+ actionInfo = dispatcher.match("DELETE", request.getRequestURI()!!)!! // delete
+ params = actionInfo.getParams(request)
assertEquals("42", params["id"])
}
View
6 KaraTests/src/karatests/controllers/FooController.kt
@@ -5,6 +5,10 @@ import kara.controllers.*
class FooController() : BaseController() {
+ Get("#") fun blank() : ActionResult {
+ return TextResult("blank")
+ }
+
Get("bar") fun bar() : ActionResult {
return TextResult("bar")
}
@@ -13,7 +17,7 @@ class FooController() : BaseController() {
return TextResult("bar/baz")
}
- Get("[default]") fun foobar() : ActionResult {
+ Get("#") fun foobar() : ActionResult {
return TextResult("foobar")
}
View
7 KaraTests/src/karatests/controllers/Main.kt
@@ -1,9 +1,12 @@
package karatests.controllers
+import org.apache.log4j.BasicConfigurator
+
/** Tests for dispatching routes to get action info. */
fun main(args : Array<String>) {
+ BasicConfigurator.configure()
- runDispatchTests(args)
- runActionTests(args)
+ runDispatchTests()
+ runActionTests()
}
View
8 KaraTests/src/karatests/mock/MockDispatch.kt
@@ -9,6 +9,7 @@ val _dispatcher = Dispatcher()
val _mockAppConfig = AppConfig("", "test")
public fun initMockDispatchWithReflection() {
+ _mockAppConfig["kara.appPackage"] = "karatests.controllers"
_dispatcher.initWithReflection(_mockAppConfig)
}
@@ -19,4 +20,11 @@ public fun mockDispatch(httpMethod : String, url : String) : MockHttpServletResp
val response = MockHttpServletResponse()
_dispatcher.dispatch(_mockAppConfig, request, response)
return response
+}
+
+
+/** Creates a HttpServletRequest with the given method and url*/
+public fun mockRequest(httpMethod : String, url : String) : MockHttpServletRequest {
+ val request = MockHttpServletRequest(httpMethod, url)
+ return request
}
View
15 KaraTests/src/karatests/mock/MockHttpServletRequest.kt
@@ -9,6 +9,9 @@ import javax.servlet.ServletInputStream
import java.util.Locale
import java.io.BufferedReader
import javax.servlet.http.Cookie
+import java.util.ArrayList
+import java.util.HashMap
+import java.util.Hashtable
class MockHttpServletRequest(method : String, url : String) : HttpServletRequest {
@@ -60,8 +63,11 @@ class MockHttpServletRequest(method : String, url : String) : HttpServletRequest
public override fun getSession() : HttpSession? {
throw UnsupportedOperationException()
}
+
+ val session = MockHttpSession()
+
public override fun getSession(p0 : Boolean) : HttpSession? {
- throw UnsupportedOperationException()
+ return session
}
public override fun getHeaders(p0 : String?) : Enumeration<String>? {
throw UnsupportedOperationException()
@@ -139,16 +145,19 @@ class MockHttpServletRequest(method : String, url : String) : HttpServletRequest
throw UnsupportedOperationException()
}
public override fun getParameter(p0 : String?) : String? {
- throw UnsupportedOperationException()
+ return params[p0]
}
public override fun getRemoteHost() : String? {
throw UnsupportedOperationException()
}
public override fun getAttributeNames() : Enumeration<String>? {
throw UnsupportedOperationException()
}
+
+ val params = Hashtable<String,String>()
+
public override fun getParameterNames() : Enumeration<String>? {
- throw UnsupportedOperationException()
+ return params.keys()
}
public override fun setAttribute(p0 : String?, p1 : Any?) {
throw UnsupportedOperationException()
View
65 KaraTests/src/karatests/mock/MockHttpSession.kt
@@ -0,0 +1,65 @@
+package karatests.mock
+
+import javax.servlet.http.HttpSession
+import javax.servlet.ServletContext
+import javax.servlet.http.HttpSessionContext
+import java.util.Enumeration
+import java.sql.Date
+import java.util.Hashtable
+
+/**
+ * Stub out the HttpSession interface for testing.
+ */
+class MockHttpSession : HttpSession {
+
+ val attributes = Hashtable<String,Any>()
+
+ public override fun getCreationTime(): Long {
+ return java.util.Date().getTime()
+ }
+ public override fun getId(): String? {
+ return "mock"
+ }
+ public override fun getLastAccessedTime(): Long {
+ return java.util.Date().getTime()
+ }
+ public override fun getServletContext(): ServletContext? {
+ throw UnsupportedOperationException()
+ }
+ public override fun setMaxInactiveInterval(p0: Int) {
+ throw UnsupportedOperationException()
+ }
+ public override fun getMaxInactiveInterval(): Int {
+ throw UnsupportedOperationException()
+ }
+ public override fun getSessionContext(): HttpSessionContext? {
+ throw UnsupportedOperationException()
+ }
+ public override fun getAttribute(p0: String?): Any? {
+ return attributes[p0]
+ }
+ public override fun getValue(p0: String?): Any? {
+ throw UnsupportedOperationException()
+ }
+ public override fun getAttributeNames(): Enumeration<String>? {
+ throw UnsupportedOperationException()
+ }
+ public override fun getValueNames(): Array<String>? {
+ return attributes.keySet().toArray<String>()
+ }
+ public override fun setAttribute(p0: String?, p1: Any?) {
+ attributes[p0!!] = p1!!
+ }
+ public override fun putValue(p0: String?, p1: Any?) {
+ }
+ public override fun removeAttribute(p0: String?) {
+ }
+ public override fun removeValue(p0: String?) {
+ }
+ public override fun invalidate() {
+ }
+ public override fun isNew(): Boolean {
+ return true
+ }
+
+}
View
70 README.md
@@ -75,6 +75,7 @@ Here's an overview of the Kara command line usage:
project <name> Generates a new Kara project with the given name.
Use the --package=<package> option to specify a package
that's different than the project name.
+ update Updates the application's Kara dependency to the latest version
controller <name> Generates a new controller with the given name.
"Controller" will be automatically appended to the name)
view <controller> <view> Generate a new view for the given controller.
@@ -126,6 +127,11 @@ To create a new view in your existing project, run something like:
which will generate a view called List that belongs to the BlogController.
+Since the Kara library is shipped with the Kara installation and changes frequently, it's often necessary to update the KaraLib.jar file in your application's lib folder.
+Running the *update* generator will do just that:
+
+ kara generate update
+
## Project Structure
@@ -157,7 +163,9 @@ HTML views in Kara are created using a custom Kotlin DSL. Each view inherits fro
}
}
-As you can see, the actual view markup is placed in the overriden render() method. The render() method accepts one argument, the action context. This context hold references to the action's request, response, session, and parameters.
+As you can see, the actual view markup is placed in the overriden render() method.
+The render() method accepts one argument, the action context.
+This context hold references to the action's request, response, session, and parameters.
Some more complex view markup might look like this:
@@ -174,10 +182,41 @@ Some more complex view markup might look like this:
+ "Some more text"
}
-Each function represents a single HTML tag, and accepts arguments for the tag's attributes. The last argument is an optional function literal that can be used to populate the tag's children (as with the ol and fieldset tags above). Text content can either be passed directly to the tag function, or added inside its body with the + operator.
+Each function represents a single HTML tag, and accepts arguments for the tag's attributes.
+The last argument is an optional function literal that can be used to populate the tag's children (as with the ol and fieldset tags above).
+Text content can either be passed directly to the tag function, or added inside its body with the + operator.
This flexible markup mechanism highlights the power of the Kotlin syntax, and can't be acheived in languages like Java or even Scala.
+### Layouts
+
+Applications generally contain HTML markup that's shared between views.
+In Kara (as well as many other web frameworks) these are called layouts.
+By convention, layout files are placed in the root of the app's views directory.
+Each layout inherits from the *HtmlLayout* class. Consider the following example:
+
+ class DefaultLayout() : HtmlLayout() {
+ override fun render(context: ActionContext, mainView: HtmlView) {
+ head {
+ title("Kara Demo Title")
+ stylesheet(DefaultStyles())
+ }
+ body {
+ h1("Kara Demo Site")
+ div(id="main") {
+ renderView(context, mainView)
+ }
+ a(text="Kara is developed by Tiny Mission", href="http://tinymission.com")
+ }
+ }
+ }
+
+As with views, a layout's markup is placed in the render() method, which accepts the current action context, as well as the main view to render.
+The mainView is rendered with the renderView() function.
+
+At this point, the layout used to render each view is specified at the controller level (either passed to the constructor, or specified later inside an action).
+
+
### Forms
Kara has a special form builder tag that allows you to generate form markup directly from a model object using reflection. For example:
@@ -281,6 +320,28 @@ An action method handles a specific request to the app, defined by the routing p
The controller above has three actions (index, test, and update). The first two respond to GET requests at / and /test, respectively.
The update action responds to POST requests at /updatebook.
+If the route doesn't start with /, it's relative to the current controller.
+The lowercase name of the controller, minus *controller*, is used as the first component of the route.
+Any pound signs are replaced with the name of the action method.
+
+ class FooController() : BaseController(DefaultLayout()) {
+ Get("") fun index() : ActionResult {
+ // maps to /foo
+ }
+
+ Get("bar") fun bar() : ActionResult {
+ // maps to /foo/bar
+ }
+
+ Get("#") fun blank() : ActionResult {
+ // maps to /foo/blank
+ }
+
+ Get(":id/#") fun edit(id : Int) : ActionResult {
+ // maps to /foo/3/edit
+ }
+ }
+
The routing mechanism allows for more complex routes, like:
Get("complex/*/list/:id") fun complex() : ActionResult {
@@ -293,6 +354,11 @@ The parameter values are available inside the request through the controllers Ro
this.params[0] // wildcard param
this.params["id"] // named :id param
+When compound objects are passed as form parameters, they can be retrieved as a hash:
+
+ // if form contains: book[title]=Foundation&book[author]=Isaac%20Asimov
+ this.params.getHash("book") // will return a has with {title="Foundation", author="Isaac Asimov"}
+
The most common ActionResult is an HtmlView, but you can also return raw text with TextResult(), JSON objects with JsonResult(), and redirects with RedirectRestul().
View
BIN out/jars/KaraExec.jar
Binary file not shown.
View
BIN out/jars/KaraLib.jar
Binary file not shown.

0 comments on commit c61345f

Please sign in to comment.