Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit c61345f6dac0e1f45ce72b232deaeecbfc0ecd74 1 parent 0e7fe3a
Andy Selvig ajselvig authored
9 .idea/libraries/javassist_3_12_1_GA.xml
... ... @@ -0,0 +1,9 @@
  1 +<component name="libraryTable">
  2 + <library name="javassist-3.12.1.GA">
  3 + <CLASSES>
  4 + <root url="jar://$PROJECT_DIR$/lib/javassist-3.12.1.GA.jar!/" />
  5 + </CLASSES>
  6 + <JAVADOC />
  7 + <SOURCES />
  8 + </library>
  9 +</component>
252 .idea/workspace.xml
@@ -2,27 +2,40 @@
2 2 <project version="4">
3 3 <component name="ChangeListManager">
4 4 <list default="true" id="2d472f65-4e1f-4bcf-9336-59340b03091d" name="Default" comment="">
5   - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/kotlin-runtime.jar" afterPath="$PROJECT_DIR$/lib/kotlin-runtime.jar" />
6   - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" afterPath="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" />
  5 + <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt" />
  6 + <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/javassist_3_12_1_GA.xml" />
  7 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" />
  8 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" />
  9 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" />
  10 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" />
  11 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" />
  12 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" />
  13 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" afterPath="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" />
  14 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/KaraTests.iml" afterPath="$PROJECT_DIR$/KaraTests/KaraTests.iml" />
7 15 <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraExec/src/Main.kt" afterPath="$PROJECT_DIR$/KaraExec/src/Main.kt" />
  16 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" />
  17 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" />
  18 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" afterPath="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" />
  19 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
  20 + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" afterPath="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" />
8 21 <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
9 22 </list>
10 23 <ignored path="Kara.iws" />
11 24 <ignored path=".idea/workspace.xml" />
12 25 <file path="/Dimensions.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352565087547" ignored="false" />
13 26 <file path="/a.dummy" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352565409553" ignored="false" />
14   - <file path="/Dispatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785029397" ignored="false" />
  27 + <file path="/Dispatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356759341306" ignored="false" />
15 28 <file path="/BaseTags.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785526099" ignored="false" />
16 29 <file path="/Enums.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352569691890" ignored="false" />
17 30 <file path="/Element.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355435684785" ignored="false" />
18 31 <file path="/MockHttpServletResponse.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352571599397" ignored="false" />
19   - <file path="/FooController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1352574853407" ignored="false" />
  32 + <file path="/FooController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756115012" ignored="false" />
20 33 <file path="/Application.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355786586928" ignored="false" />
21 34 <file path="/AppLoader.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355899016243" ignored="false" />
22 35 <file path="/Main.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356733173848" ignored="false" />
23 36 <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" />
24 37 <file path="/FileWatcher.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354993061099" ignored="false" />
25   - <file path="/HomeController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355462965216" ignored="false" />
  38 + <file path="/HomeController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356736561555" ignored="false" />
26 39 <file path="/JettyRunner.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355896378428" ignored="false" />
27 40 <file path="/Index.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354990519488" ignored="false" />
28 41 <file path="/fragment.java" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1354852259600" ignored="false" />
@@ -119,10 +132,10 @@
119 132 <file path="/Show.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355291672775" ignored="false" />
120 133 <file path="/Exceptions.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355627624427" ignored="false" />
121 134 <file path="/Error.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355428502830" ignored="false" />
122   - <file path="/ActionInfo.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785186368" ignored="false" />
  135 + <file path="/ActionInfo.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356755296782" ignored="false" />
123 136 <file path="/Util.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355460410532" ignored="false" />
124 137 <file path="/ErrorView.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355464388567" ignored="false" />
125   - <file path="/RouteParams.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355461329295" ignored="false" />
  138 + <file path="/RouteParams.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356736392377" ignored="false" />
126 139 <file path="/BaseController.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355463443372" ignored="false" />
127 140 <file path="/AppConfig.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355898964207" ignored="false" />
128 141 <file path="/Generator.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356734885202" ignored="false" />
@@ -142,8 +155,8 @@
142 155 <file path="/Servlet.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355788085682" ignored="false" />
143 156 <file path="/Stylesheet.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355785331005" ignored="false" />
144 157 <file path="/a.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355804316991" ignored="false" />
145   - <file path="/DispatchTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355805407591" ignored="false" />
146   - <file path="/MockDispatch.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355806220044" ignored="false" />
  158 + <file path="/DispatchTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356752507487" ignored="false" />
  159 + <file path="/MockDispatch.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356752592438" ignored="false" />
147 160 <file path="/Templates.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355860908482" ignored="false" />
148 161 <file path="/GeneralTemplates.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355895976591" ignored="false" />
149 162 <file path="/Json.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355863127844" ignored="false" />
@@ -175,7 +188,11 @@
175 188 <file path="$USER_HOME$/tmp/karaexample/src/com/karaexample/styles/DefaultStyles.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355961191801" ignored="false" />
176 189 <file path="$USER_HOME$/tmp/karaexample/.idea/ant.xml" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355943788020" ignored="false" />
177 190 <file path="$USER_HOME$/tmp/karaexample/src/com/karaexample/Application.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355961191801" ignored="false" />
178   - <file path="/README.md" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1355988305514" ignored="false" />
  191 + <file path="/README.md" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356762706749" ignored="false" />
  192 + <file path="/MockHttpServletRequest.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356753941172" ignored="false" />
  193 + <file path="/ActionTests.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756177707" ignored="false" />
  194 + <file path="/MockHttpSession.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356753902745" ignored="false" />
  195 + <file path="/Annotations.kt" changelist="2d472f65-4e1f-4bcf-9336-59340b03091d" time="1356756350271" ignored="false" />
179 196 <option name="TRACKING_ENABLED" value="true" />
180 197 <option name="SHOW_DIALOG" value="false" />
181 198 <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -235,10 +252,19 @@
235 252 </component>
236 253 <component name="FileEditorManager">
237 254 <leaf>
238   - <file leaf-file-name="README.md" pinned="false" current="false" current-in-tab="false">
  255 + <file leaf-file-name="README.md" pinned="false" current="true" current-in-tab="true">
