<commit_before>package fi.csc.microarray.messaging;

import org.apache.log4j.Logger;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;

import fi.csc.microarray.DemoAuthenticationRequestListener;
import fi.csc.microarray.config.DirectoryLayout;
import fi.csc.microarray.messaging.auth.SimpleAuthenticationRequestListener;

public abstract class MessagingTestBase {
	/**
	 * Logger for this class
	 */
	private static Logger logger;
	
	protected MessagingEndpoint endpoint;
	protected SimpleAuthenticationRequestListener authenticationListener;
	private String configURL;
	private String username;
	private String password;
	
	public MessagingTestBase() {
	}
	
	public MessagingTestBase(String username, String password) {
		this.username = username;
		this.password = password;
	}

	public MessagingTestBase(String username, String password, String configURL) {
		this.configURL = configURL;
		this.username = username;
		this.password = password;
	}

	
	
	@BeforeSuite
	protected void setUp() throws Exception {
		
		// use demo listener if no username or password
		System.out.println("setting up authentication listener");
		if (this.username == null || this.password == null) {
			this.authenticationListener = new DemoAuthenticationRequestListener();
		} else {
			this.authenticationListener = new SimpleAuthenticationRequestListener(this.username, this.password);
		}
		
		// use default config if no config url
		System.out.println("initialising client");
		if (configURL == null) {
			DirectoryLayout.initialiseSimpleLayout().getConfiguration();
		} else {
			try {
				DirectoryLayout.initialiseClientLayout(configURL);
			} catch (IllegalStateException e) {
				// ignore
			}
		}
		
		System.out.println("setting up messaging");
		logger = Logger.getLogger(MessagingTestBase.class);
		logger.debug("loaded config");
		endpoint =  new MessagingEndpoint(new NodeBase() {
			public String getName() {
				return "test";
			}
		});
		logger.debug("endpoint created");
		endpoint.setAuthenticationListener(authenticationListener);
	}
	
	@AfterSuite
	protected void tearDown() throws Exception {
		System.out.println("closing messaging endpoint");
		endpoint.close();
		endpoint = null;
	}

}<commit_msg>logging<commit_after>package fi.csc.microarray.messaging;

import org.apache.log4j.Logger;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;

import fi.csc.microarray.DemoAuthenticationRequestListener;
import fi.csc.microarray.config.DirectoryLayout;
import fi.csc.microarray.messaging.auth.SimpleAuthenticationRequestListener;

public abstract class MessagingTestBase {
	/**
	 * Logger for this class
	 */
	private static Logger logger;
	
	protected MessagingEndpoint endpoint;
	protected SimpleAuthenticationRequestListener authenticationListener;
	private String configURL;
	private String username;
	private String password;
	
	public MessagingTestBase() {
	}
	
	public MessagingTestBase(String username, String password) {
		this.username = username;
		this.password = password;
	}

	public MessagingTestBase(String username, String password, String configURL) {
		this.configURL = configURL;
		this.username = username;
		this.password = password;
	}

	
	
	@BeforeSuite
	protected void setUp() throws Exception {
		
		// use demo listener if no username or password
		System.out.println("setting up authentication listener");
		if (this.username == null || this.password == null) {
			this.authenticationListener = new DemoAuthenticationRequestListener();
		} else {
			this.authenticationListener = new SimpleAuthenticationRequestListener(this.username, this.password);
		}
		
		// use default config if no config url
		System.out.println("initialising client");
		if (configURL == null) {
			DirectoryLayout.initialiseSimpleLayout().getConfiguration();
		} else {
			try {
				DirectoryLayout.initialiseClientLayout(configURL);
			} catch (IllegalStateException e) {
				// ignore
			}
		}
		
		System.out.println("setting up messaging");
		logger = Logger.getLogger(MessagingTestBase.class);
		logger.debug("loaded config");
		endpoint =  new MessagingEndpoint(new NodeBase() {
			public String getName() {
				return "test";
			}
		});
		System.out.println("endpoint created");
		endpoint.setAuthenticationListener(authenticationListener);
	}
	
	@AfterSuite
	protected void tearDown() throws Exception {
		System.out.println("closing messaging endpoint");
		endpoint.close();
		endpoint = null;
	}

}
{'fraction_non_alphanumeric': 0.09688195991091314, 'fraction_numerical': 0.00044543429844097997, 'mean_word_length': 4.728316326530612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5527032', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1199, 'n_words': 294}