Github user chtyim commented on a diff in the pull request:
https://github.com/apache/incubator-twill/pull/28#discussion_r27095484
--- Diff:
twill-ext/src/test/java/org/apache/twill/ext/BundledJarRunnerTest.java ---
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.twill.ext;
+
+import com.google.common.io.ByteStreams;
+import com.google.common.io.Files;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
+
+/**
+ * Tests for {@link BundledJarRunner}.
+ */
+public class BundledJarRunnerTest {
+
+ private static String jarOutput;
+
+ static class Simple {
+ public static void main(String[] args) {
+ jarOutput = args[0];
+ }
+ }
+
+ static class NoZeroArgsConstructor {
+ public static void main(String[] args) {
+ NoZeroArgsConstructor obj = new NoZeroArgsConstructor(args[0]);
+ }
+ public NoZeroArgsConstructor(String arg) {
+ jarOutput = arg;
+ }
+ }
+
+ @Test
+ public void runSimpleJar() throws Throwable {
+ String output = "Simple";
+ String jarFileName = "simple.jar";
+ String className = "org.apache.twill.ext.BundledJarRunnerTest$Simple";
+ runJarFile(jarFileName, className, new String[]{output});
+ Assert.assertEquals(jarOutput, output);
+ }
+
+ @Test
+ public void runNoZeroArgsConstructorJar() throws Throwable {
+ String output = "NoZeroArgsConstructor";
+ String jarFileName = "nozeroargs.jar";
+ String className =
"org.apache.twill.ext.BundledJarRunnerTest$NoZeroArgsConstructor";
+ runJarFile(jarFileName, className, new String[]{output});
+ Assert.assertEquals(jarOutput, output);
+ }
+
+ private void runJarFile(String jarFileName, String className, String[]
mainArgs) throws Throwable {
+ File outdir = Files.createTempDir();
--- End diff --
Can you use junit `@ClassRule TemporaryFolder` instead? That will make the
code cleaner and no need to worry about cleaning up.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---