Search This Blog

Thursday, April 19, 2012

How to handle clear key in CICS

In CICS the clear key can be handled by the EIBAID.While entering into a transaction we can evaluate the EIBAID and if the EIBAID value is DFHCLEAR Then we can simply throw the map with its values. IF we  ever try to recieve a map after pressing the clear key then it will issue a AEIP abend, as the clear key clears the cics terminal amd while recieving the map it recieves a null value. So it issues an AEIP abend.

The Sample code is :-

EVALUATE EIBTRNID
WHEN TRANS

EVALUATE EIBAID

WHEN DFHCLEAR
PERFORM 100-SEND-PARA
END-EVALUATE
END-EVALUATE.
 
 
 
The send para is:-
 
100-SEND-PARA.



EXEC CICS SEND
MAP(POA)
MAPSET(TCHM121)
FROM(POAO)
ERASE
FREEKB
CURSOR
END-EXEC .

Thursday, April 5, 2012

Mainframe Tips

  • How to list last 10 datasets used in tso region


 goto ispf 3.4 option, on the top menubar select reflist and select option 1 and you will find the last datasets used



  • Auto-indentation
When writing code in certain programming languages, indentation is an important part of the style to ensure that the code is more readable. You can set up the vi editor to automatically indent to adhere to a language-specific style when necessary. You use autoindent to turn automatic indenting on or off



  • Switch case
You can switch the case of the alpha character underneath your cursor in vi the tilde key (~). Doing so shifts from lowercase to uppercase and vice versa. Holding down the key rolls over each character in the line, flipping the case of any alpha characters the editor comes across. You can enter a numeric character prior to the tilde to denote how many alpha characters you want to change.



  • Section save
You can save sections of a file you're currently editing by entering :start,endw file, where start is the first line in the current file from which you want to save, end is the last line that you want to save to, w denotes that you want to write to another file (or overwrite an existing file), and file is the name of the file to which you want to save the specified section. You can use the $ notation for the last line to specify to the end of the file and double greater-than symbols (>>) after the w to indicate that you want to append to rather than overwrite the file

Sunday, July 17, 2011

Using progress bar in VB.NET

A simple example of how to user a progress bar.  Here we will do a
simple query, and advance through the records while showing a
progress bar.  In order to try this, simple create a new Windows
Application, and drap a progress bar control onto your form.Next,
you can add the code from below, and you should be all set.
The progress bar will automatically increase steps based on the
number of records we have in the database.This gives an idea to
the user of how long they will be waiting.


Progress Bar Code :-


DataSet DS = new DataSet();DS = GetDataSet("select * from Employees");
//Verify we have recordsif (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
{
      
//Set Progress Bar
      
ProgressBarMigration.Visible = true;  //Make it visible
      ProgressBarMigration.Minimum = 0;  //Set Min Steps
      ProgressBarMigration.Maximum = DS.Tables[0].Rows.Count;  //Set Number of Max Steps
      ProgressBarMigration.Value = 0;  //Initiliaze to beginning

      //parse through each record
      
foreach (DataRow dr in DS.Tables[0].Rows)
      {
            ProgressBarMigration.Value += 1;
            System.Threading.
Thread.Sleep(50);  //Sleep to slow down to see steps

            //Ideally here you would do your transactions
      }
      ProgressBarMigration.Visible =
false;
      
MessageBox.Show("Migration Complete.");
}

Destroy cookie using VB.NET and ASP.NET

This is a small function which allows you to destroy a cookie.
All that is needed is to pass the cookie name.  If the cookie is
found, it'll set it so that it has expired.

Public Shared Sub DestroyCookie(ByVal CookieName As String)
 Dim CookieObj As HttpCookie = HttpContext.Current.Request.Cookies("CookieName")
   
    If CookieObj IsNot Nothing Then
        CookieObj.Expires = DateTime.Now.AddDays(-1d)
        HttpContext.Current.Response.Cookies.Add(CookieObj)
       
    End If
End Sub


Just call this static function and.If you are calling it from a regular
class you may want to make it a non static method.  I had this is
a HttpHelper class, which I would just call by using
HttpHelper.DestroyCookie("mycookiename")

Saturday, June 11, 2011

Drawing a pie chart in .NET

This program shows how to draw a pie chart from the values obtained from a table..

Imports System.Data.OleDb
Imports System.Drawing.Drawing2D
Imports System.Messaging
Imports System.ServiceProcess

