SRADA-903: Removed '-c custom template' CLI option as not planned to be supported.
authorMaria Guseva <m.guseva@samsung.com>
Tue, 12 Jul 2016 11:02:18 +0000 (14:02 +0300)
committerMaria Guseva <m.guseva@samsung.com>
Tue, 12 Jul 2016 14:00:42 +0000 (17:00 +0300)
TracingArgumentsTest and TracingArgumentsParserTest updated correspondingly.
TracingArgumentsTest.isValid_ExclusiveOpts test removed as unrelevant anymore.

Change-Id: Iaa03813be3cee772564738b6925333272f42c910

org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/tracing/TracingArguments.java
org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/tracing/TracingArgumentsParser.java
org.tizen.dynamicanalyzer.cli/test/src/org/tizen/dynamicanalyzer/cli/tracing/TracingArgumentsParserTest.java
org.tizen.dynamicanalyzer.cli/test/src/org/tizen/dynamicanalyzer/cli/tracing/TracingArgumentsTest.java

index 179d779..d40c6a8 100644 (file)
@@ -18,7 +18,6 @@ public class TracingArguments implements Cloneable, Serializable {
        private String device;       // device serial number or IP address
        private String application;  // application name
        private Template template;   // analysis template
-       private File customTemplate; // file with custom template configuration
        private File output;         // file with tracing output
        // TODO duration actually is not supported yet by CLI, always set to 0
        private long durationSec;    // tracing duration in seconds (0 is for unlimited duration)
@@ -70,15 +69,9 @@ public class TracingArguments implements Cloneable, Serializable {
                }
 
                // Templates check
-               if (template == null && customTemplate == null) {
+               if (template == null || template == Template.TEMPLATE_CUSTOM) {
                        result = false;
-                       msg += " * Template is not specified%n";
-               } else if (template != null && customTemplate != null) {
-                       result = false;
-                       msg += " * Custom template is specified along with standard template%n";
-               } else if (template != null && template == Template.TEMPLATE_CUSTOM) {
-                       result = false;
-                       msg += " * Standard template specified as custom%n";
+                       msg += " * Proper template is not specified%n";
                }
 
                errMessage = result ? "" : String.format(msg).trim();
@@ -139,22 +132,6 @@ public class TracingArguments implements Cloneable, Serializable {
        }
 
        /**
-        * @return the custom template file
-        */
-       public File getCustomTemplate() {
-               return customTemplate;
-       }
-
-       /**
-        * @param customTemplate the custom template file to set
-        * @return this object to allow chained methods execution
-        */
-       public TracingArguments setCustomTemplate(File customTemplate) {
-               this.customTemplate = customTemplate;
-               return this;
-       }
-
-       /**
         * @return the duration in seconds
         */
        public long getDuration() {
index b717bf4..03603e0 100644 (file)
@@ -8,7 +8,6 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.DefaultParser;
 import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionGroup;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.tizen.dynamicanalyzer.setting.Template;
@@ -30,6 +29,7 @@ public class TracingArgumentsParser {
        private static Option template = Option.builder("t")
                        .hasArg()
                        .argName("template")
+                       .required()
                        .desc("tracing template")
                        .build();
 
@@ -46,27 +46,14 @@ public class TracingArgumentsParser {
                        .desc("redirect tracing output to file")
                        .build();
 
-       private static Option customTemplate = Option.builder("c")
-                       .hasArg()
-                       .argName("template file")
-                       .desc("custom tracing template file")
-                       .build();
-
-       // Mutually exclusive options
-       private static OptionGroup templateGroup = new OptionGroup()
-                       .addOption(template)
-                       .addOption(customTemplate);
-
        private static Options opts = new Options();
 
        static {
-               // One of template options is required
-               templateGroup.setRequired(true);
                opts.addOption(application)
                        // TODO duration option is not supported yet
                        // .addOption(duration)
                        .addOption(output)
-                       .addOptionGroup(templateGroup);
+                       .addOption(template);
        }
 
        /**
@@ -105,13 +92,8 @@ public class TracingArgumentsParser {
                result.setApplication(cmdline.getOptionValue(application.getOpt()));
 
                // Get template or custom template file
-               if (cmdline.hasOption(template.getOpt())) {
-                       String tempString = cmdline.getOptionValue(template.getOpt());
-                       result.setTemplate(Template.getTemplate(tempString));
-               } else {
-                       String tempString = cmdline.getOptionValue(customTemplate.getOpt());
-                       result.setCustomTemplate(new File(tempString));
-               }
+               String tempString = cmdline.getOptionValue(template.getOpt());
+               result.setTemplate(Template.getTemplate(tempString));
 
                // Get duration
                if (cmdline.hasOption(duration.getOpt())) {
@@ -159,16 +141,10 @@ public class TracingArgumentsParser {
                result.add('-' + application.getOpt());
                result.add(app);
 
-               // Template or Custom Template
+               // Template
                Template temp = args.getTemplate();
-               File customTemp = args.getCustomTemplate();
-               if (temp != null) {
-                       result.add('-' + template.getOpt());
-                       result.add(temp.getName());
-               } else {
-                       result.add('-' + customTemplate.getOpt());
-                       result.add(customTemp.getAbsolutePath());
-               }
+               result.add('-' + template.getOpt());
+               result.add(temp.getName());
 
                // Duration
                long dur = args.getDuration();
index eb8ad53..c0d7bbc 100644 (file)
@@ -95,7 +95,6 @@ public class TracingArgumentsParserTest {
                                templateOpt, template.getName() });
                assertNotNull(result);
                assertTrue(result.isValid());
-               assertNull(result.getCustomTemplate());
                assertNull(result.getOutput());
                assertEquals(0, result.getDuration());
        }
@@ -244,17 +243,6 @@ public class TracingArgumentsParserTest {
        }
 
        @Test
-       public void toStringArray_ExclusiveOpts() {
-               TracingArguments args = new TracingArguments()
-                                                               .setDevice(device)
-                                                               .setApplication(application)
-                                                               .setTemplate(template)
-                                                               .setCustomTemplate(customTemplate);
-               String[] result = TracingArgumentsParser.toStringArray(args);
-               assertNull(result);
-       }
-
-       @Test
        public void toStringArray_AllOpts() {
                TracingArguments args = new TracingArguments()
                                                                .setDevice(device)
index ad34b49..8236e15 100644 (file)
@@ -20,7 +20,6 @@ public class TracingArgumentsTest {
        private final static String   device = "device";
        private final static String   application = "application";
        private final static Template template = Template.TEMPLATE_BOTTLENECK;
-       private final static File     customTemplate = new File("template.tpt");
        private final static File     output = new File("output.out");
 
        @Before
@@ -84,16 +83,6 @@ public class TracingArgumentsTest {
        }
 
        @Test
-       public void isValid_ExclusiveOpts() {
-               TracingArguments args = new TracingArguments()
-                                                               .setDevice(device)
-                                                               .setApplication(application)
-                                                               .setTemplate(template)
-                                                               .setCustomTemplate(customTemplate);
-               assertFalse(args.isValid());
-       }
-
-       @Test
        public void isValid_AllOpts() {
                TracingArguments args = new TracingArguments()
                                                                .setDevice(device)