Package com.lucidera.luciddb.test.udr

Examples of com.lucidera.luciddb.test.udr.SQLRunner


            + "APPLIB.REMOTE_ROWS(cursor( "
            + "select cast(null as int) as id, cast(null as varchar(255)) as name, "
            + "cast(null as boolean) as is_married " + "from (values(0)) "
            + "),7778,FALSE) " + ")");
       
        SQLRunner runner = new SQLRunner(ps);

        runner.start();
       
        Thread.sleep(5000);
       
        Socket client = new Socket("localhost", 7778);

        ObjectOutputStream objOut = new ObjectOutputStream(
            client.getOutputStream());
        List<Object> header = new ArrayList<Object>();
      
        header.add("1"); // version
       
        List format = new ArrayList();
        // KS 10-APR-2011
        // The "Mismatch" here is on types, but the RemoteRowsUDX only checks
        // for column count. Thus the final STRING is what triggers the
        // mismatch as of this date.
        // Also, the indexOf message match below was initially wrong with what
        // the UDX produces.
        format.add("STRING"); // Mismatch
        format.add("STRING");
        format.add("BOOLEAN");
        format.add("STRING"); // mismatched columns
       
        header.add(format);
        objOut.writeObject(header);
       
        objOut.close();
        client.close();
        runner.join();
       
        ps.close();
        conn.close();
              
        String errorMsg = runner.getErrorMsg();
        if (errorMsg == null) {
          errorMsg = "";
        }
        boolean test = false;
        if(errorMsg.indexOf("Header Mismatch:")!=-1){
            test = true;
        }
           
        assertTrue("Header mismatch test is not passed: ",test);
       
        //Case2: Bad objects sent across (wrong datatypes in actual rows)
        conn = driver.connect(driverURI, props);
        ps = conn.prepareStatement(
            "insert into s.t " +
            "select * from table( "
            + "APPLIB.REMOTE_ROWS(cursor( "
            + "select cast(null as int) as id, cast(null as varchar(255)) as name, "
            + "cast(null as boolean) as is_married " + "from (values(0)) "
            + "),7778,FALSE) " + ")");
       
        runner = new SQLRunner(ps);

        runner.start();
       
        Thread.sleep(5000);
       
        client = new Socket("localhost", 7778);

        objOut = new ObjectOutputStream(
            client.getOutputStream());
        header = new ArrayList<Object>();
      
        header.add("1"); // version
       
        format = new ArrayList();
        format.add("INTEGER");
        format.add("STRING");
        format.add("BOOLEAN");
       
        header.add(format);
        objOut.writeObject(header);
       
        objOut.reset();
        objOut.flush();

        List<Object> list = new ArrayList<Object>();
        list.add("Test1"); // wrong type.
        list.add(111); // wrong type.
        list.add(true);
       
        objOut.writeObject(list);
        objOut.close();
        client.close();
        runner.join();
       
        ps.close();
        conn.close();
              
        errorMsg = runner.getErrorMsg();
        test = false;
        if(errorMsg.indexOf("Value 'Test1' cannot be converted to parameter of type INTEGER")!=-1){
            test = true;
        }
           
        assertTrue("Bad objects sent across: ",test);
       
        //Casee3: Compress stream
        conn = driver.connect(driverURI, props);
        ps = conn.prepareStatement(
            "insert into s.t " +
            "select * from table( "
            + "APPLIB.REMOTE_ROWS(cursor( "
            + "select cast(null as int) as id, cast(null as varchar(255)) as name, "
            + "cast(null as boolean) as is_married " + "from (values(0)) "
            + "),7778,TRUE) " + ")"); // TRUE
       
        runner = new SQLRunner(ps);

        runner.start();
       
        Thread.sleep(5000);
       
        client = new Socket("localhost", 7778);

        GZIPOutputStream gzOut = new GZIPOutputStream(client.getOutputStream());
        objOut = new ObjectOutputStream(
          gzOut);
        header = new ArrayList<Object>();
      
        header.add("1"); // version
       
        format = new ArrayList();
        format.add("INTEGER");
        format.add("STRING");
        format.add("BOOLEAN");
       
        header.add(format);
        objOut.writeObject(header);
       
        objOut.reset();
        objOut.flush();

        list = new ArrayList<Object>();
        list.add(111);
        list.add("Test1");
        list.add(true);
       
        objOut.writeObject(list);
        objOut.close();
        client.close();
        runner.join();
       
        ps.close();
        conn.close();
              
        errorMsg = runner.getErrorMsg();
        test = false;
        if(errorMsg == null){
            test = true;
        }
           
View Full Code Here

TOP

Related Classes of com.lucidera.luciddb.test.udr.SQLRunner

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.