Powered By Blogger

Tuesday, April 28, 2020

SOAP UI - Read Excel data using Groovy Code


How to read the data in excel using Groovy script in SOAP UI Free Version tool


To Read the data from excel sheet we need to download the "jxl-2.6.jar", any latest version can work
and place the jar in the location where SOAP UI in "ext" folder under "bin" (.\\SmartBear\SoapUI-5.5.0\bin\ext)

Groovy code for reading the Excel data - "save the excel file as *.xls file format"

// IMPORT THE LIBRARIES WE NEED

import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*

// DECLARE THE VARIABLES

def myTestCase = context.testCase //myTestCase contains the test case

def counter,next,previous,size //Variables used to handle the loop and to move inside the file
def ProjectPath = new com.eviware.soapui.support.GroovyUtils(context).projectPath+"/OnboardingsInput.xls" //(Give the required file name - Sample.xls)

log.info(ProjectPath)
Workbook workbook1 = Workbook.getWorkbook(new File(ProjectPath)) //file containing the data

Sheet sheet1 = workbook1.getSheet("ProfileController") // ( WorkBook -  Sheet name should be specified)

size= sheet1.getRows().toInteger() //get the number of rows, each row is a data set

propTestStep = myTestCase.getTestStepByName("ExcelProperties") // (Give the Name as Created for the Properties file - created in the TestSuite(TS) by Right Click on TS and Select the Properties file)

propTestStep.setPropertyValue("Total", size.toString())

counter = propTestStep.getPropertyValue("Count").toString() //counter variable contains iteration number

counter = counter.toInteger()

log.info(counter)


// OBTAINING THE DATA YOU NEED


// Code to read an single data

Cell m1 = sheet1.getCell(12,1)
CandidateID = m1.getContents()
propTestStep.setPropertyValue("CandidateID", CandidateID) //the value is saved in the property


//To get Complete  column values

for(i=1;i<size;i++)
{
          def G=sheet1.getCell(6,i).getContents()
          propTestStep.setPropertyValue("ResponseCode"+i,G)
}

//Decide if the test has to be run again or not

if (counter == size-1)
{
propTestStep.setPropertyValue("StopVal", "T")

log.info "Setting the StopVal property now..."
}

else if (counter==0)
{
def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
propTestStep.setPropertyValue("StopVal", "F")
}

else
{
propTestStep.setPropertyValue("StopVal", "F")
}


// To read and access the Values , create an "Excel Property" file in the Test Suite and create the Key and values of 3 variables

1. Count - 1
2. StopVal - F
3. Total - once executed automatically the value will be generated.






Saturday, August 12, 2017

How to Remove the Error in Maveen Project "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment."


To resolve this issue, please do the following steps, 
  1. Right click on the Maveen Project.
  2. Choose "Build path" in the Menu.
  3. Choose "Configure Build path".
  4. Choose "Libraries tab".
  5. Select "JRE System Library" and click on "Edit: button.
  6. Choose "workspace default JRE" and click "Finish".


Wednesday, June 22, 2016

Program : 22


 #include<stdio.h>
 #include<conio.h>
 struct slinklist
 {
    int data;
    struct slinklist *next;
 };
 typedef struct slinklist node;
 node *start=NULL;
 void createlist(int);
 void insert_node_at_begin();
