/*
* JBoss, Home of Professional Open Source
* Copyright 2009 Red Hat Inc. and/or its affiliates and other
* contributors as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a full listing of
* individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.infinispan.config.parsing;
import org.infinispan.Cache;
import org.infinispan.manager.CacheContainer;
import org.infinispan.test.AbstractInfinispanTest;
import org.infinispan.test.TestingUtil;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
/**
* //todo re-enable test as it makes the suite hang
* @author Mircea.Markus@jboss.com
*/
@Test(groups = "functional", testName = "config.parsing.Coherence2InfinispanTransformerTest", enabled = false)
public class Coherence2InfinispanTransformerTest extends AbstractInfinispanTest {
private static final String BASE_DIR = "configs/coherence";
ConfigFilesConvertor convertor = new ConfigFilesConvertor();
public void testDefaultConfigFile() throws Exception {
testAllFile("/default-config.xml");
}
/**
* Transforms and tests the transformation of a complex file.
*/
private void testAllFile(String coherenceFileName) throws Exception {
ClassLoader existingCl = Thread.currentThread().getContextClassLoader();
CacheContainer dcm = null;
Cache<Object, Object> sampleDistributedCache2 = null;
try {
ClassLoader delegatingCl = new Jbc2InfinispanTransformerTest.TestClassLoader(existingCl);
Thread.currentThread().setContextClassLoader(delegatingCl);
String fileName = getFileName(coherenceFileName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
convertor.parse(fileName, baos, ConfigFilesConvertor.TRANSFORMATIONS.get(ConfigFilesConvertor.COHERENCE_35X), Thread.currentThread().getContextClassLoader());
dcm = TestCacheManagerFactory.fromStream(new ByteArrayInputStream(baos.toByteArray()));
Cache<Object,Object> defaultCache = dcm.getCache();
defaultCache.put("key", "value");
Cache<Object, Object> cache = dcm.getCache("dist-*");
cache.put("a","v");
} finally {
Thread.currentThread().setContextClassLoader(existingCl);
TestingUtil.killCaches(sampleDistributedCache2);
TestingUtil.killCacheManagers(dcm);
}
}
private String getFileName(String s) {
return BASE_DIR + File.separator + s;
}
}