ravendb / ravendb-jvm-embedded

Other
2 stars 2 forks source link

Allow setting `provider` in `ServerOptions`? #2

Open vijayakumarsuraj opened 2 years ago

vijayakumarsuraj commented 2 years ago

I ran into this issue trying to write tests using the new "exploration queries" feature from 5.3. But, because the version of ravendb-server that is bundled here doesn't support that feature, my tests fail.

Instead of waiting for a newer version of this library, I think it would be nice if I could just point it at a different ravendb-server.zip file to get my tests running.

ml054 commented 2 years ago

Hi, @vijayakumarsuraj Thank you for reporting this issue

I confirm that currently you can't override server location and use external RavenDB instance. I opened an issue so you can track progress: https://issues.hibernatingrhinos.com/issue/RDBC-557

As temporary workaround you can create your own Provider similar to this one: https://github.com/ravendb/ravendb-jvm-embedded/blob/f5939e1d5e4214bede7ac5077927a45f1e96fc78/src/test/java/net/ravendb/embedded/CopyServerProvider.java#L8

Where you can copy from custom copy.

Provider field isn't public in ServerOptions so as workaround you can use reflection:

Field providerField = serverOptions.getClass().getDeclaredField("provider");
providerField.setAccessible(true);
providerField.set(serverOptions, new MyCustomRavenDBProvider());