On 1/23/07, sebb <[EMAIL PROTECTED]> wrote:

Unless you need i18n, just implement the getLabel() method.


Aha, yes, having looked at the superclass implementation I now see that is
the way forwards here.

I can see my JAR file on the classpath, but nothing else of note.

It should appear in the GUI if you have got the class structure correct.



Which I clearly do not. Harumph.

I've now switched to doing my jar compilation from within Ant, whereas
previously I was using Eclipse which resulted in all sorts of build output
folders/up-to-date JAR containing out-of-date Class hilarity. Adding a new
top-level set of classes within the jakarta-jmeter-2.2 folder structure
alongside core,components,functions etc seems to have cleared that up. I've
also had a side tour through how all the right-click popup menus are build
(answer for future googlenauts: through elegant reflection in
org.apache.jmeter.gui.util.MenuFactory.java).

Now, however, with my fresh Jar file on the classpath for JMeter at runtime
I can see two "Transaction Controller" instances in the Logic Controllers
menu. If I add them both to a test plan, save it, and inspect the JMX I see:

     <hashTree>
       <TransactionController guiclass="
org.apache.jmeter.control.gui.FailingTransactionControllerGui"
testclass="TransactionController" testname="Tra
nsaction Controller" enabled="true"/>
       <hashTree/>
       <TransactionController guiclass="TransactionControllerGui"
testclass="TransactionController" testname="Transaction Controller"
enabled="true"/>
       <hashTree/>
     </hashTree>

Obviously, the second is the normal JMeter Transaction Controller and is OK,
but the first is my new one and it's broken. My GUI class is somehow
registered against the old Transaction Controller class.

I've stared and stared at this code and I cannot see why this is happening.
I've attached both files, but it seems to me the important bit is in
FailingTransactionControllerGui:

   /* Implements JMeterGUIComponent.createTestElement() */
   public TestElement createTestElement() {
       FailingTransactionController lc = new
FailingTransactionController();
       configureTestElement(lc);
       return lc;
   }

What is wrong with this bit of code?  Why is my testclass assoiciated with
this guiclass incorrect?
/**
Project:		EasySellFlights

Class Name:		FailingTransactionController.java

This module Comtec Limited STRICTLY PRIVATE AND CONFIDENTIAL code.
(C) COPYRIGHT 2005 Comtec. All Rights Reserved.
*/

/**
* <dl>
* <dt> <b>Description:</b><dd>
* See below.
*
* <dt> <b>Revision History:</b><dd>
* <dt><dd>
*  <pre> $History: FailingTransactionController.java $
* </dl></pre>
*
*   @version        $Revision: 5 $
*   @author         Richard Gaywood
*
*/

package org.apache.jmeter.control;

import java.io.Serializable;

import org.apache.jmeter.samplers.SampleEvent;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterThread;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.threads.ListenerNotifier;
import org.apache.jmeter.threads.SamplePackage;

import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;


public class FailingTransactionController  extends GenericController implements Controller, Serializable {
    protected static final Logger log = LoggingManager.getLoggerForClass();

    transient private String threadName;

    transient private ListenerNotifier lnf;

    transient private JMeterContext threadContext;

    transient private JMeterVariables threadVars;

    transient private SampleResult res;
    
    transient private Sampler lastSampler;
    transient private boolean succeeded;

    /**
     * Creates a Transaction Controller
     */
    public FailingTransactionController() {
        threadName = Thread.currentThread().getName();
        lnf = new ListenerNotifier();
        succeeded=true;
        log_debug("FailingTransactionCOntroller created RMG");
    }

    private void log_debug(String s) {
        String n = this.getName();
        log.debug(threadName + " " + n + " " + s);
    }

    private int calls;

    /**
     * @see org.apache.jmeter.control.Controller#next()
     */
    public Sampler next() {
        Sampler returnValue = null;
        if (isFirst()) // must be the start of the subtree
        {
            log_debug("+++++++++++++++++++++++++++++");
            calls = 0;
            res = new SampleResult();
            res.sampleStart();
        } else {
            // once it's false, it stays false
            if (succeeded==true)
                succeeded = threadContext.getPreviousResult().isSuccessful();
        }

        calls++;

        returnValue = super.next();
       

        if (returnValue == null) // Must be the end of the controller
        {
            log_debug("-----------------------------" + calls);
            if (res == null) {
                log_debug("already called");
            } else {
                res.sampleEnd();
                res.setSuccessful(succeeded);
                res.setSampleLabel(getName());
                res.setResponseCodeOK();
                res.setResponseMessage("Called: " + calls);
                res.setThreadName(threadName);

                // TODO could these be done earlier (or just once?)
                threadContext = getThreadContext();
                threadVars = threadContext.getVariables();

                SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT);
                if (pack == null) {
                    log.warn("Could not fetch SamplePackage");
                } else {
                    lnf.notifyListeners(new SampleEvent(res, getName()), pack.getSampleListeners());
                }
                res = null;
            }
        }

        lastSampler=returnValue;
        return returnValue;
    }
    
    
}
/**
Project:		EasySellFlights

Class Name:		FailingTransactionControllerGui.java

This module Comtec Limited STRICTLY PRIVATE AND CONFIDENTIAL code.
(C) COPYRIGHT 2005 Comtec. All Rights Reserved.
*/

/**
* <dl>
* <dt> <b>Description:</b><dd>
* See below.
*
* <dt> <b>Revision History:</b><dd>
* <dt><dd>
*  <pre> $History: FailingTransactionControllerGui.java $
* </dl></pre>
*
*   @version        $Revision: 5 $
*   @author         Richard Gaywood
*
*/

package org.apache.jmeter.control.gui;

import java.awt.BorderLayout;

import org.apache.jmeter.control.FailingTransactionController;
import org.apache.jmeter.control.gui.AbstractControllerGui;
import org.apache.jmeter.testelement.TestElement;

public class FailingTransactionControllerGui extends AbstractControllerGui {
    /**
     * Create a new FailingTransactionControllerGui instance.
     */
    public FailingTransactionControllerGui() {
        init();
    }

    /* Implements JMeterGUIComponent.createTestElement() */
    public TestElement createTestElement() {
        FailingTransactionController lc = new FailingTransactionController();
        System.err.println("HELLO!" + lc.getClass());  
        configureTestElement(lc);
        return lc;
    }

    /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
    public void modifyTestElement(TestElement el) {
        configureTestElement(el);
    }

    
    public String getStaticLabel() {
        return "Failing Transaction Controller";
    }
    
    public String getLabelResource() {
        return "failing_transaction_controller_title";
    }

    /**
     * Initialize the GUI components and layout for this component.
     */
    private void init() {
        setLayout(new BorderLayout());
        setBorder(makeBorder());
        add(makeTitlePanel(), BorderLayout.NORTH);
    }
    
  
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to