Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed #1385

Thanks to Thomas Rotter -> new argument for renderView(),renderExternalView(), event.setView() -> cacheProvider so you can override the default 'template' cache provider and choose your own.
  • Loading branch information...
commit 054d416950ca578d56973ecd6de4b823179ea2eb 1 parent 84ba479
Luis Majano authored
57  system/plugins/Renderer.cfc
@@ -73,26 +73,28 @@ Description :
73 73
 	<cffunction name="renderView"	access="Public" hint="Renders the current view." output="false" returntype="Any">
74 74
 		<!--- ************************************************************* --->
75 75
 		<cfargument name="view" 					required="false" type="any"  default=""			hint="If not passed in, the value in the currentView in the current RequestContext will be used">
76  
-		<cfargument name="cache" 					required="false" type="any"  default="false" 	hint="True if you want to cache the view">
77  
-		<cfargument name="cacheTimeout" 			required="false" type="any"  default=""			hint="The cache timeout for the view contents">
78  
-		<cfargument name="cacheLastAccessTimeout" 	required="false" type="any"  default="" 		hint="The last access timeout for the view contents">
  76
+		<cfargument name="cache" 					required="false" type="any"  default="false" 	hint="Cache the rendered view or not">
  77
+		<cfargument name="cacheTimeout" 			required="false" type="any"  default=""			hint="The cache timeout for the rendered view">
  78
+		<cfargument name="cacheLastAccessTimeout" 	required="false" type="any"  default="" 		hint="The last access timeout for the rendered view">
79 79
 		<cfargument name="cacheSuffix" 				required="false" type="any"  default=""     	hint="Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching."/>
  80
+		<cfargument name="cacheProvider" 			required="false" type="any"  default="template" hint="The cache provider you want to use for storing the rendered view. By default we use the 'template' cache provider">
80 81
 		<cfargument name="module" 					required="false" type="any"  default=""      	hint="Explicitly render a view from this module by passing the module name"/>
81 82
 		<cfargument name="args"   					required="false" type="any"  default="#event.getCurrentViewArgs()#" hint="An optional set of arguments that will be available to this layouts/view rendering ONLY"/>
82 83
 		<cfargument name="collection" 				required="false" type="any"  hint="A collection to use by this Renderer to render the view as many times as the items in the collection (Array or Query)" colddoc:generic="collection"/>
83 84
 		<cfargument name="collectionAs" 			required="false" type="any"	 default=""  	    hint="The name of the collection variable in the partial rendering.  If not passed, we will use the name of the view by convention"/>
84 85
 		<cfargument name="collectionStartRow" 		required="false" type="any"	 default="1"  	    hint="The start row to limit the collection rendering with" colddoc:generic="numeric"/>
85 86
 		<cfargument name="collectionMaxRows" 		required="false" type="any"	 default="0"  	    hint="The max rows to iterate over the collection rendering with" colddoc:generic="numeric"/>
86  
-		<cfargument name="collectionDelim" 		required="false" type="any"	 default=""  	    hint="A string to delimit the collection renderings by"/>
  87
+		<cfargument name="collectionDelim" 			required="false" type="any"	 default=""  	    hint="A string to delimit the collection renderings by"/>
87 88
 		<cfargument name="prepostExempt" 			required="false" type="any"	 default="false" 	hint="If true, pre/post view interceptors will not be fired. By default they do fire" colddoc:generic="boolean">
88 89
 		<!--- ************************************************************* --->
89 90
 		<cfscript>
90  
-			var viewCacheKey 	= "";
91  
-			var viewCacheEntry 	= "";
92  
-			var timerHash 		= 0;
93  
-			var iData 			= arguments;
94  
-			var explicitModule 	= false;
95  
-			var viewLocations	= "";
  91
+			var viewCacheKey 		= "";
  92
+			var viewCacheEntry 		= "";
  93
+			var viewCacheProvider 	= instance.templateCache;
  94
+			var timerHash 			= 0;
  95
+			var iData 				= arguments;
  96
+			var explicitModule 		= false;
  97
+			var viewLocations		= "";
96 98
 
97 99
 			// If no incoming explicit module call, default the value to the one in the request context for convenience
98 100
 			if( NOT len(arguments.module) ){
@@ -140,14 +142,19 @@ Description :
140 142
 				arguments.cacheTimeout				= viewCacheEntry.timeout;
141 143
 				arguments.cacheLastAccessTimeout	= viewCacheEntry.lastAccessTimeout;
142 144
 				arguments.cacheSuffix 				= viewCacheEntry.cacheSuffix;
  145
+				arguments.cacheProvider				= viewCacheEntry.cacheProvider;
143 146
 			}
144 147
 			// Prepare caching key
145 148
 			viewCacheKey = instance.templateCache.VIEW_CACHEKEY_PREFIX & arguments.module & ":" & arguments.view & arguments.cacheSuffix;
146 149
 			// Are we caching?
147 150
 			if (arguments.cache){
  151
+				// Which provider you want to use?
  152
+				if( arguments.cacheProvider neq "template" ){
  153
+					viewCacheProvider = cacheBox.getCache( arguments.cacheProvider );
  154
+				}
148 155
 				// Try to get from cache
149  
-				timerHash = instance.debuggerService.timerStart("rendering Cached View [#arguments.view#.cfm]");
150  
-				iData.renderedView = instance.templateCache.get( viewCacheKey );
  156
+				timerHash = instance.debuggerService.timerStart("rendering Cached View [#arguments.view#.cfm] from '#arguments.cacheProvider# provider'");
  157
+				iData.renderedView = viewCacheProvider.get( viewCacheKey );
151 158
 				// Verify it existed
152 159
 				if( structKeyExists(iData, "renderedView") ){
153 160
 					instance.debuggerService.timerEnd( timerHash );
@@ -179,7 +186,7 @@ Description :
179 186
 
180 187
 			// Are we caching view
181 188
 			if ( arguments.cache ){
182  
-				instance.templateCache.set(viewCacheKey,iData.renderedView,arguments.cacheTimeout,arguments.cacheLastAccessTimeout);
  189
+				viewCacheProvider.set(viewCacheKey, iData.renderedView, arguments.cacheTimeout, arguments.cacheLastAccessTimeout);
183 190
 			}
184 191
 
185 192
 			// Return view content
@@ -333,25 +340,29 @@ Description :
333 340
 	<!--- Render an external View --->
334 341
 	<cffunction name="renderExternalView"	access="Public" hint="Renders an external view." output="false" returntype="Any">
335 342
 		<!--- ************************************************************* --->
336  
-		<cfargument name="view" 					required="true"  type="string" hint="The full path to the view. This can be an expanded path or relative. Include extension.">
  343
+		<cfargument name="view" 					required="true"  type="any" 	hint="The full path to the view. This can be an expanded path or relative. Include extension.">
337 344
 		<cfargument name="cache" 					required="false" type="boolean" default="false" hint="True if you want to cache the view.">
338  
-		<cfargument name="cacheTimeout" 			required="false" type="string"  default=""		hint="The cache timeout">
339  
-		<cfargument name="cacheLastAccessTimeout" 	required="false" type="string"  default="" 		hint="The last access timeout">
340  
-		<cfargument name="cacheSuffix" 				required="false" type="string"  default=""      hint="Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching."/>
  345
+		<cfargument name="cacheTimeout" 			required="false" type="any"  	default=""		hint="The cache timeout">
  346
+		<cfargument name="cacheLastAccessTimeout" 	required="false" type="any"  	default="" 		hint="The last access timeout">
  347
+		<cfargument name="cacheSuffix" 				required="false" type="any"  	default=""      hint="Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching."/>
  348
+		<cfargument name="cacheProvider" 			required="false" type="any"  	default="template" hint="The cache provider you want to use for storing the rendered view. By default we use the 'template' cache provider">
341 349
 		<cfargument name="args"   					required="false" type="any"  	default="#event.getCurrentViewArgs()#" hint="An optional set of arguments that will be available to this layouts/view rendering ONLY"/>
342 350
 		<!--- ************************************************************* --->
343 351
 		<cfscript>
344 352
 			var cbox_renderedView = "";
345 353
 			// Cache Entries
346  
-			var cbox_cacheKey 	= "";
347  
-			var cbox_cacheEntry = "";
348  
-			var viewLocations 	= "";
  354
+			var cbox_cacheKey 		= "";
  355
+			var cbox_cacheEntry 	= "";
  356
+			var cbox_cacheProvider 	= instance.templateCache;
  357
+			var viewLocations 		= "";
349 358
 
350 359
 			// Setup the cache key
351 360
 			cbox_cacheKey = instance.templateCache.VIEW_CACHEKEY_PREFIX & "external-" & arguments.view & arguments.cacheSuffix;
  361
+			// Setup the cache provider
  362
+			if( arguments.cacheProvider neq "template" ){ cbox_cacheProvider = cacheBox.getCache( arguments.cacheProvider ); }
352 363
 			// Try to get from cache
353  
-			cbox_timerHash 		= instance.debuggerService.timerStart("rendering Cached External View [#arguments.view#.cfm]");
354  
-			cbox_renderedView 	= instance.templateCache.get(cbox_cacheKey);
  364
+			cbox_timerHash 		= instance.debuggerService.timerStart("rendering Cached External View [#arguments.view#.cfm] from '#arguments.cacheProvider#' provider");
  365
+			cbox_renderedView 	= cbox_cacheProvider.get(cbox_cacheKey);
355 366
 			if( isDefined("cbox_renderedView") ){
356 367
 				instance.debuggerService.timerEnd( cbox_timerHash );
357 368
 				return cbox_renderedView;
@@ -365,7 +376,7 @@ Description :
365 376
  			instance.debuggerService.timerEnd(cbox_timerHash);
366 377
  			// Are we caching it
367 378
  			if( arguments.cache ){
368  
- 				instance.templateCache.set(cbox_cacheKey,cbox_renderedView,arguments.cacheTimeout,arguments.cacheLastAccessTimeout);
  379
+ 				cbox_cacheProvider.set(cbox_cacheKey, cbox_renderedView, arguments.cacheTimeout, arguments.cacheLastAccessTimeout);
369 380
  			}
370 381
  			return cbox_renderedView;
371 382
 		</cfscript>
28  system/web/context/RequestContext.cfc
@@ -214,14 +214,15 @@ Description :
214 214
 
215 215
 	<cffunction name="setView" access="public" returntype="any" hint="I Set the view to render in this request. Private Request Collection Name: currentView, currentLayout"  output="false">
216 216
 		<!--- ************************************************************* --->
217  
-	    <cfargument name="view"     				required="false" type="string"  hint="The name of the view to set. If a layout has been defined it will assign it, else if will assign the default layout. No extension please">
  217
+	    <cfargument name="view"     				required="false" type="any"  	hint="The name of the view to set. If a layout has been defined it will assign it, else if will assign the default layout. No extension please">
218 218
 		<cfargument name="nolayout" 				required="false" type="boolean" default="false" hint="Boolean flag, wether the view sent in will be using a layout or not. Default is false. Uses a pre set layout or the default layout.">
219  
-		<cfargument name="cache" 					required="false" type="boolean" default="false" hint="True if you want to cache the view.">
220  
-		<cfargument name="cacheTimeout" 			required="false" type="string"  default=""	hint="The cache timeout">
221  
-		<cfargument name="cacheLastAccessTimeout" 	required="false" type="string"  default="" hint="The last access timeout">
222  
-		<cfargument name="cacheSuffix" 				required="false" type="string"  default="" hint="Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching."/>
223  
-		<cfargument name="layout" 					required="false" type="string"  hint="You can override the rendering layout of this setView() call if you want to. Else it defaults to implicit resolution or another override.">
224  
-		<cfargument name="module" 					required="false" type="string"  default="" hint="Is the view from a module or not"/>
  219
+		<cfargument name="cache" 					required="false" type="boolean" default="false" hint="True if you want to cache the rendered view.">
  220
+		<cfargument name="cacheTimeout" 			required="false" type="any"  	default=""	hint="The cache timeout">
  221
+		<cfargument name="cacheLastAccessTimeout" 	required="false" type="any"  	default="" hint="The last access timeout">
  222
+		<cfargument name="cacheSuffix" 				required="false" type="any"  	default="" hint="Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching."/>
  223
+		<cfargument name="cacheProvider" 			required="false" type="any"  	default="template" hint="The cache provider you want to use for storing the rendered view. By default we use the 'template' cache provider">
  224
+		<cfargument name="layout" 					required="false" type="any"  	hint="You can override the rendering layout of this setView() call if you want to. Else it defaults to implicit resolution or another override.">
  225
+		<cfargument name="module" 					required="false" type="any"  	default="" hint="Is the view from a module or not"/>
225 226
 		<cfargument name="args" 					required="false" type="struct"  default="#structNew()#" hint="An optional set of arguments that will be available when the view is rendered"/>
226 227
 		<!--- ************************************************************* --->
227 228
 	    <cfscript>
@@ -276,12 +277,11 @@ Description :
276 277
 				removeValue('currentLayout',true);
277 278
 			}
278 279
 
279  
-			//Do we need to cache the view
  280
+			// Do we need to cache the view
280 281
 			if( arguments.cache ){
281  
-				//prepare the cache keys
  282
+				// prepare the cache keys
282 283
 				cacheEntry.view = arguments.view;
283  
-
284  
-				//arg cleanup
  284
+				// Argument cleanup
285 285
 				if ( not isNumeric(arguments.cacheTimeout) )
286 286
 					cacheEntry.Timeout = "";
287 287
 				else
@@ -290,8 +290,10 @@ Description :
290 290
 					cacheEntry.LastAccessTimeout = "";
291 291
 				else
292 292
 					cacheEntry.LastAccessTimeout = arguments.cacheLastAccessTimeout;
293  
-				//cache suffix
294  
-				cacheEntry.cacheSuffix = arguments.cacheSuffix;
  293
+				// Cache Suffix
  294
+				cacheEntry.cacheSuffix 		= arguments.cacheSuffix;
  295
+				// Cache Provider
  296
+				cacheEntry.cacheProvider 	= arguments.cacheProvider;
295 297
 
296 298
 				//Save the view cache entry
297 299
 				setViewCacheableEntry(cacheEntry);
18  testing/cases/plugins/RendererTest.cfc
@@ -24,6 +24,15 @@ Description :
24 24
 			assertEquals( results, results2 );
25 25
 		}
26 26
 
  27
+		function testRenderViewWithCacheProviders(){
  28
+			var r = getController().getPlugin("Renderer");
  29
+			results = r.renderView(view="navigation",cache=true,cacheTimeout="5", cacheProvider="default");
  30
+			debug( results );
  31
+			results2 = r.renderView(view="navigation",cache=true,cacheTimeout="5", cacheProvider="default");
  32
+			assertEquals( results, results2 );
  33
+			assertTrue( getCacheBox().getCache("default").lookup("cbox_view-:navigation") );
  34
+		}
  35
+
27 36
 		function testRenderExternalView(){
28 37
 			var r = getController().getPlugin("Renderer");
29 38
 			results = r.renderExternalView("/coldbox/testing/testviews/externalview");
@@ -37,6 +46,15 @@ Description :
37 46
 			assertEquals( results, results2 );
38 47
 		}
39 48
 
  49
+		function testRenderExternalViewWithCachingProviders(){
  50
+			var r = getController().getPlugin("Renderer");
  51
+			results = r.renderExternalView(view="/coldbox/testing/testviews/externalview", cache="true", cacheTimeout="5", cacheProvider="default");
  52
+			results2 = r.renderExternalView(view="/coldbox/testing/testviews/externalview", cache="true", cacheTimeout="5", cacheProvider="default");
  53
+			assertEquals( results, results2 );
  54
+			debug( getCacheBox().getCache("default").getKeys() );
  55
+			assertTrue( getCacheBox().getCache("default").lookup("cbox_view-external-/coldbox/testing/testviews/externalView") );
  56
+		}
  57
+
40 58
 	</cfscript>
41 59
 
42 60
 </cfcomponent>
310  testing/cases/web/context/requestcontextTest.cfc
@@ -3,7 +3,7 @@
3 3
 	<cffunction name="setUp" returntype="void" access="public" output="false">
4 4
 		<cfscript>
5 5
 			oRC = createObject("component","coldbox.system.web.context.RequestContext");
6  
-			
  6
+
7 7
 			/* Properties */
8 8
 			props.DefaultLayout = "Main.cfm";
9 9
 			props.DefaultView = "";
@@ -18,20 +18,20 @@
18 18
 					mapping = "/coldbox/testharness"
19 19
 				}
20 20
 			};
21  
-			
  21
+
22 22
 			/* Init it */
23 23
 			oRC.init(props);
24 24
 		</cfscript>
25 25
 	</cffunction>
26  
-	
  26
+
27 27
 	<cffunction name="getRequestContext" access="private" returntype="any" hint="" output="false" >
28 28
 		<cfreturn oRC>
29 29
 	</cffunction>
30  
-	
  30
+
31 31
 	<cffunction name="testgetCollection" returntype="void" access="Public" output="false">
32 32
 		<cfscript>
33 33
 			var event = getRequestContext();
34  
-			
  34
+
35 35
 			assertTrue( isStruct(event.getCollection()) );
36 36
 		</cfscript>
37 37
 	</cffunction>
@@ -40,10 +40,10 @@
40 40
 		<cfscript>
41 41
 			var event = getRequestContext();
42 42
 			var test = {today=now()};
43  
-			
  43
+
44 44
 			event.collectionAppend(test);
45 45
 			event.clearCollection();
46  
-			
  46
+
47 47
 			AssertEquals( structnew(), event.getCollection() );
48 48
 		</cfscript>
49 49
 	</cffunction>
@@ -55,10 +55,10 @@
55 55
 			var event = getRequestContext();
56 56
 			var test = structnew();
57 57
 			test.today = now();
58  
-			
  58
+
59 59
 			event.clearCollection();
60 60
 			event.collectionAppend(test);
61  
-			
  61
+
62 62
 			AssertEquals( test, event.getCollection() );
63 63
 		</cfscript>
64 64
 	</cffunction>
@@ -70,10 +70,10 @@
70 70
 			var event = getRequestContext();
71 71
 			var test = structnew();
72 72
 			test.today = now();
73  
-			
  73
+
74 74
 			event.clearCollection();
75 75
 			event.collectionAppend(test);
76  
-			
  76
+
77 77
 			AssertEquals( 1, event.getSize() );
78 78
 		</cfscript>
79 79
 	</cffunction>
@@ -85,14 +85,14 @@
85 85
 			var event = getRequestContext();
86 86
 			var test = structnew();
87 87
 			test.today = now();
88  
-			
  88
+
89 89
 			event.clearCollection();
90 90
 			event.collectionAppend(test);
91  
-			
  91
+
92 92
 			assertEquals( test.today , event.getValue("today") );
93  
-			
  93
+
94 94
 			assertEquals( "null", event.getValue("invalidVar", "null") );
95  
-			
  95
+
96 96
 		</cfscript>
97 97
 	</cffunction>
98 98
 
@@ -103,13 +103,13 @@
103 103
 			var event = getRequestContext();
104 104
 			var test = structnew();
105 105
 			test.today = now();
106  
-			
  106
+
107 107
 			event.clearCollection();
108  
-			
  108
+
109 109
 			event.setValue("test", test.today);
110  
-			
  110
+
111 111
 			assertEquals(test.today, event.getValue("test") );
112  
-			
  112
+
113 113
 		</cfscript>
114 114
 	</cffunction>
115 115
 
@@ -120,15 +120,15 @@
120 120
 			var event = getRequestContext();
121 121
 			var test = structnew();
122 122
 			test.today = now();
123  
-			
  123
+
124 124
 			event.clearCollection();
125  
-			
  125
+
126 126
 			event.setValue("test", test.today);
127 127
 			assertEquals(test.today, event.getValue("test") );
128  
-			
  128
+
129 129
 			event.removeValue("test");
130 130
 			assertEquals( false, event.getValue("test", false) );
