Examples of IpAddress


Examples of org.jgroups.stack.IpAddress

        Assert.assertEquals(c, e);
    }


    public static void testEqualityWithDnsRoundRobin() throws UnknownHostException {
        IpAddress x1, x2, x3;

        StackType type=Util.getIpStackType();
        String tmp=type == StackType.IPv6? "::1" : "127.0.0.1";
        InetAddress addr=InetAddress.getByName(tmp);
        byte[] rawAddr=addr.getAddress();

        InetAddress inet1=InetAddress.getByAddress("MyHost1", rawAddr);
        InetAddress inet2=InetAddress.getByAddress("MyHost2", rawAddr);
        InetAddress inet3=InetAddress.getByAddress("MyHost3", rawAddr);
        Assert.assertEquals(inet1, inet2);

        x1=new IpAddress(inet1, 5555);
        x2=new IpAddress(inet2, 5555);
        x3=new IpAddress(inet3, 5555);

        Assert.assertEquals(x1, x2);
        Assert.assertEquals(x3, x1);

        HashSet<Address> s=new HashSet<Address>();
View Full Code Here

Examples of org.jgroups.stack.IpAddress

    }



    public void testInequality() throws Exception {
        IpAddress tmp=null;
        assert !a.equals(d);
        assert !c.equals(d);
        assert !a.equals(f);
        assert !e.equals(f);
        assert !f.equals(g);
View Full Code Here

Examples of org.jgroups.stack.IpAddress



    public static void testIPv6WithExternalization() throws IOException, ClassNotFoundException {
        InetAddress tmp=Util.getNonLoopbackAddress();
        IpAddress ip=new IpAddress(tmp, 5555);

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        ObjectOutputStream    oos=new ObjectOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        ObjectInputStream     ois;

        System.out.println("-- address is " + tmp);

        oos.writeObject(ip);
        buf=bos.toByteArray();
        bis=new ByteArrayInputStream(buf);
        ois=new ObjectInputStream(bis);
        IpAddress ip2=(IpAddress)ois.readObject();
        Assert.assertEquals(ip, ip2);
    }
View Full Code Here

Examples of org.jgroups.stack.IpAddress



    public static void testIPv6WithStreamable() throws IOException, ClassNotFoundException {
        InetAddress tmp=Util.getNonLoopbackAddress();
        IpAddress ip=new IpAddress(tmp, 5555);

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        DataOutputStream      dos=new DataOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        DataInputStream       dis;

        System.out.println("-- address is " + tmp);

        ip.writeTo(dos);
        buf=bos.toByteArray();
        bis=new ByteArrayInputStream(buf);
        dis=new DataInputStream(bis);
        IpAddress ip2=new IpAddress();
        ip2.readFrom(dis);
        Assert.assertEquals(ip, ip2);
    }
View Full Code Here

Examples of org.jgroups.stack.IpAddress

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        ObjectOutputStream    oos=new ObjectOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        ObjectInputStream     ois;
        IpAddress             a2, b2;
       
        a.setAdditionalData(null);
        b.setAdditionalData("Bela Ban".getBytes());
        oos.writeObject(a);
        oos.writeObject(b);
       

        buf=bos.toByteArray();       
        bis=new ByteArrayInputStream(buf);
        ois=new ObjectInputStream(bis);
        a2=(IpAddress)ois.readObject();
        b2=(IpAddress)ois.readObject();

        Assert.assertEquals(a, a2);
        Assert.assertEquals(b, b2);

        assert a2.getAdditionalData() == null;
        Assert.assertEquals("Bela Ban", new String(b2.getAdditionalData()));
    }
View Full Code Here

Examples of org.jgroups.stack.IpAddress

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        ObjectOutputStream    oos=new ObjectOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        ObjectInputStream     ois;
        IpAddress             a2, b2, c2, d2, e2, f2, g2, h2;
       
        oos.writeObject(a);
        oos.writeObject(b);
        oos.writeObject(c);
        oos.writeObject(d);
View Full Code Here

Examples of org.jgroups.stack.IpAddress

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        DataOutputStream      oos=new DataOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        DataInputStream       ois;
        IpAddress             a2, b2, x, x2, y, y2;

        x=createStackConformantAddress(5555);
        x.setAdditionalData(new byte[]{'b','e','l','a'});

        y=createStackConformantAddress(1111);
        y.setAdditionalData(new byte[]{'b','e','l','a'});

        a.setAdditionalData(null);
        b.setAdditionalData("Bela Ban".getBytes());
        a.writeTo(oos);
        b.writeTo(oos);
        x.writeTo(oos);
        y.writeTo(oos);

        buf=bos.toByteArray();
        bis=new ByteArrayInputStream(buf);
        ois=new DataInputStream(bis);
        a2=new IpAddress();
        a2.readFrom(ois);
        b2=new IpAddress();
        b2.readFrom(ois);
        x2=new IpAddress();
        x2.readFrom(ois);
        y2=new IpAddress();
        y2.readFrom(ois);

        Assert.assertEquals(a, a2);
        Assert.assertEquals(b, b2);

        assert a2.getAdditionalData() == null;
        Assert.assertEquals("Bela Ban", new String(b2.getAdditionalData()));

        assert x2.getAdditionalData() != null;
        Assert.assertEquals(4, x2.getAdditionalData().length);
View Full Code Here

Examples of org.jgroups.stack.IpAddress

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        DataOutputStream      oos=new DataOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        DataInputStream       dis;
        IpAddress             x, x2;

        x=createStackConformantAddress(65535);
        x.writeTo(oos);

        buf=bos.toByteArray();
        bis=new ByteArrayInputStream(buf);
        dis=new DataInputStream(bis);

        x2=new IpAddress();
        x2.readFrom(dis);
        System.out.println("x: " + x + ", x2: " + x2);

        assert x2.getPort() > 0;
        Assert.assertEquals(x.getPort(), x2.getPort());
    }
View Full Code Here

Examples of org.jgroups.stack.IpAddress

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        DataOutputStream      oos=new DataOutputStream(bos);
        byte[]                buf=null;
        ByteArrayInputStream  bis=null;
        DataInputStream       ois;
        IpAddress             a2, b2, c2, d2, e2, f2, g2, h2;

        a.writeTo(oos);
        b.writeTo(oos);
        c.writeTo(oos);
        d.writeTo(oos);
        e.writeTo(oos);
        f.writeTo(oos);
        g.writeTo(oos);
        h.writeTo(oos);


        buf=bos.toByteArray();
        bis=new ByteArrayInputStream(buf);
        ois=new DataInputStream(bis);
        a2=new IpAddress();
        a2.readFrom(ois);
        b2=new IpAddress();
        b2.readFrom(ois);
        c2=new IpAddress();
        c2.readFrom(ois);
        d2=new IpAddress();
        d2.readFrom(ois);
        e2=new IpAddress();
        e2.readFrom(ois);
        f2=new IpAddress();
        f2.readFrom(ois);
        g2=new IpAddress();
        g2.readFrom(ois);
        h2=new IpAddress();
        h2.readFrom(ois);

        Assert.assertEquals(b2, c2);
        Assert.assertEquals(a, a2);
        Assert.assertEquals(b, b2);
View Full Code Here

Examples of org.jgroups.stack.IpAddress


    private static IpAddress createStackConformantAddress(int port) throws UnknownHostException {
        StackType type=Util.getIpStackType();
        if(type == StackType.IPv6)
            return new IpAddress("::1", port);
        else
            return new IpAddress("127.0.0.1", port);
    }
View Full Code Here
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.