add unified test scripts for all services
This commit is contained in:
@ -1,8 +1,135 @@
|
||||
# Test Scripts for JAX-WS Hello World Service
|
||||
# Test Scripts for JAX-WS Services
|
||||
|
||||
This folder contains test scripts to interact with the JAX-WS Hello World Service.
|
||||
This folder contains test scripts to interact with the JAX-WS services.
|
||||
|
||||
## Python Test Script
|
||||
## Available Test Scripts
|
||||
|
||||
- `test_all_services.py` - **Unified test script for all services** (Recommended)
|
||||
- `test_hello_world.py` - Test the Hello World SOAP service
|
||||
- `test_register_customer.py` - Test the Customer Registration SOAP service
|
||||
- `simple_test.py` - Simple automated test script for CI/CD
|
||||
|
||||
## Unified Test Script (Recommended)
|
||||
|
||||
### test_all_services.py
|
||||
|
||||
This is the **recommended** way to test all services. It provides comprehensive testing for all three service operations in a single script.
|
||||
|
||||
**Features:**
|
||||
- Tests all service operations (Hello World, Customer Registration, Loan Processing)
|
||||
- Automated test suite with 20+ test cases
|
||||
- Interactive mode for manual testing
|
||||
- Clear pass/fail indicators with test summary
|
||||
- Comprehensive error handling and validation testing
|
||||
|
||||
**Running the unified test:**
|
||||
|
||||
**Windows:**
|
||||
```cmd
|
||||
cd scripts
|
||||
python test_all_services.py
|
||||
```
|
||||
|
||||
**Linux/Mac:**
|
||||
```bash
|
||||
cd scripts
|
||||
python3 test_all_services.py
|
||||
# OR
|
||||
chmod +x test_all_services.py
|
||||
./test_all_services.py
|
||||
```
|
||||
|
||||
**What it tests:**
|
||||
|
||||
1. **Hello World Service**
|
||||
- Normal greetings
|
||||
- Edge cases (empty names)
|
||||
|
||||
2. **Customer Registration Service**
|
||||
- Regular customer registration
|
||||
- Blacklisted customer registration
|
||||
- Duplicate registration handling
|
||||
- Validation error handling
|
||||
|
||||
3. **Loan Application Processing**
|
||||
- High credit score approvals (3.5% rate)
|
||||
- Good credit score approvals (5.5% rate)
|
||||
- Fair credit score approvals (8.5% rate)
|
||||
- Low credit score rejections
|
||||
- Blacklisted customer rejections
|
||||
- Validation error handling (empty names, invalid amounts)
|
||||
|
||||
**Interactive Mode:**
|
||||
|
||||
After automated tests complete, you can enter interactive mode with these commands:
|
||||
- `hello <name>` - Test Hello World service
|
||||
- `register <name>` - Register a regular customer
|
||||
- `blacklist <name>` - Register a blacklisted customer
|
||||
- `loan <name> <amount> <credit_score>` - Process loan application
|
||||
- `quit` - Exit
|
||||
|
||||
**Example output:**
|
||||
```
|
||||
================================================================================
|
||||
JAX-WS UNIFIED TEST CLIENT
|
||||
================================================================================
|
||||
Testing all services and operations
|
||||
|
||||
Checking services availability...
|
||||
|
||||
Hello World Service: Service is accessible
|
||||
Loan Approval Service: Service is accessible
|
||||
|
||||
================================================================================
|
||||
AUTOMATED TEST SUITE
|
||||
================================================================================
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
1. Testing Hello World Service
|
||||
--------------------------------------------------------------------------------
|
||||
✓ PASS | getHelloWorld('John') - Should return greeting
|
||||
Hello World, John!
|
||||
|
||||
✓ PASS | getHelloWorld('Alice') - Should return greeting
|
||||
Hello World, Alice!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
2. Testing Customer Registration Service
|
||||
--------------------------------------------------------------------------------
|
||||
✓ PASS | registerNewCustomer('Alice Johnson', blacklisted=False) - Register regular customer
|
||||
Registration Successful
|
||||
|
||||
✓ PASS | registerNewCustomer('Charlie Brown', blacklisted=True) - Register blacklisted customer
|
||||
Registration Successful
|
||||
|
||||
✓ PASS | registerNewCustomer('Alice Johnson', blacklisted=False) - Duplicate registration (should fail)
|
||||
Error: Customer already exists
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Testing Loan Application Processing Service
|
||||
--------------------------------------------------------------------------------
|
||||
✓ PASS | processLoanApplication('Alice Johnson', $50000, score=750) - High credit score
|
||||
approved: True
|
||||
approvedRate: 3.5
|
||||
message: Loan approved with excellent rate
|
||||
|
||||
✓ PASS | processLoanApplication('Charlie Brown', $40000, score=700) - Blacklisted customer
|
||||
approved: False
|
||||
rejectionReason: Applicant is blacklisted
|
||||
message: Loan application rejected
|
||||
|
||||
================================================================================
|
||||
TEST SUMMARY
|
||||
================================================================================
|
||||
Total Tests: 20
|
||||
Passed: 20
|
||||
Failed: 0
|
||||
Success Rate: 100.0%
|
||||
|
||||
Would you like to enter interactive mode? (y/n):
|
||||
```
|
||||
|
||||
## Python Test Scripts
|
||||
|
||||
### Prerequisites
|
||||
|
||||
@ -105,6 +232,114 @@ response = client.call_hello_world("Your Name")
|
||||
print(response) # Output: Hello World, Your Name!
|
||||
```
|
||||
|
||||
## Customer Registration Test Script
|
||||
|
||||
### Running the Customer Registration Test
|
||||
|
||||
Make sure the JAX-WS service is running (using Docker or traditional setup).
|
||||
|
||||
**Windows:**
|
||||
```cmd
|
||||
python test_register_customer.py
|
||||
```
|
||||
|
||||
**Linux/Mac:**
|
||||
```bash
|
||||
python3 test_register_customer.py
|
||||
# OR
|
||||
chmod +x test_register_customer.py
|
||||
./test_register_customer.py
|
||||
```
|
||||
|
||||
### What the Script Does
|
||||
|
||||
The `test_register_customer.py` script:
|
||||
|
||||
1. **Checks WSDL availability** - Verifies the LoanApprovalService is running
|
||||
2. **Tests customer registration** - Registers multiple customers with different scenarios
|
||||
3. **Tests blacklist functionality** - Registers both regular and blacklisted customers
|
||||
4. **Tests duplicate registration** - Verifies that duplicate registrations are handled correctly
|
||||
5. **Interactive mode** - Allows you to register customers interactively
|
||||
|
||||
### Example Output
|
||||
|
||||
```
|
||||
======================================================================
|
||||
Customer Registration Service Test Client
|
||||
======================================================================
|
||||
|
||||
1. Checking WSDL availability...
|
||||
WSDL is accessible
|
||||
|
||||
2. Testing Customer Registration...
|
||||
|
||||
Test 1: Regular customer
|
||||
Customer Name: John Doe
|
||||
Blacklisted: False
|
||||
Result: Registration Successful
|
||||
|
||||
Test 2: Regular customer
|
||||
Customer Name: Jane Smith
|
||||
Blacklisted: False
|
||||
Result: Registration Successful
|
||||
|
||||
Test 3: Blacklisted customer
|
||||
Customer Name: Bad Actor
|
||||
Blacklisted: True
|
||||
Result: Registration Successful
|
||||
|
||||
Test 4: Duplicate registration (should fail)
|
||||
Customer Name: John Doe
|
||||
Blacklisted: False
|
||||
Result: Error: Customer already exists
|
||||
|
||||
3. Interactive Mode
|
||||
------------------------------------------------------------------
|
||||
Commands:
|
||||
- register <name>: Register a regular customer
|
||||
- blacklist <name>: Register a blacklisted customer
|
||||
- quit: Exit
|
||||
|
||||
> register Alice Smith
|
||||
Result: Registration Successful
|
||||
|
||||
> blacklist Evil Corp
|
||||
Result: Registration Successful
|
||||
|
||||
> quit
|
||||
|
||||
======================================================================
|
||||
Test completed!
|
||||
======================================================================
|
||||
```
|
||||
|
||||
### Using the CustomerRegistrationClient Class
|
||||
|
||||
You can also use the `CustomerRegistrationClient` class in your own Python scripts:
|
||||
|
||||
```python
|
||||
from test_register_customer import CustomerRegistrationClient
|
||||
|
||||
# Create client
|
||||
client = CustomerRegistrationClient()
|
||||
|
||||
# Check if service is available
|
||||
is_available, message = client.check_wsdl()
|
||||
print(message)
|
||||
|
||||
# Register a regular customer
|
||||
response = client.register_customer("John Doe", is_blacklisted=False)
|
||||
print(response) # Output: Registration Successful
|
||||
|
||||
# Register a blacklisted customer
|
||||
response = client.register_customer("Bad Actor", is_blacklisted=True)
|
||||
print(response) # Output: Registration Successful
|
||||
|
||||
# Try to register duplicate
|
||||
response = client.register_customer("John Doe", is_blacklisted=False)
|
||||
print(response) # Output: Error: Customer already exists
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Service Not Available
|
||||
|
||||
Reference in New Issue
Block a user