<commit_before>package ch.softappeal.yass.core.remote.session.test;

import ch.softappeal.yass.core.remote.Server;
import ch.softappeal.yass.core.remote.Service;
import ch.softappeal.yass.core.remote.session.ReconnectingClient;
import ch.softappeal.yass.core.remote.session.Session;
import ch.softappeal.yass.core.remote.session.SessionFactory;
import ch.softappeal.yass.transport.TransportSetup;
import ch.softappeal.yass.transport.socket.SocketExecutor;
import ch.softappeal.yass.transport.socket.SocketTransport;
import ch.softappeal.yass.tutorial.contract.ClientServices;
import ch.softappeal.yass.tutorial.contract.Config;
import ch.softappeal.yass.tutorial.contract.EchoServiceImpl;
import ch.softappeal.yass.tutorial.contract.Price;
import ch.softappeal.yass.tutorial.contract.PriceEngine;
import ch.softappeal.yass.tutorial.contract.PriceListener;
import ch.softappeal.yass.tutorial.contract.ServerServices;
import ch.softappeal.yass.tutorial.contract.instrument.InstrumentService;
import ch.softappeal.yass.tutorial.server.SocketServer;
import ch.softappeal.yass.util.Exceptions;
import ch.softappeal.yass.util.NamedThreadFactory;
import ch.softappeal.yass.util.Nullable;
import org.junit.Ignore;
import org.junit.Test;

import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class ReconnectingClientTest {

    @Ignore
    @Test public void test() throws InterruptedException {
        final ExecutorService executor = Executors.newCachedThreadPool(new NamedThreadFactory("executor", Exceptions.STD_ERR));
        try {
            new ReconnectingClient(executor, 10) {
                @Override protected void connect(final SessionFactory sessionFactory) {
                    SocketTransport.connect(
                        new TransportSetup(
                            new Server(
                                Config.METHOD_MAPPER_FACTORY,
                                new Service(ClientServices.PriceListener, new PriceListener() {
                                    @Override public void newPrices(final List<Price> prices) {
                                        final StringBuilder s = new StringBuilder();
                                        s.append(new Date() + " - newPrices - ");
                                        for (final Price price : prices) {
                                            s.append(' ').append(price.instrumentId).append(":").append(price.value);
                                        }
                                        System.out.println(s);
                                    }
                                }),
                                new Service(ClientServices.EchoService, new EchoServiceImpl())
                            ),
                            executor,
                            Config.PACKET_SERIALIZER,
                            sessionFactory
                        ),
                        new SocketExecutor(executor, Exceptions.STD_ERR),
                        Config.PATH_SERIALIZER, SocketServer.PATH,
                        SocketServer.ADDRESS
                    );
                }
                @Override protected void connectFailed(final Exception e) {
                    System.out.println("connectFailed: " + e.getMessage());
                }
                @Override protected void connected(final Session session) throws Exception {
                    System.out.println("connected ");
                    final PriceEngine priceEngine = session.invoker(ServerServices.PriceEngine).proxy();
                    final InstrumentService instrumentService = session.invoker(ServerServices.InstrumentService).proxy();
                    priceEngine.subscribe(instrumentService.getInstruments().stream().map(instrument -> instrument.id).collect(Collectors.toList()));
                }
                @Override protected void disconnected(@Nullable final Throwable throwable) {
                    System.out.println("disconnected: " + ((throwable == null) ? "<null>" : throwable.getClass()));
                }
            };
            TimeUnit.SECONDS.sleep(60L);
        } finally {
            executor.shutdownNow();
        }
    }

}<commit_msg>cosmetic<commit_after>package ch.softappeal.yass.core.remote.session.test;

import ch.softappeal.yass.core.remote.Server;
import ch.softappeal.yass.core.remote.Service;
import ch.softappeal.yass.core.remote.session.ReconnectingClient;
import ch.softappeal.yass.core.remote.session.Session;
import ch.softappeal.yass.core.remote.session.SessionFactory;
import ch.softappeal.yass.transport.TransportSetup;
import ch.softappeal.yass.transport.socket.SocketExecutor;
import ch.softappeal.yass.transport.socket.SocketTransport;
import ch.softappeal.yass.tutorial.contract.ClientServices;
import ch.softappeal.yass.tutorial.contract.Config;
import ch.softappeal.yass.tutorial.contract.EchoServiceImpl;
import ch.softappeal.yass.tutorial.contract.Price;
import ch.softappeal.yass.tutorial.contract.PriceEngine;
import ch.softappeal.yass.tutorial.contract.PriceListener;
import ch.softappeal.yass.tutorial.contract.ServerServices;
import ch.softappeal.yass.tutorial.contract.instrument.InstrumentService;
import ch.softappeal.yass.tutorial.server.SocketServer;
import ch.softappeal.yass.util.Exceptions;
import ch.softappeal.yass.util.NamedThreadFactory;
import ch.softappeal.yass.util.Nullable;
import org.junit.Ignore;
import org.junit.Test;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class ReconnectingClientTest {

    @Ignore
    @Test public void test() throws InterruptedException {
        final Server server = new Server(
            Config.METHOD_MAPPER_FACTORY,
            new Service(ClientServices.PriceListener, new PriceListener() {
                @Override public void newPrices(final List<Price> prices) {
                    final StringBuilder s = new StringBuilder();
                    s.append("newPrices - ");
                    for (final Price price : prices) {
                        s.append(' ').append(price.instrumentId).append(":").append(price.value);
                    }
                    System.out.println(s);
                }
            }),
            new Service(ClientServices.EchoService, new EchoServiceImpl())
        );
        final ExecutorService executor = Executors.newCachedThreadPool(new NamedThreadFactory("executor", Exceptions.STD_ERR));
        try {
            new ReconnectingClient(executor, 10) {
                @Override protected void connect(final SessionFactory sessionFactory) {
                    SocketTransport.connect(
                        new TransportSetup(server, executor, Config.PACKET_SERIALIZER, sessionFactory),
                        new SocketExecutor(executor, Exceptions.STD_ERR),
                        Config.PATH_SERIALIZER, SocketServer.PATH,
                        SocketServer.ADDRESS
                    );
                }
                @Override protected void connectFailed(final Exception e) {
                    System.out.println("connectFailed: " + e.getMessage());
                }
                @Override protected void connected(final Session session) throws Exception {
                    System.out.println("connected");
                    final PriceEngine priceEngine = session.invoker(ServerServices.PriceEngine).proxy();
                    final InstrumentService instrumentService = session.invoker(ServerServices.InstrumentService).proxy();
                    priceEngine.subscribe(instrumentService.getInstruments().stream().map(instrument -> instrument.id).collect(Collectors.toList()));
                }
                @Override protected void disconnected(@Nullable final Throwable throwable) {
                    System.out.println("disconnected: " + ((throwable == null) ? "<null>" : throwable.getClass()));
                }
            };
            TimeUnit.SECONDS.sleep(60L);
        } finally {
            executor.shutdownNow();
        }
    }

}
{'fraction_non_alphanumeric': 0.09402534701267351, 'fraction_numerical': 0.0009656004828002414, 'mean_word_length': 2.2354549004295197, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3876935', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2016, 'n_words': 341}