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

Class PigTest

test/org/apache/pig/pigunit/PigTest.java:60–462  ·  view source on GitHub ↗

Pig Unit Equivalent of xUnit for testing Pig. Call PigTest#getCluster() then construct a test and call an assert method. Have a look to the test of this class for more example.

Source from the content-addressed store, hash-verified

58 * Have a look to the test of this class for more example.
59 */
60public class PigTest {
61 /** The text of the Pig script to test with no substitution or change. */
62 private final String originalTextPigScript;
63 /** The list of arguments of the script. */
64 private final String[] args;
65 /** The list of file arguments of the script. */
66 private final String[] argFiles;
67 /** The list of aliases to override in the script. */
68 private final Map<String, String> aliasOverrides;
69
70 private static ThreadLocal<PigServer> pig = new ThreadLocal<PigServer>();
71 private static ThreadLocal<Cluster> cluster = new ThreadLocal<Cluster>();
72
73 private static final Logger LOG = Logger.getLogger(PigTest.class);
74 private static final String EXEC_CLUSTER = "pigunit.exectype";
75
76 /**
77 * Initializes the Pig test.
78 *
79 * @param args The list of arguments of the script.
80 * @param argFiles The list of file arguments of the script.
81 * @param pigTextScript The text of the Pig script to test with no substitution or change.
82 */
83 @SuppressWarnings("serial")
84 PigTest(String[] args, String[] argFiles, String pigTextScript) {
85 this.originalTextPigScript = pigTextScript;
86 this.args = args;
87 this.argFiles = argFiles;
88 this.aliasOverrides = new HashMap<String, String>() {{
89 put("STORE", "");
90 put("DUMP", "");
91 }};
92 }
93
94 public PigTest(String scriptPath) throws IOException {
95 this(null, null, readFile(scriptPath));
96 }
97
98 public PigTest(String[] script) {
99 this(null, null, StringUtils.join(script, "\n"));
100 }
101
102 public PigTest(String scriptPath, String[] args) throws IOException {
103 this(args, null, readFile(scriptPath));
104 }
105
106 public PigTest(String[] script, String[] args) {
107 this(args, null, StringUtils.join(script, "\n"));
108 }
109
110 public PigTest(String[] script, String[] args, String[] argsFile) {
111 this(args, argsFile, StringUtils.join(script, "\n"));
112 }
113
114 public PigTest(String scriptPath, String[] args, String[] argFiles) throws IOException {
115 this(args, argFiles, readFile(scriptPath));
116 }
117

Callers

nothing calls this directly

Calls 1

getLoggerMethod · 0.45

Tested by

no test coverage detected