View | Details | Raw Unified | Return to bug 58743
Collapse All | Expand All

(-)a/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java (+89 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 * License for the specific language governing permissions and limitations
15
 * under the License.
16
 *
17
 */
18
package org.apache.jmeter.testelement.property;
19
20
import static org.junit.Assert.assertThat;
21
22
import java.util.ArrayList;
23
import java.util.Collection;
24
import java.util.Collections;
25
import java.util.List;
26
27
import org.apache.jmeter.testelement.TestElement;
28
import org.hamcrest.CoreMatchers;
29
import org.junit.Before;
30
import org.junit.Test;
31
32
public class AbstractPropertyTest {
33
34
    private AbstractProperty dummyProperty;
35
36
    @SuppressWarnings("serial")
37
    @Before
38
    public void setUp() {
39
40
        this.dummyProperty = new AbstractProperty() {
41
42
            @Override
43
            public void setObjectValue(Object value) {
44
                // not needed for our tests
45
            }
46
47
            @Override
48
            public void recoverRunningVersion(TestElement owner) {
49
                // not needed for our tests
50
            }
51
52
            @Override
53
            public String getStringValue() {
54
                // not needed for our tests
55
                return null;
56
            }
57
58
            @Override
59
            public Object getObjectValue() {
60
                // not needed for our tests
61
                return null;
62
            }
63
        };
64
    }
65
66
    @Test
67
    public void testNormalizeListWithEmptyList() {
68
        Collection<JMeterProperty> emptyCollection = Collections.emptyList();
69
        Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(emptyCollection);
70
        assertThat(newCollection, CoreMatchers.nullValue());
71
    }
72
73
    @Test
74
    public void testNormalizeListWithEmptyArrayList() {
75
        Collection<JMeterProperty> emptyCollection = new ArrayList<JMeterProperty>();
76
        Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(emptyCollection);
77
        assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(emptyCollection)));
78
        assertThat(newCollection, CoreMatchers.equalTo(emptyCollection));
79
    }
80
81
    @Test
82
    public void testNormalizeListWithFilledArrayList() {
83
        List<JMeterProperty> filledCollection = new ArrayList<JMeterProperty>();
84
        filledCollection.add(new StringProperty("key", "value"));
85
        Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(filledCollection);
86
        assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(filledCollection)));
87
        assertThat(newCollection, CoreMatchers.equalTo(filledCollection));
88
    }
89
}

Return to bug 58743