当前位置: 首页>>代码示例>>Java>>正文


Java DeviceAllocationInformation.getDeviceId方法代码示例

本文整理汇总了Java中com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation.getDeviceId方法的典型用法代码示例。如果您正苦于以下问题:Java DeviceAllocationInformation.getDeviceId方法的具体用法?Java DeviceAllocationInformation.getDeviceId怎么用?Java DeviceAllocationInformation.getDeviceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation的用法示例。


在下文中一共展示了DeviceAllocationInformation.getDeviceId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的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);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:20,代码来源:PoolManager.java

示例2: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的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);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:24,代码来源:ServerDispatcher.java

示例3: getPresentDeviceFirstTestTwo

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceFirstTestTwo() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_PREFERRED)
                                                                       .screenHeight(600)
                                                                       .screenWidth(800);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例4: getPresentDeviceFirstTestThree

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceFirstTestThree() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(128);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:17,代码来源:PoolManagerDeviceSelectionTest.java

示例5: getPresentDeviceSecond

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceSecond() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().screenDpi(240);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(secondDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(secondDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(secondDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(SECOND_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:PoolManagerDeviceSelectionTest.java

示例6: getPresentDeviceThird

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceThird() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(512)
                                                                       .deviceType(DeviceType.DEVICE_ONLY);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(thirdDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(thirdDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(thirdDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(THIRD_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例7: getPresentDeviceFourth

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceFourth() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_ONLY)
                                                                       .screenDpi(180);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fourthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fourthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fourthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FOURTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例8: getPresentDeviceWithCamera

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceWithCamera() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_ONLY)
                                                                       .isCameraAvailable(true);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fourthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fourthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fourthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FOURTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例9: getPresentDeviceWithoutCamera

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceWithoutCamera() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().isCameraAvailable(false);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fifthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fifthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fifthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIFTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:PoolManagerDeviceSelectionTest.java

示例10: getPresentDeviceFirstTestOne

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
@Test
public void getPresentDeviceFirstTestOne() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(128);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);
    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:16,代码来源:PoolManagerDeviceSelectionTest.java

示例11: assertCorrectDeviceFetched

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
private void assertCorrectDeviceFetched(String expectedDeviceSerialNumber,
                                        DeviceAllocationInformation allocatedDeviceInformation) {
    String deviceId = allocatedDeviceInformation.getDeviceId();
    assertEquals("Failed to receive the ID of the correct device.",
                 String.format(DEVICE_ID_FORMAT, expectedDeviceSerialNumber),
                 deviceId);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:8,代码来源:PoolManagerDeviceSelectionTest.java

示例12: getDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的package包/类
/**
 * Gets a {@link Device Device} instance with the given {@link DeviceSelector device characteristics}.
 *
 * @param deviceSelector
 *        - required {@link DeviceSelector parameters} needed to construct new {@link Device Device} instance.
 * @return a {@link Device Device} instance with the given device parameters.
 */
public Device getDevice(DeviceSelector deviceSelector) {
    try {
        DeviceAllocationInformation deviceDescriptor = dispatcher.getDeviceDescriptor(deviceSelector,
                                                                                      allocateDeviceRetryCount);

        final String deviceId = deviceDescriptor.getDeviceId();
        LOGGER.info(String.format("Fetched device with ID: %s .", deviceId));

        long passkey = deviceDescriptor.getProxyPasskey();

        Device device = new Device(passkey, deviceId);
        deviceToDescriptor.put(device, deviceDescriptor);

        if (this.screenRecordingproperties.isEnabled()) {
            int duration = this.screenRecordingproperties.getDuration();
            device.startScreenRecording(duration, false);
        }
        if (this.logcatAnnotationProperties.isEnabled()) {
            device.clearLogcat();
        }

        ConfigurationPropertiesLoader.loadImplicitWait();

        return device;
    } catch (NoAvailableDeviceFoundException e) {
        String message = "No devices matching the requested parameters were found";
        LOGGER.error(message, e);
        throw new NoAvailableDeviceFoundException(message, e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:38,代码来源:Builder.java

示例13: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入方法依赖的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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:40,代码来源:Builder.java


注:本文中的com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation.getDeviceId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。