131  
-			
  131
+
132 132
 		</cfscript>
133 133
 	</cffunction>
134 134
 
@@ -139,15 +139,15 @@
139 139
 			var event = getRequestContext();
140 140
 			var test = structnew();
141 141
 			test.today = now();
142  
-			
  142
+
143 143
 			event.clearCollection();
144  
-			
  144
+
145 145
 			event.setValue("test", test.today);
146 146
 			assertTrue( event.valueExists("test") );
147  
-			
  147
+
148 148
 			event.removeValue("test");
149 149
 			assertFalse( event.valueExists("test") );
150  
-			
  150
+
151 151
 		</cfscript>
152 152
 	</cffunction>
153 153
 
@@ -158,15 +158,15 @@
158 158
 			var event = getRequestContext();
159 159
 			var test = structnew();
160 160
 			test.today = now();
161  
-			
  161
+
162 162
 			event.clearCollection();
163  
-			
  163
+
164 164
 			AssertFalse( event.valueExists("test") );
165  
-			
  165
+
166 166
 			event.paramValue("test", test.today);
167  
-			
  167
+
168 168
 			assertTrue( event.valueExists("test") );
169  
-			
  169
+
170 170
 		</cfscript>
171 171
 	</cffunction>
172 172
 
@@ -176,30 +176,40 @@
176 176
 		<cfscript>
177 177
 			var event = getRequestContext();
178 178
 			var view = "vwHome";
179  
-			
  179
+
180 180
 			event.clearCollection();
181  
-			
  181
+
182 182
 			event.setView(view);
183 183
 			assertEquals( view, event.getCurrentView() );
184  
-			
  184
+
185 185
 			event.clearCollection();
186  
-			
  186
+
187 187
 			event.setView(view, true);
188 188
 			assertEquals(view, event.getCurrentView() );
189 189
 			assertEquals('', event.getCurrentLayout() );
190  
-			
  190
+
  191
+			// set view with caching
  192
+			event.setView(view="home", cache="True", cacheProvider="luis", cacheTimeout="20", cacheLastAccessTimeout="1", cacheSuffix="test");
  193
+			r = event.getViewCacheableEntry();
  194
+			//debug( r );
  195
+
  196
+			assertEquals( "home", r.view );
  197
+			assertEquals( "20", r.timeout );
  198
+			assertEquals( "1", r.lastAccessTimeout );
  199
+			assertEquals( "test", r.cacheSuffix );
  200
+			assertEquals( "luis", r.cacheProvider );
191 201
 		</cfscript>
192 202
 	</cffunction>
193  
-	
  203
+
194 204
 	<!--- ************************************************************* --->
195  
-	
  205
+
196 206
 	<cffunction name="testCurrentLayout" access="public" returntype="void" output="false">
197 207
 		<cfscript>
198 208
 			var event = getRequestContext();
199 209
 			var layout = "layout.pdf";
200  
-			
  210
+
201 211
 			event.clearCollection();
202  
-			
  212
+
203 213
 			event.setLayout(layout);
204 214
 			assertEquals( layout & ".cfm", event.getCurrentLayout() );
205 215
 		</cfscript>
@@ -211,270 +221,270 @@
211 221
 		<cfscript>
212 222
 			var event = getRequestContext();
213 223
 			var defaultEvent = "ehTest.doSomething";
214  
-			
  224
+
215 225
 			event.setValue("event", defaultEvent);
216  
-			
  226
+
217 227
 			assertEquals( defaultEvent, event.getCurrentEvent() );
218 228
 			assertEquals( "ehTest", event.getCurrentHandler() );
219 229
 			assertEquals( "doSomething", event.getCurrentAction() );
220  
-			
  230
+
221 231
 			defaultEvent = "blog.content.doSomething";
222  
-			
  232
+
223 233
 			event.setValue("event", defaultEvent);
224  
-			
  234
+
225 235
 			assertEquals( defaultEvent, event.getCurrentEvent() );
226 236
 			assertEquals( "content", event.getCurrentHandler() );
227 237
 			assertEquals( "doSomething", event.getCurrentAction() );
228  
-			
  238
+
229 239
 			defaultEvent = "blog.content.security.doSomething";
230  
-			
  240
+
231 241
 			event.setValue("event", defaultEvent);
232  
-			
  242
+
233 243
 			assertEquals( defaultEvent, event.getCurrentEvent() );
234 244
 			assertEquals( "security", event.getCurrentHandler() );
235 245
 			assertEquals( "doSomething", event.getCurrentAction() );
236  
-			
  246
+
237 247
 		</cfscript>
238 248
 	</cffunction>
239  
-	
  249
+
240 250
 	<!--- ************************************************************* --->
241  
-	
  251
+
242 252
 	<cffunction name="testoverrideEvent" access="Public"  output="false" returntype="void">
243 253
 		<cfscript>
244 254
 			var event = getRequestContext();
245 255
 			var newEvent = "pio.yea";
246  
-			
  256
+
247 257
 			event.clearCollection();
248 258
 			event.setValue("event","blog.dspEntries");
249 259
 			event.overrideEvent(newEvent);
250  
-			
  260
