Pubblicazione File: frmTestOOSMom
Documento generato mediante: Documentation Creator By BGSoftware


VERSION 5.00
Begin VB.Form frmTestOOSMom 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Test Object Oriented del servizio SMom - By Giorgio Bernardi"
   ClientHeight    =   8520
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10470
   Icon            =   "frmTestOOSMom.frx":0000
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   15.028
   ScaleMode       =   0  'User
   ScaleWidth      =   18.468
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "Configurazione"
      Height          =   2655
      Left            =   5640
      TabIndex        =   8
      Top             =   0
      Width           =   4815
      Begin VB.CommandButton CmdTestNormale 
         Caption         =   "Test Chiamate Dirette"
         Height          =   375
         Left            =   2880
         TabIndex        =   34
         Top             =   2160
         Width           =   1815
      End
      Begin VB.CommandButton CmdInizializza 
         Caption         =   "(Re) Inizializza SMom"
         Height          =   375
         Left            =   120
         TabIndex        =   23
         Top             =   2160
         Width           =   2655
      End
      Begin VB.Frame Frame3 
         Appearance      =   0  'Flat
         ForeColor       =   &H80000008&
         Height          =   855
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   4575
         Begin VB.OptionButton ClientOServer 
            Caption         =   "Client e Server Locale"
            Height          =   255
            Index           =   3
            Left            =   120
            TabIndex        =   24
            Top             =   120
            Value           =   -1  'True
            Width           =   1935
         End
         Begin VB.OptionButton ClientOServer 
            Caption         =   "Client e Server Tcp"
            Height          =   255
            Index           =   2
            Left            =   2520
            TabIndex        =   18
            Top             =   120
            Width           =   1695
         End
         Begin VB.OptionButton ClientOServer 
            Caption         =   "Server Tcp"
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   17
            Top             =   480
            Width           =   1935
         End
         Begin VB.OptionButton ClientOServer 
            Caption         =   "Client Tcp"
            Height          =   255
            Index           =   0
            Left            =   2520
            TabIndex        =   16
            Top             =   480
            Width           =   1695
         End
      End
      Begin VB.Frame Frame4 
         Appearance      =   0  'Flat
         ForeColor       =   &H80000008&
         Height          =   495
         Left            =   120
         TabIndex        =   14
         Top             =   1080
         Width           =   4575
         Begin VB.OptionButton StubDinamico 
            Caption         =   "Stub Statico"
            Height          =   255
            Index           =   1
            Left            =   2520
            TabIndex        =   19
            Top             =   120
            Width           =   1815
         End
         Begin VB.OptionButton StubDinamico 
            Caption         =   "Stub Dinamico"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   15
            Top             =   120
            Value           =   -1  'True
            Width           =   1815
         End
      End
      Begin VB.Frame Frame5 
         Appearance      =   0  'Flat
         ForeColor       =   &H80000008&
         Height          =   495
         Left            =   120
         TabIndex        =   20
         Top             =   1560
         Width           =   4575
         Begin VB.OptionButton SkelDinamico 
            Caption         =   "Skeleton Dinamico"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   22
            Top             =   120
            Value           =   -1  'True
            Width           =   1815
         End
         Begin VB.OptionButton SkelDinamico 
            Caption         =   "Skeleton Statico"
            Height          =   255
            Index           =   1
            Left            =   2520
            TabIndex        =   21
            Top             =   120
            Width           =   1815
         End
      End
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "Divide => Verificare l'errore con divisione per 0 :-)"
      Height          =   375
      Index           =   6
      Left            =   0
      TabIndex        =   7
      Top             =   2160
      Width           =   5535
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "BigConcatena => Non funziona con Skel VB dinamico!"
      Height          =   375
      Index           =   5
      Left            =   0
      TabIndex        =   5
      Top             =   1800
      Width           =   5535
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "Concatena => Test parametri Stringa"
      Height          =   375
      Index           =   4
      Left            =   0
      TabIndex        =   4
      Top             =   1440
      Width           =   5535
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "GetSum => con risultato"
      Height          =   375
      Index           =   3
      Left            =   0
      TabIndex        =   3
      Top             =   1080
      Width           =   5535
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "ComputeDiff => Con risultato"
      Height          =   375
      Index           =   2
      Left            =   0
      TabIndex        =   2
      Top             =   720
      Width           =   5535
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "ComputeSum => Nessun risultato. Test parametri interi"
      Height          =   375
      Index           =   1
      Left            =   0
      TabIndex        =   1
      Top             =   360
      Width           =   5535
   End
   Begin VB.TextBox txtArrivati 
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   5055
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   3480
      Width           =   10455
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "Hello! => Test base per verificare la connettivitą"
      Height          =   375
      Index           =   0
      Left            =   0
      TabIndex        =   6
      Top             =   0
      Width           =   5535
   End
   Begin VB.Frame Frame2 
      Caption         =   "Parametri"
      Height          =   735
      Left            =   0
      TabIndex        =   9
      Top             =   2640
      Width           =   10455
      Begin VB.TextBox Text12 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   9360
         TabIndex        =   33
         Text            =   "!"
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text11 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   8520
         TabIndex        =   32
         Text            =   "brutti"
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text10 
         Appearance      =   0  'Flat
         Height          =   345
         Left            =   7680
         TabIndex        =   31
         Text            =   "ai "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text9 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   6840
         TabIndex        =   30
         Text            =   "anche "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text8 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   6000
         TabIndex        =   29
         Text            =   "ma "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text7 
         Appearance      =   0  'Flat
         Height          =   345
         Left            =   5160
         TabIndex        =   28
         Text            =   "belli "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text6 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   4320
         TabIndex        =   27
         Text            =   "i "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text5 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   3480
         TabIndex        =   26
         Text            =   "tutti "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text4 
         Appearance      =   0  'Flat
         Height          =   345
         Left            =   2640
         TabIndex        =   25
         Text            =   "a "
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         Height          =   345
         Left            =   120
         TabIndex        =   12
         Text            =   "45"
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text2 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   960
         TabIndex        =   11
         Text            =   "15"
         Top             =   240
         Width           =   825
      End
      Begin VB.TextBox Text3 
         Appearance      =   0  'Flat
         Height          =   350
         Left            =   1800
         TabIndex        =   10
         Text            =   "Ciao "
         Top             =   240
         Width           =   825
      End
   End
