Verify that ASSERT operator works @throws Exception
()
| 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. |
nothing calls this directly
no test coverage detected