jdaugherty commented on code in PR #14876:
URL: https://github.com/apache/grails-core/pull/14876#discussion_r2187501283


##########
grails-gsp/plugin/src/test/groovy/org/grails/web/pages/ParseSpec.groovy:
##########
@@ -0,0 +1,345 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.grails.web.pages
+
+import grails.core.DefaultGrailsApplication
+import grails.core.GrailsApplication
+import grails.util.GrailsWebMockUtil
+import grails.util.GrailsWebUtil
+import grails.web.pages.GroovyPagesUriService
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.runtime.IOGroovyMethods
+import org.grails.gsp.GroovyPage
+import org.grails.gsp.compiler.GroovyPageParser
+import org.grails.taglib.GrailsTagException
+import org.grails.web.servlet.mvc.GrailsWebRequest
+import org.grails.web.util.GrailsApplicationAttributes
+import org.junit.jupiter.api.Assertions
+import org.springframework.mock.web.MockServletContext
+import org.springframework.web.context.WebApplicationContext
+import org.springframework.web.context.request.RequestContextHolder
+import org.springframework.web.context.support.GenericWebApplicationContext
+import spock.lang.PendingFeature
+import spock.lang.Specification
+
+/**
+ * Tests the GSP parser.  This can detect issues caused by improper
+ * GSP->Groovy conversion.  Normally, to compare the code, you can
+ * run the page with a showSource parameter specified.
+ * <p>
+ * The methods parseCode() and trimAndRemoveCR() have been added
+ * to simplify test case code.
+ */
+class ParseSpec extends Specification {
+    static final String GSP_FOOTER = """public static final Map JSP_TAGS = new 
HashMap()
+protected void init() {
+\tthis.jspTags = JSP_TAGS
+}
+public static final String CONTENT_TYPE = 'text/html;charset=UTF-8'
+public static final long LAST_MODIFIED = 0L
+public static final String EXPRESSION_CODEC = 'HTML'
+public static final String STATIC_CODEC = 'none'
+public static final String OUT_CODEC = 'none'
+public static final String TAGLIB_CODEC = 'none'
+}
+"""
+
+    void "parse"() {
+        given:
+        String expected = makeImports() +
+                "\n" +
+                "class myTest1 extends org.grails.gsp.GroovyPage {\n" +
+                "public String getGroovyPageFileName() { \"myTest1\" }\n" +
+                "public Object run() {\n" +
+                "Writer out = getOut()\n" +
+                "Writer expressionOut = getExpressionOut()\n" +
+                "printHtmlPart(0)\n" +
+                "}\n" + GSP_FOOTER

Review Comment:
   Some of these I can't.  This is testing the lower level parsing logic and it 
will break the test.  I've done what I can.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@grails.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to