01: /*******************************************************************************
02: * Copyright (c) 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.databinding.validation.ValidationStatus;
15: import org.eclipse.core.internal.databinding.conversion.StatusToStringConverter;
16: import org.eclipse.core.runtime.IStatus;
17:
18: /**
19: * @since 1.1
20: */
21: public class StatusToStringConverterTest extends TestCase {
22: private StatusToStringConverter converter;
23:
24: /* (non-Javadoc)
25: * @see junit.framework.TestCase#setUp()
26: */
27: protected void setUp() throws Exception {
28: super .setUp();
29:
30: converter = new StatusToStringConverter();
31: }
32:
33: public void testConvertedValueIsMessageOfStatus() throws Exception {
34: String message = "this is my message";
35: IStatus status = ValidationStatus.error(message);
36: assertEquals(message, converter.convert(status));
37: }
38:
39: public void testFromTypeIsIStatus() throws Exception {
40: assertEquals(IStatus.class, converter.getFromType());
41: }
42:
43: public void testToTypeIsString() throws Exception {
44: assertEquals(String.class, converter.getToType());
45: }
46:
47: public void testIllegalArgumentExceptionIsThrownWithNullInput()
48: throws Exception {
49: try {
50: converter.convert(null);
51: fail();
52: } catch (IllegalArgumentException e) {
53: }
54: }
55: }
|