View Javadoc
1   /*******************************************************************************
2    * Portions created by Sebastian Thomschke are copyright (c) 2005-2013 Sebastian
3    * Thomschke.
4    *
5    * All Rights Reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    * http://www.eclipse.org/legal/epl-v10.html
9    *
10   * Contributors:
11   *     Sebastian Thomschke - initial implementation.
12   *******************************************************************************/
13  package net.sf.oval.test.guard;
14  
15  import junit.framework.TestCase;
16  import net.sf.oval.constraint.NotNull;
17  import net.sf.oval.guard.Guarded;
18  
19  /**
20   * @author Sebastian Thomschke
21   */
22  public class ChainedConstructorsTest extends TestCase
23  {
24  	@Guarded
25  	public static final class Entity
26  	{
27  		public Entity(@NotNull final Object param)
28  		{
29  			this(param.toString(), "whatever");
30  		}
31  
32  		public Entity(@NotNull final String param1, @NotNull final String params2)
33  		{
34  			// do stuff
35  		}
36  	}
37  
38  	@SuppressWarnings("unused")
39  	public void testConstructorChaining()
40  	{
41  		try
42  		{
43  			new Entity(null);
44  			fail();
45  		}
46  		catch (final Exception ex)
47  		{
48  			// TODO: currently fails with an NPE instead of a ConstraintViolationException https://sourceforge.net/p/oval/bugs/83/
49  		}
50  	}
51  }