2
* Copyright Terracotta, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package net.sf.ehcache.config.generator;
19
import java.util.ArrayList;
20
import java.util.Arrays;
21
import java.util.List;
23
import junit.framework.Assert;
24
import net.sf.ehcache.CacheManager;
26
import org.junit.Test;
28
public class DecoratedCacheConfigTest {
30
private static final List<String> ALL_CACHE_NAMES = Arrays.asList(new String[] {"noDecoratorCache", "oneDecoratorCache",
31
"oneDecoratorCacheFirst", "twoDecoratorCache", "twoDecoratorCacheSecond", "twoDecoratorCacheFirst"});
34
public void testDecoratedCacheConfig() {
35
CacheManager cm = CacheManager.newInstance(DecoratedCacheConfigTest.class.getClassLoader().getResource(
36
"ehcache-decorator-noname-test.xml"));
37
List<String> names = new ArrayList<String>(Arrays.asList(cm.getCacheNames()));
38
names.removeAll(ALL_CACHE_NAMES);
39
Assert.assertEquals("This list should be empty - " + names, 0, names.size());
40
// System.out.println("Original config: " + cm.getOriginalConfigurationText());
41
String text = cm.getActiveConfigurationText();
42
// System.out.println("Cache manager config: " + text);
43
for (String name : ALL_CACHE_NAMES) {
44
Assert.assertTrue("Config not generated for cache name: " + name, text.contains("name=\"" + name + "\""));
45
String cacheConfigTest = cm.getActiveConfigurationText(name);
46
// System.out.println("Config for cache: '"+name+"': " + cacheConfigTest);
47
Assert.assertTrue("Config not generated for cache name: " + name + ", with explicit call: ",
48
cacheConfigTest.contains("name=\"" + name + "\""));