Publish Post

 void insert_node_at_mid();
 void insert_node_at_end();
 void delete_node_at_begin();
 void delete_node_at_mid();
 void delete_node_at_end();
 void display_left_to_right();
 void display_right_to_left(node*);
 node *getnode();
 int countnode(node*);
 int menu();
 void main()
 {
    int ch,n=5;
    clrscr();
    do
    {
        ch=menu();
        switch(ch)
        {
            case 1:createlist(n);
                   break;
            case 2:insert_node_at_begin();
                   break;
            case 3:insert_node_at_mid();
                   break;
            case 4:insert_node_at_end();
                   break;
            case 5:delete_node_at_begin();
                   break;
            case 6:delete_node_at_mid();
                   break;
            case 7:delete_node_at_end();
                   break;
            case 8:display_left_to_right();
                   break;
            case 9:display_right_to_left(start);
                   break;
            case 10:exit(1);
            default:printf("wrong choice");
                   break;
        }
    }while(1);
    getch();
}
int menu()
{
    int ch;
    printf("menu\n");
    printf("1.create list \n");
    printf("2.insert node at begin\n");
    printf("3.insert node at mid\n");
    printf("4.insert node at end\n");
    printf("5.delete node at begin\n");
    printf("6.delete node at mid\n");
    printf("7.delete node at end\n");
    printf("8.display list from left to right\n");
    printf("9.display list from right to left\n");
    printf("10.exit\n");
    printf("enter your choice");
    scanf("%d",&ch);
    return(ch);
}
void createlist(int n)
{
    int i;
    node *newnode,*temp;
    for(i=0;i<n;i++)
    {
        newnode=getnode();
        if(start==NULL)
        {
            start=newnode;
        }
        else
        {
            temp=start;
            while(temp->next!=NULL)
            {
                temp=temp->next;
            }
            temp->next=newnode;
        }
    }
}
void insert_node_at_begin()
{
    node *newnode;
    newnode=getnode();
    if(start==NULL)
    {
        start=newnode;
    }
    else
    {
        newnode->next=start;
        start=newnode;
    }
}
void insert_node_at_mid()
{
    node *newnode,*post,*prev;
    int ctr=1,p,count;
    newnode=getnode();
    if(start==NULL)
    {
        start=newnode;
    }
    else
    {
        printf("enter the position");
        scanf("%d",&p);
        count=countnode(start);
        if(p>1&&p<count)
        {
            prev=start;
            post=start;
            while(ctr<p)
            {
                prev=post;
                post=post->next;
                ctr++;
            }
            prev->next=newnode;
            newnode->next=post;
        }
        else
            printf("invalid choice");
    }
}
void insert_node_at_end()
{
    node *newnode,*temp;
    newnode=getnode();
    if(start==NULL)
    start=newnode;
    else
    {
        temp=start;
        while(temp->next!=NULL)
        {
            temp=temp->next;
        }
        temp->next=newnode;
    }
}
void delete_node_at_begin()
{
    node *temp;
    if(start==NULL)
    printf("list is empty");
    else
    {
        temp=start;
        start=start->next;
        free(temp);
        printf("element is deleted");
    }
}
void delete_node_at_mid()
{
    node *temp,*prev;
    int ctr=1,p,count=0;
    if(start==NULL)
    printf("list is empty");
    else
    {
        printf("enter position");
        scanf("%d",&p);
        count=countnode(start);
        if(p>1&&p<count)
        {
            prev=start;
            temp=start;
            while(ctr<p)
            {
                prev=temp;
                temp=temp->next;
                ctr++;
            }
            prev->next=temp->next;
            free(temp);
        }
        else
        printf("invalid choice");
    }
}
void delete_node_at_end()
{
    node *temp,*prev;
    if(start==NULL)
    printf("list is empty");
    else
    {
        temp=start;
        prev=start;
        while(temp->next!=NULL)
        {
            prev=temp;
            temp=temp->next;
        }
        prev->next=NULL;
        free(temp);
    }
}
void display_left_to_right()
{
    node *temp;
    if(start==NULL)
    {
        printf("list is empty");
    }
    else
    {
           temp=start;
           while(temp!=NULL)
           {
            printf("%d",temp->data);
            temp=temp->next;
           }
    }
}
void display_right_to_left(node *st)
{
    if(st==NULL)
    return 0;
    else
    {
        display_right_to_left(st->next);
        printf("%d",st->data);
    }
}
int countnode(node *st)
{
    int count=0;
    node *temp;
    if(st==NULL)
    return 0;
    else
    return(1+countnode(st->next));
}
node *getnode()
{
    node *newnode;
    newnode=(node*)malloc(sizeof(node));
    printf("enter data");
    scanf("%d",&newnode->data);
    newnode->next=NULL;
    return(newnode);
}

Wednesday, February 26, 2014

Misc Programs

Deleting the Duplicates from an array

#include<stdio.h>
#include<conio.h>
void main()
{
   int n, a[10], b[10], count = 0, i, j;
   clrscr();
   printf("Enter the Range :");
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
      printf("Enter a[%d]",i);
      scanf("%d",&a[i]);
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<count;j++)
      {
     if(a[i]==b[j])
        break;
      }
      if(j==count)
      {
     b[count] = a[i];
     count++;
      }
   }
   printf("Array obtained after removing duplicate elements\n");
   for(i=0;i<count;i++)
      printf("%d\n",b[i]);

   getch();
}