End
Attribute VB_Name = "frmTestOOSMom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' *********************************************************************
'* CLASS Form per il testing del middleware Simple Message Oriented M.
'* <BR/>Autore: <B>Giorgio Bernardi</B>
'* E-Mail: <A HREF="mailto:giorgio.bernardi@studio.unibo.it">Giorgio.Bernardi@studio.unibo.it</A>
'* Data  : Settembre 2004
'* <DIV CLASS="ClassDescription">
'*  Form di test. E' possibile testare il funzionamento locale, remoto e remoto collegato a Java.
'* </DIV>
' *********************************************************************
Option Explicit

'* Classe di test reale
Private WithEvents ClsTest  As ClsTestProcedures
Attribute ClsTest.VB_VarHelpID = -1
'* Classe usata come stub
Private ClsStub             As ClsTestProcedures

Dim MsgManager1      As New SMom.CTCPManager
Dim MsgManager2      As New SMom.CTCPManager

Private IsInitialized   As Boolean

Private Sub Append(Msg As String)
    txtArrivati.Text = txtArrivati.Text & vbCrLf & ">" & Msg
End Sub

'* Inizializza la classe, lo stub e lo skeleton
Public Sub TestClsTestProcedures(Dispatcher As IDispatcher, MsgManagerAddress As String)
    Set ClsTest = New ClsTestProcedures
    'Skeleton
    If SkelDinamico(1).Value Then
        'Utilizzo dello skeleton statico
        Dim clsSckeleton As New ClsTestProcedures_Sckeleton
        Set clsSckeleton.ClasseReale = ClsTest
        Dispatcher.Register clsSckeleton
    Else
        'Utilizzo dello Skeleton Dinamico
        Dim clsSckeletonD As New SMom.CDynamicSkeleton
        Set clsSckeletonD.Servant = ClsTest
        clsSckeletonD.SkeletonID = "ClsTestProcedures_Sckeleton"
        Dispatcher.Register clsSckeletonD
    End If
    
    'Stub
    If StubDinamico(1).Value Then
        'Utilizzo di stub statico
        Dim clsMyStub As New ClsTestProcedures_Stub
        Set clsMyStub.Dispatcher = Dispatcher
        clsMyStub.MsgManagerAddress = MsgManagerAddress
        Dispatcher.Register clsMyStub
        Set ClsStub = clsMyStub
    Else
        'Utilizzo di stub Dinamico
        Dim clsMyStubD As New ClsTestProcedures_Proxy
        Set clsMyStubD.DynamicStub.Dispatcher = Dispatcher
        clsMyStubD.DynamicStub.RemoteMsgManagerAddress = MsgManagerAddress
        clsMyStubD.DynamicStub.StubID = "ClsTestProcedures_Stub"
        clsMyStubD.DynamicStub.RemoteSkeletonID = "ClsTestProcedures_Sckeleton"
        Dispatcher.Register clsMyStubD.DynamicStub
        Set ClsStub = clsMyStubD
    End If
    IsInitialized = True
