[ 
https://issues.apache.org/jira/browse/FLINK-1525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14545119#comment-14545119
 ] 

ASF GitHub Bot commented on FLINK-1525:
---------------------------------------

Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/flink/pull/664#discussion_r30391280
  
    --- 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 --
    
    I'll remove it


> Provide utils to pass -D parameters to UDFs 
> --------------------------------------------
>
>                 Key: FLINK-1525
>                 URL: https://issues.apache.org/jira/browse/FLINK-1525
>             Project: Flink
>          Issue Type: Improvement
>          Components: flink-contrib
>            Reporter: Robert Metzger
>            Assignee: Robert Metzger
>              Labels: starter
>
> Hadoop users are used to setting job configuration through "-D" on the 
> command line.
> Right now, Flink users have to manually parse command line arguments and pass 
> them to the methods.
> It would be nice to provide a standard args parser with is taking care of 
> such stuff.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to