////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

In general, code that is marked with cache related annotations can be unit
tested without doing anything special to deal with caching.  The caching just
won't be enabled and the code in cached methods will be executed each time the
method is invoked.

[source,groovy]
----
include::{cacheExampleSourceDir}/grails-app/services/com/demo/BasicCachingService.groovy[tags=get_data,indent=0]
----

[source,groovy]
----
include::{cacheExampleSourceDir}/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy[tags=basic_declaration]
----

In order for caching to be active when the unit test is running, cache manager
and key generator beans must be added to the Spring application context by the
test.

[source,groovy]
----
include::{cacheExampleSourceDir}/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy[tags=basic_declaration]
----
