Package org.agilewiki.jactor

Examples of org.agilewiki.jactor.MailboxFactory


import org.agilewiki.jactor.MailboxFactory;

public class JidTest extends TestCase {
    public void test1() {
        System.err.println("\nTest 1");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            Jid a = new Jid();
            a.initialize(mailboxFactory.createMailbox());
            int l = GetSerializedLength.req.send(future, a);
            System.err.println(l);
            assertEquals(l, 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here


        }
    }

    public void test2() {
        System.err.println("\nTest 2");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            Jid jid = (Jid) JidFactory.fac.newActor(factory.getMailbox(), factory);
            int l = GetSerializedLength.req.send(future, jid);
            System.err.println(l);
            assertEquals(l, 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        }
    }

    public void test3() {
        System.err.println("\nTest 3");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            Jid a = new Jid();
            a.initialize(mailboxFactory.createMailbox());
            int l = GetSerializedLength.req.send(future, a);
            AppendableBytes appendableBytes = new AppendableBytes(l);
            (new Save(appendableBytes)).send(future, a);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        }
    }

    public void test4() {
        System.err.println("\nTest 4");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            Jid a = new Jid();
            a.initialize(mailboxFactory.createMailbox());
            byte[] bytes = GetSerializedBytes.req.send(future, a);
            int l = bytes.length;
            System.err.println(l);
            assertEquals(l, 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        }
    }

    public void test5() {
        System.err.println("\nTest 5");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            Jid jid = (Jid) JidFactory.fac.newActor(factory.getMailbox(), factory);
            jid.load(new ReadableBytes(new byte[0], 0));
            int l = GetSerializedLength.req.send(future, jid);
            System.err.println(l);
            assertEquals(l, 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        }
    }

    public void test6() {
        System.err.println("\nTest 6");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            Jid jid1 = (Jid) JidFactory.fac.newActor(factory.getMailbox(), factory);
            jid1.load(new ReadableBytes(new byte[0], 0));
            Jid jid2 = (Jid) (new CopyJID(mailbox)).send(future, jid1);
            int l = GetSerializedLength.req.send(future, jid2);
            System.err.println(l);
            assertEquals(l, 0);
            boolean eq = (new IsJidEqual(jid2)).send(future, jid1);
            assertTrue(eq);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        }
    }

    public void test7() {
        System.err.println("\nTest 7");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            Jid a = new Jid();
            a.initialize(mailboxFactory.createMailbox());
            Jid b = (Jid) future.send(a, new ResolvePathname(""));
            assertEquals(a, b);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.actor.ActorJidFactory;
import org.agilewiki.jid.scalar.vlens.actor.SetActor;

public class IntegerTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            IntegerJid int1 = (IntegerJid) IntegerJidFactory.fac.newActor(factory.getMailbox(), factory);
            IntegerJid int2 = (IntegerJid) (new CopyJID()).send(future, int1);
            (new SetInteger(1)).send(future, int2);
            IntegerJid int3 = (IntegerJid) (new CopyJID()).send(future, int2);

            int sl = GetSerializedLength.req.send(future, int1);
            assertEquals(4, sl);
            sl = GetSerializedLength.req.send(future, int2);
            assertEquals(4, sl);
            sl = GetSerializedLength.req.send(future, int3);
            assertEquals(4, sl);

            int v = GetInteger.req.send(future, int1);
            assertEquals(0, v);
            v = GetInteger.req.send(future, int2);
            assertEquals(1, v);
            v = GetInteger.req.send(future, int3);
            assertEquals(1, v);

            Actor jidJid1 = ActorJidFactory.fac.newActor(factory.getMailbox(), factory);
            SetActor sjvi = new SetActor(JidFactories.INTEGER_JID_TYPE);
            sjvi.send(future, jidJid1);
            IntegerJid rpa = (IntegerJid) (new ResolvePathname("0")).send(future, jidJid1);
            v = GetInteger.req.send(future, rpa);
            assertEquals(0, v);
            (new SetInteger(-1)).send(future, rpa);
            rpa = (IntegerJid) (new ResolvePathname("0")).send(future, jidJid1);
            v = GetInteger.req.send(future, rpa);
            assertEquals(-1, v);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.actor.ActorJidFactory;
import org.agilewiki.jid.scalar.vlens.actor.SetActor;

public class BytesTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            Actor bytes1 = BytesJidFactory.fac.newActor(factory.getMailbox(), factory);
            Actor bytes2 = (new CopyJID()).send(future, bytes1);
            (new SetBytes(new byte[3])).send(future, bytes2);
            Actor bytes3 = (new CopyJID()).send(future, bytes2);

            int sl = GetSerializedLength.req.send(future, bytes1);
            assertEquals(4, sl);
            sl = GetSerializedLength.req.send(future, bytes2);
            assertEquals(7, sl);
            sl = GetSerializedLength.req.send(future, bytes3);
            assertEquals(7, sl);

            assertNull(GetBytes.req.send(future, bytes1));
            assertEquals(3, GetBytes.req.send(future, bytes2).length);
            assertEquals(3, GetBytes.req.send(future, bytes3).length);

            Actor jidJid1 = ActorJidFactory.fac.newActor(factory.getMailbox(), factory);
            SetActor sjvbs = new SetActor(JidFactories.BYTES_JID_TYPE);
            sjvbs.send(future, jidJid1);
            Actor rpa = (new ResolvePathname("0")).send(future, jidJid1);
            assertNull(GetBytes.req.send(future, rpa));
            assertTrue((new MakeBytes(new byte[0])).send(future, rpa));
            assertFalse((new MakeBytes(new byte[99])).send(future, rpa));
            rpa = (new ResolvePathname("0")).send(future, jidJid1);
            assertEquals(0, GetBytes.req.send(future, rpa).length);
            Clear.req.sendEvent(rpa);
            assertNull(GetBytes.req.send(future, rpa));

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.actor.RootJid;
import org.agilewiki.jid.scalar.vlens.actor.SetActor;

public class BigIntegerIntegerMapTest extends TestCase {
    public void test1() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setMap = new SetActor(new IntegerMapJidFactory(JidFactories.INTEGER_INTEGER_MAP_JID_TYPE, IntegerJidFactory.fac));
        setMap.send(future, root);
        IntegerMapJid map = (IntegerMapJid) GetActor.req.send(future, root);

        int i = 0;
        while (i < 10) {
            new KMake(i).send(future, map);
            i += 1;
        }

        mailboxFactory.close();
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor.MailboxFactory

Copyright © 2018 www.massapicom. 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.