<commit_before>package alma.contLogTest.TestLogLevelsCompImpl;

import java.util.Arrays;
import java.util.List;

import junit.framework.Assert;
import junit.framework.AssertionFailedError;

import si.ijs.maci.Administrator;
import si.ijs.maci.AdministratorPOATie;
import si.ijs.maci.ComponentInfo;
import si.ijs.maci.ContainerInfo;

import alma.JavaContainerError.wrappers.AcsJContainerEx;
import alma.Logging.LoggingConfigurable;
import alma.Logging.LoggingConfigurableHelper;
import alma.acs.container.AcsManagerProxy;
import alma.acs.container.ContainerServices;
import alma.acs.logging.AcsLogger;
import alma.maciErrType.NoPermissionEx;


/**
 * Provides container access to JUnit tests. 
 * Uses JUnit asserts from {@link Assert} which means that runtime exceptions such as 
 * {@link AssertionFailedError} may be thrown.
 * 
 * @author hsommer
 */
public class ContainerTestUtil
{
	private final ContainerServices containerServices;
	private final AcsLogger logger;
	private final AcsManagerProxy managerProxy;
	private AcsManagerProxy adminProxy;

	
	/**
	 * The constructor only stores the parameters.
	 * You must call {@link #loginToManager()} explicitly before using the other methods.
	 * Make sure to call {@link #logoutFromManager()} when done. 
	 */
	public ContainerTestUtil(ContainerServices cs, AcsManagerProxy managerProxy) {
		Assert.assertNotNull(cs);
		Assert.assertNotNull(managerProxy);
		this.containerServices = cs;
		this.logger = cs.getLogger();
		this.managerProxy = managerProxy;
	}	
	
	public void loginToManager() throws AcsJContainerEx {
		if (adminProxy == null) {
	    	AdministratorPOATie adminpoa = new AdministratorPOATie(new ManagerAdminClient(containerServices.getName(), logger)); 
			Administrator adminCorbaObj = adminpoa._this(containerServices.getAdvancedContainerServices().getORB());
			
			adminProxy = managerProxy.createInstance();
			adminProxy.loginToManager(adminCorbaObj, false);
			int adminManagerHandle = adminProxy.getManagerHandle();
			Assert.assertTrue(adminManagerHandle > 0);
		}
	}
	
	public void logoutFromManager() {
		if (adminProxy != null) {
			adminProxy.logoutFromManager();
			adminProxy = null;<commit_msg>loginToManager takes a integer instead of a boolean<commit_after>package alma.contLogTest.TestLogLevelsCompImpl;

import java.util.Arrays;
import java.util.List;

import junit.framework.Assert;
import junit.framework.AssertionFailedError;

import si.ijs.maci.Administrator;
import si.ijs.maci.AdministratorPOATie;
import si.ijs.maci.ComponentInfo;
import si.ijs.maci.ContainerInfo;

import alma.JavaContainerError.wrappers.AcsJContainerEx;
import alma.Logging.LoggingConfigurable;
import alma.Logging.LoggingConfigurableHelper;
import alma.acs.container.AcsManagerProxy;
import alma.acs.container.ContainerServices;
import alma.acs.logging.AcsLogger;
import alma.maciErrType.NoPermissionEx;


/**
 * Provides container access to JUnit tests. 
 * Uses JUnit asserts from {@link Assert} which means that runtime exceptions such as 
 * {@link AssertionFailedError} may be thrown.
 * 
 * @author hsommer
 */
public class ContainerTestUtil
{
	private final ContainerServices containerServices;
	private final AcsLogger logger;
	private final AcsManagerProxy managerProxy;
	private AcsManagerProxy adminProxy;

	
	/**
	 * The constructor only stores the parameters.
	 * You must call {@link #loginToManager()} explicitly before using the other methods.
	 * Make sure to call {@link #logoutFromManager()} when done. 
	 */
	public ContainerTestUtil(ContainerServices cs, AcsManagerProxy managerProxy) {
		Assert.assertNotNull(cs);
		Assert.assertNotNull(managerProxy);
		this.containerServices = cs;
		this.logger = cs.getLogger();
		this.managerProxy = managerProxy;
	}	
	
	public void loginToManager() throws AcsJContainerEx {
		if (adminProxy == null) {
	    	AdministratorPOATie adminpoa = new AdministratorPOATie(new ManagerAdminClient(containerServices.getName(), logger)); 
			Administrator adminCorbaObj = adminpoa._this(containerServices.getAdvancedContainerServices().getORB());
			
			adminProxy = managerProxy.createInstance();
			adminProxy.loginToManager(adminCorbaObj, 1);
			int adminManagerHandle = adminProxy.getManagerHandle();
			Assert.assertTrue(adminManagerHandle > 0);
		}
	}
	
	public void logoutFromManager() {
		if (adminProxy != null) {
			adminProxy.logoutFromManager();
			adminProxy = null;
{'fraction_non_alphanumeric': 0.08925318761384335, 'fraction_numerical': 0.0006830601092896175, 'mean_word_length': 5.4985207100591715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '6083409', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1266, 'n_words': 304}