<commit_before><commit_msg>Added test case for WebContextRegistry<commit_after>/*******************************************************************************
 * Copyright (c) 2012 by committers of lunifera.org

 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributor:
 * 		<NAME> - initial implementation
 * 
 *******************************************************************************/
package org.lunifera.runtime.web.common.tests;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.lunifera.runtime.web.common.IWebContext;
import org.lunifera.runtime.web.common.IWebContextRegistry;

public class WebContextRegistryTest {

	protected boolean called;

	@Before
	public void setup() {

	}

	/**
	 * Test creating the context and its disposal.
	 */
	@Test
	public void test_createAndDisposeContext() {
		IWebContextRegistry registry = ContextRegistryHelper.registry;
		Assert.assertEquals(0, registry.size());
		IWebContext context = registry.createContext("user1");
		Assert.assertEquals(1, registry.size());
		IWebContext context2 = registry.createContext("user1");
		Assert.assertEquals(2, registry.size());
		context.dispose();
		Assert.assertEquals(1, registry.size());
		context2.dispose();
		Assert.assertEquals(0, registry.size());
	}

	/**
	 * Test async exeucte.
	 */
	@Test
	public void test_getContext() {
		IWebContextRegistry registry = ContextRegistryHelper.registry;
		IWebContext context = registry.createContext("user1");
		IWebContext context2 = registry.createContext("user1");

		Assert.assertSame(context, registry.getContext(context.getId()));
		Assert.assertNotSame(context, registry.getContext(context2.getId()));
	}
}
{'fraction_non_alphanumeric': 0.18799368088467613, 'fraction_numerical': 0.011058451816745656, 'mean_word_length': 5.551724137931035, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4829485', 'n_tokens_mistral': 547, 'n_tokens_neox': 507, 'n_words': 120}