239 256 <entry file="file://$PROJECT_DIR$/README.md">
240 257 <provider selected="true" editor-type-id="text-editor">
241   - <state line="113" column="0" selection-start="6294" selection-end="6294" vertical-scroll-proportion="0.0">
  258 + <state line="355" column="0" selection-start="15908" selection-end="15908" vertical-scroll-proportion="0.5840555">
  259 + <folding />
  260 + </state>
  261 + </provider>
  262 + </entry>
  263 + </file>
  264 + <file leaf-file-name="DefaultLayout.kt" pinned="false" current="false" current-in-tab="false">
  265 + <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/DefaultLayout.kt">
  266 + <provider selected="true" editor-type-id="text-editor">
  267 + <state line="14" column="27" selection-start="397" selection-end="397" vertical-scroll-proportion="0.0">
242 268 <folding />
243 269 </state>
244 270 </provider>
@@ -247,25 +273,34 @@
247 273 <file leaf-file-name="Main.kt" pinned="false" current="false" current-in-tab="false">
248 274 <entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
249 275 <provider selected="true" editor-type-id="text-editor">
250   - <state line="96" column="29" selection-start="3236" selection-end="3236" vertical-scroll-proportion="0.0">
  276 + <state line="35" column="60" selection-start="901" selection-end="901" vertical-scroll-proportion="0.0">
251 277 <folding />
252 278 </state>
253 279 </provider>
254 280 </entry>
255 281 </file>
256   - <file leaf-file-name="Generator.kt" pinned="false" current="true" current-in-tab="true">
257   - <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/Generator.kt">
  282 + <file leaf-file-name="HomeController.kt" pinned="false" current="false" current-in-tab="false">
  283 + <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
258 284 <provider selected="true" editor-type-id="text-editor">
259   - <state line="241" column="0" selection-start="8545" selection-end="8545" vertical-scroll-proportion="0.86259544">
  285 + <state line="15" column="0" selection-start="375" selection-end="375" vertical-scroll-proportion="0.0">
260 286 <folding />
261 287 </state>
262 288 </provider>
263 289 </entry>
264 290 </file>
265   - <file leaf-file-name="AppConfig.kt" pinned="false" current="false" current-in-tab="false">
266   - <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt">
  291 + <file leaf-file-name="RouteParams.kt" pinned="false" current="false" current-in-tab="false">
  292 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt">
267 293 <provider selected="true" editor-type-id="text-editor">
268   - <state line="46" column="49" selection-start="1418" selection-end="1418" vertical-scroll-proportion="0.0">
  294 + <state line="45" column="31" selection-start="1212" selection-end="1212" vertical-scroll-proportion="0.0">
  295 + <folding />
  296 + </state>
  297 + </provider>
  298 + </entry>
  299 + </file>
  300 + <file leaf-file-name="ActionInfo.kt" pinned="false" current="false" current-in-tab="false">
  301 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt">
  302 + <provider selected="true" editor-type-id="text-editor">
  303 + <state line="95" column="13" selection-start="3482" selection-end="3482" vertical-scroll-proportion="0.0">
269 304 <folding />
270 305 </state>
271 306 </provider>
@@ -296,22 +331,22 @@
296 331 <component name="IdeDocumentHistory">
297 332 <option name="changedFiles">
298 333 <list>
299   - <option value="$PROJECT_DIR$/KaraLib/src/kara/views/Json.kt" />
300   - <option value="$PROJECT_DIR$/KaraDemo/config/appconfig.json" />
301   - <option value="$PROJECT_DIR$/KaraLib/src/kara/config/Config.kt" />
302   - <option value="$PROJECT_DIR$/KaraExec/src/server/JettyRunner.kt" />
303   - <option value="$PROJECT_DIR$/KaraLib/src/kara/config/ConfigReader.kt" />
304   - <option value="$PROJECT_DIR$/kara" />
305   - <option value="$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt" />
306   - <option value="$PROJECT_DIR$/KaraExec/src/server/AppLoader.kt" />
307   - <option value="$PROJECT_DIR$/KaraDemo/config/appconfig.development.json" />
308   - <option value="$PROJECT_DIR$/KaraExec/src/generators/templates/GeneralTemplates.kt" />
309   - <option value="$PROJECT_DIR$/ivy.xml" />
310   - <option value="$PROJECT_DIR$/KaraExec/src/generators/templates/ProjectTemplates.kt" />
311 334 <option value="$PROJECT_DIR$/KaraExec/src/generators/templates/ViewTemplates.kt" />
312   - <option value="$PROJECT_DIR$/README.md" />
313   - <option value="$PROJECT_DIR$/KaraExec/src/Main.kt" />
314 335 <option value="$PROJECT_DIR$/KaraExec/src/generators/Generator.kt" />
  336 + <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt" />
  337 + <option value="$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt" />
  338 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockDispatch.kt" />
  339 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt" />
  340 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpServletRequest.kt" />
  341 + <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt" />
  342 + <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt" />
  343 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt" />
  344 + <option value="$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt" />
  345 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt" />
  346 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt" />
  347 + <option value="$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt" />
  348 + <option value="$PROJECT_DIR$/KaraExec/src/Main.kt" />
  349 + <option value="$PROJECT_DIR$/README.md" />
315 350 </list>
316 351 </option>
317 352 </component>
@@ -319,9 +354,9 @@
319 354 <treeState />
320 355 </component>
321 356 <component name="ProjectFrameBounds">
322   - <option name="x" value="212" />
  357 + <option name="x" value="157" />
323 358 <option name="y" value="22" />
324   - <option name="width" value="1468" />
  359 + <option name="width" value="1523" />
325 360 <option name="height" value="968" />
326 361 </component>
327 362 <component name="ProjectInspectionProfilesVisibleTreeState">
@@ -384,9 +419,15 @@
384 419 <option name="myItemId" value="Kara" />
385 420 <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
386 421 </PATH_ELEMENT>
  422 + </PATH>
  423 + <PATH>
  424 + <PATH_ELEMENT>
  425 + <option name="myItemId" value="Kara" />
  426 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
  427 + </PATH_ELEMENT>
