[ 
https://issues.apache.org/jira/browse/PIG-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13255678#comment-13255678
 ] 

Gianmarco De Francisci Morales commented on PIG-2650:
-----------------------------------------------------

Hi Julien,

Looks great!
Can you fix testMockSchema()?
It fails both on the schema comparison and on the data comparison.

Maybe use Utils.getSchemaFromString() instead of comparing Strings?
The schema in the query is (a:chararray, b:chararray) so I would do:
{code}
    Assert.assertEquals(Utils.getSchemaFromString("a:chararray,b:chararray"), 
data.getSchema("bar"));
    
    Iterator<Tuple> out = data.get("bar").iterator();
    
    Assert.assertEquals(tuple("a", "a"), out.next());
    Assert.assertEquals(tuple("b", "b"), out.next());
    Assert.assertEquals(tuple("c", "c"), out.next());
{code}

Apart from this small issue, +1
                
> Convenience mock Loader and Storer to simplify unit testing of Pig scripts
> --------------------------------------------------------------------------
>
>                 Key: PIG-2650
>                 URL: https://issues.apache.org/jira/browse/PIG-2650
>             Project: Pig
>          Issue Type: New Feature
>            Reporter: Julien Le Dem
>            Assignee: Julien Le Dem
>         Attachments: PIG-2650-a.patch, PIG-2650-b.patch, PIG-2650.patch
>
>
> A test would look as follows:
> {code}
> PigServer pigServer = new PigServer(ExecType.LOCAL);
> TupleFactory tf = TupleFactory.getInstance();
> Data data = Storage.resetData(pigServer.getPigContext());
> data.set("foo", Arrays.asList(
>     tf.newTuple("a"),
>     tf.newTuple("b"),
>     tf.newTuple("c")
>     ));
> pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
> // some complex script to test
> pigServer.registerQuery("STORE A INTO 'bar' USING mock.Storage();");
> Iterator<Tuple> out = data.get("bar").iterator();
> assertEquals("a", out.next().get(0));
> assertEquals("b", out.next().get(0));
> assertEquals("c", out.next().get(0));
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to