Permalink
Browse files

convert test to new style

  • Loading branch information...
1 parent c603f49 commit 4c8dd845ef8fdca8dfb9d183e4857a7d4a70a493 @jeffbrown jeffbrown committed May 23, 2012
@@ -25,6 +25,7 @@ class UrlMappings {
}
"/containsBean/$beanName"(controller: 'namespaceInspector', action: 'containsBean')
+ "/beanType/$beanName"(controller: 'namespaceInspector', action: 'beanType')
"/"(view:"/index")
"500"(view:'/error')
@@ -7,6 +7,10 @@ class NamespaceInspectorController {
render "Contains bean '${beanName}'? ${grailsApplication.mainContext.containsBean(beanName)}"
}
+ def beanType(String beanName) {
+ render "${beanName} is an instance of ${grailsApplication.mainContext.getBean(beanName).class.name}"
+ }
+
def showTableNames() {
def conn = dataSource.connection
def metaData = conn.metaData
@@ -1,42 +0,0 @@
-package namespace
-
-class NamespaceServiceFunctionalTests extends functionaltestplugin.FunctionalTestCase {
-
- void testExpectedBeanNames() {
-
- // gadget service is defined in the app
- get '/containsBean/gadgetService'
- assertStatus 200
- assertContentContains "Contains bean 'gadgetService'? true"
-
- // widget service is defined in namespace-one plugin and should have been aliased
- get '/containsBean/widgetService'
- assertStatus 200
- assertContentContains "Contains bean 'widgetService'? true"
-
- // fidget service is defined in namespace-one and namespace-two plugins so should not have been aliased
- get '/containsBean/fidgetService'
- assertStatus 200
- assertContentContains "Contains bean 'fidgetService'? false"
-
- get '/containsBean/namespaceOneFidgetService'
- assertStatus 200
- assertContentContains "Contains bean 'namespaceOneFidgetService'? true"
-
- get '/containsBean/namespaceOneGadgetService'
- assertStatus 200
- assertContentContains "Contains bean 'namespaceOneGadgetService'? true"
-
- get '/containsBean/namespaceOneWidgetService'
- assertStatus 200
- assertContentContains "Contains bean 'namespaceOneWidgetService'? true"
-
- get '/containsBean/namespaceTwoGadgetService'
- assertStatus 200
- assertContentContains "Contains bean 'namespaceTwoGadgetService'? true"
-
- get '/containsBean/namespaceTwoFidgetService'
- assertStatus 200
- assertContentContains "Contains bean 'namespaceTwoFidgetService'? true"
- }
-}
@@ -0,0 +1,122 @@
+package grails.functional.tests.services
+
+import grails.functional.tests.BaseApplicationSpec;
+
+class ServiceBeanNameSpec extends BaseApplicationSpec {
+
+ void 'Test service name defined in the app and in namespace-one plugin and in namespace-two plugin'() {
+ when:
+ go 'containsBean/gadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'gadgetService'? true"))
+
+ when:
+ go 'beanType/gadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("gadgetService is an instance of namespace.GadgetService"))
+
+ when:
+ go 'containsBean/namespaceOneGadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'namespaceOneGadgetService'? true"))
+
+ when:
+ go 'beanType/namespaceOneGadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("namespaceOneGadgetService is an instance of com.namespaceone.GadgetService"))
+
+ when:
+ go 'containsBean/namespaceTwoGadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'namespaceTwoGadgetService'? true"))
+
+ when:
+ go 'beanType/namespaceTwoGadgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("namespaceTwoGadgetService is an instance of com.namespacetwo.GadgetService"))
+ }
+
+ void 'Test service name defined in namespace-one plugin and in namespace-two plugin'() {
+ when:
+ go 'containsBean/fidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'fidgetService'? false"))
+
+ when:
+ go 'containsBean/namespaceOneFidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'namespaceOneFidgetService'? true"))
+
+ when:
+ go 'beanType/namespaceOneFidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("namespaceOneFidgetService is an instance of com.namespaceone.FidgetService"))
+
+ when:
+ go 'containsBean/namespaceTwoFidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'namespaceTwoFidgetService'? true"))
+
+ when:
+ go 'beanType/namespaceTwoFidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("namespaceTwoFidgetService is an instance of com.namespacetwo.FidgetService"))
+ }
+
+ void 'Test service name defined in namespace-one plugin'() {
+ when:
+ go 'containsBean/widgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'widgetService'? true"))
+
+ when:
+ go 'beanType/widgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("widgetService is an instance of com.namespaceone.WidgetService"))
+
+ when:
+ go 'containsBean/namespaceOneWidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("Contains bean 'namespaceOneWidgetService'? true"))
+
+ when:
+ go 'beanType/namespaceOneWidgetService'
+
+ then:
+ statusCode == 200
+ $(text: contains("namespaceOneWidgetService is an instance of com.namespaceone.WidgetService"))
+ }
+
+ @Override
+ String getApplication() {
+ 'kitchen_sink_app'
+ }
+}

0 comments on commit 4c8dd84

Please sign in to comment.