GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / commons / UrlMappingsArtefactHandlerTests.groovy
blob1b280d34ac393b30ca5855db093c8bc19fc737ad
1 package org.codehaus.groovy.grails.commons;
3 import org.springframework.core.io.*
5 /**
6 * tests for UrlMappingsArtefactHandler
8 * @author Graeme Rocher
9 * @since 0.5
11 * <p/>
12 * Created: Mar 6, 2007
13 * Time: 6:20:30 PM
15 public class UrlMappingsArtefactHandlerTests extends GroovyTestCase {
17 def mappingScript = '''
18 mappings {
19 "/$id/$year?/$month?/$day?" {
20 controller = "blog"
21 action = "show"
22 constraints {
23 year(matches:/\\d{4}/)
24 month(matches:/\\d{2}/)
28 "/product/$name" {
29 controller = "product"
30 action = "show"
33 '''
35 void testUrlMappingsArtefactHandler() {
36 def gcl = new GroovyClassLoader()
37 Class mappings = gcl.parseClass(new ByteArrayResource(mappingScript.bytes).inputStream, "MyUrlMappings")
38 def handler = new UrlMappingsArtefactHandler()
40 assert handler.isArtefactClass(mappings)
41 assert handler.newArtefactClass(mappings)