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

Method testRun_setsErrorThrowableOnPigStats

test/org/apache/pig/TestMain.java:66–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64 }
65
66 @Test
67 public void testRun_setsErrorThrowableOnPigStats() {
68 File outputFile = null;
69 try {
70 String filename = this.getClass().getSimpleName() + "_" + "testRun_setsErrorThrowableOnPigStats";
71 outputFile = File.createTempFile(filename, ".out");
72 outputFile.delete();
73
74 File scriptFile = File.createTempFile(filename, ".pig");
75 BufferedWriter bw = new BufferedWriter(new FileWriter(scriptFile));
76 bw.write("a = load 'test/org/apache/pig/test/data/passwd';\n");
77 bw.write("b = group a by $0\n");
78 bw.write("c = foreach b generate group, COUNT(a) as cnt;\n");
79 bw.write("store c into 'out'\n");
80 bw.close();
81
82 Main.run(new String[]{"-x", "local", scriptFile.getAbsolutePath()}, null);
83 PigStats stats = PigStats.get();
84
85 Throwable t = stats.getErrorThrowable();
86 assertTrue(t instanceof FrontendException);
87
88 FrontendException fe = (FrontendException) t;
89 SourceLocation sl = fe.getSourceLocation();
90 assertEquals(2, sl.line());
91 assertEquals(15, sl.offset());
92
93 Throwable cause = fe.getCause();
94 assertTrue(cause instanceof ParserException);
95
96 } catch (Exception e) {
97 log.error("Encountered exception", e);
98 fail("Encountered Exception");
99 }
100 }
101
102 @Test
103 public void testRun_setsErrorThrowableForParamSubstitution() {

Callers

nothing calls this directly

Calls 15

runMethod · 0.95
getMethod · 0.95
getErrorThrowableMethod · 0.95
lineMethod · 0.95
offsetMethod · 0.95
getClassMethod · 0.80
getAbsolutePathMethod · 0.80
getSourceLocationMethod · 0.80
deleteMethod · 0.65
closeMethod · 0.65
createTempFileMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected