Overriding Grails datasource configuration during Integration testWhat's the difference between unit tests and integration tests?Integration test for a Grails 1.1 app not working in Grails 2.0.3. Could it be a GORM configuration issue?How do you create a sample datasource for a Grails integration test?Cannot get property 'config' on null object - Grails Service Spock TestingEnvironment Specific Grails Service ConfigurationGrails 2.3.5. Base URL changes in functional tests when using “test-app” as opposed to “test-app functional:”Grails doesn't allow GORM in setupSpec() of Spock, but setup() happens after whereDefine optional (multiple) datasource in GrailsGrails 3.0.9: Spock integration tests' @Rollback annotation is not workingA component required a bean named 'dataSource_dbCreate' that could not be found

Draw simple lines in Inkscape

What are these boxed doors outside store fronts in New York?

If Manufacturer spice model and Datasheet give different values which should I use?

I see my dog run

Non-Jewish family in an Orthodox Jewish Wedding

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

Closed subgroups of abelian groups

What do you call a Matrix-like slowdown and camera movement effect?

Why CLRS example on residual networks does not follows its formula?

A function which translates a sentence to title-case

How can I fix this gap between bookcases I made?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Is it possible to do 50 km distance without any previous training?

"which" command doesn't work / path of Safari?

How to make payment on the internet without leaving a money trail?

Example of a relative pronoun

What defenses are there against being summoned by the Gate spell?

Why is the design of haulage companies so “special”?

How do you conduct xenoanthropology after first contact?

Can a German sentence have two subjects?

Calculus Optimization - Point on graph closest to given point

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

declaring a variable twice in IIFE



Overriding Grails datasource configuration during Integration test


What's the difference between unit tests and integration tests?Integration test for a Grails 1.1 app not working in Grails 2.0.3. Could it be a GORM configuration issue?How do you create a sample datasource for a Grails integration test?Cannot get property 'config' on null object - Grails Service Spock TestingEnvironment Specific Grails Service ConfigurationGrails 2.3.5. Base URL changes in functional tests when using “test-app” as opposed to “test-app functional:”Grails doesn't allow GORM in setupSpec() of Spock, but setup() happens after whereDefine optional (multiple) datasource in GrailsGrails 3.0.9: Spock integration tests' @Rollback annotation is not workingA component required a bean named 'dataSource_dbCreate' that could not be found






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am writing an integration test for a Grails application. The test creates a database schema and a db user dynamically for the test and tear it down at the end.



I would like to apply the newly created values to the application under test instead of the ones configured in application.yaml.



  1. I tried injecting grailsApplication, but it is null in Spock integration test.


  2. defaultGrailsApp I am able to change the props, but the application doesn't take the new properties

My test looks like this (psedo code) :



@Integration
@Rollback
class MyServiceSpec extends Specification {

@Autowired
MyService mySvc

def setupSpec()
//create db user
// create db schema
//grant permissions

def cleanupSpec()
// delete test user
// delete schema


void 'Test MyService'()
when:
mySvc.createReport(job)

then:
// check db for valid state



Is there a way to override application.yml properties programmatically in Grails and override datasource configuration?



UPDATE 1:
Would it be possible to add a Spy to dataSource so I can provide my own implementation at run time? I'm a bit new to Grails/Groovy , does anybody have source code familiarity to figure this out?










share|improve this question
























  • I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

    – droggo
    Mar 14 at 7:53

















0















I am writing an integration test for a Grails application. The test creates a database schema and a db user dynamically for the test and tear it down at the end.



I would like to apply the newly created values to the application under test instead of the ones configured in application.yaml.



  1. I tried injecting grailsApplication, but it is null in Spock integration test.


  2. defaultGrailsApp I am able to change the props, but the application doesn't take the new properties

My test looks like this (psedo code) :



@Integration
@Rollback
class MyServiceSpec extends Specification {

@Autowired
MyService mySvc

def setupSpec()
//create db user
// create db schema
//grant permissions

def cleanupSpec()
// delete test user
// delete schema


void 'Test MyService'()
when:
mySvc.createReport(job)

then:
// check db for valid state



Is there a way to override application.yml properties programmatically in Grails and override datasource configuration?



UPDATE 1:
Would it be possible to add a Spy to dataSource so I can provide my own implementation at run time? I'm a bit new to Grails/Groovy , does anybody have source code familiarity to figure this out?










share|improve this question
























  • I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

    – droggo
    Mar 14 at 7:53













0












0








0








I am writing an integration test for a Grails application. The test creates a database schema and a db user dynamically for the test and tear it down at the end.



I would like to apply the newly created values to the application under test instead of the ones configured in application.yaml.



  1. I tried injecting grailsApplication, but it is null in Spock integration test.


  2. defaultGrailsApp I am able to change the props, but the application doesn't take the new properties

My test looks like this (psedo code) :



@Integration
@Rollback
class MyServiceSpec extends Specification {

@Autowired
MyService mySvc

def setupSpec()
//create db user
// create db schema
//grant permissions

def cleanupSpec()
// delete test user
// delete schema


void 'Test MyService'()
when:
mySvc.createReport(job)

then:
// check db for valid state



Is there a way to override application.yml properties programmatically in Grails and override datasource configuration?



UPDATE 1:
Would it be possible to add a Spy to dataSource so I can provide my own implementation at run time? I'm a bit new to Grails/Groovy , does anybody have source code familiarity to figure this out?










share|improve this question
















I am writing an integration test for a Grails application. The test creates a database schema and a db user dynamically for the test and tear it down at the end.



I would like to apply the newly created values to the application under test instead of the ones configured in application.yaml.



  1. I tried injecting grailsApplication, but it is null in Spock integration test.


  2. defaultGrailsApp I am able to change the props, but the application doesn't take the new properties

My test looks like this (psedo code) :



@Integration
@Rollback
class MyServiceSpec extends Specification {

@Autowired
MyService mySvc

def setupSpec()
//create db user
// create db schema
//grant permissions

def cleanupSpec()
// delete test user
// delete schema


void 'Test MyService'()
when:
mySvc.createReport(job)

then:
// check db for valid state



Is there a way to override application.yml properties programmatically in Grails and override datasource configuration?



UPDATE 1:
Would it be possible to add a Spy to dataSource so I can provide my own implementation at run time? I'm a bit new to Grails/Groovy , does anybody have source code familiarity to figure this out?







grails groovy integration-testing spock spy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 11 at 14:58







JavaHead

















asked Mar 9 at 3:51









JavaHeadJavaHead

384112




384112












  • I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

    – droggo
    Mar 14 at 7:53

















  • I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

    – droggo
    Mar 14 at 7:53
















I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

– droggo
Mar 14 at 7:53





I think this solves your issue: grails.1312388.n4.nabble.com/… . Use environmental variables or use application.groovy where you can set values using groovy

– droggo
Mar 14 at 7:53












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073813%2foverriding-grails-datasource-configuration-during-integration-test%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073813%2foverriding-grails-datasource-configuration-during-integration-test%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme