Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6eca4688144c43f80caba078b1216fc5d893e0f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
 * Copyright (c) 2001, 2008 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.common.runtime.tests.model.component;

import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.ValueHolderInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentFactory;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIOutputInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterTypeInfo;
import org.eclipse.jst.jsf.common.runtime.tests.model.RuntimeTestUtil;

public class TestUIOutputInfo extends TestComponentInfo {
    private UIOutputInfo _uiOutputInfo;
    private UIOutputInfo _uiOutputInfo2;
    private ValueHolderInfo _valueHolder;
    private ValueHolderInfo _valueHolder2;
    private ConverterDecorator _converter;
    private ConverterTypeInfo  _converterTypeInfo;
    private UIOutputInfo _uiOutputInfo_NoValueHolderAtConstruction;

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        _valueHolder = new ValueHolderInfo(null, "value", "value");
        _uiOutputInfo = ComponentFactory.createUIOutputInfo("id", null,
                _componentTypeInfo, _valueHolder, true);

        _converterTypeInfo = ConverterTypeInfo.UNKNOWN; 
        _converter = new ConverterDecorator(null, _converterTypeInfo);
        _valueHolder2 = new ValueHolderInfo(_converter, "value2", "value2");
        _uiOutputInfo2 = ComponentFactory.createUIOutputInfo("id2", null,
                _componentTypeInfo, _valueHolder2, true);

        _uiOutputInfo_NoValueHolderAtConstruction = ComponentFactory
                .createUIOutputInfo("id", null, _componentTypeInfo, null, true);
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testGetConverter() {
        // not converter by setup
        assertNull(_uiOutputInfo.getConverter());
        assertTrue(_uiOutputInfo.getDecorators(ComponentFactory.CONVERTER)
                .isEmpty());

        // this one has a converter by construction
        assertEquals(_converter, _uiOutputInfo2.getConverter());
        assertEquals(_converter, _uiOutputInfo2.getDecorators(
                ComponentFactory.CONVERTER).get(0));
        assertEquals(_converterTypeInfo, ((ConverterDecorator)_uiOutputInfo2.getDecorators(
                ComponentFactory.CONVERTER).get(0)).getTypeInfo());
    }

    public void testGetLocalValue() {
        assertEquals("value", _uiOutputInfo.getLocalValue());
        assertEquals("value2", _uiOutputInfo2.getLocalValue());
        assertNull(_uiOutputInfo_NoValueHolderAtConstruction.getLocalValue());
    }

    public void testGetValue() {
        assertEquals("value", _uiOutputInfo.getValue());
        assertEquals("value2", _uiOutputInfo2.getValue());
        assertNull(_uiOutputInfo_NoValueHolderAtConstruction.getValue());
    }

    public void testImplicitAdapter() {
        RuntimeTestUtil.verifyImplicitAdapter(getComponentInfo(),
                ComponentFactory.VALUE_HOLDER, _valueHolder);
    }

    @Override
    public void testSerializable() throws Exception {
        final UIOutputInfo deserialized = RuntimeTestUtil
                .serializeDeserialize(_uiOutputInfo);

        RuntimeTestUtil.verifySame(_uiOutputInfo, deserialized);

        final UIOutputInfo deserialized2 = RuntimeTestUtil
                .serializeDeserialize(_uiOutputInfo2);
        RuntimeTestUtil.verifySame(_uiOutputInfo2, deserialized2);
    }

    @Override
    protected ComponentInfo getComponentInfo() {
        return _uiOutputInfo;
    }
}

Back to the top