Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:grails/grails-core

  • Loading branch information...
commit a5bf8e178b20e6fe937ecb2ba3ec70f9013bd7a1 2 parents e263b38 + 17d2ccc
graemerocher graemerocher authored
Showing with 252 additions and 28 deletions.
  1. +4 −1 src/java/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtil.java
  2. +14 −0 src/test/grails/test/GrailsUnitTestCaseTests.groovy
  3. +6 −0 src/test/grails/test/MockUtilsSaveDomainTests.groovy
  4. +10 −2 src/test/grails/test/MockUtilsTests.groovy
  5. +14 −0 src/test/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassTests.groovy
  6. +7 −0 src/test/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtilTests.java
  7. +5 −0 src/test/org/codehaus/groovy/grails/orm/hibernate/AbstractGrailsHibernateTests.groovy
  8. +11 −0 src/test/org/codehaus/groovy/grails/orm/hibernate/BidirectionalListMappingTests.groovy
  9. +10 −0 src/test/org/codehaus/groovy/grails/orm/hibernate/ComponentDomainTests.groovy
  10. +14 −0 src/test/org/codehaus/groovy/grails/orm/hibernate/DerivedPropertiesTests.groovy
  11. +14 −2 src/test/org/codehaus/groovy/grails/orm/hibernate/UnidirectionalOneToManyHibernateMappedTests.groovy
  12. +14 −2 src/test/org/codehaus/groovy/grails/orm/hibernate/cfg/GORMNamespaceHandlerTests.groovy
  13. +9 −1 src/test/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinderTests.java
  14. +16 −0 src/test/org/codehaus/groovy/grails/scaffolding/DomainClassPropertyComparatorTests.java
  15. +17 −0 src/test/org/codehaus/groovy/grails/validation/ConstrainedPropertyTests.java
  16. +11 −0 src/test/org/codehaus/groovy/grails/validation/ConstraintsBuilderTests.groovy
  17. +24 −5 src/test/org/codehaus/groovy/grails/validation/ConstraintsEvaluatingPropertyTests.java
  18. +16 −10 src/test/org/codehaus/groovy/grails/validation/GrailsDomainClassValidatorTests.groovy
  19. +12 −0 src/test/org/codehaus/groovy/grails/validation/NullableConstraintTests.groovy
  20. +10 −0 src/test/org/codehaus/groovy/grails/web/taglib/PropertyEditorTests.groovy
  21. +14 −5 src/test/org/codehaus/groovy/grails/web/taglib/ValidationTagLibTests.groovy
