Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5519 amar.kumar 1
package in.shop2020.alert.test;
2
 
3
import java.util.Date;
4
 
5
import in.shop2020.alert.AlertMapper;
6
import in.shop2020.alert.AlertService.Client;
7
import in.shop2020.alert.AlertServiceException;
8
import in.shop2020.alert.AlertType;
9
import in.shop2020.alert.EntityProcessedState;
10
import in.shop2020.alert.EntityType;
11
import in.shop2020.alert.MonitoredEntity;
12
import in.shop2020.alert.SearchFilter;
13
 
14
import org.apache.thrift.TException;
15
import org.apache.thrift.protocol.TBinaryProtocol;
16
import org.apache.thrift.protocol.TProtocol;
17
import org.apache.thrift.transport.TFramedTransport;
18
import org.apache.thrift.transport.TSocket;
19
import org.apache.thrift.transport.TTransport;
20
import org.apache.thrift.transport.TTransportException;
21
 
22
public class TestAlertServer {
23
	private static final int SOCKET_TIMEOUT = 1000 * 60 * 5;
24
 
25
	public static void main(String[] args) throws AlertServiceException{
26
		TSocket socket = new TSocket("localhost", 9018);
27
		socket.setTimeout(SOCKET_TIMEOUT);
28
 
29
		TTransport transport = new TFramedTransport(socket);
30
		TProtocol protocol = new TBinaryProtocol(transport);
31
		Client client = new Client(protocol);
32
		try {
33
			transport.open();
34
		} catch (TTransportException e) {
35
			e.printStackTrace();
36
		}
37
 
38
		try {
39
//			MonitoredEntity entity = new MonitoredEntity();
40
//			entity.setEntityType(EntityType.ORDER);
41
//			entity.setEventType(3);
42
//			entity.setEntityIdentifier("testing insertion");
43
//			entity.setWarnExpiryTime(new Date().UTC(2012, 6, 21, 18, 35, 0));
44
//			entity.setWarnExpiryTime(new Date().UTC(2012, 6, 22, 11, 45, 0));
45
//			entity.setDescription("Test Order entity");
46
//			entity.setEntityProcessedState(EntityProcessedState.WARNING_SENT);
47
//			client.scheduleAlert(entity);
48
//			client.updateMonitoredObject(entity);
49
//			client.endMonitoringEntity(EntityType.ORDER, "123");
50
//			client.deActivateEntityMonitoring(EntityType.ORDER);
51
//			client.activateEntityMonitoring(EntityType.ORDER, "amar.kumar@shop2020.in");
52
//			AlertMapper alertMap = new AlertMapper();
53
//			alertMap.setEntityType(EntityType.ORDER);
54
//			alertMap.setEventType(2);
55
//			alertMap.setEventdesciption("TEst");
56
//			alertMap.setAlertType(AlertType.EMAIL);
57
//			alertMap.setUserIds("amar.kumar@shop2020.in");
58
//			client.registerEventType(alertMap);
59
//			client.updateMonitoredObject(entity);
60
//			SearchFilter searchFilter = new SearchFilter();
61
//			searchFilter.setEntityProcessedState(EntityProcessedState.UNEXPIRED);
62
//			System.out.println(client.getEntities(searchFilter));
63
			System.out.println(client.getAlertMapper(EntityType.ORDER, 3));
64
		} catch (TException e) {
65
			e.printStackTrace();
66
		} catch (AlertServiceException ex) {
67
			ex.printStackTrace();
68
		}
69
	}
70
}