I have an additional datastore created, and works Ok on the UI.
But when I want to implement some testing on the store Jmix complains “Store XXXX is not registered”.
How does one register the additonal datastore on the XXXTestConfiguration class? note that I need it to pull the properties from the file (as the StoreConfiguration class does)
Which works for registering data sources with the EmbeddedDatabase.
That gave me the idea of doing something like…:
@Bean
DataSource db1DataSource(MyStoreConfiguration myStoreConfiguration) {
// instantiate the dataSource
}
But it fails miserably complaining that no beans can provide MyStoreConfiguration (which is on MyStoreConfiguration.class next to the main Configuration class.
I see I could instantiate the DataSource by hand like here but I need the Configuration class to read the properties file (I want to put in some integration tests that make sure the MSSQL database works as expected)
So… still stuck not knowing how to register my additional dataSource for testing
Why do you need another configuration class?
What about creating src/test/resources/application-test.properties file and using test profile when running tests like this:
@SpringBootTest
@ActiveProfiles("test")
public class MyTest {
//...
}
By the MyStoreConfiguration.class class I was referring to the class that Studio creates in the main package to load the datastore configuration. Not an additional class. Full class bellow (collapsed)
By doing that the application context loads without complaining about the dataStore not being registered. But then when I try to use it I get: No bean named ‘myStoreTransactionManager’ available
It is as if the aforementioned configuration class (which provides the dataStore beans) is never loaded. But when running the application it is there.
I should also mention that this is an addon module, not application module.