01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.threads;
20:
21: import org.apache.jmeter.config.ConfigTestElement;
22: import org.apache.jmeter.control.GenericController;
23: import org.apache.jmeter.samplers.AbstractSampler;
24: import org.apache.jmeter.samplers.SampleResult;
25: import org.apache.jorphan.collections.ListedHashTree;
26:
27: public class TestTestCompiler extends junit.framework.TestCase {
28: public TestTestCompiler(String name) {
29: super (name);
30: }
31:
32: public void testConfigGathering() throws Exception {
33: ListedHashTree testing = new ListedHashTree();
34: GenericController controller = new GenericController();
35: ConfigTestElement config1 = new ConfigTestElement();
36: config1.setName("config1");
37: config1.setProperty("test.property", "A test value");
38: TestSampler sampler = new TestSampler();
39: sampler.setName("sampler");
40: testing.add(controller, config1);
41: testing.add(controller, sampler);
42: TestCompiler.initialize();
43:
44: TestCompiler compiler = new TestCompiler(testing,
45: new JMeterVariables());
46: testing.traverse(compiler);
47: sampler = (TestSampler) compiler.configureSampler(sampler)
48: .getSampler();
49: assertEquals("A test value", sampler
50: .getPropertyAsString("test.property"));
51: }
52:
53: class TestSampler extends AbstractSampler {
54: public SampleResult sample(org.apache.jmeter.samplers.Entry e) {
55: return null;
56: }
57:
58: public Object clone() {
59: return new TestSampler();
60: }
61: }
62: }
|