+
251 261
 			assertEquals( newEvent , event.getCurrentEvent() );
252 262
 		</cfscript>
253 263
 	</cffunction>
254 264
 
255 265
 	<!--- ************************************************************* --->
256  
-	
  266
+
257 267
 	<cffunction name="testshowdebugpanel" access="public" returntype="void">
258 268
 		<cfscript>
259 269
 			var event = getRequestContext();
260  
-			
  270
+
261 271
 			event.showDebugPanel(true);
262 272
 			AssertTrue( event.getDebugPanelFlag() );
263  
-			
  273
+
264 274
 			event.showDebugPanel(false);
265 275
 			AssertFalse( event.getDebugPanelFlag() );
266  
-			
  276
+
267 277
 		</cfscript>
268 278
 	</cffunction>
269  
-	
  279
+
270 280
 	<!--- ************************************************************* --->
271  
-	
  281
+
272 282
 	<cffunction name="testProxyRequest" access="public" returntype="void" >
273 283
 		<cfscript>
274 284
 			var event = getRequestContext();
275  
-			
  285
+
276 286
 			AssertFalse( event.isProxyRequest() );
277  
-			
  287
+
278 288
 			event.setProxyRequest();
279 289
 			AssertTrue( event.isProxyRequest() );
280 290
 		</cfscript>
281 291
 	</cffunction>
282  
-	
  292
+
283 293
 	<!--- ************************************************************* --->
284  
-	
  294
+
285 295
 	<cffunction name="testNoRender" access="public" returntype="void">
286 296
 		<cfscript>
287 297
 			var event = getRequestContext();
288  
-			
  298
+
289 299
 			event.NoRender(remove=true);
290 300
 			AssertFalse( event.isNoRender() );
291  
-			
  301
+
292 302
 			event.NoRender(remove=false);
293 303
 			AssertTrue( event.isNoRender() );
294  
-			
  304
+
295 305
 		</cfscript>
296 306
 	</cffunction>
297  
-	
  307
+
298 308
 	<!--- ************************************************************* --->
299  
-	
  309
+
300 310
 	<cffunction name="testgetEventName" access="public" returntype="void" output="false">
301 311
 		<cfscript>
302 312
 			var event = getRequestContext();
303 313
 			var test = props.eventName;
304 314
 
305 315
 			assertEquals( test, event.getEventName() );
306  
-			
  316
+
307 317
 		</cfscript>
308 318
 	</cffunction>
309  
-	
  319
+
310 320
 	<!--- ************************************************************* --->
311  
-	
  321
+
312 322
 	<cffunction name="testgetSelf" access="public" output="false" returntype="void">
313 323
 		<cfscript>
314 324
 			var event = getRequestContext();
315 325
 			var test = props.eventname;
316 326
 
317 327
 			assertEquals( "index.cfm?#test#=", event.getSelf() );
318  
-			
  328
+
319 329
 		</cfscript>
320 330
 	</cffunction>
321  
-	
  331
+
322 332
 	<!--- ************************************************************* --->
323  
-	
  333
+
324 334
 	<cffunction name="testEventCacheableEntry" access="public" output="false" returntype="void">
325 335
 		<cfscript>
326 336
 			var event = getRequestContext();
327 337
 			var centry = structnew();
328  
-			
  338
+
329 339
 			AssertFalse( event.isEventCacheable(), "event cacheable");
330  
-			
  340
+
331 341
 			centry.cacheable = true;
332 342
 			centry.test = true;
333  
-			
  343
+
334 344
 			event.setEventCacheableEntry(centry);
335 345
 			AssertTrue( event.isEventCacheable(), "event cacheable 2");
336 346
 			AssertEquals(centry, event.getEventCacheableEntry() );
337  
-			
  347
+
338 348
 		</cfscript>
339 349
 	</cffunction>
340  
-	
  350
+
341 351
 	<!--- ************************************************************* --->
342  
-	
  352
+
343 353
 	<cffunction name="testViewCacheableEntry" access="public" output="false" returntype="void">
344 354
 		<cfscript>
345 355
 			var event = getRequestContext();
346 356
 			var centry = structnew();
347  
-			
  357
+
348 358
 			AssertFalse( event.isViewCacheable(), "view cacheable");
349  
-			
  359
+
350 360
 			centry.cacheable = true;
351 361
 			centry.test = true;
352  
-			
  362
+
353 363
 			event.setViewCacheableEntry(centry);
354 364
 			AssertTrue( event.isViewCacheable(), "view cacheable 2");
355 365
 			AssertEquals(centry, event.getViewCacheableEntry() );
356  
-			
  366
+
357 367
 		</cfscript>
358 368
 	</cffunction>
359  
-	
  369
+
360 370
 	<!--- ************************************************************* --->
361  
-	
  371
+
362 372
 	<cffunction name="testRoutedStruct" access="public" output="false" returntype="void">
363 373
 		<cfscript>
364 374
 			var event = getRequestContext();
365 375
 			var routedStruct = structnew();
366  
-			
  376
+
367 377
 			routedStruct.page = "aboutus";
368 378
 			routedStruct.day = "13";
369  
-			
  379
