public void ConfigDefaultAndProtected() { UT_INIT(); String[] args= { "COMMANDLINE", "--TEST_VARIABLE=fromCommandLine", }; Configuration cfg= new Configuration(); cfg.SetCommandLineArgs( args ); Variable var= new Variable(); // command line UT_EQ( Configuration.PrioCmdLine, cfg.Load ( var.Define( "TEST", "VARIABLE" ) ) ); UT_EQ( "fromCommandLine" ,var.GetString() ); // set default, does not overwrite cfg.DefaultValues.Store( var.Define("TEST", "VARIABLE"), "not overwriting" ); UT_EQ( Configuration.PrioCmdLine, cfg.Load ( var.Define( "TEST", "VARIABLE" ) ) ); UT_EQ( "fromCommandLine" ,var.GetString() ); // set protected, overwrites command line cfg.ProtectedValues.Store( var.Define("TEST", "VARIABLE"), "does overwrite" ); UT_EQ( Configuration.PrioProtected, cfg.Load ( var.Define( "TEST", "VARIABLE" ) ) ); UT_EQ( "does overwrite" ,var.GetString() ); // set default, something else cfg.DefaultValues.Store( var.Define("TEST", "VAR2"), "this is var 2" ); UT_EQ( Configuration.PrioDefault, cfg.Load ( var.Define( "TEST", "VAR2" ) ) ); UT_EQ( "this is var 2" ,var.GetString() ); // set and remove an entry using plugin interface var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg.DefaultValues.Load( var ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); var.AddString("To be deleted"); UT_EQ( 1, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg.DefaultValues.Store( var ); UT_EQ( 1, var.Size() ); UT_EQ( -1 ,var.Priority ); var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg.DefaultValues.Load( var ); UT_EQ( 1, var.Size() ); UT_EQ( -1 ,var.Priority ); var.ClearValues(); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg.DefaultValues.Store( var ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg.DefaultValues.Load( var ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); // set and remove an entry using configuration interface cfg .Load ( var ); UT_EQ( 0, var.Size() ); UT_EQ( 0 ,var.Priority ); cfg .Store( var ); UT_EQ( 0, var.Size() ); UT_EQ( 0 ,var.Priority ); var.AddString("To be deleted"); UT_EQ( 1, var.Size() ); UT_EQ( 0 ,var.Priority ); cfg .Store( var ); UT_EQ( 1, var.Size() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg .Load ( var ); UT_EQ( 1, var.Size() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg .Store( var ); UT_EQ( 0, var.Size() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); cfg .Load ( var ); UT_EQ( 0, var.Size() ); UT_EQ( 0 ,var.Priority ); var.Define( "TEST", "Remove" ); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); cfg .Load ( var ); UT_EQ( 0, var.Size() ); UT_EQ( 0 ,var.Priority ); // protected var.Define( "TEST", "Protected"); UT_EQ( 0, var.Size() ); UT_EQ( -1 ,var.Priority ); var.DefaultValue._( "Default" ); var.StoreDefault( "def par"); UT_EQ( "def par", var.GetString() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); var.ClearValues(); var.AddString( "def var" ); var.StoreDefault(); UT_EQ( "def var", var.GetString() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); var.ClearValues(); var.StoreDefault(); UT_EQ( "Default", var.GetString() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); var.ClearValues(); var.AddString( "def var" ); var.Protect(); UT_EQ( "def var", var.GetString() ); UT_EQ( Configuration.PrioProtected ,var.Priority ); var.Protect("prot par"); UT_EQ( "prot par", var.GetString() ); UT_EQ( Configuration.PrioProtected ,var.Priority ); var.ClearValues(); var.Protect(); UT_EQ( "Default", var.GetString() ); UT_EQ( Configuration.PrioProtected ,var.Priority ); var.DefaultValue.SetNull(); var.ClearValues(); var.Protect(); UT_EQ( 0, var.Size() ); UT_EQ( Configuration.PrioProtected ,var.Priority ); var.Load(); UT_EQ( "Default", var.GetString() ); UT_EQ( Configuration.PrioDefault ,var.Priority ); }