387 428 <PATH_ELEMENT>
388   - <option name="myItemId" value="External Libraries" />
389   - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
  429 + <option name="myItemId" value="KaraTests" />
  430 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
390 431 </PATH_ELEMENT>
391 432 </PATH>
392 433 <PATH>
@@ -394,6 +435,22 @@
394 435 <option name="myItemId" value="Kara" />
395 436 <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
396 437 </PATH_ELEMENT>
  438 + <PATH_ELEMENT>
  439 + <option name="myItemId" value="KaraTests" />
  440 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  441 + </PATH_ELEMENT>
  442 + <PATH_ELEMENT>
  443 + <option name="myItemId" value="src" />
  444 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  445 + </PATH_ELEMENT>
  446 + <PATH_ELEMENT>
  447 + <option name="myItemId" value="karatests" />
  448 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  449 + </PATH_ELEMENT>
  450 + <PATH_ELEMENT>
  451 + <option name="myItemId" value="views" />
  452 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  453 + </PATH_ELEMENT>
397 454 </PATH>
398 455 <PATH>
399 456 <PATH_ELEMENT>
@@ -404,6 +461,14 @@
404 461 <option name="myItemId" value="KaraTests" />
405 462 <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
406 463 </PATH_ELEMENT>
  464 + <PATH_ELEMENT>
  465 + <option name="myItemId" value="src" />
  466 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  467 + </PATH_ELEMENT>
  468 + <PATH_ELEMENT>
  469 + <option name="myItemId" value="karatests" />
  470 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  471 + </PATH_ELEMENT>
407 472 </PATH>
408 473 <PATH>
409 474 <PATH_ELEMENT>
@@ -422,6 +487,10 @@
422 487 <option name="myItemId" value="karatests" />
423 488 <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
424 489 </PATH_ELEMENT>
  490 + <PATH_ELEMENT>
  491 + <option name="myItemId" value="mock" />
  492 + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
  493 + </PATH_ELEMENT>
425 494 </PATH>
426 495 <PATH>
427 496 <PATH_ELEMENT>
@@ -872,7 +941,7 @@
872 941 <property name="options.lastSelected" value="appearance" />
873 942 <property name="MemberChooser.sorted" value="false" />
874 943 <property name="recentsLimit" value="5" />
875   - <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/guava-11.0.2.jar!/" />
  944 + <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/javassist-3.12.1.GA.jar!/" />
876 945 <property name="project.structure.side.proportion" value="0.1946387" />
877 946 <property name="MemberChooser.copyJavadoc" value="false" />
878 947 <property name="GoToClass.toSaveIncludeLibraries" value="false" />
@@ -898,7 +967,7 @@
898 967 <recent name="$PROJECT_DIR$/KaraTests/src" />
899 968 </key>
900 969 </component>
901   - <component name="RunManager" selected="Kotlin.kara demo server">
  970 + <component name="RunManager" selected="Kotlin.karatests.controllers">
902 971 <configuration default="false" name="kara demo server" type="JetRunConfigurationType" factoryName="Kotlin" temporary="true">
903 972 <option name="MAIN_CLASS_NAME" value="kara.namespace" />
904 973 <option name="VM_PARAMETERS" value="" />
@@ -1098,8 +1167,9 @@
1098 1167 <item index="5" class="java.lang.String" itemvalue="Kotlin.karatests.views" />
1099 1168 </list>
1100 1169 <recent_temporary>
1101   - <list size="1">
1102   - <item index="0" class="java.lang.String" itemvalue="Kotlin.kara demo server" />
  1170 + <list size="2">
  1171 + <item index="0" class="java.lang.String" itemvalue="Kotlin.karatests.controllers" />
  1172 + <item index="1" class="java.lang.String" itemvalue="Kotlin.kara demo server" />
1103 1173 </list>
1104 1174 </recent_temporary>
1105 1175 <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
@@ -1156,7 +1226,7 @@
1156 1226 </todo-panel>
1157 1227 </component>
1158 1228 <component name="ToolWindowManager">
1159   - <frame x="212" y="22" width="1468" height="968" extended-state="0" />
  1229 + <frame x="157" y="22" width="1523" height="968" extended-state="0" />
1160 1230 <editor active="true" />
1161 1231 <layout>
1162 1232 <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 @@
1168 1238 <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" />
1169 1239 <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" />
1170 1240 <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" />
1171   - <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" />
  1241 + <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" />
1172 1242 <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" />
1173 1243 <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" />
1174 1244 <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" />
1175 1245 <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" />
1176   - <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" />
1177   - <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" />
  1246 + <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" />
  1247 + <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" />
1178 1248 <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" />
1179 1249 <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" />
1180 1250 <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 @@
1254 1324 </buildFile>
1255 1325 </component>
1256 1326 <component name="editorHistoryManager">
1257   - <entry file="file://$PROJECT_DIR$/KaraDemo/KaraDemo.iml">
  1327 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/mock/MockHttpSession.kt">
1258 1328 <provider selected="true" editor-type-id="text-editor">
1259   - <state line="7" column="73" selection-start="401" selection-end="401" vertical-scroll-proportion="0.16613925" />
  1329 + <state line="52" column="31" selection-start="1656" selection-end="1656" vertical-scroll-proportion="1.4661654">
  1330 + <folding />
  1331 + </state>
1260 1332 </provider>
1261 1333 </entry>
1262   - <entry file="file://$PROJECT_DIR$/build.xml">
  1334 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/HomeController.kt">
1263 1335 <provider selected="true" editor-type-id="text-editor">
1264   - <state line="6" column="0" selection-start="184" selection-end="184" vertical-scroll-proportion="0.14263074" />
  1336 + <state line="9" column="20" selection-start="258" selection-end="258" vertical-scroll-proportion="0.22881356">
  1337 + <folding />
  1338 + </state>
1265 1339 </provider>
1266 1340 </entry>
1267   - <entry file="file://$PROJECT_DIR$/ivy.xml">
  1341 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/RouteParams.kt">
1268 1342 <provider selected="true" editor-type-id="text-editor">
1269   - <state line="2" column="16" selection-start="100" selection-end="100" vertical-scroll-proportion="0.0">
  1343 + <state line="45" column="31" selection-start="1212" selection-end="1212" vertical-scroll-proportion="0.0">