+
370 380
 			event.setRoutedStruct(routedStruct);
371  
-			
  381
+
372 382
 			AssertEquals(event.getRoutedStruct(),routedStruct);
373  
-			
  383
+
374 384
 		</cfscript>
375 385
 	</cffunction>
376  
-	
  386
+
377 387
 	<cffunction name="testSES" access="public" output="false" returntype="void">
378 388
 		<cfscript>
379 389
 			var event = getRequestContext();
380 390
 			base = "http://www.luismajano.com/index.cfm";
381  
-			
  391
+
382 392
 			event.setsesBaseURL(base);
383 393
 			assertEquals( event.getsesBaseURL(), base );
384  
-			
  394
+
385 395
 			event.setisSES(true);
386 396
 			assertEquals( event.isSES(), true );
387  
-			
388  
-			
  397
+
  398
+
389 399
 		</cfscript>
390 400
 	</cffunction>
391  
-	
  401
+
392 402
 	<cffunction name="testBuildLink" access="public" output="false" returntype="void">
393 403
 		<cfscript>
394 404
 			var event = getRequestContext();
395 405
 			base = "http://www.luismajano.com/index.cfm";
396 406
 			basessl = "https://www.luismajano.com/index.cfm";
397  
-			
  407
+
398 408
 			/* simple setup */
399 409
 			event.setisSES(false);
400 410
 			testurl = event.buildLink('general.index');
401 411
 			AssertEquals(testurl, "index.cfm?event=general.index" );
402  
-			
  412
+
403 413
 			/* simple qs */
404 414
 			event.setisSES(false);
405 415
 			testurl = event.buildLink(linkTo='general.index',queryString="page=2");
406 416
 			AssertEquals(testurl, "index.cfm?event=general.index&page=2" );
407  
-			
  417
+
408 418
 			/* empty qs */
409 419
 			event.setisSES(false);
410 420
 			testurl = event.buildLink(linkTo='general.index',queryString="");
411 421
 			AssertEquals(testurl, "index.cfm?event=general.index" );
412  
-			
  422
+
413 423
 			/* ses test */
414 424
 			event.setisSES(true);
415 425
 			event.setsesBaseURL(base);
416 426
 			testurl = event.buildLink('general/index');
417 427
 			AssertEquals(testurl, base & "/general/index" );
418  
-			
  428
+
419 429
 			/* query string transformation */
420 430
 			event.setisSES(true);
421 431
 			event.setsesBaseURL(base);
422 432
 			testurl = event.buildLink(linkTo='general/index',queryString="page=2&test=4");
423 433
 			AssertEquals(testurl, base & "/general/index/page/2/test/4" );
424  
-			
  434
+
425 435
 			/* ssl test */
426 436
 			event.setisSES(true);
427 437
 			event.setsesBaseURL(base);
428 438
 			testurl = event.buildLink(linkto='general/index',ssl=true);
429  
-			AssertEquals(testurl, basessl & "/general/index" );	
430  
-			
  439
+			AssertEquals(testurl, basessl & "/general/index" );
  440
+
431 441
 			/* translate */
432 442
 			event.setisSES(true);
433 443
 			event.setsesBaseURL(base);
434 444
 			testurl = event.buildLink(linkto='general.index',translate=false);
435  
-			AssertEquals(testurl, base & "/general.index" );	
436  
-			
  445
+			AssertEquals(testurl, base & "/general.index" );
  446
+
437 447
 		</cfscript>
438 448
 	</cffunction>
439  
-	
  449
+
440 450
 	<cffunction name="testRenderData" access="public" output="false" returntype="void">
441 451
 		<cfscript>
442 452
 			var event = getRequestContext();
443  
-			
  453
+
444 454
 			AssertEquals( event.getRenderData(), structnew());
445  
-			
  455
+
446 456
 			// Test JSON
447  
-			event.renderData(type='JSON',data="[1,2,3,4]");		
  457
+			event.renderData(type='JSON',data="[1,2,3,4]");
448 458
 			rd = event.getRenderData();
449 459
 			assertEquals( rd.contenttype, "application/json");
450 460
 			assertEquals( rd.type, "json");
451 461
 			assertEquals( rd.jsonQueryFormat, "query");
452 462
 			assertEquals( rd.statusCode, "200");
453 463
 			assertEquals( rd.statusText, "");
454  
-			
455  
-			
456  
-			event.renderData(type='JSON',data="[1,2,3,4]",jsonQueryFormat="array",jsonCase="upper");		
  464
+
  465
+
  466
+			event.renderData(type='JSON',data="[1,2,3,4]",jsonQueryFormat="array",jsonCase="upper");
457 467
 			rd = event.getRenderData();
458 468
 			assertEquals( rd.jsonQueryFormat, "array");
459  
-			
  469
+
460 470
 			//JSONP
461 471
 			event.renderData(type='JSONP',data="[1,2,3,4]",jsonCallback="testCallback");
462 472
 			rd = event.getRenderData();
463 473
 			assertEquals( rd.type, "jsonp");
464 474
 			assertEquals( rd.jsonCallback, 'testCallback');