5 src/java/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtil.java
View
@@ -55,6 +55,7 @@
import org.codehaus.groovy.grails.exceptions.GrailsConfigurationException;
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder;
import org.codehaus.groovy.grails.orm.hibernate.cfg.PropertyConfig;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
import org.codehaus.groovy.grails.validation.ConstrainedProperty;
import org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder;
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
@@ -376,8 +377,10 @@ public static boolean isNotConfigurational(PropertyDescriptor descriptor) {
Map<String, ConstrainedProperty> constrainedProperties = delegate.getConstrainedProperties();
if (properties != null && !(constrainedProperties.isEmpty() && javaEntity)) {
+ boolean hasHibernate = PluginManagerHolder.getPluginManager().hasGrailsPlugin("hibernate");
for (GrailsDomainClassProperty p : properties) {
- PropertyConfig propertyConfig = GrailsDomainBinder.getPropertyConfig(p);
+ // assume no formula issues if Hibernate isn't available to avoid CNFE
+ PropertyConfig propertyConfig = hasHibernate ? GrailsDomainBinder.getPropertyConfig(p) : null;
if (propertyConfig != null && propertyConfig.getFormula() != null) {
if (constrainedProperties.remove(p.getName()) != null) {
// constraint is registered but cannot be applied to a derived property
14 src/test/grails/test/GrailsUnitTestCaseTests.groovy
View
@@ -20,6 +20,9 @@ import grails.converters.XML
import junit.framework.AssertionFailedError
import org.codehaus.groovy.grails.commons.ConfigurationHolder
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.codehaus.groovy.grails.plugins.codecs.HTMLCodec
/**
@@ -150,6 +153,17 @@ class GrailsUnitTestCaseTests extends GroovyTestCase {
class TestUnitTestCase extends GrailsUnitTestCase {
+ protected void setUp() {
+ super.setUp()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
void testMockInstances1() {
mockDomain(GrailsUnitTestClass)
6 src/test/grails/test/MockUtilsSaveDomainTests.groovy
View
@@ -14,6 +14,9 @@
*/
package grails.test
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.springframework.validation.Errors
class MockUtilsSaveDomainTests extends GroovyTestCase {
@@ -30,11 +33,14 @@ class MockUtilsSaveDomainTests extends GroovyTestCase {
protected void setUp() {
metaTestHelper.setUp()
errorsMap = new IdentityHashMap()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
}
protected void tearDown() {
metaTestHelper.tearDown()
MockUtils.resetIds()
+ PluginManagerHolder.pluginManager = null
}
/**
12 src/test/grails/test/MockUtilsTests.groovy
View
@@ -14,6 +14,9 @@
*/
package grails.test
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
import org.springframework.mock.web.MockHttpServletRequest
import org.springframework.mock.web.MockHttpServletResponse
@@ -37,14 +40,19 @@ class MockUtilsTests extends GroovyTestCase {
private Map errorsMap
- void setUp() {
+ protected void setUp() {
+ super.setUp()
metaTestHelper.setUp()
errorsMap = new IdentityHashMap()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
}
- void tearDown() {
+ protected void tearDown() {
+ super.tearDown()
metaTestHelper.tearDown()
MockUtils.resetIds()
+ PluginManagerHolder.pluginManager = null
}
/**
14 src/test/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassTests.groovy
View
@@ -1,6 +1,9 @@
package org.codehaus.groovy.grails.commons
import org.codehaus.groovy.grails.exceptions.InvalidPropertyException
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
/**
* Note there are more tests for DefaultGrailsDomainClass in test/persistence written in Java
@@ -9,6 +12,17 @@ class DefaultGrailsDomainClassTests extends GroovyTestCase {
def gcl = new GroovyClassLoader()
+ protected void setUp() {
+ super.setUp()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
void testFetchMode() {
gcl.parseClass """
class Test {
7 src/test/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtilTests.java
View
@@ -26,6 +26,9 @@
import org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration;
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder;
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+import org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGeneratorTests;
import org.codehaus.groovy.grails.validation.ConstrainedProperty;
import org.codehaus.groovy.grails.validation.NullableConstraint;
import org.hibernate.cfg.ImprovedNamingStrategy;
@@ -42,12 +45,16 @@
protected void setUp() throws Exception {
super.setUp();
ExpandoMetaClass.enableGlobally();
+ MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
+ PluginManagerHolder.setPluginManager(pluginManager);
+ pluginManager.registerMockPlugin(DefaultGrailsTemplateGeneratorTests.fakeHibernatePlugin);
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
GrailsDomainBinder.namingStrategy = ImprovedNamingStrategy.INSTANCE;
+ PluginManagerHolder.setPluginManager(null);
}
public void testIsBasicType() {
5 src/test/org/codehaus/groovy/grails/orm/hibernate/AbstractGrailsHibernateTests.groovy
View
@@ -102,6 +102,8 @@ hibernate {
mockManager.doArtefactConfiguration()
ctx.registerMockBean(PluginMetaManager.BEAN_ID, new DefaultPluginMetaManager())
+ afterPluginInitialization()
+
ga.initialise()
ga.setApplicationContext(ctx)
ApplicationHolder.setApplication(ga)
@@ -164,6 +166,9 @@ hibernate {
protected void onTearDown() {
}
+
+ protected void afterPluginInitialization() {
+ }
}
class MockHibernateGrailsPlugin {
11 src/test/org/codehaus/groovy/grails/orm/hibernate/BidirectionalListMappingTests.groovy
View
@@ -2,6 +2,9 @@ package org.codehaus.groovy.grails.orm.hibernate
import org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration
import org.codehaus.groovy.grails.commons.DefaultGrailsApplication
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.hibernate.FetchMode
import org.hibernate.engine.CascadeStyle
@@ -35,6 +38,9 @@ class BidirectionalListMappingTests extends GroovyTestCase {
protected void setUp() {
ExpandoMetaClass.enableGlobally()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
def gcl = new GroovyClassLoader()
gcl.parseClass '''
class TestFaqSection {
@@ -63,6 +69,11 @@ class TestFaqElement {
config.buildMappings()
}
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
void testIndexBackrefMapping() {
PersistentClass faqSection = config.getClassMapping("TestFaqSection")
PersistentClass faqElement = config.getClassMapping("TestFaqElement")
10 src/test/org/codehaus/groovy/grails/orm/hibernate/ComponentDomainTests.groovy
View
@@ -1,6 +1,9 @@
package org.codehaus.groovy.grails.orm.hibernate
import org.codehaus.groovy.grails.commons.test.AbstractGrailsMockTests
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
class ComponentDomainTests extends AbstractGrailsMockTests {
@@ -17,6 +20,9 @@ class ComponentDomainTests extends AbstractGrailsMockTests {
}
protected void onSetUp() {
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
gcl.parseClass('''
class Person {
Long id
@@ -36,4 +42,8 @@ class Address {
'''
)
}
+
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
+ }
}
14 src/test/org/codehaus/groovy/grails/orm/hibernate/DerivedPropertiesTests.groovy
View
@@ -1,5 +1,9 @@
package org.codehaus.groovy.grails.orm.hibernate
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
+
class DerivedPropertiesTests extends AbstractGrailsHibernateTests {
protected void onSetUp() {
@@ -29,7 +33,17 @@ class ClassWithConstrainedDerivedProperty {
'''
}
+ protected void afterPluginInitialization() {
+ // base class registers its own plugins but the hibernate plugin has the wrong name
+ PluginManagerHolder.pluginManager.plugins['hibernate'] = PluginManagerHolder.pluginManager.plugins['mockHibernate']
+ }
+
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
+ }
+
void testDerivedPropertiesCannotBeMadeValidateable() {
+
def myDomainClass = ga.getDomainClass('ClassWithConstrainedDerivedProperty')
def myClass = myDomainClass.clazz
16 src/test/org/codehaus/groovy/grails/orm/hibernate/UnidirectionalOneToManyHibernateMappedTests.groovy
View
@@ -2,15 +2,27 @@ package org.codehaus.groovy.grails.orm.hibernate
import org.codehaus.groovy.grails.commons.DefaultGrailsApplication
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
/**
* @author Graeme Rocher
* @since 1.0
- *
- * Created: Apr 8, 2008
*/
class UnidirectionalOneToManyHibernateMappedTests extends GroovyTestCase {
+ protected void setUp() {
+ super.setUp()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
void testAnnotatedOneToManyDomain() {
def config = new GrailsAnnotationConfiguration()
def gcl = new GroovyClassLoader()
16 src/test/org/codehaus/groovy/grails/orm/hibernate/cfg/GORMNamespaceHandlerTests.groovy
View
@@ -5,6 +5,9 @@ import grails.spring.BeanBuilder
import org.apache.commons.dbcp.BasicDataSource
import org.codehaus.groovy.grails.commons.GrailsApplication
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.hibernate.SessionFactory
import org.springframework.core.io.ByteArrayResource
import org.springframework.context.support.StaticMessageSource
@@ -12,11 +15,20 @@ import org.springframework.context.support.StaticMessageSource
/**
* @author Graeme Rocher
* @since 1.1
- *
- * Created: Jan 16, 2009
*/
class GORMNamespaceHandlerTests extends GroovyTestCase {
+ protected void setUp() {
+ super.setUp()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
/* void testGORMSessionFromXML() {
def appCtx = new GenericApplicationContext()
10 src/test/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinderTests.java
View
@@ -20,18 +20,22 @@
import groovy.lang.IntRange;
import groovy.lang.ObjectRange;
+import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.lang.reflect.Field;
import junit.framework.TestCase;
+
import org.codehaus.groovy.grails.commons.DefaultGrailsApplication;
import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
import org.codehaus.groovy.grails.commons.GrailsApplication;
import org.codehaus.groovy.grails.commons.GrailsDomainClass;
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+import org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGeneratorTests;
import org.codehaus.groovy.grails.validation.ConstrainedProperty;
import org.codehaus.groovy.grails.validation.TestClass;
import org.hibernate.cfg.ImprovedNamingStrategy;
@@ -212,12 +216,16 @@
protected void setUp() throws Exception {
super.setUp();
ExpandoMetaClass.enableGlobally();
+ MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
+ PluginManagerHolder.setPluginManager(pluginManager);
+ pluginManager.registerMockPlugin(DefaultGrailsTemplateGeneratorTests.fakeHibernatePlugin);
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
GrailsDomainBinder.namingStrategy = ImprovedNamingStrategy.INSTANCE;
+ PluginManagerHolder.setPluginManager(null);
}
public void testCachedMapProperty() {
16 src/test/org/codehaus/groovy/grails/scaffolding/DomainClassPropertyComparatorTests.java
View
@@ -25,6 +25,8 @@
import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
import org.codehaus.groovy.grails.commons.GrailsDomainClass;
import org.codehaus.groovy.grails.commons.GrailsDomainClassProperty;
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
/**
* @author Graeme Rocher
@@ -32,6 +34,20 @@
*/
public class DomainClassPropertyComparatorTests extends TestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
+ PluginManagerHolder.setPluginManager(pluginManager);
+ pluginManager.registerMockPlugin(DefaultGrailsTemplateGeneratorTests.fakeHibernatePlugin);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ PluginManagerHolder.setPluginManager(null);
+ }
+
@SuppressWarnings("unchecked")
public void testPropertyComparator() throws Exception {
GroovyClassLoader gcl = new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
17 src/test/org/codehaus/groovy/grails/validation/ConstrainedPropertyTests.java
View
@@ -16,6 +16,9 @@
import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
import org.codehaus.groovy.grails.commons.GrailsDomainClass;
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+import org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGeneratorTests;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
@@ -23,6 +26,20 @@
private int testValidatorValue = 0;
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
+ PluginManagerHolder.setPluginManager(pluginManager);
+ pluginManager.registerMockPlugin(DefaultGrailsTemplateGeneratorTests.fakeHibernatePlugin);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ PluginManagerHolder.setPluginManager(null);
+ }
+
public int getTestValidatorValue() {
return testValidatorValue;
}
11 src/test/org/codehaus/groovy/grails/validation/ConstraintsBuilderTests.groovy
View
@@ -2,6 +2,9 @@ package org.codehaus.groovy.grails.validation
import org.codehaus.groovy.grails.commons.test.*
import org.codehaus.groovy.grails.commons.metaclass.*
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.springframework.validation.BindException
import org.springframework.validation.Errors;
@@ -94,6 +97,10 @@ class ConstraintsBuilderTests extends AbstractGrailsMockTests {
}
protected void onSetUp() {
+
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
gcl.parseClass('''
class Book {
Long id
@@ -118,4 +125,8 @@ class Site {
}
''')
}
+
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
+ }
}
29 src/test/org/codehaus/groovy/grails/validation/ConstraintsEvaluatingPropertyTests.java
View
@@ -1,18 +1,37 @@
package org.codehaus.groovy.grails.validation;
import groovy.lang.GroovyClassLoader;
-import junit.framework.TestCase;
-import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
-import org.codehaus.groovy.grails.commons.GrailsDomainClass;
import java.util.Collection;
import java.util.Map;
+import junit.framework.TestCase;
+
+import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
+import org.codehaus.groovy.grails.commons.GrailsDomainClass;
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+import org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGeneratorTests;
+
public class ConstraintsEvaluatingPropertyTests extends TestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
+ PluginManagerHolder.setPluginManager(pluginManager);
+ pluginManager.registerMockPlugin(DefaultGrailsTemplateGeneratorTests.fakeHibernatePlugin);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ PluginManagerHolder.setPluginManager(null);
+ }
+
/*
- * Test method for 'org.codehaus.groovy.grails.validation.metaclass.ConstraintsDynamicProperty.get(Object)'
- */
+ * Test method for 'org.codehaus.groovy.grails.validation.metaclass.ConstraintsDynamicProperty.get(Object)'
+ */
@SuppressWarnings("unchecked")
public void testGet() throws Exception {
GroovyClassLoader gcl = new GroovyClassLoader();
26 src/test/org/codehaus/groovy/grails/validation/GrailsDomainClassValidatorTests.groovy
View
@@ -1,12 +1,15 @@
package org.codehaus.groovy.grails.validation
-import org.codehaus.groovy.grails.commons.test.*
-import org.codehaus.groovy.grails.commons.metaclass.*
-import org.springframework.validation.BindException;
+import org.codehaus.groovy.grails.commons.test.*
+import org.codehaus.groovy.grails.commons.metaclass.*
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
+import org.springframework.validation.BindException
class GrailsDomainClassValidatorTests extends AbstractGrailsMockTests {
- public void testCascadingValidation() {
+ void testCascadingValidation() {
def bookClass = ga.getDomainClass("Book")
def authorClass = ga.getDomainClass("Author")
def addressClass = ga.getDomainClass("Address")
@@ -21,9 +24,6 @@ class GrailsDomainClassValidatorTests extends AbstractGrailsMockTests {
bookMetaClass.initialize()
authorMetaClass.initialize()
-
-
-
def book = bookClass.newInstance()
book.metaClass = bookMetaClass
@@ -86,10 +86,12 @@ class GrailsDomainClassValidatorTests extends AbstractGrailsMockTests {
errors = new BindException(author, author.class.name)
authorValidator.validate(author, errors, true)
assert !errors.hasErrors()
-
}
- public void onSetUp() {
+ protected void onSetUp() {
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
gcl.parseClass('''
class Book {
Long id
@@ -126,4 +128,8 @@ class Address {
}
''')
}
-}
+
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
+ }
+}
12 src/test/org/codehaus/groovy/grails/validation/NullableConstraintTests.groovy
View
@@ -1,6 +1,9 @@
package org.codehaus.groovy.grails.validation;
import org.codehaus.groovy.grails.commons.*
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.codehaus.groovy.grails.web.binding.DataBindingUtils;
/**
@@ -11,6 +14,10 @@ class NullableConstraintTests extends GroovyTestCase {
def gcl
protected void setUp() {
+ super.setUp()
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
gcl = new GroovyClassLoader()
gcl.parseClass("""
class Project {
@@ -52,6 +59,11 @@ class ProjectVersion {
""")
}
+ protected void tearDown() {
+ super.tearDown()
+ PluginManagerHolder.pluginManager = null
+ }
+
void testNullableConstraint() {
def ga = new DefaultGrailsApplication(gcl.loadedClasses, gcl)
10 src/test/org/codehaus/groovy/grails/web/taglib/PropertyEditorTests.groovy
View
@@ -2,6 +2,9 @@ package org.codehaus.groovy.grails.web.taglib
import java.beans.PropertyEditorSupport
import org.codehaus.groovy.grails.commons.GrailsApplication
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.springframework.beans.PropertyEditorRegistrar
import org.springframework.beans.PropertyEditorRegistry
import org.springframework.beans.factory.config.ConstructorArgumentValues
@@ -14,6 +17,9 @@ import org.springframework.beans.factory.support.RootBeanDefinition
class PropertyEditorTests extends AbstractGrailsTagTests {
protected void onSetUp() {
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
gcl = new GroovyClassLoader(getClass().classLoader)
gcl.parseClass '''
import grails.persistence.*
@@ -46,6 +52,10 @@ class OneToManyPropertyEditorDomain {
'''
}
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
+ }
+
void testUseCustomPropertyEditor() {
appCtx.registerBeanDefinition("testCustomEditorRegistrar", new RootBeanDefinition(TestCustomPropertyEditorRegistrar))
19 src/test/org/codehaus/groovy/grails/web/taglib/ValidationTagLibTests.groovy
View
@@ -1,5 +1,8 @@
package org.codehaus.groovy.grails.web.taglib
+import org.codehaus.groovy.grails.plugins.GrailsPlugin
+import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
import org.springframework.context.MessageSourceResolvable
@@ -9,8 +12,11 @@ import org.springframework.validation.FieldError
class ValidationTagLibTests extends AbstractGrailsTagTests {
- void onSetUp() {
- gcl.parseClass('''
+ protected void onSetUp() {
+ PluginManagerHolder.pluginManager = new MockGrailsPluginManager()
+ PluginManagerHolder.pluginManager.registerMockPlugin([getName: { -> 'hibernate' }] as GrailsPlugin)
+
+ gcl.parseClass '''
class Book {
Long id
Long version
@@ -19,16 +25,19 @@ class Book {
Date releaseDate
BigDecimal usPrice
}
- ''')
+'''
- gcl.parseClass('''
+ gcl.parseClass '''
class Article {
Long id
Long version
String title
}
- ''')
+'''
+ }
+ protected void onTearDown() {
+ PluginManagerHolder.pluginManager = null
}
void testFieldValueWithClassAndPropertyNameLookupFromBundle() {
Please sign in to comment.
Something went wrong with that request. Please try again.