0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.s60tools.hticonnection.services.connectiontestservice;
|
|
19 |
|
|
20 |
import com.nokia.HTI.BaseService;
|
|
21 |
import com.nokia.HTI.IService;
|
|
22 |
import com.nokia.s60tools.hticonnection.core.AbstractRequest;
|
|
23 |
import com.nokia.s60tools.hticonnection.core.RequestResult;
|
|
24 |
import com.nokia.s60tools.hticonnection.exceptions.RequestFailedException;
|
|
25 |
import com.nokia.s60tools.hticonnection.resources.Messages;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Callable object that can be used to wait for request to complete.
|
|
29 |
*/
|
|
30 |
public class ConnectionTestRequest extends AbstractRequest{
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Name used for request.
|
|
34 |
*/
|
|
35 |
private static final String REQUEST_NAME = "Connection test"; //$NON-NLS-1$
|
|
36 |
|
|
37 |
// Values that are used to test service.
|
|
38 |
private final int WAIT_TIME = 1000;
|
|
39 |
private final String ECHO_STR = "Test"; //$NON-NLS-1$
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Capture a full screen.
|
|
43 |
*/
|
|
44 |
public ConnectionTestRequest(){
|
|
45 |
super(REQUEST_NAME);
|
|
46 |
}
|
|
47 |
|
|
48 |
/* (non-Javadoc)
|
|
49 |
* @see com.nokia.s60tools.hticonnection.core.AbstractRequest#createService()
|
|
50 |
*/
|
|
51 |
public BaseService createService(){
|
|
52 |
return new com.nokia.HTI.BaseService();
|
|
53 |
}
|
|
54 |
|
|
55 |
/* (non-Javadoc)
|
|
56 |
* @see com.nokia.s60tools.hticonnection.core.AbstractRequest#invokeService(com.nokia.HTI.IService)
|
|
57 |
*/
|
|
58 |
public RequestResult invokeService(IService service) throws Exception{
|
|
59 |
String echo = ((com.nokia.HTI.BaseService)service)
|
|
60 |
.echo(ECHO_STR, WAIT_TIME);
|
|
61 |
|
|
62 |
// Testing that correct string is returned.
|
|
63 |
if(!echo.equals(ECHO_STR)){
|
|
64 |
throw new RequestFailedException(REQUEST_NAME +
|
|
65 |
Messages.getString("ConnectionTestRequest.WrongResultReturned_Exception_Msg")); //$NON-NLS-1$
|
|
66 |
}
|
|
67 |
|
|
68 |
// Returning result that request was successful.
|
|
69 |
RequestResult requestResult = new RequestResult(true);
|
|
70 |
return requestResult;
|
|
71 |
}
|
|
72 |
}
|