Package com.eviware.soapui.model.testsuite

Examples of com.eviware.soapui.model.testsuite.TestCase


    for( int c = 0; c < project.getTestSuiteCount(); c++ )
    {
      TestSuite suite = project.getTestSuiteAt( c );
      for( int i = 0; i < suite.getTestCaseCount(); i++ )
      {
        TestCase tc = suite.getTestCaseAt( i );
        if( ( testSuite == null || suite.getName().equals( testSuite ) ) && testCase != null
            && tc.getName().equals( testCase ) )
          testCasesToRun.add( tc );

        addListeners( tc );
      }
    }

    try
    {
      // validate testSuite argument
      if( testCase != null && testCasesToRun.size() == 0 )
      {
        if( testSuite == null )
          throw new Exception( "TestCase with name [" + testCase + "] is missing in Project [" + project.getName()
              + "]" );
        else
          throw new Exception( "TestCase with name [" + testCase + "] in TestSuite [" + testSuite
              + "] is missing in Project [" + project.getName() + "]" );
      }

      // decide what to run
      if( testCasesToRun.size() > 0 )
      {
        for( TestCase testCase : testCasesToRun )
          runTestCase( ( WsdlTestCase )testCase );
      }
      else if( testSuite != null )
      {
        WsdlTestSuite ts = project.getTestSuiteByName( testSuite );
        if( ts == null )
          throw new Exception( "TestSuite with name [" + testSuite + "] not found in project" );
        else
          runSuite( ts );
      }
      else
      {
        runProject( project );
      }

      long timeTaken = ( System.nanoTime() - startTime ) / 1000000;

      if( printReport )
      {
        printReport( timeTaken );
      }

      exportReports( project );

      if( saveAfterRun && !project.isRemote() )
      {
        try
        {
          project.save();
        }
        catch( Throwable t )
        {
          log.error( "Failed to save project", t );
        }
      }

      if( ( assertions.size() > 0 || failedTests.size() > 0 ) && !ignoreErrors )
      {
        throwFailureException();
      }

      return true;
    }
    finally
    {
      for( int c = 0; c < project.getTestSuiteCount(); c++ )
      {
        TestSuite suite = project.getTestSuiteAt( c );
        for( int i = 0; i < suite.getTestCaseCount(); i++ )
        {
          TestCase tc = suite.getTestCaseAt( i );
          removeListeners( tc );
        }
      }
    }
  }
