2016-05-12 8 views
3

私はJavaクラスを作成し、それをJARとしてエクスポートしました。私はそれをJMeter($ JMETER_HOME/lib)に正常にインポートしたので、BeanshellサンプラーとJSR233サンプラーで正常にインポートできます。JMeter BeanShellまたはJSR233でPOJOを使用する

私はRunning Java class with JMeter (Bean Shell)のようないくつかの手順に従っているが、私はまだエラーを取得しています:

「コマンドが見つかりませんMYITEM(java.lang.Stringで、java.lang.Stringで)」クラスコンストラクタを使用しようとすると。

メソッドを使用しようとすると "メソッドを解決しようとしました:未定義の変数のgetDescription()..."

class MyJavaItem{ 

    //XML 
    String title; 
    String link; 
    String description; 
    String pubDate; 
    String guid; 
    String dcDate; 
    //JSON 
    int code; 
    String message; 
    String reference; 
    String documentId; 
    String documentType; 


    public MyJavaItem(String title, String description) { 

     this.title = title; 
     this.description = description; 
     // 
     JSONObject jsonObject = new JSONObject(description); 
     try { 
      message = jsonObject.getString("message"); 
     } catch (JSONException e){ 

     } 
     try { 
      code = jsonObject.getInt("code"); 
     } catch (JSONException e){ 

     } 
     try { 
      reference = jsonObject.getString("reference"); 
     } catch (JSONException e){ 

     } 
     try { 
      documentType = jsonObject.getString("documentType"); 
     } catch (JSONException e){ 

     } 
     try { 
      documentId = jsonObject.getString("documentId"); 
     } catch (JSONException e){ 

     } 

    } 

    public boolean containsReference(String ref){ 
     return 
       StringUtils.containsIgnoreCase(message,ref) || 
         StringUtils.containsIgnoreCase(documentId,ref) || 
         StringUtils.containsIgnoreCase(reference,ref); 

    } 

    public int getCode() { 
     return code; 
    } 

    public void setCode(int code) { 
     this.code = code; 
    } 

    public String getMessage() { 
     return message; 
    } 

    public void setMessage(String message) { 
     this.message = message; 
    } 

    public String getReference() { 
     return reference; 
    } 

    public void setReference(String reference) { 
     this.reference = reference; 
    } 

    public String getTitle() { 
     return title; 
    } 

    public void setTitle(String title) { 
     this.title = title; 
    } 

    public String getLink() { 
     return link; 
    } 

    public void setLink(String link) { 
     this.link = link; 
    } 

    public String getDescription() { 
     return description; 
    } 

    public void setDescription(String description) { 
     this.description = description; 
    } 

    public String getPubDate() { 
     return pubDate; 
    } 

    public void setPubDate(String pubDate) { 
     this.pubDate = pubDate; 
    } 

    public String getGuid() { 
     return guid; 
    } 

    public void setGuid(String guid) { 
     this.guid = guid; 
    } 

    public String getDcDate() { 
     return dcDate; 
    } 

    public void setDcDate(String dcDate) { 
     this.dcDate = dcDate; 
    } 

    public String getDocumentId() { 
     return documentId; 
    } 

    public void setDocumentId(String documentId) { 
     this.documentId = documentId; 
    } 

    public String getDocumentType() { 
     return documentType; 
    } 

    public void setDocumentType(String documentType) { 
     this.documentType = documentType; 
    } 

    public static MyJavaItem findByNumAtCard(ArrayList<MyJavaItem> activeMQArray, String numAtCard) { 
     for (MyJavaItem item : activeMQArray){ 
      if (item.containsReference(numAtCard)){ 
       return item; 
      } 
     } 
     return null; 
    } 
} 

そして、これが私のBeanShell/JSR233サンプラーです:

import MyJavaItem; 
import ParseXML; 
import java.util.List; 

String staging = ParseXML.staging; 
String returns = ParseXML.magentoReturnsResponses; 

ArrayList items = ParseXML.parseXML(staging,returns); 

log.info("" + bsh.shared.items.size()); 
for (Object item : items){ 
    MyJavaItem item = items.get(i); // VALID 
    MyJavaItem myItem = (MyJavaItem) item; //VALID 
    MyJavaItem aaaa = MyJavaItem("title","description"); //INVALID 
    aaa.getDescription(); //INVALID 
} 

答えて

1

あなたのクラスがpublicではないので、 "to the world" 表示されません。変更するには

public class MyJavaItem{ 
関連する問題