Trying Test the app

Kailasham6 years ago

Hi Guys,

I'm trying to test the app instead of the testing tool which you've already provided. I'm trying to pass the in Binary form to the port ID like ADM protocol would work on port 5092.

public void testDecode() throws Exception {

        AdmProtocolDecoder decoder = new AdmProtocolDecoder(new AdmProtocol());

        verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "010042033836313331313030323639343838320501000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073"));

        verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "01002680336510002062A34C423DCF8E42A50B1700005801140767E30F568F2534107D220000"));

        verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "010022003300072020000000000000000044062A330000000000107F10565D4A8310"));

        verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "0100268033641080207AA34C424CCF8E4239030800005B01140755E30F560000F00F70220000"));

        verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "01002680336510002062A34C423DCF8E42A50B1700005801140767E30F568F2534107D220000"));

        verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "01002200333508202000000000000000007F0D9F030000000000E39A1056E24A8210"));

    }
    protected ChannelBuffer binary(ByteOrder endianness, String... data) {
        return ChannelBuffers.wrappedBuffer(
                endianness, DatatypeConverter.parseHexBinary(concatenateStrings(data)));
    }
    protected void verifyPosition(BaseProtocolDecoder decoder, Object object) throws Exception {
        verifyDecodedPosition(decoder.decode(null, null, object), true, false, null);
    }

How could I send the raw Binary data to the port. ?

I've created the EventLoop:

EventLoopGroup group = new NioEventLoopGroup();
        try{
            Bootstrap clientBootstrap = new Bootstrap();

            clientBootstrap.group(group);
            clientBootstrap.channel(NioSocketChannel.class);
            clientBootstrap.remoteAddress(new InetSocketAddress("localhost", 5092));
            clientBootstrap.handler(new ChannelInitializer<SocketChannel>() {
                protected void initChannel(SocketChannel socketChannel) throws Exception {
                    socketChannel.pipeline().addLast(new ClientHandler());
                }
            });
            ChannelFuture channelFuture = (ChannelFuture) clientBootstrap.connect().sync();
            channelFuture.getChannel().getCloseFuture().sync();
        } finally {
            group.shutdownGracefully().sync();
        }

Do to you have any other application to test each protocol?

Kailasham6 years ago

As I do not have many kinds of GPS devices to test this, is there any other application which would send data to the particular port?

Anton Tananaev6 years ago

You can use hex.sh script to send raw data. There is also test-integration.sh for testing multiple protocols in one go.

Kailasham6 years ago

When I tried to Convert the

verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
                "010042033836313331313030323639343838320501000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073")); 

on https://www.traccar.org/hex-decoder/ it shows : B861311002694882s

Anton Tananaev6 years ago

Why are you trying to decode binary message into a string? Of course it will never work.

Kailasham6 years ago

I tried to establish connection to the specific port i.e 5092. It shows connection refused how do make the server listen this app?

Anton Tananaev6 years ago

It probably means that your server is not running.