<commit_before>/*
 * (C) Copyright 2008-2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy
 * of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */


package org.jaffre.client;


import java.net.UnknownHostException;

import org.example.services.SomeTestMethods;
import org.example.services.SomeTestMethodsService;
import org.jaffre.client.spi.SSLSocketJaffreClient;
import org.jaffre.server.JaffreServer;
import org.jaffre.server.spi.DefaultJaffreServer;
import org.jaffre.server.spi.SSLSocketJaffreConnector;
import org.test.JaffreTestCaseBase;
import org.test.TestPort;


/**
 * @author <NAME>
 */
public final class SSLClientTestCase extends JaffreTestCaseBase
{
	private SSLSocketJaffreConnector m_connector;

	private SSLSocketJaffreClient m_client;


	@Override
	public void setUp() throws Exception
	{
	}


	@Override
	public void tearDown() throws Exception
	{
		m_connector.stop();
		m_client.dispose();
	}


	private void setUpClientAndServer(int p_iPort)
		throws UnknownHostException, InterruptedException
	{
		// server
		final JaffreServer             l_server;
		final SSLSocketJaffreConnector l_connector;

		l_server = new DefaultJaffreServer();

		l_server.registerInterface(new SomeTestMethodsService());

		l_connector = new SSLSocketJaffreConnector();

		l_connector.setServer(l_server);
		l_connector.setBindingAddress("localhost");
		l_connector.setPort(p_iPort);
		l_connector.setKeyStore("resources/keystore");
		l_connector.setKeyStoreType("JCEKS");
		l_connector.setKeyStorePassword("<PASSWORD>");
		l_connector.setTrustStore("resources/truststore");
		l_connector.setTrustStoreType("JCEKS");
		l_connector.setTrustStorePassword("<PASSWORD>");

		l_connector.start();

		m_connector = l_connector;

		Thread.sleep(500L);

		// client
		final SSLSocketJaffreClient l_client;

		l_client = new SSLSocketJaffreClient();

		l_client.setServiceAddress("localhost");
		l_client.setServicePort(p_iPort);
		l_client.setKeyStoreType("JCEKS");
		l_client.setKeyStore("resources/keystore");
		l_client.setKeyStorePassword("<PASSWORD>");
		l_client.setTrustStoreType("JCEKS");
		l_client.setTrustStore("resources/truststore");
		l_client.setTrustStorePassword("<PASSWORD>");

		m_client = l_client;
	}


	public void testMultiDispose() throws Exception
	{
		setUpClientAndServer(TestPort.getNext());

		m_client.dispose();
		m_client.dispose();
		m_client.dispose();
	}


	public void testCallThenClientDispose() throws Exception
	{
		final SomeTestMethods l_interface;
		final String          l_strIn;
		final String          l_strOut;

		setUpClientAndServer(TestPort.getNext());

		l_interface = m_client.getProxy(SomeTestMethods.class);

		l_strIn  = "The rain in spain stays mainly in the plain.";
		l_strOut = l_interface.echo(l_strIn);

		assert(l_strIn.equals(l_strOut));

		m_client.dispose();
	}


	public void testCallNoKeepAlive() throws Exception
	{
		final SomeTestMethods l_interface;
		final String          l_strIn;
		final String          l_strOut;

		setUpClientAndServer(TestPort.getNext());

		m_client.setKeepAlive(false);

		l_interface = m_client.getProxy(SomeTestMethods.class);

		l_strIn  = "The rain in spain stays mainly in the plain.";
		l_strOut = l_interface.echo(l_strIn);

		assert(l_strIn.equals(l_strOut));

		m_client.dispose();
	}
}<commit_msg>Fix assertions<commit_after>/*
 * (C) Copyright 2008-2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy
 * of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */


package org.jaffre.client;


import java.net.UnknownHostException;

import org.example.services.SomeTestMethods;
import org.example.services.SomeTestMethodsService;
import org.jaffre.client.spi.SSLSocketJaffreClient;
import org.jaffre.server.JaffreServer;
import org.jaffre.server.spi.DefaultJaffreServer;
import org.jaffre.server.spi.SSLSocketJaffreConnector;
import org.test.JaffreTestCaseBase;
import org.test.TestPort;


/**
 * @author <NAME>
 */
public final class SSLClientTestCase extends JaffreTestCaseBase
{
	private SSLSocketJaffreConnector m_connector;

	private SSLSocketJaffreClient m_client;


	@Override
	public void setUp() throws Exception
	{
	}


	@Override
	public void tearDown() throws Exception
	{
		m_connector.stop();
		m_client.dispose();
	}


	private void setUpClientAndServer(int p_iPort)
		throws UnknownHostException, InterruptedException
	{
		// server
		final JaffreServer             l_server;
		final SSLSocketJaffreConnector l_connector;

		l_server = new DefaultJaffreServer();

		l_server.registerInterface(new SomeTestMethodsService());

		l_connector = new SSLSocketJaffreConnector();

		l_connector.setServer(l_server);
		l_connector.setBindingAddress("localhost");
		l_connector.setPort(p_iPort);
		l_connector.setKeyStore("resources/keystore");
		l_connector.setKeyStoreType("JCEKS");
		l_connector.setKeyStorePassword("<PASSWORD>");
		l_connector.setTrustStore("resources/truststore");
		l_connector.setTrustStoreType("JCEKS");
		l_connector.setTrustStorePassword("<PASSWORD>");

		l_connector.start();

		m_connector = l_connector;

		Thread.sleep(500L);

		// client
		final SSLSocketJaffreClient l_client;

		l_client = new SSLSocketJaffreClient();

		l_client.setServiceAddress("localhost");
		l_client.setServicePort(p_iPort);
		l_client.setKeyStoreType("JCEKS");
		l_client.setKeyStore("resources/keystore");
		l_client.setKeyStorePassword("<PASSWORD>");
		l_client.setTrustStoreType("JCEKS");
		l_client.setTrustStore("resources/truststore");
		l_client.setTrustStorePassword("<PASSWORD>");

		m_client = l_client;
	}


	public void testMultiDispose() throws Exception
	{
		setUpClientAndServer(TestPort.getNext());

		m_client.dispose();
		m_client.dispose();
		m_client.dispose();
	}


	public void testCallThenClientDispose() throws Exception
	{
		final SomeTestMethods l_interface;
		final String          l_strIn;
		final String          l_strOut;

		setUpClientAndServer(TestPort.getNext());

		l_interface = m_client.getProxy(SomeTestMethods.class);

		l_strIn  = "The rain in spain stays mainly in the plain.";
		l_strOut = l_interface.echo(l_strIn);

		assertEquals(l_strIn, l_strOut);

		m_client.dispose();
	}


	public void testCallNoKeepAlive() throws Exception
	{
		final SomeTestMethods l_interface;
		final String          l_strIn;
		final String          l_strOut;

		setUpClientAndServer(TestPort.getNext());

		m_client.setKeepAlive(false);

		l_interface = m_client.getProxy(SomeTestMethods.class);

		l_strIn  = "The rain in spain stays mainly in the plain.";
		l_strOut = l_interface.echo(l_strIn);

		assertEquals(l_strIn, l_strOut);

		m_client.dispose();
	}
}
{'fraction_non_alphanumeric': 0.09855226457696906, 'fraction_numerical': 0.0039845929074246245, 'mean_word_length': 4.864485981308412, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7656064', 'n_tokens_mistral': 2599, 'n_tokens_neox': 2372, 'n_words': 513}