Package limelight.events

Examples of limelight.events.EventHandlerTest$SimpleEvent


        SimpleEvent[] earr = null;       
        if (method == 'e') {           
            earr = new SimpleEvent[totalInv];
            for (int i = 0; i < earr.length; i++) {
                earr[i] = new SimpleEvent();
                earr[i].setSequenceNumber(i);
                earr[i].setMessage("Message #"+i);
                earr[i].setTimestamp(Math.sqrt(i));
            }
        }

        BenchClient client = new BenchClient(td.serverLocation);

//        System.out.println("invoking " + N + (smokeTest ? " (SMOKE TEST)" : "")
//                + " times for test " + method + " arraysSize=" + td.arrSizeToSend
//                + " " + (new Date()));
        //boolean validate = true;
        long start = System.currentTimeMillis();
        for (int count = 0; count < N; count++) {
            int off = count * arrSize;
            //String arg = "echo"+i;
            if (method == 'v') {
                if (direction == 'e') {
                    client.echoVoid();
                } else if (direction == 'r' || direction == 's') {
                    throw new RuntimeException("usupported direction " + direction + " for void method");
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
            } else if (method == 'b') {
              System.arraycopy(barr, off, ba, 0, ba.length);
                byte[] uba = null;
                int ulen = -1;
                if (direction == 'e') {
                    uba = client.echoBase64(ba);
                } else if (direction == 'r') {
                    ulen = client.receiveBase64(ba);
                    if (ulen != ba.length) fail(method2s(direction, method) + " returned wrong size");
                } else if (direction == 's') {
                    uba = client.sendBase64(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force
                    if (direction == 's') off = 0;
                    if (uba == null) fail(method2s(direction, method) + " byte array response was null");
                    if (uba.length != ba.length) {
                        fail(method2s(direction, method) + " byte array had wrong size " + uba.length
                                + " (expected " + ba.length + ")");
                    }
                    for (int i = 0; i < ba.length; i++) {
                        if (uba[i] != barr[i + off]) {
                            fail("byte array response had wrong content");
                        }
                    }
                }
            } else if (method == 'd') {
              ArrayList<Double> da = new ArrayList<Double>();              
              new Util<Double>().copyList(darr, off, da, td.arrSizeToSend);             
                List<Double> uda = null;
                int dlen = -1;
                if (direction == 'e') {
                    uda = client.echoDoubles(da);
                } else if (direction == 'r') {
                    dlen = client.receiveDoubles(da);
                    if (dlen != da.size()) fail("receive double array returned wrong size");
                } else if (direction == 's') {
                    uda = client.sendDoubles(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uda == null) fail(method2s(direction, method) + " double array response was null");
                    if (uda.size() != da.size()) {
                        fail(method2s(direction, method) + " double array had wrong size " + uda.size()
                                + " (expected " + da.size() + ")");
                    }
                    for (int i = 0; i < uda.size(); i++) {
                        if (uda.get(i) != darr[i + off]) {
                            fail(method2s(direction, method) + " double array response had wrong content");
                        }
                    }
                }
            } else if (method == 'i') {
              ArrayList<Integer> ia = new ArrayList<Integer>();
              new Util<Integer>().copyList(iarr, off, ia, td.arrSizeToSend);
                List<Integer> uia = null;
                int ulen = -1;
                if (direction == 'e') {
                    uia = client.echoInts(ia);
                } else if (direction == 'r') {
                    ulen = client.receiveInts(ia);
                    if (ulen != ia.size()) {
                        fail(method2s(direction, method) + " receive byte array returned wrong size");
                    }
                } else if (direction == 's') {
                    uia = client.sendInts(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uia == null) fail(method2s(direction, method) + " int array response was null");
                    if (uia.size() != ia.size()) {
                        fail(method2s(direction, method) + " int array had wrong size " + uia.size()
                                + " (expected " + ia.size() + ")");
                    }
                    for (int i = 0; i < uia.size(); i++) {
                        if (uia.get(i) != iarr[i + off]) {
                            fail(method2s(direction, method) + " int array response had wrong content");
                        }
                    }
                }
            } else if (method == 's') {
              ArrayList<String> sa = new ArrayList<String>();
              new Util<String>().copyList(sarr, off, sa, td.arrSizeToSend);
                List<String> usa = null;
                int slen = -1;
                if (direction == 'e') {
                    usa = client.echoStrings(sa);
                } else if (direction == 'r') {
                    slen = client.receiveStrings(sa);
                    if (slen != sa.size())
                        fail(method2s(direction, method) + " receive string array returned wrong size");
                } else if (direction == 's') {
                    usa = client.sendStrings(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (usa == null) fail(method2s(direction, method) + " string array response was null");
                    if (usa.size() != sa.size()) {
                        fail(method2s(direction, method) + " string array had wrong size " + usa.size()
                                + " (expected " + sa.size() + ")");
                    }
                    for (int i = 0; i < usa.size(); i++) {
                        String s1 = usa.get(i);
                        String s2 = sarr[i + off];
                        if (!s1.equals(s2)) {
                            fail(method2s(direction, method) + " string array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
                }
            } else if (method == 'm') {
              ArrayList<MeshInterfaceObject> ma = new ArrayList<MeshInterfaceObject>();
              new Util<MeshInterfaceObject>().copyList(marr, off, ma, td.arrSizeToSend);
                List<MeshInterfaceObject> uma = null;
                int slen = -1;
                if (direction == 'e') {
                    uma = client.echoMeshInterfaceObjects(ma);
                } else if (direction == 'r') {
                    slen = client.receiveMeshInterfaceObjects(ma);
                    if (slen != ma.size())
                        fail(method2s(direction, method) + " receive MeshInterfaceObject array returned wrong size");
                } else if (direction == 's') {
                    uma = client.sendMeshInterfaceObjects(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uma == null) fail(method2s(direction, method) + " MeshInterfaceObject array response was null");
                    if (uma.size() != ma.size()) {
                        fail(method2s(direction, method) + " string MeshInterfaceObject had wrong size " + uma.size()
                                + " (expected " + ma.size() + ")");
                    }
                    for (int i = 0; i < uma.size(); i++) {
                        MeshInterfaceObject s1 = uma.get(i);
                        MeshInterfaceObject s2 = marr[i + off];
                        if (!toString(s1).equals(toString(s2))) {
                            fail(method2s(direction, method) + " MeshInterfaceObject array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
                }
            } else if (method == 'e') {
              ArrayList<SimpleEvent> ea = new ArrayList<SimpleEvent>();
              new Util<SimpleEvent>().copyList(earr, off, ea, td.arrSizeToSend);
                List<SimpleEvent> uea = null;
                int slen = -1;
                if (direction == 'e') {
                    uea = client.echoSimpleEvents(ea);
                } else if (direction == 'r') {
                    slen = client.receiveSimpleEvents(ea);
                    if (slen != ea.size())
                        fail(method2s(direction, method) + " receive SimpleEvent array returned wrong size");
                } else if (direction == 's') {
                    uea = client.sendSimpleEvents(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uea == null) fail(method2s(direction, method) + " SimpleEvent array response was null");
                    if (uea.size() != ea.size()) {
                        fail(method2s(direction, method) + " string SimpleEvent had wrong size " + uea.size()
                                + " (expected " + ea.size() + ")");
                    }
                    for (int i = 0; i < uea.size(); i++) {
                        SimpleEvent s1 = uea.get(i);
                        SimpleEvent s2 = earr[i + off];
                        if (!toString(s1).equals(toString(s2))) {
                            fail(method2s(direction, method) + " SimpleEvent array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
View Full Code Here


        LOG.info("Executing operation sendSimpleEvents");
        SendSimpleEventsResponse ret = new SendSimpleEventsResponse();
        ArrayOfSimpleEvent value = new ArrayOfSimpleEvent();
        List<SimpleEvent> item = value.getItem();
        for(int i = 0 ; i < size.getSize() ; i++) {         
          SimpleEvent object = new SimpleEvent();
            object.setSequenceNumber(i);
            object.setMessage("Message #" + i);
            object.setTimestamp(Math.sqrt(i));
            item.add(object);
        }
        ret.setSendSimpleEventsReturn(value);
        return ret;
    }
View Full Code Here

TOP

Related Classes of limelight.events.EventHandlerTest$SimpleEvent

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.