465  
-			
466  
-			// Test WDDX 
  475
+
  476
+			// Test WDDX
467 477
 			event.renderData(type="WDDX",data=arrayNew(1));
468 478
 			rd = event.getRenderData();
469 479
 			assertEquals( rd.contenttype, "text/xml");
470 480
 			assertEquals( rd.type, "wddx");
471  
-			
  481
+
472 482
 			// Test PLAIN
473 483
 			event.renderData(data="Hello");
474 484
 			rd = event.getRenderData();
475 485
 			assertEquals( rd.type, "html");
476 486
 			assertEquals( rd.contenttype, "text/html");
477  
-			
  487
+
478 488
 			// Test XML
479 489
 			event.renderData(data=structnew(),type="xml");
480 490
 			rd = event.getRenderData();
@@ -482,96 +492,96 @@
482 492
 			assertEquals( rd.contenttype, "text/xml");
483 493
 			assertEquals( rd.xmlListDelimiter, ",");
484 494
 			assertEquals( rd.xmlColumnList, "");
485  
-			
  495
+
486 496
 			// Test contenttype
487 497
 			event.renderData(data="Hello",contentType="application/ms-excel");
488 498
 			rd = event.getRenderData();
489 499
 			assertEquals( rd.type, "html");
490 500
 			assertEquals( rd.contenttype, "application/ms-excel");
491  
-			
  501
+
492 502
 			// Test StatusCodes
493 503
 			event.renderData(data="hello",statusCode="400",statusText="Invalid Call!");
494 504
 			rd = event.getRenderData();
495 505
 			assertEquals( rd.statusCode, "400");
496 506
 			assertEquals( rd.statusText, "Invalid Call!");
497  
-			
  507
+
498 508
 		</cfscript>
499 509
 	</cffunction>
500  
-	
  510
+
501 511
 	<cffunction name="testNoExecution">
502 512
 		<cfscript>
503 513
 			var event = getRequestContext();
504  
-			
  514
+
505 515
 			assertFalse( event.isNoExecution() );
506 516
 			event.noExecution();
507 517
 			assertTrue( event.isNoExecution() );
508  
-			
  518
+
509 519
 		</cfscript>
510 520
 	</cffunction>
511  
-	
  521
+
512 522
 	<cffunction name="testCurrentModule" access="public"  returntype="void" output="false">
513 523
 		<cfscript>
514 524
 			var event = getRequestContext();
515  
-			
  525
+
516 526
 			event.setValue("event","myModule:test.home");
517  
-			
  527
+
518 528
 			//debug(event.getCurrentEVent());
519 529
 			assertEquals("myModule", event.getCurrentModule());
520  
-			
  530
+
521 531
 			event.setValue("event","test.home");
522 532
 			assertEquals("", event.getCurrentModule());
523  
-			
  533
+
524 534
 		</cfscript>
525 535
 	</cffunction>
526  
-	
527  
-	
  536
+
  537
+
528 538
 	<cffunction name="testModuleRoot" access="public"  returntype="void" output="false">
529 539
 		<cfscript>
530 540
 			var event = getRequestContext();
531  
-			
532  
-			
  541
+
  542
+
533 543
 			//debug(event.getCurrentEVent());
534 544
 			assertEquals("", event.getmoduleRoot());
535 545
 			event.setValue("event","test1:test.home");
536 546
 			assertEquals(props.modules.test1.mapping, event.getmoduleRoot());
537  
-			
538  
-			
  547
+
  548
+
539 549
 		</cfscript>
540 550
 	</cffunction>
541  
-	
542  
-	
  551
+
  552
+
543 553
 	<cffunction name="testsetHTTPHeader" access="public"  returntype="void" output="false">
544 554
 		<cfscript>
545 555
 			var event = getRequestContext();
546  
-			
  556
+
547 557
 			event.setHTTPHeader(statusCode="200",statusText="Hello");
548  
-			
  558
+
549 559
 			event.setHTTPHeader(name="expires",value="#now()#");
550 560
 		</cfscript>
551 561
 	</cffunction>
552  
-	
  562
+
553 563
 	<cffunction name="testGetHTTPConetnt" access="public"  returntype="void" output="false">
554 564
 		<cfscript>
555 565
 			var event = getRequestContext();
556  
-			
  566
+
557 567
 			test = event.getHTTPContent();
558  
-			
  568
+
559 569
 			assertTrue( isSimpleValue(test) );
560  
-			
  570
+
561 571
 		</cfscript>
562 572
 	</cffunction>
563  
-	
  573
+
564 574
 	<cffunction name="testNoLayout" access="public"  returntype="void" output="false">
565 575
 		<cfscript>
566 576
 			var event = getRequestContext();
567  
-			
  577
+
568 578
 			event.noLayout().setView("test");
569  
-			
  579
+
570 580
 			//debug( event.getCollection(private=true) );
571 581
 			assertEquals( true, event.getValue("layoutOverride",false,true) );
572  
-			
  582
+
573 583
 		</cfscript>
574 584
 	</cffunction>
575  
-	
576  
-	
  585
+
  586
+
577 587
 </cfcomponent>

0 notes on commit 054d416

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