Public Class Form1
Dim Conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mdb1.mdb")
Dim dr As OleDbDataReader
Dim rd As New Random(255)
Dim Arr As New ArrayList
Dim pos As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Bind()
End Sub
Public Sub FinalDrawPieChart()
         Dim APiePercent(Arr.Count) As Integer
         For index = 0 To Arr.Count - 1
          APiePercent(index) = Convert.ToInt32(Arr.Item(index))
         Next
         Using PieGraphic = Me.CreateGraphics()
         DrawPieChart(APiePercent, PieGraphic, New Point(20, 20), New Size(130, 130))
         End Using
     End Sub

     Public Sub DrawPieChart(ByVal PiePercents() As Integer, ByVal PieGraphic As Graphics, ByVal PieLocation As Point, ByVal PieSize As Size)

         Dim sum = 0
         For index = 0 To Arr.Count - 1
         sum += PiePercents(index)
         Next

         Dim eachper As Double
         eachper = 0.0
         For index = 0 To Arr.Count - 1
         eachper = CSng((PiePercents(index) * 100) / sum)
          Next

         Dim PiePercentTotal = 0
         Dim percy As Integer
         percy = 40

         For PiePercent = 0 To Arr.Count - 1
         Using brush As New SolidBrush(Color.FromArgb(rd.Next()))
         PieGraphic.FillPie(brush, New Rectangle(Location, PieSize), CSng((PiePercentTotal * 360) / 100), CSng(((PiePercents(PiePercent) * 100) / sum) * 360) / 100)

         PieGraphic.FillRectangle(brush, 250, percy, 20, 20)
 
         PieGraphic.DrawString(Arr.Item(PiePercent), New Font("Arial", 16), New SolidBrush(Color.Black), New Point(290, percy))

              percy = percy + 30
              End Using

             PiePercentTotal += ((PiePercents(PiePercent) * 100) / sum)
             Next
            Return
            End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Arr.Clear()
         Try
             Conn.Open()
             Dim cmd As OleDbCommand = New OleDbCommand("Select Age From Student", Conn)
             dr = cmd.ExecuteReader
              While dr.Read()
                  Arr.Add(dr.GetValue(0).ToString())
                 pos += 1
              End While
Catch ex As Exception
              MessageBox.Show(ex.ToString())
          Finally
              dr.Close()
             Conn.Close()
         End Try
FinalDrawPieChart()

End Sub

Tuesday, February 15, 2011

File operations in VB.NET

In this article we will learn how to delete, copy and move files in VB.NET

This method shows how to delete files in a folder.Using System.IO class Directory 

class we will check whether the folder name in "sourcePath" exists or not.If directory

is not present in the disk then we will create it. Then we will check any files are present

in that folder.If present then we loop through all files one by one and delete those file 

using File.Delete method.

Public Sub DeleteFilesFromFolders(ByVal sourcePath As String)
        If (Directory.Exists(DirPath)) Then
            For Each fName As String In Directory.GetFiles(DirPath)
                If File.Exists(fName) Then
                    File.Delete(fName)
                End If
            Next
        End If
    End Sub

 

This method shows how to move files from one folder to another folder.

  Public Sub MoveFiles(ByVal sourcePath As String, ByVal DestinationPath As String)
        If (Directory.Exists(sourcePath)) Then
            For Each fName As String In Directory.GetFiles(sourcePath)
                If File.Exists(fName) Then
                    Dim dFile As String = String.Empty
                    dFile = Path.GetFileName(fName)
                    Dim dFilePath As String = String.Empty
                    dFilePath = DestinationPath + dFile
                    File.Move(fName, dFilePath)
                End If
            Next
        End If
    End Sub
 

This method shows how to copy files from one folder to another folder.

    Public Sub CopyFiles(ByVal sourcePath As String, ByVal DestinationPath As String)
        If (Directory.Exists(sourcePath)) Then
            For Each fName As String In Directory.GetFiles(sourcePath)
                If File.Exists(fName) Then
                    Dim dFile As String = String.Empty
                    dFile = Path.GetFileName(fName)
                    Dim dFilePath As String = String.Empty
                    dFilePath = DestinationPath + dFile
                    File.Copy(fName, dFilePath, True)
                End If
            Next
        End If
    End Sub

Adding data to an existing file using VB.NET

In this article we will learn how to append data to an existing file.

Here I am using FileStream object to write contents to a file.
First a FileSteam and File object is created. Using file object we will compare wether file is exists are not.

