Github user hsaputra commented on a diff in the pull request: https://github.com/apache/flink/pull/664#discussion_r30342062 --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java --- @@ -0,0 +1,220 @@ +/* + * 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.flink.api.java.utils; + +import org.apache.flink.api.java.ClosureCleaner; +import org.apache.flink.configuration.Configuration; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; +import java.util.Properties; + +public class ParameterToolTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + + // ----- Parser tests ----------------- + + @Test(expected = RuntimeException.class) + public void testIllegalArgs() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"berlin"}); + Assert.assertEquals(0, parameter.getNumberOfParameters()); + } + + @Test + public void testNoVal() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-berlin"}); + Assert.assertEquals(1, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("berlin")); + } + + @Test + public void testNoValDouble() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--berlin"}); + Assert.assertEquals(1, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("berlin")); + } + + @Test + public void testMultipleNoVal() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "--b", "--c", "--d", "--e", "--f"}); + Assert.assertEquals(6, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("a")); + Assert.assertTrue(parameter.has("b")); + Assert.assertTrue(parameter.has("c")); + Assert.assertTrue(parameter.has("d")); + Assert.assertTrue(parameter.has("e")); + Assert.assertTrue(parameter.has("f")); + } + + @Test + public void testMultipleNoValMixed() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "-c", "-d", "--e", "--f"}); + Assert.assertEquals(6, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("a")); + Assert.assertTrue(parameter.has("b")); + Assert.assertTrue(parameter.has("c")); + Assert.assertTrue(parameter.has("d")); + Assert.assertTrue(parameter.has("e")); + Assert.assertTrue(parameter.has("f")); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyVal() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "--"}); + Assert.assertEquals(2, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("a")); + Assert.assertTrue(parameter.has("b")); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyValShort() { + ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "-"}); + Assert.assertEquals(2, parameter.getNumberOfParameters()); + Assert.assertTrue(parameter.has("a")); + Assert.assertTrue(parameter.has("b")); + } + + + + /*@Test --- End diff -- Do you want to keep this test as optional? If yes then it is better to have comments on why and when to uncomment this test. Otherwise, let's just remove it for now.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---