1   package com.lexicalscope.jewel.cli;
2   
3   import static org.hamcrest.Matchers.equalTo;
4   
5   import org.junit.Rule;
6   import org.junit.Test;
7   import org.junit.rules.ExpectedException;
8   
9   /*
10   * Copyright 2011 Tim Wood
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   * http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License. 
23   */
24  
25  public class TestInvalidSpecificationErrorHandling {
26      @Rule public final ExpectedException exception = ExpectedException.none();
27  
28      public interface InvalidDefaultOptionSpecification {
29          @Option(defaultToNull = true, defaultValue = { "another value" }) public String incorrectlySpecified();
30      }
31  
32      @Test public void testNullAndNonNullDefaults()
33      {
34          exception.expect(InvalidOptionSpecificationException.class);
35          exception
36                  .expectMessage(equalTo("option cannot have null default and non-null default value: public java.lang.String incorrectlySpecified()"));
37          CliFactory.createCli(InvalidDefaultOptionSpecification.class);
38      }
39  }