1270 1344 <folding />
1271 1345 </state>
1272 1346 </provider>
1273 1347 </entry>
1274   - <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/ProjectTemplates.kt">
  1348 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/Annotations.kt">
1275 1349 <provider selected="true" editor-type-id="text-editor">
1276   - <state line="9" column="0" selection-start="142" selection-end="142" vertical-scroll-proportion="0.0" />
  1350 + <state line="6" column="8" selection-start="128" selection-end="128" vertical-scroll-proportion="0.0">
  1351 + <folding />
  1352 + </state>
1277 1353 </provider>
1278 1354 </entry>
1279   - <entry file="file://$PROJECT_DIR$/KaraExec/src/server/JettyRunner.kt">
  1355 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/BaseController.kt">
1280 1356 <provider selected="true" editor-type-id="text-editor">
1281   - <state line="68" column="0" selection-start="2297" selection-end="2297" vertical-scroll-proportion="1.5572519" />
  1357 + <state line="17" column="15" selection-start="519" selection-end="519" vertical-scroll-proportion="0.44973546">
  1358 + <folding />
  1359 + </state>
1282 1360 </provider>
1283 1361 </entry>
1284   - <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/ViewTemplates.kt">
  1362 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt">
1285 1363 <provider selected="true" editor-type-id="text-editor">
1286   - <state line="30" column="49" selection-start="723" selection-end="723" vertical-scroll-proportion="0.0" />
  1364 + <state line="10" column="0" selection-start="186" selection-end="186" vertical-scroll-proportion="0.0">
  1365 + <folding />
  1366 + </state>
1287 1367 </provider>
1288 1368 </entry>
1289   - <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/home/Index.kt">
  1369 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/Main.kt">
1290 1370 <provider selected="true" editor-type-id="text-editor">
1291   - <state line="20" column="25" selection-start="507" selection-end="703" vertical-scroll-proportion="0.0" />
  1371 + <state line="7" column="33" selection-start="197" selection-end="197" vertical-scroll-proportion="0.18518518">
  1372 + <folding />
  1373 + </state>
1292 1374 </provider>
1293 1375 </entry>
1294   - <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/home/Forms.kt">
  1376 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/DispatchTests.kt">
1295 1377 <provider selected="true" editor-type-id="text-editor">
1296   - <state line="5" column="0" selection-start="78" selection-end="965" vertical-scroll-proportion="0.0" />
  1378 + <state line="4" column="28" selection-start="115" selection-end="115" vertical-scroll-proportion="0.105820104">
  1379 + <folding />
  1380 + </state>
1297 1381 </provider>
1298 1382 </entry>
1299   - <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/styles/DefaultStyles.kt">
  1383 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/Dispatcher.kt">
1300 1384 <provider selected="true" editor-type-id="text-editor">
1301   - <state line="6" column="0" selection-start="104" selection-end="965" vertical-scroll-proportion="0.0" />
  1385 + <state line="85" column="34" selection-start="3271" selection-end="3271" vertical-scroll-proportion="0.35978836">
  1386 + <folding />
  1387 + </state>
1302 1388 </provider>
1303 1389 </entry>
1304   - <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
  1390 + <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/controllers/ActionInfo.kt">
1305 1391 <provider selected="true" editor-type-id="text-editor">
1306   - <state line="10" column="5" selection-start="267" selection-end="267" vertical-scroll-proportion="0.0" />
  1392 + <state line="95" column="13" selection-start="3482" selection-end="3482" vertical-scroll-proportion="0.0">
  1393 + <folding />
  1394 + </state>
1307 1395 </provider>
1308 1396 </entry>
1309   - <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/FooController.kt">
  1397 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/ActionTests.kt">
1310 1398 <provider selected="true" editor-type-id="text-editor">
1311   - <state line="7" column="36" selection-start="139" selection-end="139" vertical-scroll-proportion="0.0" />
  1399 + <state line="7" column="28" selection-start="168" selection-end="168" vertical-scroll-proportion="0.1779661">
  1400 + <folding />
  1401 + </state>
1312 1402 </provider>
1313 1403 </entry>
1314   - <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/templates/GeneralTemplates.kt">
  1404 + <entry file="file://$PROJECT_DIR$/KaraTests/src/karatests/controllers/CrudController.kt">
1315 1405 <provider selected="true" editor-type-id="text-editor">
1316   - <state line="70" column="13" selection-start="1173" selection-end="1173" vertical-scroll-proportion="0.0" />
  1406 + <state line="17" column="5" selection-start="367" selection-end="367" vertical-scroll-proportion="0.43220338">
  1407 + <folding />
  1408 + </state>
1317 1409 </provider>
1318 1410 </entry>
1319   - <entry file="file://$PROJECT_DIR$/KaraLib/src/kara/config/AppConfig.kt">
  1411 + <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/controllers/HomeController.kt">
1320 1412 <provider selected="true" editor-type-id="text-editor">
1321   - <state line="46" column="49" selection-start="1418" selection-end="1418" vertical-scroll-proportion="0.0">
  1413 + <state line="15" column="0" selection-start="375" selection-end="375" vertical-scroll-proportion="0.0">
1322 1414 <folding />
1323 1415 </state>
1324 1416 </provider>
1325 1417 </entry>
1326   - <entry file="file://$PROJECT_DIR$/README.md">
  1418 + <entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
1327 1419 <provider selected="true" editor-type-id="text-editor">
1328   - <state line="113" column="0" selection-start="6294" selection-end="6294" vertical-scroll-proportion="0.0">
  1420 + <state line="35" column="60" selection-start="901" selection-end="901" vertical-scroll-proportion="0.0">
1329 1421 <folding />
1330 1422 </state>
1331 1423 </provider>
1332 1424 </entry>
1333   - <entry file="file://$PROJECT_DIR$/KaraExec/src/Main.kt">
  1425 + <entry file="file://$PROJECT_DIR$/KaraDemo/src/karademo/views/DefaultLayout.kt">
1334 1426 <provider selected="true" editor-type-id="text-editor">
1335   - <state line="96" column="29" selection-start="3236" selection-end="3236" vertical-scroll-proportion="0.0">
  1427 + <state line="14" column="27" selection-start="397" selection-end="397" vertical-scroll-proportion="0.0">