End Sub

Private Sub ClsTest_OnComputeRequest(Msg As String)
    Append "Giunta Richiesta per=>" & Msg
End Sub

'* Test delle funzionalitą
Public Sub CmdExecute_Click(Index As Integer)
    If IsInitialized Then
        On Error GoTo ErrorCatch
        Select Case Index
            Case 0
                Append "Chiamata senza risultato a hello()"
                Call ClsStub.hello
            Case 1
                Append "Chiamata senza risultato a ComputeSum()"
                ClsStub.ComputeSum CLng(Text1.Text), CLng(Text2.Text)
            Case 2
                Append "Risultato di ComputeDiff=" & _
                    ClsStub.ComputeDiff(CLng(Text1.Text), CLng(Text2.Text))
            Case 3
                Append "Risultato di GetSum=" & _
                    ClsStub.GetSum(CLng(Text1.Text), CLng(Text2.Text))
            Case 4
                Append "Risultato di Concatena=" & _
                    ClsStub.Concatena(Text1.Text, Text2.Text, Text3.Text)
            Case 5
                Append "Risultato di BigConcatena=" & _
                    ClsStub.BigConcatena(Text1.Text, Text2.Text, Text3.Text, Text4.Text, _
                                        Text5.Text, Text6.Text, Text7.Text, Text8.Text, _
                                        Text9.Text, Text10.Text, Text11.Text, Text12.Text)
            Case 6
                Append "Risultato di Divide=" & _
                    ClsStub.Divide(CLng(Text1.Text), CLng(Text2.Text))
        End Select
    Else
        MsgBox "E' necessario inizializzare l'ambiente prima di testarlo", vbInformation
    End If
Exit Sub
ErrorCatch:
    Append "Eccezione generata per operazione di indice " & Index & ">" & Err.Description
End Sub

'* Inizializza l'ambiente Client/Server a seconda delle impostazioni della finestra
Public Sub InitServer()
Dim Dispatcher      As New SMom.CSinchronusAndSequentialDispatcher
    If ClientOServer(3).Value Then  'Locale
        Dim MsgManager              As New SMom.CLocalManager
        Set MsgManager.Dispatcher = Dispatcher
        Set Dispatcher.MsgManager = MsgManager
        Call TestClsTestProcedures(Dispatcher, vbNullString)
    Else    'Tcp
        'Client
        Set MsgManager1.Dispatcher = Dispatcher
        MsgManager1.setPort 4501
        If ClientOServer(0).Value Or ClientOServer(2).Value Then MsgManager1.StartListenForMessages
        'Server
        Set MsgManager2.Dispatcher = Dispatcher
        MsgManager2.setPort 5501
        If ClientOServer(1).Value Or ClientOServer(2).Value Then MsgManager2.StartListenForMessages
        
        Set Dispatcher.MsgManager = MsgManager1
        Call TestClsTestProcedures(Dispatcher, MsgManager2.getAddress())
    End If
End Sub

'* Distrugge l'ambiente per poterlo eventualmente reinizializzare
Public Sub DestroyServer()
    If IsInitialized Then
        If Not MsgManager2 Is Nothing Then MsgManager2.Destroy
        If Not MsgManager1 Is Nothing Then MsgManager1.Destroy
        Set MsgManager1 = Nothing
        Set MsgManager2 = Nothing
        Set ClsStub = Nothing
        Set ClsTest = Nothing
        IsInitialized = False
    End If
End Sub

Private Sub CmdInizializza_Click()
    Call DestroyServer  'Distruggo se serve
    Call InitServer
End Sub

Private Sub CmdTestNormale_Click()
    Call DestroyServer
    Set ClsStub = New ClsTestProcedures
    Set ClsTest = ClsStub
    IsInitialized = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Call DestroyServer
End Sub

Private Sub Form_Unload(Cancel As Integer)
    End
End Sub

Documento generato mediante: Documentation Creator By BGSoftware