Package com.volantis.mcs.devices

Examples of com.volantis.mcs.devices.Device


            throws RepositoryException {

        headers.addHeader("accept", "text/html");
        headers.addHeader("accept", "application/xml");

        Device device = DevicesHelper.getDevice(
            connectionMock, headers, accessor, null).getDevice();

        assertEquals("PC", device.getName());

    }
View Full Code Here


            throws RepositoryException {

        headers.addHeader("accept", "application/vnd.wap.wml");
        headers.addHeader("accept", "text/html");

        Device device = DevicesHelper.getDevice(
            connectionMock, headers, accessor, null).getDevice();

        assertEquals("WAP-Handset", device.getName());

    }
View Full Code Here

    public void testGetDeviceWithMatchingCombinedAcceptHeader()
            throws RepositoryException {

        headers.addHeader("accept", "wap.wml, text/html");

        Device device = DevicesHelper.getDevice(
            connectionMock, headers, accessor, null).getDevice();

        assertEquals("WAP-Handset", device.getName());

    }
View Full Code Here

    public void testGetDeviceWithNonMatchingCombinedAcceptHeader()
            throws RepositoryException {

        headers.addHeader("accept", "text/html, application/xml");

        Device device = DevicesHelper.getDevice(
            connectionMock, headers, accessor, null).getDevice();

        assertEquals("PC", device.getName());

    }
View Full Code Here

    public void testGetDeviceWithNearMatchingCombinedAcceptHeader()
            throws RepositoryException {

        headers.addHeader("accept", "application/vnd.wap.wml, application/xml");

        Device device = DevicesHelper.getDevice(
            connectionMock, headers, accessor, null).getDevice();

        assertEquals("WAP-Handset", device.getName());

    }
View Full Code Here

    public void testGetDeviceWithSuppliedDefault() throws RepositoryException {

        String defaultDeviceName = "Custom";
        headers.addHeader("accept", "text/html, application/xml");

        Device device = DevicesHelper.getDevice(
             connectionMock, headers, accessor, null, defaultDeviceName)
                .getDevice();

         assertEquals(defaultDeviceName, device.getName());
    }
View Full Code Here

            "http://www.w3.org/1999/06/24-CCPPexchange;ns=13");
        headers.addHeader("13-profile", "http://test.com");

        final DeviceIdentificationResult identificationResult =
            DevicesHelper.getDevice(connectionMock, headers, accessorMock, null);
        final Device device = identificationResult.getDevice();

        // right device is returned
        assertEquals("secondary device name", device.getName());
        // identificationResult.getHeaderNamesUsed() contains the headers used
        // for NN-profile check
        assertTrue(
            identificationResult.getHeaderNamesUsed().contains("13-profile"));
        assertTrue(
View Full Code Here

        // NN-profile header
        headers.addHeader("13-profile", "http://test.com");

        final DeviceIdentificationResult identificationResult =
            DevicesHelper.getDevice(connectionMock, headers, accessorMock, null);
        final Device device = identificationResult.getDevice();

        // right device is returned
        assertEquals("secondary device name", device.getName());
        // identificationResult.getHeaderNamesUsed() contains the headers used
        // for NN-profile check
        assertTrue(
            identificationResult.getHeaderNamesUsed().contains("13-profile"));
        assertTrue(
View Full Code Here

        headers.addHeader("13-profile", "http://test13.com");
        headers.addHeader("19-profile", "http://test19.com");

        final DeviceIdentificationResult identificationResult =
            DevicesHelper.getDevice(connectionMock, headers, accessorMock, null);
        final Device device = identificationResult.getDevice();

        // it doesn't matter which device is returned
        assertTrue(device == deviceMock2a || device == deviceMock2b);
        // identificationResult.getHeaderNamesUsed() contains the headers used
        // for NN-profile check
        final Collection headerNamesUsed =
            identificationResult.getHeaderNamesUsed();
        assertTrue(headerNamesUsed.contains("Opt"));
        // must contain at least one *-profile header
        String profileHeaderName = null;
        for (Iterator iter = headerNamesUsed.iterator(); iter.hasNext(); ) {
            final String headerName = (String) iter.next();
            if (headerName.endsWith("-profile")) {
                profileHeaderName = headerName;
            }
        }
        assertNotNull(profileHeaderName);
        assertTrue(profileHeaderName.equals("13-profile") ||
            profileHeaderName.equals("19-profile"));

        //now try it again with different Opt header order
        headers = HttpFactory.getDefaultInstance().createHTTPHeaders();
        // initial user agent string
        headers.addHeader("User-Agent", "ua string");
        // NN-profile header
        headers.addHeader("Opt",
            "http://www.w3.org/1999/06/24-CCPPexchange;ns=19");
        headers.addHeader("Opt",
            "http://www.w3.org/1999/06/24-CCPPexchange;ns=13");
        headers.addHeader("13-profile", "http://test13.com");
        headers.addHeader("19-profile", "http://test19.com");

        final DeviceIdentificationResult identificationResult2 =
            DevicesHelper.getDevice(connectionMock, headers, accessorMock, null);
        // identified the same device
        assertTrue(device.getName().equals(
            identificationResult2.getDevice().getName()));
        // used the same headers to identify the device
        assertEquals(
            headerNamesUsed, identificationResult2.getHeaderNamesUsed());
    }
View Full Code Here

                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                String deviceName = "Master";

                Device device = repository.getDevice(deviceName);
                assertEquals("Name should match: ", deviceName, device.getName());

                device = repository.getDevice("Not Found");
                assertNull("No device should be found", device);

                deviceName = "Nokia-6210";
                device = repository.getDevice(deviceName);
                assertEquals("Name should match: ", deviceName, device.getName());
                DefaultDevice fallbackDevice =
                    ((DefaultDevice)device).getFallbackDevice();
                assertNotNull(fallbackDevice);
                assertEquals("Fallback name should match: ", "Nokia-Series7110",
                        fallbackDevice.getName());
View Full Code Here

TOP

Related Classes of com.volantis.mcs.devices.Device

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.