pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julien Le Dem (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PIG-2650) Convenience mock Loader and Storer to simplify unit testing of Pig scripts
Date Fri, 13 Apr 2012 17:15:18 GMT

     [ https://issues.apache.org/jira/browse/PIG-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Julien Le Dem updated PIG-2650:
-------------------------------

    Description: 
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}

  was:
A test would look as follows:
{code}
TupleFactory tf = TupleFactory.getInstance();
Loader.setData("foo", Arrays.asList(
    tf.newTuple("a"),
    tf.newTuple("b"),
    tf.newTuple("c")
    ));

PigServer pigServer = new PigServer(ExecType.LOCAL);
pigServer.registerQuery("A = LOAD 'foo' USING mock.Loader();");
// some complex script to test
pigServer.registerQuery("STORE A INTO 'bar' USING mock.Storer();");

List<Tuple> data = Storer.getData("bar");
assertEquals("a", data.get(0).get(0));
assertEquals("b", data.get(1).get(0));
assertEquals("c", data.get(2).get(0));
{code}

    
> 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.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

        

Mime
View raw message