Finding the Kth largest Element in an array

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[20];
    int num,k,i,c;
    clrscr();
    printf("Enter number of elements\n");
    scanf("%d",&num);
    printf("Enter elements\n");
    for(i=0;i<num;i++)
    {
         printf("Enter a[%d] = ",i);
         scanf("%d",&a[i]);
    }
    printf("Enter k\n");
    scanf("%d",&k);
    c=1;
    for(i=1;i<num;i++)
    {
              if(c==k)
              {
                  printf("kth Smallest with k=%d is %d",k,a[i-1]);
                  break;
              }
              if(a[i]!=a[i-1])
                  c++;
    }
    getch();

}

Saturday, February 22, 2014

Transpose of a Matrix

C Program for Transpose of a Matrix

#include <stdio.h>
#include<conio.h>
void main()
{
   int r, c, i, j, matrix[10][10], transpose[10][10];
   clrscr();
   printf("Enter the number of rows and columns of matrix ");
   scanf("%d%d",&r,&c);
   printf("Enter the elements of matrix \n");

   for( i = 0 ; i < r ; i++ )
   {
      for( j = 0 ; j < c ; j++ )
      {
         scanf("%d",&matrix[i][j]);
      }
   }
   for( i = 0 ; i < r ; i++ )
   {
      for( j = 0 ; j < c ; j++ )
      {
         transpose[j][i] = matrix[i][j];
      }
   }
   printf("Transpose of entered matrix :-\n");
   for( i = 0 ; i < c ; i++ )
   {
      for( j = 0 ; j < r ; j++ )
      {
         printf("%d\t",transpose[i][j]);
      } 
      printf("\n");
   }
   getch();
}

Wednesday, August 15, 2012

Programs For Placements

// Factorial using Recursion

#include<stdio.h>
#include<conio.h>
long int fact(long int);
void main()
{
 long int n,res;
 clrscr();
 printf("\n Enter the n value:");
 scanf("%ld",&n);
 res=fact(n);
 printf("\n The Result is %ld",res);
 getch();
}
long int fact(long int n)
{
 long int f=1,res;
 if(n==0 || n==1)
          return 1;
 else
         res=n*fact(n-1);
   return res;
}

// Factorial without Recursion

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,fact=1,i;
 clrscr();
 printf("\n Enter the n value:");
 scanf("%d",&n);
 if(n==1 || n==0)
 {
  n=1;
  printf("\n The result is : %d",n);
 }
 for(i=1;i<=n;i++)
                fact=fact*i;
 printf("The Result is =%d",fact);
getch();
}

// Program for Fibonacci series for a=0 and b=1 fixed values

#include<stdio.h>
#include<conio.h>
void main()
{
 int a=0,b=1,c,n,i;
 clrscr();
 printf("\n Enter the range of the series:");
 scanf("%d",&n);
 printf("\n The Series is %d \t %d",a,b);
 for(i=2;i<n;i++)
 {
  c=a+b;
  a=b;
  b=c;
  printf("\t %d \t",c);
 }
 getch();
}

// Program for Fibonacci Series asking a and b values from user

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,c,n,i;
 clrscr();
 read:printf("\n Enter the values of a and b:");
 scanf("%d %d",&a,&b);
 if(a==0 && b==0)
 goto read;
 printf("\n Enter the range:");
 scanf("%d",&n);
 printf("The Series is %d\t%d",a,b);
 for(i=2;i<n;i++)
 {
  c=a+b;
  a=b;
  b=c;
  printf("\t%d",c);
 }
getch();
}

// Prime numbers from 2 to N

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i,j,flag=0;
 clrscr();
 printf("\n Enter the range:");
 scanf("%d",&n);
 for(i=2;i<=n;i++)
 {
  for(j=2;j<=i;j++)
  {
   if(i%j==0)
    flag++;
  }
  if(flag==1)
  printf("\n The Prime nubers are : %d",i);
  flag=0;
 }
 getch();
}

// List of Prime Numbers Between Two Integer values.

#include<stdio.h>
#include<conio.h>
void main()
{
 int m,n,i,j,flag=0;
 clrscr();
 read: printf("\n Enter the range between M and N:");
 scanf("%d %d",&m,&n);

 if(m>n)
 goto read;
 for(i=m;i<=n;i++)
 {
  for(j=2;j<=i;j++)
  {
   if(i%j==0)
    flag++;
  }
  if(flag==1)
  printf("\n The Prime nubers are : %d",i);
  flag=0;
 }
 getch();
}

