Final Testing of the Prototype


We now have a complete prototype of the application: We built the event class, both subscription classes, the notification class, and the state maintenance and matching logic. We tested each piece individually as we built the application, and the last test exercised all the pieces of the application together.

Now that the prototype ADF is complete, it's important to wipe the slate clean and compile everything from scratch. When the application is deployed, it won't go through the incremental create and update process we used to develop it, so we should verify that the complete application can be created and works as expected. This ensures that no artifacts from the incremental development process affect the way the application works.

You'll find a script called cleanup.cmd in the music store sample's scripts directory that returns your system to a clean state from which you can try to compile the complete application again. This script does the following things:

  • Stops the Windows service (NS$MusicStore)

  • Deletes the instance and application

  • Unregisters the instance

  • Clears the notifications output file

  • Drops the music store database

Note that this cleanup script does not touch any of your source files, so, assuming that your ADF was complete at the time you last compiled it with the SQL-NS update tools, it should still be complete and ready to compile after running the cleanup script. The following steps describe how to run the cleanup script and recompile the whole application:

1.

From a Notification Services Command Prompt on your development machine, navigate to the scripts directory for the music store sample by typing the following command:

 cd /d C:\SQL-NS\Samples\MusicStore\Scripts 


2.

Run cleanup.cmd.

3.

Run create_music_store_database.cmd. This rebuilds the music store database.

4.

Ensure that your ADF contains the complete prototype code. It should be the same as the supplementary file, ApplicationDefinition-6.xml, in the C:\SQL-NS\Chapters\06\SupplementaryFiles directory.

5.

Run create.cmd to recompile the instance and application from scratch.

6.

Run register.cmd to register the instance.

7.

Run grant_permissions.cmd to assign the appropriate database permissions.

8.

Run enable.cmd to enable the instance.

9.

Start the Windows service by typing the following command:

 net start NS$MusicStore 


10.

If you don't already have it open, open the music store Management Studio solution, C:\SQL-NS\Samples\MusicStore\MusicStore.ssmssln.

11.

Open the scripts AddSubscribers.sql, AddSubscriptions.sql, and SubmitEvents.sql. You'll find all three scripts in the Queries folder beneath the MusicStore project.

12.

Run AddSubscribers.sql to add subscriber and subscriber device data to the instance.

Caution

If you execute AddSubscribers.sql (or any of the other SQL scripts referenced in this section) from a query window that was previously connected to the MusicStore database before it was deleted and re-created, you may receive the following error message:

 A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) 


If this happens, just execute the script again and the connection will be reestablished.

13.

Run AddSubscriptions.sql to add event-triggered subscriptions to the instance.

14.

Start SubscriptionLoader (if you don't already have it open) and add a scheduled subscription of the NewSongByGenre subscription class. Set the start time to be about 2 to 3 minutes into the future.

15.

Open the notifications output file, FileNotifications.txt (from the Miscellaneous folder under the MusicStore project). Because you ran the cleanup script earlier, the notifications file should be blank.

16.

Run SubmitEvents.sql to submit some sample events. You must complete this step before the start time of the scheduled subscription you added.

17.

Within about 30 seconds, Management Studio should tell you that the notifications output file has changed. Reload the file to see the notification text. Depending on when you submitted the events, notifications for the event-triggered subscriptions and scheduled subscriptions may be generated separately. Thus, you may have to reload the notifications file twice.

When you complete all the preceding steps and get the results you expect, you can be sure that what you've built works in a basic end-to-end scenario.

Tip

In a real application, you'd typically follow this up with additional test cases that employ different samples of event and subscription data. When doing this, you'll want to pick data samples that exercise the boundary conditions in your application's logic. Remember that the purpose of the prototype stage is to ensure that the core logic of your application works, before adding the fancier input and output pieces. At the prototype stage, things are still relatively simple, so the cost of finding and fixing bugs in your application's logic will be much less than at later stages of the development process.





Microsoft SQL Server 2005 Notification Services
Microsoft SQL Server 2005 Notification Services
ISBN: 0672327791
EAN: 2147483647
Year: 2006
Pages: 166
Authors: Shyam Pather

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net