You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Erick Erickson <er...@gmail.com> on 2013/06/15 14:46:34 UTC

Restoring system variables

I just ran across this little gem in a test:

  @Rule
  public TestRule solrTestRules =
      RuleChain.outerRule(new SystemPropertiesRestoreRule())

Without looking at the code, I'm guessing that this will restore any
system variables that you change in a test, is this correct?

If so, I've found a new trick to make test writing easier <G>.....

Thanks,
Erick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Restoring system variables

Posted by Erick Erickson <er...@gmail.com>.
Thanks for the confirmation!

In this case I'm explicitly testing whether the persisted values in
solr.xml are the original, i.e something like
config="${mysystemvar:defaultvalue}" _but_ the actual value used in
Solr is the -Dmysystemvar=whatever and we don't store back
config="whatever"... i'm using unlikely system variable names, but
it's still best to have them undefined after the test I think...

Thanks again
Erick

On Sat, Jun 15, 2013 at 8:52 AM, Dawid Weiss <da...@gmail.com> wrote:
> Yep. You cqn use that but it would be probably better if you did not have go
> modify system properties at all? ;)
>
> On Jun 15, 2013 2:47 PM, "Erick Erickson" <er...@gmail.com> wrote:
>>
>> I just ran across this little gem in a test:
>>
>>   @Rule
>>   public TestRule solrTestRules =
>>       RuleChain.outerRule(new SystemPropertiesRestoreRule())
>>
>> Without looking at the code, I'm guessing that this will restore any
>> system variables that you change in a test, is this correct?
>>
>> If so, I've found a new trick to make test writing easier <G>.....
>>
>> Thanks,
>> Erick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Restoring system variables

Posted by Dawid Weiss <da...@gmail.com>.
Yep. You cqn use that but it would be probably better if you did not have
go modify system properties at all? ;)
On Jun 15, 2013 2:47 PM, "Erick Erickson" <er...@gmail.com> wrote:

> I just ran across this little gem in a test:
>
>   @Rule
>   public TestRule solrTestRules =
>       RuleChain.outerRule(new SystemPropertiesRestoreRule())
>
> Without looking at the code, I'm guessing that this will restore any
> system variables that you change in a test, is this correct?
>
> If so, I've found a new trick to make test writing easier <G>.....
>
> Thanks,
> Erick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>