01: /*******************************************************************************
02: * Copyright (c) 2007 Brad Reynolds 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: * Brad Reynolds - initial API and implementation
10: ******************************************************************************/package org.eclipse.core.tests.internal.databinding.internal.beans;
11:
12: import java.beans.PropertyDescriptor;
13:
14: import org.eclipse.core.databinding.observable.value.WritableValue;
15: import org.eclipse.core.internal.databinding.internal.beans.BeanObservableValueDecorator;
16: import org.eclipse.core.internal.databinding.internal.beans.JavaBeanObservableValue;
17: import org.eclipse.jface.databinding.swt.SWTObservables;
18: import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
19: import org.eclipse.swt.widgets.Display;
20:
21: /**
22: * @since 3.3
23: */
24: public class BeanObservableValueDecoratorTest extends
25: AbstractDefaultRealmTestCase {
26: private Bean bean;
27: private JavaBeanObservableValue observableValue;
28: private BeanObservableValueDecorator decorator;
29: private PropertyDescriptor propertyDescriptor;
30:
31: /*
32: * (non-Javadoc)
33: *
34: * @see junit.framework.TestCase#setUp()
35: */
36: protected void setUp() throws Exception {
37: super .setUp();
38:
39: bean = new Bean();
40: propertyDescriptor = new PropertyDescriptor("value", Bean.class);
41: observableValue = new JavaBeanObservableValue(SWTObservables
42: .getRealm(Display.getDefault()), bean,
43: propertyDescriptor);
44: decorator = new BeanObservableValueDecorator(observableValue,
45: new WritableValue(bean, Object.class), observableValue
46: .getPropertyDescriptor());
47: }
48:
49: public void testGetDelegate() throws Exception {
50: assertEquals(observableValue, decorator.getDelegate());
51: }
52:
53: public void testGetObserved() throws Exception {
54: assertEquals(bean, decorator.getObserved());
55: }
56:
57: public void testGetPropertyDescriptor() throws Exception {
58: assertEquals(propertyDescriptor, decorator
59: .getPropertyDescriptor());
60: }
61: }
|