1336 1428 <folding />
1337 1429 </state>
1338 1430 </provider>
1339 1431 </entry>
1340   - <entry file="file://$PROJECT_DIR$/KaraExec/src/generators/Generator.kt">
  1432 + <entry file="file://$PROJECT_DIR$/README.md">
1341 1433 <provider selected="true" editor-type-id="text-editor">
1342   - <state line="241" column="0" selection-start="8545" selection-end="8545" vertical-scroll-proportion="0.86259544">
  1434 + <state line="355" column="0" selection-start="15908" selection-end="15908" vertical-scroll-proportion="0.5840555">
1343 1435 <folding />
1344 1436 </state>
1345 1437 </provider>
@@ -1351,8 +1443,8 @@
1351 1443 <settings>
1352 1444 <artifact-editor>
1353 1445 <show-content>
1354   - <type id="artifact" />
1355 1446 <type id="library" />
  1447 + <type id="artifact" />
1356 1448 </show-content>
1357 1449 </artifact-editor>
1358 1450 <last-edited>KaraExec:jar</last-edited>
@@ -1403,7 +1495,7 @@
1403 1495 </state>
1404 1496 <state key="ModuleStructureConfigurable.UI">
1405 1497 <settings>
1406   - <last-edited>KaraExec</last-edited>
  1498 + <last-edited>KaraTests</last-edited>
1407 1499 <splitter-proportions>
1408 1500 <option name="proportions">
1409 1501 <list>
@@ -1427,7 +1519,7 @@
1427 1519 </state>
1428 1520 <state key="ProjectLibrariesConfigurable.UI">
1429 1521 <settings>
1430   - <last-edited>guava-11.0.2</last-edited>
  1522 + <last-edited>javassist-3.12.1.GA</last-edited>
1431 1523 <splitter-proportions>
1432 1524 <option name="proportions">
1433 1525 <list>
4 KaraDemo/src/karademo/controllers/HomeController.kt
@@ -15,6 +15,8 @@ class HomeController() : BaseController(DefaultLayout()) {
15 15 }
16 16
17 17 Post("/updatebook") fun update() : ActionResult {
  18 + println("parameters:")
  19 + println(params.getHash("book").toString())
18 20 return RedirectResult("/forms")
19 21 }
20 22
@@ -24,8 +26,6 @@ class HomeController() : BaseController(DefaultLayout()) {
24 26 isPublished = true
25 27 }
26 28 //(this.session).setAttribute("hello", "world")
27   - if (book.isPublished)
28   - throw RuntimeException("This is an exception!")
29 29 return Forms(book)
30 30 }
31 31
2  KaraExec/src/Main.kt
@@ -35,7 +35,6 @@ Commands:
35 35 c, config Show the application's configuration for the current environment
36 36 g, generate Generates a new project or file (see below)
37 37 h, help Show this help message
38   - u, update Updates the application's Kara dependency to the latest version
39 38 s, server Run the Kara server on the current directory
40 39
41 40 Options:
@@ -48,6 +47,7 @@ Generators:
48 47 project <name> Generates a new Kara project with the given name.
49 48 Use the --package=<package> option to specify a package
50 49 that's different than the project name.
  50 + update Updates the application's Kara dependency to the latest version