//Sum of the individual digits. [Eg: 145 – 1+4+5=10]

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,rem,i,sum=0;
 clrscr();
 printf("\n Enter the digit:");
 scanf("%d",&n);
 while(n!=0)
 {
  rem=n%10;
  n=n/10;
  sum=sum+rem;
  }
 printf("The Result is %d",sum);
 getch();
}

// swapping of 2 numbers with temporary (Call by Reference)

#include<stdio.h>
#include<conio.h>
void swap(int *,int *);

void main()
{
 int a,b,c;
 clrscr();
 printf("\n Enter the values of a and b:");
 scanf("%d %d",&a,&b);
 printf("\n \n Before swapping the values are %d \t %d \n",a,b);
 swap(&a,&b);
 printf("\n The After swapping the values are %d \t %d \n",a,b);
 getch();
}
void swap(int *x,int *y)
{
 int t;
 t=*x;
 *x=*y;
 *y=t;
}

//Swapping without temporary variable

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b;
 clrscr();
 printf("\n Enter the values of a and b:");
 scanf("%d %d",&a,&b);
 printf("\n Before swapping %d and %d\n",a,b);
 a=a+b;
 b=a-b;
 a=a-b;
 printf("\n After swapping %d and %d",a,b);
 getch();
}

// Reversing a Digit Eg: if a = 321 the result should be 123

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
 int num,i,count=0,res,sum=0,mo;
 clrscr();
 printf("\n Enter the number:");
 scanf("%d",&num);
 res=num;
 while(num!=0)
 {
 num=num/10;
 count++;
 }
  for(i=count-1;res!=0;i--)
  {
  mo=res%10;
  sum = sum+(mo*pow(10,i));
  res=res/10;
  }
  printf("Final Result = %d \n \t",sum);
  getch();
 }

// Reversing the digit in another way but it is not the correct one so max avoid this program

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b;
 printf("Enter the number to be reversed:");
 scanf("%d",&a);
 if(a<0)
  a=-a;
 printf("Reverse number is");
 do
 {
  b=a%10;
  printf("%d\n \t",b);
  a=a/10;
  } while(a>0);
  getch();
 }

More Programs Yet to Come

Tuesday, May 8, 2012

Unix Commands...

  • Clear - Used to clear the screen
  • ls- Used to list all the files and folders
  • mkdir- to create a new directory (folder)
  • cat><File name> - used to create a new file
  • cat <File name>- To view file contents
  • cd <Folder name>- to Enter into the directory(folder) created
  • cd <Space Bar Key> - To come out of the directory (folder)
  • rmdir- To remove the directory(folder)
  • who- tell who all are connected to the server
  • date- displays the date and time (of the system)
  • cal- displays the present year calendar of all the months
  • cal <month(in number)> <Year(in number)>- displays the specified month and year
  • pwd- This command is provided to know the current working directory.
  • cp <Old File> <New File> - To copy the contents of old file to a new file
  • mv <Old File> <New File>- to move the data of old file into new file
  • wc <File Name>- To count the number of words lines and characters in a given file
  • bc- Calculator  to come out of it Press CTRL+d
  • who am i- Identify the user and lists the user name, Terminal line, the date and time of login.
  • Semi column(;) - to run multiple commands at a time.
  • vi editor- visual editor used to write C Programs.
  • sort <File Name>- it will sort the file according to the alphabetic order.
  • rm <File Name>- To delete the file which is already created.

How to run a C file in UNIX???

First open a file using VI editor (vi <File name.c>) after entering into it then press the key 'i' so that we can insert the data into the file which we created. after writing the program press escape key and the ':wq' to save and quit the program. After that use the command 'gcc <File Name.c>' to compile u r C program. If no errors then just give './a.out' to see the output.

 Sample Program for addition of 2 numbers:
$vi add.c
press 'i' key to type the program.
#include<stdio.h>
int main()
{
 int a,b,c;
 printf("\n Enter the values of A and B:");
 scanf("%d %d",&a,&b);
 c=a+b;
 printf("The Result is %d",c);
 return c;
}
 press the 'escape key' and ':wq'
after that compile using gcc or cc.
$gcc add.c
To view the output.
$./a.out  
finally u r result will be displayed if u don't have any errors.