View Full Code Here


    {
      try
      {
        String exportSeparator = System.getProperty( SOAPUI_EXPORT_SEPARATOR, "-" );

        TestCase tc = currentStep.getTestCase();
        String nameBase = StringUtils.createFileName( tc.getTestSuite().getName(), '_' ) + exportSeparator
            + StringUtils.createFileName( tc.getName(), '_' ) + exportSeparator
            + StringUtils.createFileName( currentStep.getName(), '_' ) + "-" + count.longValue() + "-"
            + result.getStatus();

        WsdlTestCaseRunner callingTestCaseRunner = ( WsdlTestCaseRunner )runContext
            .getProperty( "#CallingTestCaseRunner#" );

        if( callingTestCaseRunner != null )
        {
          WsdlTestCase ctc = callingTestCaseRunner.getTestCase();
          WsdlRunTestCaseTestStep runTestCaseTestStep = ( WsdlRunTestCaseTestStep )runContext
              .getProperty( "#CallingRunTestCaseStep#" );

          nameBase = StringUtils.createFileName( ctc.getTestSuite().getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( ctc.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( runTestCaseTestStep.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( tc.getTestSuite().getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( tc.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( currentStep.getName(), '_' ) + "-" + count.longValue() + "-"
              + result.getStatus();
        }

        String absoluteOutputFolder = getAbsoluteOutputFolder( ModelSupport.getModelItemProject( tc ) );
View Full Code Here

    testSuite.addTestSuiteListener( internalTestSuiteListener );

    for( int c = 0; c < testSuite.getTestCaseCount(); c++ )
    {
      TestCase testCase = testSuite.getTestCaseAt( c );
      testCase.addPropertyChangeListener( TestCase.NAME_PROPERTY, propertyChangeListener );
      testCaseNodes.add( new TestCaseTreeNode( testCase, getTreeModel() ) );
    }

    getTreeModel().mapModelItems( testCaseNodes );
View Full Code Here

    for( int c = 0; c < project.getTestSuiteCount(); c++ )
    {
      TestSuite suite = project.getTestSuiteAt( c );
      for( int i = 0; i < suite.getTestCaseCount(); i++ )
      {
        TestCase tc = suite.getTestCaseAt( i );
        if( ( testSuite == null || suite.getName().equals( suite.getName() ) ) && testCase != null
            && tc.getName().equals( testCase ) )
          testCasesToRun.add( tc );

        addListeners( tc );
      }
    }
View Full Code Here

    {
      try
      {
        String exportSeparator = System.getProperty( SOAPUI_EXPORT_SEPARATOR, "-" );

        TestCase tc = currentStep.getTestCase();

        String nameBase = StringUtils.createFileName( securityTestName, '_' ) + exportSeparator
            + StringUtils.createFileName( securityScanName, '_' ) + exportSeparator
            + StringUtils.createFileName( tc.getTestSuite().getName(), '_' ) + exportSeparator
            + StringUtils.createFileName( tc.getName(), '_' ) + exportSeparator
            + StringUtils.createFileName( currentStep.getName(), '_' ) + "-" + count.longValue() + "-"
            + result.getStatus();

        WsdlTestCaseRunner callingTestCaseRunner = ( WsdlTestCaseRunner )runContext
            .getProperty( "#CallingTestCaseRunner#" );

        if( callingTestCaseRunner != null )
        {
          WsdlTestCase ctc = callingTestCaseRunner.getTestCase();
          WsdlRunTestCaseTestStep runTestCaseTestStep = ( WsdlRunTestCaseTestStep )runContext
              .getProperty( "#CallingRunTestCaseStep#" );

          nameBase = StringUtils.createFileName( securityTestName, '_' ) + exportSeparator
              + StringUtils.createFileName( ctc.getTestSuite().getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( ctc.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( runTestCaseTestStep.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( tc.getTestSuite().getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( tc.getName(), '_' ) + exportSeparator
              + StringUtils.createFileName( currentStep.getName(), '_' ) + "-" + count.longValue() + "-"
              + result.getStatus();
        }

        String absoluteOutputFolder = getAbsoluteOutputFolder( ModelSupport.getModelItemProject( tc ) );
View Full Code Here

  private String getScopedProperty( PropertyExpansionContext context, String pe, boolean globalOverride )
  {
    ModelItem modelItem = context.getModelItem();

    TestStep testStep = null;
    TestCase testCase = null;
    TestSuite testSuite = null;
    Project project = null;
    WsdlMockService mockService = null;
    WsdlMockResponse mockResponse = null;
    SecurityTest securityTest = null;

    if( modelItem instanceof WsdlTestStep )
    {
      testStep = ( WsdlTestStep )modelItem;
      testCase = testStep.getTestCase();
      testSuite = testCase.getTestSuite();
      project = testSuite.getProject();
    }
    else if( modelItem instanceof WsdlTestCase )
    {
      testCase = ( WsdlTestCase )modelItem;
      testSuite = testCase.getTestSuite();
      project = testSuite.getProject();
    }
    else if( modelItem instanceof WsdlLoadTest )
    {
      testCase = ( ( WsdlLoadTest )modelItem ).getTestCase();
      testSuite = testCase.getTestSuite();
      project = testSuite.getProject();
    }
    else if( modelItem instanceof WsdlTestSuite )
    {
      testSuite = ( WsdlTestSuite )modelItem;
      project = testSuite.getProject();
    }
    else if( modelItem instanceof WsdlInterface )
    {
      project = ( ( WsdlInterface )modelItem ).getProject();
    }
    else if( modelItem instanceof WsdlProject )
    {
      project = ( WsdlProject )modelItem;
    }
    else if( modelItem instanceof WsdlMockService )
    {
      mockService = ( WsdlMockService )modelItem;
      project = mockService.getProject();
    }
    else if( modelItem instanceof TestRequest )
    {
      testStep = ( ( TestRequest )modelItem ).getTestStep();
      testCase = testStep.getTestCase();
      testSuite = testCase.getTestSuite();
      project = testSuite.getProject();
    }
    else if( modelItem instanceof AbstractHttpRequestInterface<?> )
    {
      project = ( ( AbstractHttpRequest<?> )modelItem ).getOperation().getInterface().getProject();
    }
    else if( modelItem instanceof WsdlMockOperation )
    {
      mockService = ( ( WsdlMockOperation )modelItem ).getMockService();
      project = mockService.getProject();
    }
    else if( modelItem instanceof WsdlMockResponse )
    {
      mockResponse = ( WsdlMockResponse )modelItem;
      mockService = mockResponse.getMockOperation().getMockService();
      project = mockService.getProject();
    }
    else if( modelItem instanceof SecurityTest )
    {
      securityTest = ( SecurityTest )modelItem;
      testCase = ( ( SecurityTest )modelItem ).getTestCase();
      testSuite = testCase.getTestSuite();
      project = testSuite.getProject();
    }

    // no project -> nothing
    if( project == null )
View Full Code Here

    {
      Component result = super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );

      if( value instanceof TestCase )
      {
        TestCase item = ( TestCase )value;
        setIcon( item.getIcon() );
        setText( item.getName() );
      }

      return result;
    }
View Full Code Here

      return items;
    }

    Project project = securityScan.getTestStep().getTestCase().getTestSuite().getProject();
    TestSuite targetTestSuite = project.getTestSuiteByName( targetTestSuiteName );
    TestCase targetTestCase = targetTestSuite.getTestCaseByName( targetTestCaseName );
    SecurityTest targetSecurityTest = targetTestCase.getSecurityTestByName( targetSecurityTestName );
    TestStep targetTestStep = targetTestCase.getTestStepByName( targetSecurityTestStepName );

    boolean overwrite = dialog.getBooleanValue( CloneParameterDialog.OVERWRITE );

    for( String scanName : targetSecurityScans )
    {
View Full Code Here

    okAction.setDialog( dialog );
    cancelAction.setDialog( dialog );
    applyAction.setDialog( dialog );

    final TestCase testCase = securityScan.getTestStep().getTestCase();
    final Project project = testCase.getTestSuite().getProject();

    dialog.getFormField( CloneParameterDialog.TARGET_TESTSUITE ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        TestSuite testSuite = project.getTestSuiteByName( newValue );
        String[] testCaseNames = ModelSupport.getNames( testSuite.getTestCaseList() );
        dialog.setOptions( CloneParameterDialog.TARGET_TESTCASE, testCaseNames );

        if( testCaseNames.length > 0 )
        {
          dialog.setValue( CloneParameterDialog.TARGET_TESTCASE, testCaseNames[0] );
          TestCase testCase = testSuite.getTestCaseByName( testCaseNames[0] );

          String[] testStepNames = new String[0];
          String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
          if( securityTestNames.length > 0 )
          {
            testStepNames = getSecurableTestStepsNames( testCase );
          }
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );

          if( securityTestNames.length > 0 )
          {
            dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
            if( testStepNames.length > 0 )
            {
              dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
            }
            else
            {
              dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
            }

            String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
            SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
            String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
            TestStep testStep = testCase.getTestStepByName( testStepName );
            String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
                testStep.getId(), AbstractSecurityScanWithProperties.class ) );
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
          }
          else
          {
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
            dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
          }
        }
        else
        {
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
        }
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_TESTCASE ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        TestCase testCase = testSuite.getTestCaseByName( newValue );

        String[] testStepNames = new String[0];
        String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
        dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
        if( securityTestNames.length > 0 )
        {
          testStepNames = getSecurableTestStepsNames( testCase );
        }
        dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );

        if( securityTestNames.length > 0 )
        {
          dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
          if( testStepNames.length > 0 )
          {
            dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
          }
          else
          {
            dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
          }

          String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
          SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
          String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
          TestStep testStep = testCase.getTestStepByName( testStepName );
          String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
              testStep.getId(), AbstractSecurityScanWithProperties.class ) );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
        }
        else
        {
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
        }
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_TESTSTEP ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
        TestCase testCase = testSuite.getTestCaseByName( testCaseName );
        String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
        SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
        TestStep testStep = testCase.getTestStepByName( newValue );

        String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
            testStep.getId(), AbstractSecurityScanWithProperties.class ) );
        dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_SECURITYTEST ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
        TestCase testCase = testSuite.getTestCaseByName( testCaseName );
        SecurityTest securityTest = testCase.getSecurityTestByName( newValue );
        String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
        TestStep testStep = testCase.getTestStepByName( testStepName );

        String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
            testStep.getId(), AbstractSecurityScanWithProperties.class ) );
        dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
      }
View Full Code Here

      }
    }

    if( httpRequest instanceof TestRequest )
    {
      TestCase tc = ( ( TestRequest )httpRequest ).getTestStep().getTestCase();
      if( tc instanceof WsdlTestCase && ( ( WsdlTestCase )tc ).isForLoadTest() )
      {
        initHeadersForLoadTest( httpMethod );
        return;
      }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.model.testsuite.TestCase

Copyright © 2018 www.massapicom. 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.