01: /*******************************************************************************
02: * Copyright (c) 2006 Cerner 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: * Brad Reynolds - initial API and implementation
10: ******************************************************************************/package org.eclipse.core.tests.databinding.observable;
11:
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: import org.eclipse.core.databinding.observable.Observables;
16: import org.eclipse.core.databinding.observable.list.IObservableList;
17: import org.eclipse.core.databinding.observable.list.ObservableList;
18: import org.eclipse.core.internal.databinding.observable.UnmodifiableObservableList;
19: import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
20:
21: public class ObservablesTest extends AbstractDefaultRealmTestCase {
22: public void testUnmodifableObservableListExceptions()
23: throws Exception {
24: try {
25: Observables.unmodifiableObservableList(null);
26: fail("IllegalArgumentException should have been thrown.");
27: } catch (IllegalArgumentException e) {
28: }
29: }
30:
31: public void testUnmodifiableObservableList() throws Exception {
32: IObservableList unmodifiable = Observables
33: .unmodifiableObservableList(new ObservableListStub(
34: new ArrayList(0), String.class));
35: assertTrue(unmodifiable instanceof UnmodifiableObservableList);
36: }
37:
38: private static class ObservableListStub extends ObservableList {
39: /**
40: * @param wrappedList
41: * @param elementType
42: */
43: protected ObservableListStub(List wrappedList,
44: Object elementType) {
45: super(wrappedList, elementType);
46: }
47: }
48: }
|