51 51 controller <name> Generates a new controller with the given name.
52 52 "Controller" will be automatically appended to the name)
53 53 view <controller> <view> Generate a new view for the given controller.
15 KaraLib/src/kara/controllers/ActionInfo.kt
@@ -33,8 +33,9 @@ class ActionInfo(val route : String, val controller : BaseController, val method
33 33 return true
34 34 }
35 35
36   - public fun getParams(url : String, query : String?) : RouteParams {
37   -
  36 + public fun getParams(request : HttpServletRequest) : RouteParams {
  37 + val url = request.getRequestURI()!!
  38 + val query = request.getQueryString()
38 39 val params = RouteParams()
39 40
40 41 // parse the query string
@@ -58,11 +59,19 @@ class ActionInfo(val route : String, val controller : BaseController, val method
58 59 val routeComp = routeComps[i]
59 60 routeComp.getParam(params, comp)
60 61 }
  62 +
  63 + // parse the form parameters
  64 + for (name in request.getParameterNames()) {
  65 + val value = request.getParameter(name)!!
  66 + params[name] = value
  67 + }
  68 +
61 69 return params
62 70 }
63 71
  72 + /** Execute the action based on the given request and populate the response. */
64 73 public fun exec(val appConfig: AppConfig, request: HttpServletRequest, response : HttpServletResponse) {
65   - val params = getParams(request.getRequestURI()!!, request.getQueryString())
  74 + val params = getParams(request)
66 75 controller.beforeRequest(request, response, params)
67 76 val context = ActionContext(appConfig, request, response, params)
68 77
8 KaraLib/src/kara/controllers/Annotations.kt
@@ -4,16 +4,16 @@ import java.lang.annotation.*
4 4
5 5 /** Used to annotate actions that respond to GET requests.
6 6 */
7   -Retention(RetentionPolicy.RUNTIME) annotation class Get(val route : String = "[default]")
  7 +Retention(RetentionPolicy.RUNTIME) annotation class Get(val route : String = "")
8 8
9 9 /** Used to annotate actions that respond to POST requests.
10 10 */
11   -Retention(RetentionPolicy.RUNTIME) annotation class Post(val route : String = "[default]")
  11 +Retention(RetentionPolicy.RUNTIME) annotation class Post(val route : String = "")
12 12
13 13 /** Used to annotate actions that respond to PUT requests.
14 14 */
15   -Retention(RetentionPolicy.RUNTIME) annotation class Put(val route : String = "[default]")
  15 +Retention(RetentionPolicy.RUNTIME) annotation class Put(val route : String = "")
16 16
17 17 /** Used to annotate actions that respond to DELETE requests.
18 18 */
19   -Retention(RetentionPolicy.RUNTIME) annotation class Delete(val route : String = "[default]")
  19 +Retention(RetentionPolicy.RUNTIME) annotation class Delete(val route : String = "")
9 KaraLib/src/kara/controllers/Dispatcher.kt
@@ -82,13 +82,16 @@ class Dispatcher() {
82 82 fun parseAction(annString : String, controller : BaseController, method : Method) {
83 83 // get the route based on the annotation and the controller
84 84 var route = annString.substring(annString.indexOf('=')+1, annString.indexOf(')'))
85   - if (!annString.contains("=") || route == "[default]") {
86   - route = method.getName()?.toLowerCase() as String
87   - }
  85 +// if (!annString.contains("=") || route.length() == 0) {
  86 +// route = method.getName()?.toLowerCase() as String
  87 +// }
  88 + route = route.replace("#", method.getName()?.toLowerCase()!!)
88 89 val root = controller.root
89 90 if (!route.startsWith("/")) {
90 91 route = root + route
91 92 }
  93 + if (route.length() > 1 && route.endsWith("/"))
  94 + route = route.substring(0, route.length()-1)
92 95
93 96 val actionInfo = ActionInfo(route, controller, method)
94 97 logger.debug("adding action: " + actionInfo.toString());
15 KaraLib/src/kara/controllers/RouteParams.kt
@@ -40,6 +40,21 @@ class RouteParams() {
40 40 return _list.size()
41 41 }
42 42
  43 + /** Gets a hash with the nested values of the given name. */
  44 + fun getHash(name : String) : HashMap<String,String> {
  45 + val map = HashMap<String,String>()
  46 + val prefix = name + "["
  47 + for (key in _map.keySet()) {
  48 + if (key.startsWith(prefix)) {
  49 + var subkey = key.replace(prefix, "")
  50 + subkey = subkey.substring(0, subkey.length()-1)
  51 + val value = _map[key]!!
  52 + map[subkey] = value
  53 + }
  54 + }
  55 + return map
  56 + }
  57 +
43 58 public fun toString() : String {
44 59 val pairs = _map.iterator().map { it ->
45 60 "${it.getKey()}: ${it.getValue()}"
6 KaraTests/KaraTests.iml
@@ -10,6 +10,12 @@
10 10 <orderEntry type="module" module-name="KaraLib" />
11 11 <orderEntry type="library" name="KotlinRuntime" level="project" />
12 12 <orderEntry type="library" name="javax.servlet-3.0.0.v201112011016" level="project" />
  13 + <orderEntry type="library" name="slf4j-log4j12-1.6.6" level="project" />
  14 + <orderEntry type="library" name="log4j-1.2.17" level="project" />
  15 + <orderEntry type="library" name="guava-11.0.2" level="project" />
  16 + <orderEntry type="library" name="slf4j-api-1.6.6" level="project" />
  17 + <orderEntry type="library" name="reflections-0.9.8" level="project" />
  18 + <orderEntry type="library" name="javassist-3.12.1.GA" level="project" />
13 19 </component>
14 20 </module>
15 21
5 KaraTests/src/karatests/controllers/ActionTests.kt
@@ -9,7 +9,7 @@ import kara.config.AppConfig
9 9
10 10
11 11 /** Tests for executing actions */
12   -fun runActionTests(args : Array<String>) {
  12 +fun runActionTests() {
13 13
14 14 initMockDispatchWithReflection()
15 15
@@ -18,6 +18,9 @@ fun runActionTests(args : Array<String>) {
18 18 assertTrue(output?.contains("Default Layout") as Boolean, "Home view contains layout")
19 19 assertTrue(output?.contains("Welcome Home") as Boolean, "Home view contains view")
20 20
  21 + response = mockDispatch("GET", "/foo/blank")
  22 + assertEquals("blank", response.stringOutput())
  23 +
21 24 response = mockDispatch("GET", "/foo/bar")
22 25 assertEquals("bar", response.stringOutput())
23 26
33 KaraTests/src/karatests/controllers/DispatchTests.kt
@@ -3,9 +3,10 @@ package karatests.controllers
3 3 import kara.controllers.Dispatcher
4 4 import kotlin.test.*
5 5 import kara.config.AppConfig
  6 +import karatests.mock.mockRequest
6 7
7 8 /** Tests for dispatching routes to get action info. */
8   -fun runDispatchTests(args : Array<String>) {
  9 +fun runDispatchTests() {
9 10
10 11 val appConfig = AppConfig("", "development")
11 12 appConfig["kara.appPackage"] = "karatests.controllers"
@@ -27,33 +28,39 @@ fun runDispatchTests(args : Array<String>) {
27 28
28 29 dispatcher.match("GET", "/foo/foobar") // default action name
29 30
30   - actionInfo = dispatcher.match("GET", "/foo/bar/list")!! // unnamed param
31   - var params = actionInfo.getParams("/foo/bar/list", "")
  31 + var request = mockRequest("GET", "/foo/bar/list")
  32 + actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // unnamed param
  33 + var params = actionInfo.getParams(request)
32 34 assertEquals("bar", params[0])
33 35
34   - actionInfo = dispatcher.match("GET", "/foo/complex/bar/list/42")!! // named and unnamed params
35   - params = actionInfo.getParams("/foo/complex/bar/list/42", "")
  36 + request = mockRequest("GET", "/foo/complex/bar/list/42")
  37 + actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // named and unnamed params
  38 + params = actionInfo.getParams(request)
36 39 assertEquals("bar", params[0])
37 40 assertEquals("42", params["id"])
38 41 assertEquals(2, params.size())
39 42
40 43 // crud controller
41   - actionInfo = dispatcher.match("GET", "/crud?name=value")!! // empty route with parameters
  44 + request = mockRequest("GET", "/crud?name=value")
  45 + actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // empty route with parameters
42 46 assertEquals(CrudController().javaClass, actionInfo.controller.javaClass)
43   - params = actionInfo.getParams("/crud?name=value", "")
  47 + params = actionInfo.getParams(request)
44 48 assertEquals("value", params["name"])
45 49
46   - actionInfo = dispatcher.match("GET", "/crud/42")!! // named parameter
47   - params = actionInfo.getParams("/crud/42", "")
  50 + request = mockRequest("GET", "/crud/42")
  51 + actionInfo = dispatcher.match("GET", request.getRequestURI()!!)!! // named parameter
  52 + params = actionInfo.getParams(request)
48 53 assertEquals("42", params["id"])
49 54
50 55 dispatcher.match("POST", "/crud") // models
51 56
52   - actionInfo = dispatcher.match("PUT", "/crud/42")!! // put
53   - params = actionInfo.getParams("/crud/42", "")
  57 + request = mockRequest("PUT", "/crud/42")
  58 + actionInfo = dispatcher.match("PUT", request.getRequestURI()!!)!! // put
  59 + params = actionInfo.getParams(request)
54 60 assertEquals("42", params["id"])
55 61
56   - actionInfo = dispatcher.match("DELETE", "/crud/42")!! // delete
57   - params = actionInfo.getParams("/crud/42", "")
  62 + request = mockRequest("DELETE", "/crud/42")
  63 + actionInfo = dispatcher.match("DELETE", request.getRequestURI()!!)!! // delete
  64 + params = actionInfo.getParams(request)
58 65 assertEquals("42", params["id"])
59 66 }
6 KaraTests/src/karatests/controllers/FooController.kt
@@ -5,6 +5,10 @@ import kara.controllers.*
5 5
6 6 class FooController() : BaseController() {
7 7
  8 + Get("#") fun blank() : ActionResult {
  9 + return TextResult("blank")
  10 + }
  11 +
8 12 Get("bar") fun bar() : ActionResult {
9 13 return TextResult("bar")
10 14 }
@@ -13,7 +17,7 @@ class FooController() : BaseController() {
13 17 return TextResult("bar/baz")
14 18 }
15 19
16   - Get("[default]") fun foobar() : ActionResult {
  20 + Get("#") fun foobar() : ActionResult {
17 21 return TextResult("foobar")
18 22 }
19 23
7 KaraTests/src/karatests/controllers/Main.kt
... ... @@ -1,9 +1,12 @@
1 1 package karatests.controllers
2 2
  3 +import org.apache.log4j.BasicConfigurator
  4 +
3 5
4 6 /** Tests for dispatching routes to get action info. */
5 7 fun main(args : Array<String>) {
  8 + BasicConfigurator.configure()
6 9
7   - runDispatchTests(args)
8   - runActionTests(args)
  10 + runDispatchTests()
  11 + runActionTests()
9 12 }
8 KaraTests/src/karatests/mock/MockDispatch.kt
@@ -9,6 +9,7 @@ val _dispatcher = Dispatcher()
9 9 val _mockAppConfig = AppConfig("", "test")
10 10
11 11 public fun initMockDispatchWithReflection() {
  12 + _mockAppConfig["kara.appPackage"] = "karatests.controllers"
12 13 _dispatcher.initWithReflection(_mockAppConfig)
13 14 }
14 15
@@ -19,4 +20,11 @@ public fun mockDispatch(httpMethod : String, url : String) : MockHttpServletResp
19 20 val response = MockHttpServletResponse()
20 21 _dispatcher.dispatch(_mockAppConfig, request, response)
21 22 return response
  23 +}
  24 +
  25 +
  26 +/** Creates a HttpServletRequest with the given method and url*/
  27 +public fun mockRequest(httpMethod : String, url : String) : MockHttpServletRequest {
  28 + val request = MockHttpServletRequest(httpMethod, url)
  29 + return request
22 30 }
15 KaraTests/src/karatests/mock/MockHttpServletRequest.kt
@@ -9,6 +9,9 @@ import javax.servlet.ServletInputStream
9 9 import java.util.Locale
10 10 import java.io.BufferedReader
11 11 import javax.servlet.http.Cookie
  12 +import java.util.ArrayList
  13 +import java.util.HashMap
  14 +import java.util.Hashtable
12 15
13 16
14 17 class MockHttpServletRequest(method : String, url : String) : HttpServletRequest {
@@ -60,8 +63,11 @@ class MockHttpServletRequest(method : String, url : String) : HttpServletRequest
60 63 public override fun getSession() : HttpSession? {
61 64 throw UnsupportedOperationException()
62 65 }
  66 +
  67 + val session = MockHttpSession()
  68 +
63 69 public override fun getSession(p0 : Boolean) : HttpSession? {
64   - throw UnsupportedOperationException()
  70 + return session
65 71 }
66 72 public override fun getHeaders(p0 : String?) : Enumeration<String>? {
67 73 throw UnsupportedOperationException()
@@ -139,7 +145,7 @@ class MockHttpServletRequest(method : String, url : String) : HttpServletRequest
139 145 throw UnsupportedOperationException()
140 146 }
141 147 public override fun getParameter(p0 : String?) : String? {
142   - throw UnsupportedOperationException()
  148 + return params[p0]
143 149 }
144 150 public override fun getRemoteHost() : String? {
145 151 throw UnsupportedOperationException()
@@ -147,8 +153,11 @@ class MockHttpServletRequest(method : String, url : String) : HttpServletRequest
147 153 public override fun getAttributeNames() : Enumeration<String>? {
148 154 throw UnsupportedOperationException()
149 155 }
  156 +
  157 + val params = Hashtable<String,String>()
  158 +
150 159 public override fun getParameterNames() : Enumeration<String>? {
151   - throw UnsupportedOperationException()
  160 + return params.keys()
152 161 }
153 162 public override fun setAttribute(p0 : String?, p1 : Any?) {
154 163 throw UnsupportedOperationException()
65 KaraTests/src/karatests/mock/MockHttpSession.kt
... ... @@ -0,0 +1,65 @@
  1 +package karatests.mock
  2 +
  3 +import javax.servlet.http.HttpSession
  4 +import javax.servlet.ServletContext
  5 +import javax.servlet.http.HttpSessionContext
  6 +import java.util.Enumeration
  7 +import java.sql.Date
  8 +import java.util.Hashtable
  9 +
  10 +/**
  11 + * Stub out the HttpSession interface for testing.
  12 + */
  13 +class MockHttpSession : HttpSession {
  14 +
  15 + val attributes = Hashtable<String,Any>()
  16 +
  17 + public override fun getCreationTime(): Long {
  18 + return java.util.Date().getTime()
  19 + }
  20 + public override fun getId(): String? {
  21 + return "mock"
  22 + }
  23 + public override fun getLastAccessedTime(): Long {
  24 + return java.util.Date().getTime()
  25 + }
  26 + public override fun getServletContext(): ServletContext? {
  27 + throw UnsupportedOperationException()
  28 + }
  29 + public override fun setMaxInactiveInterval(p0: Int) {
  30 + throw UnsupportedOperationException()
  31 + }
  32 + public override fun getMaxInactiveInterval(): Int {
  33 + throw UnsupportedOperationException()
  34 + }
  35 + public override fun getSessionContext(): HttpSessionContext? {
  36 + throw UnsupportedOperationException()
  37 + }
  38 + public override fun getAttribute(p0: String?): Any? {
  39 + return attributes[p0]
  40 + }
  41 + public override fun getValue(p0: String?): Any? {
  42 + throw UnsupportedOperationException()
  43 + }
  44 + public override fun getAttributeNames(): Enumeration<String>? {
  45 + throw UnsupportedOperationException()
  46 + }
  47 + public override fun getValueNames(): Array<String>? {
  48 + return attributes.keySet().toArray<String>()
  49 + }
  50 + public override fun setAttribute(p0: String?, p1: Any?) {
  51 + attributes[p0!!] = p1!!
  52 + }
  53 + public override fun putValue(p0: String?, p1: Any?) {
  54 + }
  55 + public override fun removeAttribute(p0: String?) {
  56 + }
  57 + public override fun removeValue(p0: String?) {
  58 + }
  59 + public override fun invalidate() {
  60 + }
  61 + public override fun isNew(): Boolean {
  62 + return true
  63 + }
  64 +
  65 +}
70 README.md
Source Rendered
@@ -75,6 +75,7 @@ Here's an overview of the Kara command line usage:
75 75 project <name> Generates a new Kara project with the given name.
76 76 Use the --package=<package> option to specify a package
77 77 that's different than the project name.
  78 + update Updates the application's Kara dependency to the latest version
78 79 controller <name> Generates a new controller with the given name.
79 80 "Controller" will be automatically appended to the name)
80 81 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:
126 127
127 128 which will generate a view called List that belongs to the BlogController.
128 129
  130 +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.
  131 +Running the *update* generator will do just that:
  132 +
  133 + kara generate update
  134 +
129 135
130 136 ## Project Structure
131 137
@@ -157,7 +163,9 @@ HTML views in Kara are created using a custom Kotlin DSL. Each view inherits fro
157 163 }
158 164 }
159 165
160   -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.
  166 +As you can see, the actual view markup is placed in the overriden render() method.
  167 +The render() method accepts one argument, the action context.
  168 +This context hold references to the action's request, response, session, and parameters.
161 169
162 170 Some more complex view markup might look like this:
163 171
@@ -174,10 +182,41 @@ Some more complex view markup might look like this:
174 182 + "Some more text"
175 183 }
176 184
177   -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.
  185 +Each function represents a single HTML tag, and accepts arguments for the tag's attributes.
  186 +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).
  187 +Text content can either be passed directly to the tag function, or added inside its body with the + operator.
178 188
179 189 This flexible markup mechanism highlights the power of the Kotlin syntax, and can't be acheived in languages like Java or even Scala.
180 190
  191 +### Layouts
  192 +
  193 +Applications generally contain HTML markup that's shared between views.
  194 +In Kara (as well as many other web frameworks) these are called layouts.
  195 +By convention, layout files are placed in the root of the app's views directory.
  196 +Each layout inherits from the *HtmlLayout* class. Consider the following example:
  197 +
  198 + class DefaultLayout() : HtmlLayout() {
  199 + override fun render(context: ActionContext, mainView: HtmlView) {
  200 + head {
  201 + title("Kara Demo Title")
  202 + stylesheet(DefaultStyles())
  203 + }
  204 + body {
  205 + h1("Kara Demo Site")
  206 + div(id="main") {
  207 + renderView(context, mainView)
  208 + }
  209 + a(text="Kara is developed by Tiny Mission", href="http://tinymission.com")
  210 + }
  211 + }
  212 + }
  213 +
  214 +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.
  215 +The mainView is rendered with the renderView() function.
  216 +
  217 +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).
  218 +
  219 +
181 220 ### Forms
182 221
183 222 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
281 320 The controller above has three actions (index, test, and update). The first two respond to GET requests at / and /test, respectively.
282 321 The update action responds to POST requests at /updatebook.
283 322
  323 +If the route doesn't start with /, it's relative to the current controller.
  324 +The lowercase name of the controller, minus *controller*, is used as the first component of the route.
  325 +Any pound signs are replaced with the name of the action method.
  326 +
  327 + class FooController() : BaseController(DefaultLayout()) {
  328 + Get("") fun index() : ActionResult {
  329 + // maps to /foo
  330 + }
  331 +
  332 + Get("bar") fun bar() : ActionResult {
  333 + // maps to /foo/bar
  334 + }
  335 +
  336 + Get("#") fun blank() : ActionResult {
  337 + // maps to /foo/blank
  338 + }
  339 +
  340 + Get(":id/#") fun edit(id : Int) : ActionResult {
  341 + // maps to /foo/3/edit
  342 + }
  343 + }
  344 +
284 345 The routing mechanism allows for more complex routes, like:
285 346
286 347 Get("complex/*/list/:id") fun complex() : ActionResult {
@@ -293,6 +354,11 @@ The parameter values are available inside the request through the controllers Ro
293 354 this.params[0] // wildcard param
294 355 this.params["id"] // named :id param
295 356
  357 +When compound objects are passed as form parameters, they can be retrieved as a hash:
  358 +
  359 + // if form contains: book[title]=Foundation&book[author]=Isaac%20Asimov
  360 + this.params.getHash("book") // will return a has with {title="Foundation", author="Isaac Asimov"}
  361 +
296 362 The most common ActionResult is an HtmlView, but you can also return raw text with TextResult(), JSON objects with JsonResult(), and redirects with RedirectRestul().
297 363
298 364
BIN  out/jars/KaraExec.jar
Binary file not shown
BIN  out/jars/KaraLib.jar
Binary file not shown

0 comments on commit c61345f

Please sign in to comment.
Something went wrong with that request. Please try again.