1   /*
2    * Copyright 2008 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.richclient.application.support;
17  
18  import javax.swing.JComponent;
19  import javax.swing.JLabel;
20  
21  import junit.framework.TestCase;
22  
23  /**
24   * testcase for {@link SimpleViewDescriptor}
25   * 
26   * @author Peter De Bruycker
27   */
28  public class SimpleViewDescriptorTests extends TestCase {
29  
30      private AbstractView view;
31  
32      public void testConstructor() {
33          SimpleViewDescriptor descriptor = new SimpleViewDescriptor("id", view);
34          assertEquals("id", descriptor.getId());
35          assertEquals(descriptor, view.getDescriptor());
36      }
37  
38      @Override
39      protected void setUp() throws Exception {
40          view = new AbstractView() {
41  
42              @Override
43              protected JComponent createControl() {
44                  return new JLabel("hello");
45              }
46          };
47  
48      }
49  
50      public void testCreatePageComponent() {
51          SimpleViewDescriptor descriptor = new SimpleViewDescriptor("id", view);
52  
53          assertSame(view, descriptor.createPageComponent());
54          // must always return the same
55          assertSame(view, descriptor.createPageComponent());
56      }
57  
58  }