use of org.onosproject.xmpp.core.XmppDeviceId in project onos by opennetworkinglab.
the class XmppControllerImplTest method setUp.
/**
* Sets up devices to use as data, mocks and launches a controller instance.
*/
@Before
public void setUp() {
device1 = new XmppDeviceAdapter();
jid1 = new XmppDeviceId(new JID("agent1@testxmpp.org"));
device2 = new XmppDeviceAdapter();
jid2 = new XmppDeviceId(new JID("agent2@testxmpp.org"));
device3 = new XmppDeviceAdapter();
jid3 = new XmppDeviceId(new JID("agent3@testxmpp.org"));
controller = new XmppControllerImpl();
agent = controller.agent;
testXmppDeviceListener = new TestXmppDeviceListener();
controller.addXmppDeviceListener(testXmppDeviceListener);
testXmppIqListener = new TestXmppIqListener();
controller.addXmppIqListener(testXmppIqListener, testNamespace);
testXmppMessageListener = new TestXmppMessageListener();
controller.addXmppMessageListener(testXmppMessageListener);
testXmppPresenceListener = new TestXmppPresenceListener();
controller.addXmppPresenceListener(testXmppPresenceListener);
CoreService mockCoreService = EasyMock.createMock(CoreService.class);
controller.coreService = mockCoreService;
ComponentConfigService mockCfgService = EasyMock.createMock(ComponentConfigService.class);
expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
mockCfgService.registerProperties(controller.getClass());
expectLastCall();
mockCfgService.unregisterProperties(controller.getClass(), false);
expectLastCall();
expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
controller.cfgService = mockCfgService;
replay(mockCfgService);
ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("xmppPort", "5269");
expect(mockContext.getProperties()).andReturn(properties);
replay(mockContext);
controller.activate(mockContext);
}
use of org.onosproject.xmpp.core.XmppDeviceId in project onos by opennetworkinglab.
the class XmppPubSubControllerImpl method asXmppDeviceId.
private XmppDeviceId asXmppDeviceId(DeviceId deviceId) {
String[] parts = deviceId.toString().split(":");
JID jid = new JID(parts[1]);
return new XmppDeviceId(jid);
}
use of org.onosproject.xmpp.core.XmppDeviceId in project onos by opennetworkinglab.
the class XmppDeviceProvider method disconnectDevice.
private void disconnectDevice(XmppDeviceId xmppDeviceId) {
Preconditions.checkNotNull(xmppDeviceId, IS_NULL_MSG);
DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
if (deviceService.getDevice(deviceId) != null) {
providerService.deviceDisconnected(deviceId);
logger.info("XMPP device {} removed from XMPP controller", deviceId);
} else {
logger.warn("XMPP device {} does not exist in the store, " + "or it may already have been removed", deviceId);
}
}
use of org.onosproject.xmpp.core.XmppDeviceId in project onos by opennetworkinglab.
the class XmppDeviceProvider method connectDevice.
private void connectDevice(XmppDeviceId xmppDeviceId) {
DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
String ipAddress = controller.getDevice(xmppDeviceId).getIpAddress().getAddress().getHostAddress();
// Assumption: manufacturer is uniquely identified by domain part of JID
String manufacturer = xmppDeviceId.getJid().getDomain();
ChassisId cid = new ChassisId();
SparseAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, XMPP.toUpperCase()).set("IpAddress", ipAddress).build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTHER, manufacturer, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, true, annotations);
if (deviceService.getDevice(deviceId) == null) {
providerService.deviceConnected(deviceId, deviceDescription);
}
}
use of org.onosproject.xmpp.core.XmppDeviceId in project onos by opennetworkinglab.
the class XmppDeviceProvider method isReachable.
@Override
public boolean isReachable(DeviceId deviceId) {
String id = deviceId.uri().getSchemeSpecificPart();
JID jid = new JID(id);
XmppDeviceId xmppDeviceId = new XmppDeviceId(jid);
return controller.getDevice(xmppDeviceId) != null;
}
Aggregations