⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packagetest.java

📁 测试工具
💻 JAVA
字号:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

/*
 * Created on Jul 16, 2003
 *
 */
package org.apache.jmeter.testelement;

import junit.framework.TestCase;

import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.config.LoginConfig;
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;

/**
 * 
 * @author unattributed
 * @version $Revision: 493796 $ $Date: 2007-01-07 18:31:05 +0000 (Sun, 07 Jan 2007) $
 */
public class PackageTest extends TestCase {
	public PackageTest(String arg0) {
		super(arg0);
	}

	public void testRecovery() throws Exception {
		ConfigTestElement config = new ConfigTestElement();
		config.addProperty(new StringProperty("name", "config"));
		config.setRunningVersion(true);
		LoginConfig loginConfig = new LoginConfig();
		loginConfig.setUsername("user1");
		loginConfig.setPassword("pass1");
		assertTrue(config.getProperty("login") instanceof NullProperty);
		// This test should work whether or not all Nulls are equal
		assertEquals(new NullProperty("login"), config.getProperty("login"));
		config.addProperty(new TestElementProperty("login", loginConfig));
		assertEquals(loginConfig.toString(), config.getPropertyAsString("login"));
		config.recoverRunningVersion();
		assertTrue(config.getProperty("login") instanceof NullProperty);
		assertEquals(new NullProperty("login"), config.getProperty("login"));
	}

	public void testArguments() throws Exception {
		Arguments args = new Arguments();
		args.addArgument("arg1", "val1", "=");
		TestElementProperty prop = new TestElementProperty("args", args);
		ConfigTestElement te = new ConfigTestElement();
		te.addProperty(prop);
		te.setRunningVersion(true);
		Arguments config = new Arguments();
		config.addArgument("config1", "configValue", "=");
		TestElementProperty configProp = new TestElementProperty("args", config);
		ConfigTestElement te2 = new ConfigTestElement();
		te2.addProperty(configProp);
		te.addTestElement(te2);
		assertEquals(2, args.getArgumentCount());
		assertEquals("config1=configValue", args.getArgument(1).toString());
		te.recoverRunningVersion();
		te.addTestElement(te2);
		assertEquals(2, args.getArgumentCount());
		assertEquals("config1=configValue", args.getArgument(1).toString());

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -