01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.core.tests.internal.databinding.conversion;
11:
12: import junit.framework.TestCase;
13:
14: import org.eclipse.core.internal.databinding.validation.ObjectToPrimitiveValidator;
15: import org.eclipse.core.runtime.IStatus;
16:
17: /**
18: * @since 3.2
19: *
20: */
21: public class ObjectToPrimitiveValidatorTest extends TestCase {
22:
23: private ObjectToPrimitiveValidator objectToPrimitiveValidator;
24:
25: protected void setUp() throws Exception {
26: this .objectToPrimitiveValidator = new ObjectToPrimitiveValidator(
27: Integer.TYPE);
28: }
29:
30: /**
31: * Test method for
32: * {@link org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidator#isValid(java.lang.Object)}.
33: */
34: public void testIsValid() {
35: IStatus result = this .objectToPrimitiveValidator.validate(null);
36: assertEquals("The wrong validation error was found.", result
37: .getMessage(), this .objectToPrimitiveValidator
38: .getNullHint());
39:
40: result = this .objectToPrimitiveValidator
41: .validate(new Integer(1));
42: assertTrue("No validation error should be found.", result
43: .isOK());
44:
45: result = this .objectToPrimitiveValidator.validate(new Object());
46: assertEquals("The wrong validation error was found.", result
47: .getMessage(), this.objectToPrimitiveValidator
48: .getClassHint());
49: }
50:
51: }
|