/*
 Copyright 2008 Robert C. Ilardi

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

package com.roguelogic.tests;

import java.io.IOException;

import com.roguelogic.util.StringUtils;
import com.roguelogic.util.SystemUtils;

public class TestSimpleWSEcho {

  public static void main(String[] args) throws IOException {
    SimpleEchoWSFacadeWSClient client = new SimpleEchoWSFacadeWSClient(args[0]);

    System.out.println(client.echo("Hello World!")); //Test String

    StringUtils.PrintArray("EchoStrArr", client.echo(new String[] { "Hello World!", "Robert C. Ilardi" })); //Test String Array

    System.out.println(client.echo(1234)); //Test Int
    System.out.println(client.echo(-1234)); //Test Int

    StringUtils.PrintArray("EchoIntArr", client.echo(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 46356456, -78672 })); //Test Int Array

    System.out.println(client.echo(1234.56f)); //Test Float
    System.out.println(client.echo(-1234.56f)); //Test Float

    StringUtils.PrintArray("EchoFloatArr", client.echo(new float[] { 7647.994f, -134.401f })); //Test Float Array

    System.out.println(client.echo(1234.000056d)); //Test Double
    System.out.println(client.echo(-1234.000056d)); //Test Double

    StringUtils.PrintArray("EchoDoubleArr", client.echo(new double[] { 7647.00000994d, -134.000000401d })); //Test Double Array

    System.out.println(client.echo((short) 16)); //Test Short
    System.out.println(client.echo((short) -16)); //Test Short

    StringUtils.PrintArray("EchoShortArr", client.echo(new short[] { (short) 24, (short) -32, (short) 86 })); //Test Short Array

    System.out.println(client.echo(32000000000L)); //Test Long
    System.out.println(client.echo(-128000000000L)); //Test Long

    StringUtils.PrintArray("EchoLongArr", client.echo(new long[] { 32000000000L, -128000000000L })); //Test Long Array

    System.out.println(client.echo('R')); //Test Char

    StringUtils.PrintArray("EchoCharArr", client.echo(new char[] { 'R', 'C', 'I' })); //Test Char Array

    System.out.println(client.echo((byte) 65)); //Test Byte
    System.out.println(client.echo((byte) -120)); //Test Byte

    for (int i = 1; i < 100; i++) {
      byte[] bArr = SystemUtils.GenerateRandomBytes(20480);
      byte[] echoedBArr = client.echo(bArr);
      System.out.println("Are Byte Arrays Equal (Send Echo of " + bArr.length + " bytes)? " + (SystemUtils.EqualByteArrays(bArr, echoedBArr) ? "YES" : "NO"));
    }

    System.out.println(client.multiEcho("Hello Paula S. Anglo!", 4808, -567.89f, 4502340.4000452d, 'R', (short) 16, -32954555486L, (byte) 65, new String[] { "Rogue", "Logic", "Sambuca", "Http",
        "Framework" }, new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, new float[] { 425.04f, 999.99f, 1999.01f }, new double[] { 1234.3450000989d, 646464.64646464d, 0.2345679819d }, new char[] { 'R',
        'C', 'I', '+', 'P', 'S', 'A' }, new short[] { (short) -1, (short) 8, (short) 16, (short) 24, (short) 32 }, new long[] { 99999999999L, 1000000000000L }, SystemUtils
        .GenerateRandomBytesFixedLen(16))); //Test Multi Parameter Echo

  }

}
