Is there way to unit test n1ql query when using java SDK

We are using n1ql queries in our application. We are using JAVA SDK for n1ql queries.
Is there way we can unit test the data access layer which has n1ql queries. We do not want to point to live instance for running junit tests.

would it be possible to run the tests with a local couchbase server that is fired up on the same machine? Couchbase is very easy to install and setup through a script.

We thought that option of installing and running couchbase server as part of application build and run unit tests pointing to that and after running junits it will remove couchbase.
Is there a article pointing to the scripts we can reuse to install and run couchbase and remove couchbase.

One more way, we were trying to see if there is any option like embedded couchbase.
Another challenge is the build might happen on windows or ubuntu or Mac, we need to maintain all 3 kind of scripts as part of build. Instead if there is something like embedded couchbase for small data set, we can cover our functional scenarios tests as part of build.

There is no embedded version of Couchbase Server that is a fully functional one that you can embark in a test case. However what you are describing is more of an integration test, so that would make sense to have an heavier test infrastructure there…
For instance a machine where the integration test suite runs that has a couchbase instance always running.

I think it is easier to have the couchbase instance in place and to create adhoc buckets for each big test case than having to uninstall the whole database after each test.

Have a look at how the integration tests where coded in the Java SDK: N1QL integration tests are here for instance (and also the CouchbaseTestContext).

There’s also a “Mock Couchbase” project, but it is just that, a mock (eg. it won’t allow you to check the syntax of your N1QL queries, if that’s what you’re after). Maybe @mnunberg can tell you a bit more about it.