Package

Source Code of MyTest

import bot.RxEventEmitter;
import org.junit.Test;
import plumbing.ILog;
import plumbing.Log;
import robocode.Event;
import robocode.WinEvent;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action1;
import rx.schedulers.Schedulers;

public class MyTest {

    private final ILog log = Log.New(MyTest.class);

    @Test
    public void it() {
        final RxEventEmitter eventsToSubscriberAdapter = new RxEventEmitter();
        Observable<Event> events = Observable.create(new Observable.OnSubscribe<Event>() {
            @Override
            public void call(final Subscriber<? super Event> subscriber) {
                eventsToSubscriberAdapter.subscribe(subscriber);
            }
        }).observeOn(Schedulers.newThread());

        events.subscribe(new Action1<Event>() {
            @Override
            public void call(Event event) {
                log.write("caught event %s", event);
            }
        });

        eventsToSubscriberAdapter.onWin(new WinEvent());

    }
}
TOP

Related Classes of MyTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.