Permalink
Browse files

fix some failing tests, improve binary compatibility by adding more c…

…lasses to 'grails-compatibility'
  • Loading branch information...
1 parent eb5d0e1 commit aa6a9a3bf780b28ee40cb2231eb58ac174d9b660 graemerocher committed Jun 20, 2014
Showing with 162 additions and 26 deletions.
  1. +34 −0 ...ompatibility/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/ASTErrorsHelper.groovy
  2. +25 −0 ...ty/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/ASTValidationErrorsHelper.groovy
  3. +2 −2 ...oovy/org/codehaus/groovy/grails/compiler/injection/{GrailsASTUtil.groovy → GrailsASTUtils.groovy}
  4. +40 −0 ...mpatibility/src/main/groovy/org/codehaus/groovy/grails/orm/support/GrailsTransactionTemplate.java
  5. +1 −1 grails-core/src/main/groovy/grails/core/GrailsClass.java
  6. +2 −1 grails-core/src/main/groovy/grails/transaction/GrailsTransactionTemplate.groovy
  7. +3 −1 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/GrailsApplication.groovy
  8. +0 −1 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/AstTransformer.groovy
  9. +2 −0 grails-core/src/main/groovy/org/grails/compiler/injection/ASTErrorsHelper.java
  10. +3 −0 grails-core/src/main/groovy/org/grails/compiler/injection/ASTValidationErrorsHelper.java
  11. +6 −1 grails-core/src/main/groovy/org/grails/compiler/injection/GrailsAwareInjectionOperation.java
  12. +0 −1 grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java
  13. +7 −2 ...vy/org/codehaus/groovy/grails/commons/cfg/GrailsPlaceHolderConfigurerCorePluginRuntimeSpec.groovy
  14. +2 −0 grails-plugin-controllers/build.gradle
  15. +2 −0 grails-plugin-converters/build.gradle
  16. +2 −0 grails-plugin-domain-class/build.gradle
  17. +25 −0 ...class/src/test/groovy/org/codehaus/groovy/grails/domain/EntityTransformIncludesGormApiSpec.groovy
  18. +2 −0 grails-plugin-gsp/build.gradle
  19. +1 −0 grails-plugin-rest/build.gradle
  20. +0 −15 .../test/groovy/org/codehaus/groovy/grails/compiler/validation/ValidateableTransformationSpec.groovy
  21. +2 −0 grails-test-suite-persistence/build.gradle
  22. 0 ...c/main/{groovy → resources}/org/codehaus/groovy/grails/validation/DefaultErrorMessages.properties
  23. +1 −1 grails-web-common/src/main/resources/META-INF/grails.factories
View
34 ...lity/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/ASTErrorsHelper.groovy
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011 SpringSource
+ *
+ * Licensed 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
+ *
+ * http://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.codehaus.groovy.grails.compiler.injection
+
+/**
+ * Enhances a class to contain an Errors property of type org.springframework.validation.Errors. Methods added include:
+ *
+ * <pre>
+ * public void setErrors(Errors errors)
+ * public Errors getErrors()
+ * public void clearErrors()
+ * public Boolean hasErrors()
+ * </pre>
+ *
+ * @author Jeff Brown
+ * @deprecated Use {@link org.grails.compiler.injection.ASTErrorsHelper} instead
+ */
+@Deprecated
+public interface ASTErrorsHelper extends org.grails.compiler.injection.ASTErrorsHelper{
+
+}
View
25 ...ain/groovy/org/codehaus/groovy/grails/compiler/injection/ASTValidationErrorsHelper.groovy
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2011 SpringSource
+ *
+ * Licensed 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
+ *
+ * http://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.codehaus.groovy.grails.compiler.injection
+
+/**
+ * @author Jeff Brown
+ * @deprecated Use {@link org.grails.compiler.injection.ASTValidationErrorsHelper} instead
+ */
+@Deprecated
+class ASTValidationErrorsHelper extends org.grails.compiler.injection.ASTValidationErrorsHelper implements ASTErrorsHelper {
+}
View
4 ...s/compiler/injection/GrailsASTUtil.groovy → .../compiler/injection/GrailsASTUtils.groovy
@@ -23,8 +23,8 @@ import org.grails.compiler.injection.GrailsASTUtils
*
* @author Graeme Rocher
* @since 0.3
- * @deprecated Use {@link GrailsASTUtils} instead
+ * @deprecated Use {@link org.grails.compiler.injection.GrailsASTUtils} instead
*/
@Deprecated
-class GrailsASTUtil extends GrailsASTUtils{
+class GrailsASTUtils extends org.grails.compiler.injection.GrailsASTUtils{
}
View
40 ...ity/src/main/groovy/org/codehaus/groovy/grails/orm/support/GrailsTransactionTemplate.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2013 the original author or authors.
+ *
+ * Licensed 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
+ *
+ * http://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.codehaus.groovy.grails.orm.support;
+
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.interceptor.TransactionAttribute;
+
+/**
+ * @author Graeme Rocher
+ * @deprecated Use {@link grails.transaction.GrailsTransactionTemplate} instead
+ */
+@Deprecated
+public class GrailsTransactionTemplate extends grails.transaction.GrailsTransactionTemplate {
+
+ public GrailsTransactionTemplate(PlatformTransactionManager transactionManager) {
+ super(transactionManager);
+ }
+
+ public GrailsTransactionTemplate(PlatformTransactionManager transactionManager, TransactionDefinition transactionDefinition) {
+ super(transactionManager, transactionDefinition);
+ }
+
+ public GrailsTransactionTemplate(PlatformTransactionManager transactionManager, TransactionAttribute transactionAttribute) {
+ super(transactionManager, transactionAttribute);
+ }
+}
View
2 grails-core/src/main/groovy/grails/core/GrailsClass.java
@@ -27,7 +27,7 @@
* @author Graeme Rocher
* @since 0.1
*/
-public interface GrailsClass extends GrailsApplicationAware {
+public interface GrailsClass extends GrailsApplicationAware{
/**
* Whether the class is abstract or not
View
3 grails-core/src/main/groovy/grails/transaction/GrailsTransactionTemplate.groovy
@@ -39,8 +39,9 @@ import org.springframework.transaction.support.TransactionTemplate
@CompileStatic
class GrailsTransactionTemplate {
+ TransactionAttribute transactionAttribute
+
private TransactionTemplate transactionTemplate
- private TransactionAttribute transactionAttribute
GrailsTransactionTemplate(PlatformTransactionManager transactionManager) {
this(transactionManager, new DefaultTransactionAttribute())
View
4 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/GrailsApplication.groovy
@@ -15,11 +15,13 @@
*/
package org.codehaus.groovy.grails.commons
+import groovy.transform.CompileStatic
+
/**
* @author Graeme Rocher
* @deprecated Use {@link grails.core.GrailsApplication} instead
*/
@Deprecated
+@CompileStatic
public interface GrailsApplication extends grails.core.GrailsApplication{
-
}
View
1 ...-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/AstTransformer.groovy
@@ -13,6 +13,5 @@ import java.lang.annotation.Target;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.TYPE])
-@Deprecated
public @interface AstTransformer {
}
View
2 grails-core/src/main/groovy/org/grails/compiler/injection/ASTErrorsHelper.java
@@ -26,6 +26,8 @@
* public void clearErrors()
* public Boolean hasErrors()
* </pre>
+ *
+ * @author Jeff Brown
*/
public interface ASTErrorsHelper {
View
3 grails-core/src/main/groovy/org/grails/compiler/injection/ASTValidationErrorsHelper.java
@@ -44,6 +44,9 @@
import org.codehaus.groovy.syntax.Types;
import org.springframework.validation.Errors;
+/**
+ * @author Jeff Brown
+ */
public class ASTValidationErrorsHelper implements ASTErrorsHelper {
private static final ConstantExpression NULL_EXPRESSION = new ConstantExpression(null);
private static final String SET_ERRORS_METHOD_NAME = "setErrors";
View
7 grails-core/src/main/groovy/org/grails/compiler/injection/GrailsAwareInjectionOperation.java
@@ -109,11 +109,13 @@ private static void initializeState() {
Set<Class> injectorClasses = new HashSet<Class>();
CachingMetadataReaderFactory readerFactory = new CachingMetadataReaderFactory(classLoader);
for (org.codehaus.groovy.grails.io.support.Resource resource : resources) {
+ // ignore not readable classes and closures
+ if(!resource.isReadable() || resource.getFilename().contains("$_")) continue;
try {
MetadataReader metadataReader = readerFactory.getMetadataReader(new GrailsResource(resource));
AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
- if(annotationMetadata.hasAnnotation(AstTransformer.class.getName()) || annotationMetadata.hasAnnotatedMethods(org.codehaus.groovy.grails.compiler.injection.AstTransformer.class.getName())) {
+ if(annotationMetadata.hasAnnotation(AstTransformer.class.getName()) || annotationMetadata.hasAnnotation(org.codehaus.groovy.grails.compiler.injection.AstTransformer.class.getName())) {
String className = metadataReader.getClassMetadata().getClassName();
Class<?> injectorClass = classLoader.loadClass(className);
if(injectorClasses.contains(injectorClass)) continue;
@@ -131,8 +133,11 @@ private static void initializeState() {
// ignore
} catch (IOException e) {
// ignore
+ } catch(NoClassDefFoundError e) {
+ // ignore
}
+
}
Collections.sort(injectors, new Comparator<ClassInjector>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
View
1 grails-core/src/main/groovy/org/grails/spring/RuntimeSpringConfigUtilities.java
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import grails.core.GrailsApplication;
-import org.codehaus.groovy.grails.commons.spring.RuntimeSpringConfiguration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.util.ClassUtils;
import org.grails.spring.RuntimeSpringConfiguration;
View
9 ...odehaus/groovy/grails/commons/cfg/GrailsPlaceHolderConfigurerCorePluginRuntimeSpec.groovy
@@ -21,9 +21,14 @@ class GrailsPlaceHolderConfigurerCorePluginRuntimeSpec extends Specification{
def bb = new BeanBuilder(parent.createApplicationContext())
final beanBinding = new Binding()
- beanBinding.setVariable('application', new DefaultGrailsApplication())
+
+ def app = new DefaultGrailsApplication()
+ beanBinding.setVariable('application', app)
bb.setBinding(beanBinding)
- bb.beans new CoreGrailsPlugin().doWithSpring
+
+ def plugin = new CoreGrailsPlugin()
+ plugin.grailsApplication = app
+ bb.beans plugin.doWithSpring
bb.beans {
testBean(ReplacePropertyBean) {
foo = '${foo.bar}'
View
2 grails-plugin-controllers/build.gradle
@@ -11,4 +11,6 @@ dependencies {
testRuntime "jline:jline:$jlineVersion"
testRuntime "org.fusesource.jansi:jansi:$jansiVersion"
+
+ testRuntime project(":grails-compatibility")
}
View
2 grails-plugin-converters/build.gradle
@@ -3,4 +3,6 @@ dependencies {
compile project(":grails-web"),
project(':grails-plugin-domain-class')
+
+ testRuntime project(":grails-compatibility")
}
View
2 grails-plugin-domain-class/build.gradle
@@ -43,4 +43,6 @@ dependencies {
compile("org.grails:grails-datastore-simple:$datastoreVersion") {
exclude group: 'org.grails', module:'grails-datastore-core'
}
+
+ testCompile(project(":grails-compatibility"))
}
View
25 ...c/test/groovy/org/codehaus/groovy/grails/domain/EntityTransformIncludesGormApiSpec.groovy
@@ -0,0 +1,25 @@
+package org.codehaus.groovy.grails.domain
+
+import spock.lang.Specification
+
+
+/**
+ * Created by graemerocher on 20/06/2014.
+ */
+class EntityTransformIncludesGormApiSpec extends Specification{
+
+ void "Test that with the presence of grails-datastore-gorm that the GORM API is added to compiled entities annotated with @Entity"() {
+
+
+ when:"A entity annotated with @Entity is compiled"
+ def cls = new GroovyClassLoader().parseClass('''
+import grails.persistence.*
+
+@Entity
+class Book { String title }
+''')
+
+ then:"The class has the GORM APIs added to it"
+ cls.getMethod('getErrors', null) != null
+ }
+}
View
2 grails-plugin-gsp/build.gradle
@@ -17,6 +17,8 @@ dependencies {
astCompile project(":grails-web"),
project(":grails-plugin-controllers")
+
+ testCompile(project(":grails-compatibility"))
}
test {
View
1 grails-plugin-rest/build.gradle
@@ -7,4 +7,5 @@ dependencies {
compile 'com.google.code.gson:gson:2.2.4'
testCompile project(":grails-plugin-url-mappings")
+ testCompile project(":grails-compatibility")
}
View
15 ...oovy/org/codehaus/groovy/grails/compiler/validation/ValidateableTransformationSpec.groovy
@@ -27,21 +27,6 @@ class ValidateableTransformationSpec extends Specification {
2 == validateMethodCount
}
- void 'Test validate methods added to classes marked with org.codehaus.groovy.grails.validation.Validateable'() {
- given:
- def clz = gcl.parseClass('''
- @org.codehaus.groovy.grails.validation.Validateable
- class Widget {
- }
- ''')
-
- when:
- def validateMethodCount = clz.metaClass.methods.findAll { it.name == 'validate' }?.size()
-
- then:
- 2 == validateMethodCount
- }
-
void 'Test validate methods not added to classes which are not marked with Validateable'() {
given:
def clz = gcl.parseClass('''
View
2 grails-test-suite-persistence/build.gradle
@@ -36,6 +36,8 @@ dependencies {
exclude group: 'java-persistence', module:'persistence-api'
exclude group: 'javassist', module: 'javassist'
}
+
+ testRuntime project(":grails-compatibility")
}
test {
View
0 ...alidation/DefaultErrorMessages.properties → ...alidation/DefaultErrorMessages.properties
File renamed without changes.
View
2 grails-web-common/src/main/resources/META-INF/grails.factories
@@ -1,2 +1,2 @@
-org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes=org.codehaus.groovy.grails.web.servlet.DefaultGrailsApplicationAttributes
+grails.web.util.GrailsApplicationAttributes=org.grails.web.servlet.DefaultGrailsApplicationAttributes

0 comments on commit aa6a9a3

Please sign in to comment.