本文整理汇总了Java中com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java DeviceNotFoundException类的具体用法?Java DeviceNotFoundException怎么用?Java DeviceNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceNotFoundException类属于com.musala.atmosphere.commons.cs.exception包,在下文中一共展示了DeviceNotFoundException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: releaseDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
public void releaseDevice(DeviceAllocationInformation allocatedDeviceDescriptor)
throws InvalidPasskeyException,
DeviceNotFoundException {
String deviceId = allocatedDeviceDescriptor.getDeviceId();
long currentPasskey = allocatedDeviceDescriptor.getProxyPasskey();
PasskeyAuthority.validatePasskey(currentPasskey, deviceId);
try {
IDevice device = devicePoolDao.getDevice(deviceId);
if (device != null) {
releaseDevice(device, currentPasskey);
}
} catch (DevicePoolDaoException e) {
String errorMessage = String.format("Failed to release device with ID %s.", deviceId);
LOGGER.fatal(errorMessage);
}
}
示例2: validatePasskey
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
/**
* Validates the passkey for the given device.
*
* @param invocationPasskey
* - the passkey that the device should have
* @param deviceId
* - the unique identifier of the device whose passkey must be validated
* @throws InvalidPasskeyException
* if the passed passkey is not valid
* @throws DeviceNotFoundException
* thrown when an action fails, because the server fails to find the target device
*/
public static void validatePasskey(long invocationPasskey, String deviceId)
throws InvalidPasskeyException,
DeviceNotFoundException {
IDevicePoolDao devicePoolDao = dataSourceProvider.getDevicePoolDao();
IDevice device = null;
try {
device = devicePoolDao.getDevice(deviceId);
} catch (DevicePoolDaoException e) {
String message = "Failed to find the requested device for validation.";
throw new DeviceNotFoundException(message);
}
long passkey = device.getPasskey();
if (passkey != invocationPasskey) {
throw new InvalidPasskeyException("The passkey is not valid for the specified device.");
}
}
示例3: releaseDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
/**
* Releases an allocated device. Removes all cached sessions associated to the device.
*
* @param deviceDescriptor
* - the {@link DeviceAllocationInformation} corresponding to the device which should be released
*/
void releaseDevice(RequestMessage requestMessage, Session session) {
DeviceAllocationInformation deviceDescriptor = (DeviceAllocationInformation) requestMessage.getArguments()[0];
String deviceId = deviceDescriptor.getDeviceId();
removeCachedSessionByDeviceId(deviceId);
try {
poolManager.releaseDevice(deviceDescriptor);
ResponseMessage releseResponse = new ResponseMessage(MessageAction.RELEASE_DEVICE, null, null);
releseResponse.setSessionId(requestMessage.getSessionId());
sendText(jsonUtil.serialize(releseResponse), session);
} catch (InvalidPasskeyException | DeviceNotFoundException ex) {
sendErrorResponseMessage(ex, session, requestMessage.getSessionId());
LOGGER.error("Failed to release a device with id " + deviceId, ex);
}
}
示例4: initTestDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
protected static void initTestDevice(DeviceSelector deviceSelector) throws DeviceNotFoundException {
try {
GettingBuilderClass builderGet = new GettingBuilderClass();
Builder deviceBuilder = builderGet.getBuilder();
if (testDevice != null) {
deviceBuilder.releaseDevice(testDevice);
}
testDevice = deviceBuilder.getDevice(deviceSelector);
assertNotNull("Could not get a device.", testDevice);
// Assert our device is awake
if (!testDevice.isAwake()) {
testDevice.pressButton(HardwareButton.POWER);
Thread.sleep(WAKE_TIMEOUT);
}
// Assert our device is not locked
if (testDevice.isLocked()) {
testDevice.unlock();
Thread.sleep(UNLOCK_TIMEOUT);
}
// Assert we start our test from the Home screen
{
testDevice.pressButton(HardwareButton.HOME);
Thread.sleep(HOME_TIMEOUT);
}
} catch (InterruptedException e) {
LOGGER.error("Device preparation for integration test has been interrupted.", e);
}
}
示例5: releaseDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
@AfterClass
public static void releaseDevice() throws DeviceNotFoundException {
GettingBuilderClass builderGet = new GettingBuilderClass();
Builder deviceBuilder = builderGet.getBuilder();
if (testDevice != null) {
deviceBuilder.releaseDevice(testDevice);
testDevice = null;
}
}
示例6: releaseDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
private void releaseDevice() {
try {
builder.releaseDevice(device);
} catch (DeviceNotFoundException e) {
}
}
示例7: releaseDevice
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
/**
* Releases a given device.
*
* @param device
* - device to be released.
* @throws DeviceNotFoundException
* if failed to find the device
*/
public void releaseDevice(Device device) throws DeviceNotFoundException {
DeviceAllocationInformation deviceDescriptor = deviceToDescriptor.get(device);
String deviceId = deviceDescriptor.getDeviceId();
deviceToDescriptor.remove(device);
if (this.screenRecordingproperties.isEnabled()) {
device.stopScreenRecording();
}
if (this.logcatAnnotationProperties.isEnabled()) {
device.getDeviceLog(logcatAnnotationProperties);
}
device.release();
try {
dispatcher.releaseDevice(deviceDescriptor);
} catch (Exception e) {
if (e instanceof InvalidPasskeyException) {
// We did not have the correct passkey. The device most likely timed out and got freed to be used by
// someone else. So nothing to do here.
} else if (e instanceof DeviceNotFoundException) {
throw (DeviceNotFoundException) e;
} else if (e instanceof ServerConnectionFailedException) {
String message = "Could not release Device (connection failure).";
LOGGER.error(message, e);
throw new ServerConnectionFailedException(message, e);
}
}
String messageReleasedDevice = String.format("Released device with ID: %s .", deviceId);
LOGGER.info(messageReleasedDevice);
}
示例8: releaseAllDevices
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
/**
* Releases all allocated devices.
*
* @throws DeviceNotFoundException
* if failed to find the device
*/
public void releaseAllDevices() throws DeviceNotFoundException {
Set<Device> devicesToRelease = new HashSet<>(deviceToDescriptor.keySet());
for (Device device : devicesToRelease) {
releaseDevice(device);
}
}
示例9: finalize
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
@Override
protected void finalize() throws DeviceNotFoundException {
synchronized (Builder.class) {
releaseAllDevices();
builders.remove(getServerConnectionProperties());
}
}
示例10: tearDown
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
@After
public void tearDown() throws DeviceNotFoundException {
builder.releaseDevice(testDevice);
}
示例11: tearDownAfterEachTest
import com.musala.atmosphere.commons.cs.exception.DeviceNotFoundException; //导入依赖的package包/类
@After
public void tearDownAfterEachTest() throws DeviceNotFoundException {
builder.releaseAllDevices();
}
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:5,代码来源:BuilderDeviceSelectionIntegrationTest.java