1 23 package com.sun.enterprise.cli.commands; 24 25 31 import com.sun.enterprise.cli.framework.*; 32 import junit.framework.*; 38 import junit.textui.TestRunner; 39 import com.sun.enterprise.util.SystemPropertyConstants; 40 import java.io.File ; 41 46 47 52 53 public class BackupCommandsTest extends TestCase { 54 55 public void testValidateOptionsInvalidCommandName() throws Exception { 56 try{ 57 testCommand.validateOptions(); 58 } 59 catch (CommandValidationException cve){ 60 assertEquals(cve.getMessage(), 61 "There is no such command sampleCommand. Use \"asadmin help\" for a list of valid commands."); 62 } 63 } 64 65 public void testValidateOptionsInvalidVerboseAndTerse() throws Exception { 66 try{ 67 testCommand.setName("backup-domain"); 68 testCommand.setOption("terse", "true"); 69 testCommand.setOption("verbose", "true"); 70 testCommand.validateOptions(); 71 } 72 catch (CommandValidationException cve){ 73 assertEquals(cve.getMessage(), 74 "The verbose and terse options can''t both be true at the same time."); 75 } 76 } 77 78 public void testValidateOptionsInvalidDomainPath() throws Exception { 80 try{ 81 testCommand.setName("backup-domain"); 82 testCommand.setOption("domaindir", "InvalidDomainDir"); 83 testCommand.validateOptions(); 84 } 85 catch (CommandValidationException cve){ 86 assertEquals(cve.getMessage(), 87 "com.sun.enterprise.cli.framework.CommandException: Domain directory "+ 88 new File ("InvalidDomainDir").getAbsolutePath() +" is not a directory or does not exist."); 89 } 90 } 91 92 public BackupCommandsTest(String name){ 93 super(name); 94 } 95 96 BackupCommands testCommand = null; 97 98 protected void setUp() throws Exception { 99 final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance(); 104 ValidCommand validCommand = cliDescriptorsReader.getCommand(null); 105 LocalStringsManagerFactory.setCommandLocalStringsManagerProperties( 106 CLIDescriptorsReader.getInstance().getProperties()); 107 testCommand = new BackupCommands(); 108 testCommand.setName("sampleCommand"); 109 } 110 111 112 113 protected void tearDown() { 114 } 115 116 private void nyi(){ 117 fail("Not Yet Implemented"); 118 } 119 120 public static Test suite(){ 121 TestSuite suite = new TestSuite(BackupCommandsTest.class); 122 return suite; 123 } 124 125 public static void main(String args[]) throws Exception { 126 final TestRunner runner= new TestRunner(); 127 final TestResult result = runner.doRun(BackupCommandsTest.suite(), false); 128 System.exit(result.errorCount() + result.failureCount()); 129 } 130 } 131 132 | Popular Tags |