MCPcopy Create free account
hub / github.com/apache/pig / testNegative

Method testNegative

test/org/apache/pig/test/TestAssert.java:102–128  ·  view source on GitHub ↗

Verify that ASSERT operator works @throws Exception

()

Source from the content-addressed store, hash-verified

100 * @throws Exception
101 */
102 @Test
103 public void testNegative() throws Exception {
104 PigServer pigServer = new PigServer(Util.getLocalTestMode());
105 Data data = resetData(pigServer);
106
107 data.set("foo",
108 tuple(1),
109 tuple(2),
110 tuple(3)
111 );
112
113 pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage() AS (i:int);");
114 pigServer.registerQuery("ASSERT A BY i > 1 , 'i should be greater than 1';");
115
116 try {
117 pigServer.openIterator("A");
118 } catch (FrontendException fe) {
119 if (pigServer.getPigContext().getExecType().toString().startsWith("TEZ")
120 || pigServer.getPigContext().getExecType().toString().startsWith("SPARK")) {
121 Assert.assertTrue(fe.getCause().getMessage().contains(
122 "Assertion violated: i should be greater than 1"));
123 } else {
124 Assert.assertTrue(fe.getCause().getMessage().contains(
125 "Job terminated with anomalous status FAILED"));
126 }
127 }
128 }
129
130 /**
131 * Verify that ASSERT operator works. Disable fetch for this testcase.

Callers

nothing calls this directly

Calls 12

getLocalTestModeMethod · 0.95
setMethod · 0.95
registerQueryMethod · 0.95
openIteratorMethod · 0.95
getPigContextMethod · 0.95
resetDataMethod · 0.80
tupleMethod · 0.45
toStringMethod · 0.45
getExecTypeMethod · 0.45
containsMethod · 0.45
getMessageMethod · 0.45
getCauseMethod · 0.45

Tested by

no test coverage detected