3 May 2011
Download the Test Drive solution files (ZIP, 14 MB)
No code is written in this tutorial.
In the previous two modules, you built Flex applications that retrieve, display, and modify data from a database. In this module you test and debug your code.
In this tutorial, you use the Flash Builder Test Operation to test your server-side code—even before writing any Flex code. This is useful to make sure your server-side operations are all working before you call them in your application.
getEmployees()operation in the Data/Services view and select Test Operation. Click the Test button in the Test Operation view.
You will see all the return data displayed in the TestOperation view (see Figure 1).
Java developers: You will get an employee object that is an array of Employee objects.
getEmployeesById() operation from the drop-down in the Test Operation view. Enter a value for the argument and click Test (see Figure 2).
getEmployeesById() operation is invoked with the value you specified and the return data is displayed in the Test Operation view.
createEmployee() operation in the Test Operation view. Click in the Enter Value field and click the Ellipses button. You should get a pop-up window to enter input data (see Figure 3). Close this window.
Java developers: Your Input Argument window will look different because your method already knows it needs an Employee object. You can skip Steps 4 and 5 below and just enter test values here as shown in Figure 5 and then test the operation. Be sure to enter integers for
departmentid and only two characters for
state. It doesn't matter what
id you specify, it will not be used; a value will be generated automatically for it by the database when the data is inserted.
Return to the Data/Services view, right-click
createEmployee() and select Configure Return Type. In the dialog box, auto-detect from sample data, change the type from Object to Employee, and then click in the Enter Value field (see Figure 4). Click the Ellipses button that appears and enter values for each Employee field (see Figure 5). Be sure to enter integers for
id and only two characters for
It does not matter what
id you specify, it will not be used; a value will be automatically generated for it by the database when the data is inserted.
You should now see parameter and return types (Employee and int, respectively) specified for the
createEmployee()operation in the Data/Services panel.
createEmployees() in the Data/Services view and select Test Operation. Click the Test button in the Test Operation view.
This time you will see the test values you specified while configuring the return type already entered in the Enter Value field.
After you test the operation, you should see an integer displayed as the response value (see Figure 6). A new employee was successfully added to the database. If you run your application again, you will see this new employee in the DataGrid.
In this tutorial, you tested your server-side operations even before writing any code. In the next tutorial, you will monitor the traffic between your application and the server after you use service calls in your code.
Refer to the following resources to learn more about this topic:
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.