~ubuntu-branches/ubuntu/trusty/ehcache/trusty

« back to all changes in this revision

Viewing changes to src/test/java/net/sf/ehcache/config/generator/DecoratedCacheConfigTest.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-05-06 14:53:07 UTC
  • mfrom: (1.1.7) (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130506145307-v5bhw5yu70re00l3
Tags: 2.6.7-1
* Team upload.
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *  Copyright Terracotta, Inc.
 
3
 *
 
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
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
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.
 
15
 */
 
16
 
 
17
package net.sf.ehcache.config.generator;
 
18
 
 
19
import java.util.ArrayList;
 
20
import java.util.Arrays;
 
21
import java.util.List;
 
22
 
 
23
import junit.framework.Assert;
 
24
import net.sf.ehcache.CacheManager;
 
25
 
 
26
import org.junit.Test;
 
27
 
 
28
public class DecoratedCacheConfigTest {
 
29
 
 
30
    private static final List<String> ALL_CACHE_NAMES = Arrays.asList(new String[] {"noDecoratorCache", "oneDecoratorCache",
 
31
            "oneDecoratorCacheFirst", "twoDecoratorCache", "twoDecoratorCacheSecond", "twoDecoratorCacheFirst"});
 
32
 
 
33
    @Test
 
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 + "\""));
 
49
        }
 
50
    }
 
51
}