Package org.apache.jmeter.testelement

Source Code of org.apache.jmeter.testelement.PackageTest

/*
* 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());

  }

}
TOP

Related Classes of org.apache.jmeter.testelement.PackageTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.