|
What this is
Other links
The source code
// $Header: /home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/PackageTest.java,v 1.10 2004/03/30 18:07:07 sebb Exp $
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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.
*
*/
/*
* Package to test functions
*
* Functions are created and parameters set up in one thread.
*
* They are then tested in another thread, or two threads running in parallel
*
*/
package org.apache.jmeter.functions;
import java.util.Collection;
import java.util.LinkedList;
import junit.extensions.ActiveTestSuite;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* @version $Revision: 1.10 $ $Date: 2004/03/30 18:07:07 $
*/
public class PackageTest extends JMeterTestCase
{
transient private static final Logger log = LoggingManager.getLoggerForClass();
static{
//LoggingManager.setPriority("DEBUG","jmeter");
//LoggingManager.setTarget(new java.io.PrintWriter(System.out));
}
public PackageTest(String arg0)
{
super(arg0);
}
// Create the CSVRead function and set its parameters.
private static CSVRead setParams(String p1, String p2) throws Exception
{
CSVRead cr = new CSVRead();
Collection parms = new LinkedList();
if (p1 != null) parms.add(new CompoundVariable(p1));
if (p2 != null) parms.add(new CompoundVariable(p2));
cr.setParameters(parms);
return cr;
}
// Create the StringFromFile function and set its parameters.
private static StringFromFile SFFParams(String p1, String p2, String p3, String p4)
throws Exception
{
StringFromFile sff = new StringFromFile();
Collection parms = new LinkedList();
if (p1 != null) parms.add(new CompoundVariable(p1));
if (p2 != null) parms.add(new CompoundVariable(p2));
if (p3 != null) parms.add(new CompoundVariable(p3));
if (p4 != null) parms.add(new CompoundVariable(p4));
sff.setParameters(parms);
return sff;
}
public static Test suite() throws Exception
{
TestSuite suite = new TestSuite("SingleThreaded");
suite.addTest(new PackageTest("CSVParams"));
suite.addTest(new PackageTest("CSVNoFile"));
suite.addTest(new PackageTest("CSVSetup"));
suite.addTest(new PackageTest("CSVRun"));
suite.addTest(new PackageTest("CSValias"));
suite.addTest(new PackageTest("CSVBlankLine"));
//Reset files
suite.addTest(new PackageTest("CSVSetup"));
TestSuite par = new ActiveTestSuite("Parallel");
par.addTest(new PackageTest("CSVThread1"));
par.addTest(new PackageTest("CSVThread2"));
suite.addTest(par);
TestSuite sff = new TestSuite("StringFromFile");
sff.addTest(new PackageTest("SFFTest1"));
suite.addTest(sff);
return suite;
}
public void SFFTest1() throws Exception
{
StringFromFile sff1 = SFFParams("testfiles/SFFTest#.txt","","1","3");
assertEquals("uno",sff1.execute());
assertEquals("dos",sff1.execute());
assertEquals("tres",sff1.execute());
assertEquals("cuatro",sff1.execute());
assertEquals("cinco",sff1.execute());
assertEquals("one",sff1.execute());
assertEquals("two",sff1.execute());
sff1.execute();
sff1.execute();
assertEquals("five",sff1.execute());
assertEquals("eins",sff1.execute());
sff1.execute();
sff1.execute();
sff1.execute();
assertEquals("fuenf",sff1.execute());
assertEquals("**ERR**",sff1.execute());
}
// Function objects to be tested
private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6;
// Helper class used to implement co-routine between two threads
private static class Baton{
void pass(){
done();
try
{
//System.out.println(">wait:"+Thread.currentThread().getName());
wait(1000);
}
catch (InterruptedException e)
{
System.out.println(e);
}
//System.out.println("
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.