<commit_before>/*
 * Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
 */
package org.ligoj.bootstrap.resource.system.cache;

import javax.cache.CacheManager;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import com.hazelcast.config.CacheConfig;

/**
 * Test class of {@link MergedHazelCacheManagerFactoryBean}
 */
public class MergedHazelCacheManagerFactoryBeanTest {

	private MergedHazelCacheManagerFactoryBean bean;
	private String oldPolicy;

	@BeforeEach
	public void prepare() {
		bean = new MergedHazelCacheManagerFactoryBean();
		oldPolicy = System.getProperty("java.security.policy");
	}

	private void clean() {
		if (oldPolicy == null) {
			oldPolicy = System.getProperty("java.security.policy");
		} else {
			System.clearProperty("java.security.policy");
		}
	}

	@Test
	public void destroy() {
		bean.cacheManager = Mockito.mock(CacheManager.class);
		bean.destroy();
	}

	@Test
	public void getObjectTypeNotInitialized() {
		// JHCache instance, not Spring
		Assertions.assertEquals(CacheManager.class, bean.getObjectType());
	}

	@Test
	public void getObjectType() {<commit_msg>Fix incorrect cleanup of "java.security.policy" in tests<commit_after>/*
 * Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
 */
package org.ligoj.bootstrap.resource.system.cache;

import javax.cache.CacheManager;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import com.hazelcast.config.CacheConfig;

/**
 * Test class of {@link MergedHazelCacheManagerFactoryBean}
 */
public class MergedHazelCacheManagerFactoryBeanTest {

	private MergedHazelCacheManagerFactoryBean bean;
	private String oldPolicy;

	@BeforeEach
	public void prepare() {
		bean = new MergedHazelCacheManagerFactoryBean();
		oldPolicy = System.getProperty("java.security.policy");
	}

	private void clean() {
		if (oldPolicy == null) {
			System.clearProperty("java.security.policy");
		} else {
			System.setProperty("java.security.policy", oldPolicy);
		}
	}

	@Test
	public void destroy() {
		bean.cacheManager = Mockito.mock(CacheManager.class);
		bean.destroy();
	}

	@Test
	public void getObjectTypeNotInitialized() {
		// JHCache instance, not Spring
		Assertions.assertEquals(CacheManager.class, bean.getObjectType());
	}

	@Test
	public void getObjectType() {
{'fraction_non_alphanumeric': 0.11935483870967742, 'fraction_numerical': 0.0, 'mean_word_length': 4.9639423076923075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7255964', 'n_tokens_mistral': 814, 'n_tokens_neox': 788, 'n_words': 152}