use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class SSLCertMonitorIT method testExpiringDateForCertificate.
@Test
@JUnitHttpServer(port = 10342, https = true)
public void testExpiringDateForCertificate() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 4);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isUnavailable());
}
use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class SSLCertMonitorIT method testHostNameVerificationSucceeds.
@Test
@JUnitHttpServer(port = 10342, https = true, vhosts = "test.example.com")
public void testHostNameVerificationSucceeds() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
parameters.put("server-name", "${nodelabel}.example.com");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "test", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class SSLCertMonitorIT method testValidDateForCertificate.
@Test
@JUnitHttpServer(port = 10342, https = true)
public void testValidDateForCertificate() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of java.util.concurrent.ConcurrentSkipListMap in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method receiveSucceeds.
/*
Tests_SRS_MqttDeviceMethod_25_024: [**This method shall call parseTopic to parse the topic from the received Messages queue looking for presence of $iothub/methods/ in the topics .**]**
Tests_SRS_MqttDeviceMethod_25_026: [**This method shall call parsePayload to get the message payload from the recevived Messages queue corresponding to the messaging client's operation.**]**
Tests_SRS_MqttDeviceMethod_25_028: [**If the topic is of type post topic then this method shall parse further for method name and set it for the message by calling setMethodName for the message**]**
Tests_SRS_MqttDeviceMethod_25_030: [**If the topic is of type post topic then this method shall parse further to look for request id which if found is set by calling setRequestId**]**
Tests_SRS_MqttDeviceMethod_25_032: [**If the topic is of type post topic and if method name and request id has been successfully parsed then this method shall set operation type as DEVICE_OPERATION_METHOD_RECEIVE_REQUEST **]**
*/
@Test
public void receiveSucceeds() throws IOException {
//arrange
String topic = "$iothub/methods/POST/testMethod/?$rid=10";
byte[] actualPayload = "TestPayload".getBytes();
ConcurrentSkipListMap<String, byte[]> testAllReceivedMessages = new ConcurrentSkipListMap<>();
testAllReceivedMessages.put(topic, actualPayload);
Deencapsulation.setField(mockedMqtt, "allReceivedMessages", testAllReceivedMessages);
MqttDeviceMethod testMethod = new MqttDeviceMethod();
testMethod.start();
//act
Message testMessage = testMethod.receive();
DeviceMethodMessage testDMMessage = (DeviceMethodMessage) testMessage;
//assert
assertNotNull(testMessage);
assertTrue(testMessage.getMessageType().equals(MessageType.DeviceMethods));
assertTrue(testDMMessage.getRequestId().equals(String.valueOf(10)));
assertTrue(testDMMessage.getMethodName().equals("testMethod"));
assertTrue(testDMMessage.getDeviceOperationType().equals(DEVICE_OPERATION_METHOD_RECEIVE_REQUEST));
}
use of java.util.concurrent.ConcurrentSkipListMap in project azure-iot-sdk-java by Azure.
the class MqttDeviceTwinTest method receiveParsesPatchTopicForDesiredPropertiesNotificationSucceeds.
/*
**Tests_SRS_MQTTDEVICETWIN_25_042: [**If the topic is of type patch for desired properties then this method shall parse further to look for version which if found is set by calling setVersion**]**
*/
@Test
public void receiveParsesPatchTopicForDesiredPropertiesNotificationSucceeds(@Mocked final Mqtt mockMqtt) throws IOException {
final byte[] actualPayload = "UpdateDesiredPropertiesNotificationData".getBytes();
final String expectedTopic = "$iothub/twin/PATCH/properties/desired/" + "?$version=" + mockVersion;
DeviceTwinMessage receivedMessage = null;
try {
//arrange
MqttDeviceTwin testTwin = new MqttDeviceTwin();
String insertTopic = expectedTopic;
ConcurrentSkipListMap<String, byte[]> testMap = new ConcurrentSkipListMap<String, byte[]>();
testMap.put(insertTopic, actualPayload);
Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap);
//act
receivedMessage = (DeviceTwinMessage) testTwin.receive();
} finally {
//assert
assertNotNull(receivedMessage);
assertTrue(receivedMessage.getMessageType() == MessageType.DeviceTwin);
assertTrue(receivedMessage.getDeviceOperationType() == DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_RESPONSE);
assertTrue(receivedMessage.getVersion().equals(mockVersion));
assertTrue(receivedMessage.getRequestId() == null);
assertTrue(receivedMessage.getStatus() == null);
}
}
Aggregations