If file exits in the disk then we will truncate it otherwise we will create new file and allow that file for read and write using file steam object.

If file already exists then we will open that file in append mode.
Then we will point the stream reader to last line using streamwriter.
Example : sw.BaseStream.Seek(0, SeekOrigin.End)

If file does't exists then we will create new file and open that file in create mode.Then we will point the stream reader to first line using streamwriter.
Example: sw.BaseStream.Seek(0, SeekOrigin.Begin)

The code follows :

Public Sub ExportToFile(ByVal oFileName As String, ByVal myContent As String)

Dim file As FileStream
Dim f As IO.File

If (f.Exists(oFileName)) Then
file = New FileStream(FileToWrite, FileMode.Append, FileAccess.Write)
Else
file = New FileStream(FileToWrite, FileMode.Create, FileAccess.ReadWrite)
End If

Dim sw As New StreamWriter(file, System.Text.Encoding.Default)
If (f.Exists(oFileName)) Then
sw.BaseStream.Seek(0, SeekOrigin.End)
Else
sw.BaseStream.Seek(0, SeekOrigin.Begin)
End If

sw.Write(myContent)

sw.Close()

End Sub

Tuesday, January 25, 2011

Creating Google Talk Themes


Google's gtalk offer you with various self defined themes like classic, bubble ,
bubble picture , orkut etc. To create your own personalised theme follow the
following steps :-
  1. Copy and paste the following address in your My Computer Address bar.
    %userprofile%\Local Settings\Application Data\Google\Google Talk\themes\system\chat
  2. Copy the classical picture theme and move back to the themes directory.
  3. Navigate to user directory.
  4. Create a folder named "chat" in it.
  5. Paste the classical picture folder in the chat folder.
  6. Rename the folder to any other name. eg. MyTheme.
  7. In the mytheme folder navigate to contents->resources.
  8. Create a folder named images.
  9. Paste the picture in the folder which you want to make your back ground.
  10. Rename the picture to "background.jpg".
  11. Resize the image to 300x225 pixels.
  12. The code would look like this
    BODY { color: #000000; background-color: #FFFFFF; }

    BODY a:link { color: #0000FF; }

    BODY a:hover { color: #0000FF; }

    BODY a:active { color: #0000FF; }

    BODY a:visited { color: #800080; }BODY {

    margin: 6px;

    }

    DIV#content {

    font: 12px Arial;

    }

    DIV#insert {

    display: none;

    }

    DIV.system1st {

    margin: 4px 0px 4px 0px;

    }

    DIV.systemNth {

    margin: 4px 0px 4px 0px;

    }

    /* Two ways to do icons with these rules:

    Some code here

    */

    DIV.chat .icon {

    }

    DIV.chat DIV.msg {

    margin: 0px 0px 0px 0px;

    }

    DIV.chat DIV.Nth {

    margin: 5px 0px 0px 0px;

    }

    DIV.chat SPAN.salutation {

    font-weight: bold;

    }

    DIV.out {

    text-align: left;

    }

    DIV.out .icon {

    float: left;

    margin: 2px 5px 0px 0px;

    }

    DIV.in {

    text-align: left;

    }

    DIV.in .icon {

    float: left;

    margin: 2px 5px 0px 0px;

    }

    DIV.clear {

    clear: both;

    height: 1px;

    overflow: hidden;

    }

    DIV.break {

    height: 1px;

    margin: 3px 0px 4px 0px;

    overflow: hidden;

    }
  13. Add the background url to the body class
    BODY

    {

    margin: 6px;

    background-image: url("images/background.jpg");

    }
  14. You can also change the alignment and the fronts according to your wish.
  15. To apply the theme close all chat windows.
  16. Goto settings in gtalk->appearance->chat theme.
  17. Select mytheme.
  18. Then open the chat window to see the effect.

Saturday, January 8, 2011

Access specifier in VB.NET

Welcome readers......Wish you all a Happy New Year
So coming back to .NET, today I would discuss about the different access specifier
in VB.NET.

Access specifiers describe the accessibility scope of a variable, method or a class. By using access specifiers we can control the scope of the member object of a class. Access specifiers were used for providing security of our applications. In Visual Basic .Net there are five access specifiers and they are as follows:

Public: It have no restriction on accessibility. We can use the public members from any were inside the class or outside the class.

Private: Their accessibility scope is limited to only inside the class in which they are declared. We can't access the Private members from outside the class and it is the least permissive access level.

Protected: The protected members have scope of accessibility within the class and classes derived(Inherited) from that class.

Friend: Friend members have the accessibility scope from the same assembly and program that contain their declarations.

Protected Friend:
It behave like both protected and friend access specifiers. We can access the protected friend member from anywhere in same assembly and the classes inherited from the same class.




Tuesday, December 28, 2010

Difference between VB.NET and C#.NET

Its a subjective matter which language is best. Some like VB.NET’s
natural style and some like professional and terse C# syntaxes. Both
use the same framework and speed is also very much equivalents. But
still let’s list down some major differences between them :-

Advantages VB.NET :-

  • Has support for optional parameters which makes COM interoperability much easy.
  • With Option Strict off late binding is supported.Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace.
  • Has the WITH construct which is not in C#.
  • The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.
Advantages of C# :-

  • XML documentation is generated from source code but this is now been incorporated in Whidbey
  • Operator overloading which is not in current VB.NET but is been introduced in Whidbey.
  • Use of this statement makes unmanaged resource disposal simple.
  • Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies). This is the major difference that you can access unmanaged code in C# and not in VB.NET.

Monday, December 27, 2010

Common Language Runtime ( CLR )

Full form of CLR is Common Language Runtime and it forms the heart of the . NET framework. All Languages have runtime and its the responsibility of the runtime to take care of the code execution of the program. For example Java has Java Virtual Machine etc. Similarly .NET has CLR. Following are the responsibilities of CLR :
  • Garbage Collection :- CLR automatically manages memory allocation thus eliminating memory leaks. When objects are not referred Garbage Collector automatically releases those memories thus providing efficient memory management.
  • Code Access Security :- CAS grants rights to program depending on the security configuration of the machine. Example the program has rights to edit or create a new file but the security configuration of machine does not allow the program to delete a file. CAS will take care that the code runs under the environment of machines security configuration.
  • Code Verification :- This ensures proper code execution and type safety while the code runs. It prevents the source code to perform illegal operation such as accessing invalid memory locations etc.
  • IL( Intermediate language )-to-native translators and optimizer’s :- CLR uses JIT(Just In Time) and compiles the IL code to machine code and then executes. CLR also determines depending on platform what is optimized way of running the IL code.

Sunday, November 21, 2010

Testing Samsung SGH-L700

Hi,
I am a samsung l700 user and would like to share this with others who also admire the beauty and functionality of this sleek bar phone.

This is a guide to teach you all how to test your samsung l700 (most of the new samsung multimedia phones also support this) :

  • First type *#0*# on your dialing screen.You will find the following options -
  1. Red Lcd
  2. Green Lcd
  3. Blue Lcd
  4. Melody test (white lcd and melody test in some phones)
  5. Vibration test (black lcd and vibration test in some phones)
  6. Dimming test
  7. Mega cam test
  8. VGA cam test
  9. Lcd on/off
  10. Sleep mode
  11. Speaker test(left speaker and right speaker test in some phones)
Select the respective test and find out whether your phone is working fine.If you find some problem then rush to your nearest samsung service center.

Saturday, November 20, 2010

.NET Framework 4 Unleashed

Compatibility :
.Net 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance.The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework. To run older applications with .NET Framework 4, you must compile your application with the target .NET Framework version specified in the properties for your project in Visual Studio
.Net 4 also supports much more language in its client profile than its earlier versions.
Moreover it supports in process side by side execution which enables it to compile and run a project using components based on .net 4 as well as add ins based on earlier versions.

Performance monitoring :
Using Earlier versions of the .NET Framework it was not possible to determine whether the application was affecting other applications or not.But .net 4 enables us to get processor usage and memory usage estimates per application domain.We can monitor CPU and memory usage of individual application domains.

Garbage Collection :
The .NET Framework 4 provides background garbage collection. This feature replaces concurrent garbage collection in previous versions and provides better performance and memory utilization.


Other new features :
  1. It support big integers(system.numerics.biginteger) which supports all the standard integer operations, including bit manipulation.
  2. it support complex numbers(system.numerics.complex) which supports arithmetic and trigonometric operations with complex numbers.
  3. It supports the feature of identifying a 64-bit operating system and a 64-bit process.



And there are lots more features packed into .NET 4 framework which makes a programmers friendly heaven.

Friday, July 30, 2010

Fetching image from database in ASP.NET

In asp database the images are stored in form of binary array.So it is never easy to fetch the image and display it in a image control.For doing so we take a round about method where we print the image in a page and ten we direct the image url in the image control to that page.

Next we would follow the steps to do that :

Now we shall add a page named image.aspx and in the image.aspx.vb we shall write the code given below


Partial Class image
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim s As String = Request.QueryString("val")
Try
con.Open()
com.CommandText = "select * from items where pid ='" & s & "'"
com.Connection = con
dr = com.ExecuteReader
dr.Read()
Dim bytImage As Byte() = New Byte() {}
bytImage = dr.Item(7)
Response.ContentType = "image/jpeg"
Response.Expires = 0

Response.Buffer = True

Response.Clear()
Response.BinaryWrite(bytImage)
Response.End()

Catch ex As Exception

MsgBox(ex.Message)

Finally
con.Close()
com.Cancel()
dr.Close()

End Try
End Sub

End Class



In this page we will get the image from the database an a binary form and will binarywrite the image in this page.We shall get the pid from the querystring which we shall pass from the page where the image control is. In that page we will direct the image url as below :

Image1.ImageUrl = "~/image1.aspx?vall=" & DropDownList1.SelectedValue

where dropdownlist1.selected value returns a element of the pid coloum in the items table
I have already shown how to connect the database using the module in my earlier blog

Wednesday, July 21, 2010

Adding image to database in ASP.NET

First we have taken a sql database table (items) with a image type field in it.Next we have to create a connection using a module..

The module should look like this

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient


Public Module connection

Public con As New SqlConnection("Data Source=.\SQLEXPRESS;_AttachDbFilename='J:\shopping\App_Data\Database.mdf';Integrated_ Security=True;User Instance=True")
Public com As New SqlCommand
Public dr As SqlDataReader

End Module


Now to add the image follow the following steps :


Try

Dim imgByte As Byte() = Nothing
If FileUpload1.PostedFile IsNot Nothing AndAlso FileUpload1.PostedFile.FileName <> "" Then


Dim File As HttpPostedFile = FileUpload1.PostedFile
imgByte = New Byte(File.ContentLength - 1) {}
File.InputStream.Read(imgByte, 0, File.ContentLength)
End If

Dim b As Boolean

con.Open()
com.CommandText = "insert into items values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox7.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "',@eimg)"
com.Parameters.AddWithValue("@eimg", imgByte)
com.Connection = con
com.ExecuteNonQuery()


MsgBox("inserted")

Catch ex As Exception
MsgBox(ex.Message)

Finally
con.Close()
com.Cancel()
com.Parameters.Clear()
dr.Close()

End Try


First we shall upload the file using a fileupload control then we shall convert it into a byte stream and would store it into a byte array.Next we would store this byte array into the items database using parametarised query.Hence the image gets stored into the image field

Thursday, July 8, 2010

JAVA Threads

Multithreading refers to two or more tasks executing concurrently within a single program. A thread is an independent path of execution within a program. Many threads can run concurrently within a program. Every thread in Java is created and controlled by the java.lang.Thread class. A Java program can have many threads, and these threads can run concurrently, either asynchronously or synchronously.

Multithreading has several advantages over Multiprocessing such as;

  • Threads are lightweight compared to processes
  • Threads share the same address space and therefore can share both data and code
  • Context switching between threads is usually less expensive than between processes
  • Cost of thread intercommunication is relatively low that that of process intercommunication
  • Threads allow different tasks to be performed concurrently.

Thread Creation

There are two ways to create thread in java;

  • Implement the Runnable interface (java.lang.Runnable)
  • By Extending the Thread class (java.lang.Thread)
Implementing the Runnable Interface

public interface Runnable {

void run();

}

One way to create a thread in java is to implement the Runnable Interface and then instantiate an object of the class. We need to override the run() method into our class which is the only method that needs to be implemented. The run() method contains the logic of the thread.

The procedure for creating threads based on the Runnable interface is as follows:

1. A class implements the Runnable interface, providing the run() method that will be executed by the thread. An object of this class is a Runnable object.

2. An object of Thread class is created by passing a Runnable object as argument to the Thread constructor. The Thread object now has a Runnable object that implements the run() method.

3. The start() method is invoked on the Thread object created in the previous step. The start() method returns immediately after a thread has been spawned.

4. The thread ends when the run() method ends, either by normal completion or by throwing an uncaught exception

Extending Thread Class

The procedure for creating threads based on extending the Thread is as follows:

1. A class extending the Thread class overrides the run() method from the Thread class to define the code executed by the thread.

2. This subclass may call a Thread constructor explicitly in its constructors to initialize the thread, using the super() call.

3. The start() method inherited from the Thread class is invoked on the object of the class to make the thread eligible for running.


When creating threads, there are two reasons why implementing the Runnable interface may be preferable to extending the Thread class:

  • Extending the Thread class means that the subclass cannot extend any other class, whereas a class implementing the Runnable interface
    has this option.
  • A class might only be interested in being runnable, and therefore, inheriting the full overhead of the Thread class would be excessive.


Wednesday, June 30, 2010

ISO OSI Model

What is OSI model?

It is known as Open System Interface.It is a seven layer model.It is used to communicate between different nodes on a network.


OSI Layers Explained

Physical Layer: The physical layer is at the bottom of this data networking model. It deals with crude data that is in the form of electrical signals. The data bits are sent as 0's and 1's. 0's correspond to low voltage signals and 1's correspond to high voltage signals. The mechanical aspects of communication, such as wires or connectors come under this layer. The physical layer also deals with how these wires, connectors, and voltage electrical signals work.

The Data Link Layer: The transmission of the data over the communication medium is the responsibility of this layer. The 0's and 1's that are used in the communication are grouped into logical encapsulation. This encapsulation is called frames. The data is transported in frames. The responsibility of these frames is that of the data link layer.

Network Layer: There are many different types of ethernets. These networks are connected to each other through various media. When a data packet wants to reach a particular destination, it has to traverse through these networks. Essentially, there are lot of operations that are taking place between the connected networks. Also, the packet data which is traversing, has to choose an optimum route, and the addressing of these packets has to be proper. The various operations between the networks, packet data issues, addressing and routing are handled by this network layer.

Transport Layer: The transport layer ensures quality and reliability of the communication. The data packet switching is entirely handled by the transport layer. There are basically two types of packet switching. They are connectionless packet switching and connection oriented packet switching. In connectionless packet switching, the packet data is allowed to choose the route in which it is going to reach the destination. Obviously, the packet in itself cant do this. Physical devices like routers are mainly responsible for the behavior of packets, but the packets formed from the same datum can reach their destination in different ways. Whereas, in connection oriented packet switching, once the route is decided, then all the packets have to follow the same route. Examples of connectionless packet switching are text messages in mobile phones, and the example of connection oriented switching is a direct voice call.

The Sessions Layer: The sessions layer is mainly responsible for creating, maintaining and destroying the communication link. PDU (Protocol Data Unit), in which various protocols are defined, that have to be followed during communication, are the responsibility of the sessions layer. The applications that use RPC's (remote procedure calls) are taken care of by the sessions layer.

Presentation Layer: There are various techniques of data compression which are used to send and receive the optimized data. For example, if certain data is repeating itself for a number of times, then it is logical to send the data only once, and specify the number of times it is repeated. This bundling of the repeated data is one of the techniques of compressions. The compression and decompression of the data is handled by the presentation layer. Also, encryption and decryption techniques used to avoid malicious attacks on data are handled by the presentation layer.

Application Layer: This is the topmost layer of the OSI reference model. This layer comes into picture when there is a process to process communication. Whenever a user invokes any application, all the associated processes are run. Many a times, when an application wants to communicate with another application, then there has to be communication between these associated processes.

Monday, June 28, 2010

How to create a jar file

  1. First, make sure you have installed Java 1.2 or above. This facility is not available in previous versions of Java.
  2. Now create a program and place it in a separate folder.For example the main class is hello world. so first compile it using the statement
    javac helloworld.java
  3. Now you will find a file named helloworld.class
  4. Now in that same folder you create a file Manifest.mf
  5. The first line should be --- Main-Class: helloworld
  6. Now save the file
  7. Now open the command promt in that folder.
  8. Type the line --- jar cfm helloworld.jar Manifest.mf *.class
  9. Give enter and your jar file would be created.
  10. If you have gif images used in the program then place the images in that folder and type the given line in the commandline ---- jar cfm helloworld.jar Manifest.mf *.class *.gif
  11. Now your jar is created .Click on it to run it.
  12. Note :: all the commands and file name are case sensitive.

Sunday, June 27, 2010

BLACK BOX TESTING

Black box testing treats the system as a “black-box”, so it doesn’t explicitly use Knowledge of the internal structure or code. Or in other words the Test engineer need not know the internal working of the “Black box” or application.
Main focus in black box testing is on functionality of the system as a whole. The term ‘behavioral testing’ is also used for black box testing and white box testing is also sometimes called ’structural testing’. Behavioral test design is slightly different from black-box test design because the use of internal knowledge isn’t strictly forbidden, but it’s still discouraged.
Each testing method has its own advantages and disadvantages. There are some bugs that cannot be found using only black box or only white box. Majority of the applications are tested by black box testing method. We need to cover majority of test cases so that most of the bugs will get discovered by blackbox testing.
Black box testing occurs throughout the software development and testing life cycle i.e. in Unit, Integration, System, Acceptance and regression testing stages.

Tools used for Black Box testing:
Black box testing tools are mainly record and playback tools. These tools are used for regression testing that to check whether new build has created any bug in previous working application functionality. These record and playback tools records test cases in the form of some scripts like TSL, VB script, Java script, Perl.
Advantages of Black Box Testing:
- Tester can be non-technical.
- Used to verify contradictions in actual system and the specifications.
- Test cases can be designed as soon as the functional specifications are complete
Disadvantages of Black Box Testing:
- The test inputs needs to be from large sample space.
- It is difficult to identify all possible inputs in limited testing time. So writing test cases is slow and difficult
- Chances of having unidentified paths during this testing

Methods of Black box Testing:

Graph Based Testing Methods:
Each and every application is build up of some objects. All such objects are identified and graph is prepared. From this object graph each object relationship is identified and test cases written accordingly to discover the errors.
Error Guessing:
This is purely based on previous experience and judgment of tester. Error Guessing is the art of guessing where errors can be hidden. For this technique there are no specific tools, writing the test cases that cover all the application paths.
Equivalence Partitioning:
Equivalence partitioning is a black box testing method that divides the input domain of a program into classes of data from which test cases can be derived.

How this partitioning is performed while testing:
1. If an input condition specifies a range, one valid and one two invalid classes are defined.
2. If an input condition requires a specific value, one valid and two invalid equivalence classes are defined.
3. If an input condition specifies a member of a set, one valid and one invalid equivalence class is defined.
4. If an input condition is Boolean, one valid and one invalid class is defined.

In this technique, we do not use the code to determine a test suite; rather, knowing the problem that we're trying to solve, we come up with four types of test data:
1. Easy-to-compute data
2. Typical data
3. Boundary / extreme data
4. Bogus data
For example, suppose we are testing a function that uses the quadratic formula to determine the two roots of a second-degree polynomial ax2+bx+c. For simplicity, assume that we are going to work only with real numbers, and print an error message if it turns out that the two roots are complex numbers (numbers involving the square root of a negative number).
We can come up with test data for each of the four cases, based on values of the polynomial's discriminant (b2-4ac):
Easy data ( discriminant is a perfect square):
a b c Roots
1 2 1 -1, -1
1 3 2 -1, -2

Typical data (discriminant is positive):
a b c Roots
1 4 1 -3.73205, -0.267949
2 4 1 -1.70711, -0.292893

Boundary / extreme data (discriminant is zero):
a b c Roots
2 -4 2 1, 1
2 -8 8 2, 2


Bogus data ( discriminant is negative, or is zero):
a b c Roots
1 1 1 square root of negative number
0 1 1 division by zero

As with glass-box testing, you should test your code with each set of test data. If the answers match, then your code passes the black-box test.


Boundary Value Analysis:
Many systems have tendency to fail on boundary. So testing boundary values of application is important. Boundary Value Analysis (BVA) is a test Functional Testing technique where the extreme boundary values are chosen. Boundary values include maximum, minimum, just inside/outside boundaries, typical values, and error values.

BVA techniques:
1. Number of variables
For n variables: BVA yields 4n + 1 test cases .
2. Kinds of ranges
Generalizing ranges depends on the nature or type of variables
Advantages of Boundary Value Analysis
1. Robustness Testing – Boundary Value Analysis plus values that go beyond the limits
2. Min – 1, Min, Min +1, Nom, Max -1, Max, Max +1
3. Forces attention to exception handling

Limitations of Boundary Value Analysis
Boundary value testing is efficient only for variables of fixed values in boundary.
EXAMPLE:
For the function that computes the square root of integer values in the range 0 and 5000, the test case must include the following values: {0, -1, 5000, 5001}