Tabnine Logo
ZooKeeperMain$MyCommandOptions.getCmdArgument
Code IndexAdd Tabnine to your IDE (free)

How to use
getCmdArgument
method
in
org.apache.zookeeper.ZooKeeperMain$MyCommandOptions

Best Java code snippets using org.apache.zookeeper.ZooKeeperMain$MyCommandOptions.getCmdArgument (Showing top 5 results out of 315)

origin: apache/zookeeper

@Test
public void testParseWithQuotes() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  for (String quoteChar : new String[] {"'", "\""}) {
    String cmdstring = String.format("create /node %1$squoted data%1$s", quoteChar);
    zkMain.cl.parseCommand(cmdstring);
    Assert.assertEquals("quotes combine arguments", zkMain.cl.getNumArguments(), 3);
    Assert.assertEquals("create is not taken as first argument", zkMain.cl.getCmdArgument(0), "create");
    Assert.assertEquals("/node is not taken as second argument", zkMain.cl.getCmdArgument(1), "/node");
    Assert.assertEquals("quoted data is not taken as third argument", zkMain.cl.getCmdArgument(2), "quoted data");
  }
}
origin: apache/zookeeper

@Test
public void testParseWithMixedQuotes() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  for (String[] quoteChars : new String[][] {{"'", "\""}, {"\"", "'"}}) {
    String outerQuotes = quoteChars[0];
    String innerQuotes = quoteChars[1];
    String cmdstring = String.format("create /node %1$s%2$squoted data%2$s%1$s", outerQuotes, innerQuotes);
    zkMain.cl.parseCommand(cmdstring);
    Assert.assertEquals("quotes combine arguments", zkMain.cl.getNumArguments(), 3);
    Assert.assertEquals("create is not taken as first argument", zkMain.cl.getCmdArgument(0), "create");
    Assert.assertEquals("/node is not taken as second argument", zkMain.cl.getCmdArgument(1), "/node");
    Assert.assertEquals("quoted data is not taken as third argument", zkMain.cl.getCmdArgument(2), innerQuotes + "quoted data" + innerQuotes);
  }
}
origin: apache/zookeeper

@Test
public void testParseWithMultipleQuotes() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmdstring = "create /node '' ''";
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertEquals("expected 5 arguments", zkMain.cl.getNumArguments(), 4);
  Assert.assertEquals("create is not taken as first argument", zkMain.cl.getCmdArgument(0), "create");
  Assert.assertEquals("/node is not taken as second argument", zkMain.cl.getCmdArgument(1), "/node");
  Assert.assertEquals("empty string is not taken as third argument", zkMain.cl.getCmdArgument(2), "");
  Assert.assertEquals("empty string is not taken as fourth argument", zkMain.cl.getCmdArgument(3), "");
}
origin: apache/zookeeper

@Test
public void testParseWithEmptyQuotes() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmdstring = "create /node ''";
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertEquals("empty quotes should produce arguments", zkMain.cl.getNumArguments(), 3);
  Assert.assertEquals("create is not taken as first argument", zkMain.cl.getCmdArgument(0), "create");
  Assert.assertEquals("/node is not taken as second argument", zkMain.cl.getCmdArgument(1), "/node");
  Assert.assertEquals("empty string is not taken as third argument", zkMain.cl.getCmdArgument(2), "");
}
origin: apache/zookeeper

@Test
public void testParseWithExtraSpaces() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmdstring = "      ls       /  ";
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertEquals("Spaces also considered as characters", zkMain.cl.getNumArguments(), 2);
  Assert.assertEquals("ls is not taken as first argument", zkMain.cl.getCmdArgument(0), "ls");
  Assert.assertEquals("/ is not taken as second argument", zkMain.cl.getCmdArgument(1), "/");
}
org.apache.zookeeperZooKeeperMain$MyCommandOptionsgetCmdArgument

Popular methods of ZooKeeperMain$MyCommandOptions

  • parseCommand
    Breaks a string into command + arguments.
  • getArgArray
  • getCommand
  • getOption
  • parseOptions
    Parses a command line that may contain one or more flags before an optional command string
  • getNumArguments

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Permission (java.security)
    Legacy security code; do not use.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now