Examples of DeviceRepository


Examples of com.volantis.mcs.devices.DeviceRepository

        final Map namesToDescriptors = new HashMap();

        List policies = new ArrayList();
        try {
            DeviceRepository repository = ProjectDeviceRepositoryAccessor
                    .getProjectDeviceRepository(context);
            Iterator policyNames = repository.getDevicePolicyNames().iterator();
            while (policyNames.hasNext()) {
                String policyName = (String) policyNames.next();
                PolicyDescriptor policyDescriptor =
                        repository.getPolicyDescriptor(policyName,
                                Locale.getDefault());
                if (policyDescriptor != null) {
                    if (policyDescriptor.getPolicyType()
                            instanceof SelectionPolicyType) {
                        namesToDescriptors.put(policyName, policyDescriptor);
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            throws DeviceRepositoryException {
        if (repositoryURL == null) {
            throw new IllegalArgumentException("Cannot be null: repositoryURL");
        }

        DeviceRepository deviceRepository = null;
        if (repositoryURL.startsWith(JDBC_SCHEME)) {
            deviceRepository = createJDBCDeviceRepository(repositoryURL,
                unknownDevicesLogFileName);
        } else if (repositoryURL.startsWith(XML_SCHEME)) {
            try {
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

        }

        // create the repository
        final SimpleDeviceRepositoryFactory factory =
            new SimpleDeviceRepositoryFactory();
        final DeviceRepository repository =
            factory.createDeviceRepository("file://" + fileName, null);

        final Iterator entriesIter;
        if (deviceName == null) {
            // iterate throuogh the identification entries
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                DeviceRepositoryFactory factory =
                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                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",
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                DeviceRepositoryFactory factory =
                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                // Test retrieval of an IMEI that exists as an eight-digit TAC
                String devName = repository.getDeviceNameByIMEI("350612190161323");
                assertEquals("Device 3506121901613238 should be Nokia 6210 Special",
                        "Nokia-6210-Special", devName);

                // Test retrieval of an IMEI that falls back to a six-digit TAC
                devName = repository.getDeviceNameByIMEI("350612350161323");
                assertEquals("Device 3506123501613238 should be Nokia 6210",
                        "Nokia-6210", devName);

                // Test retrieval of a IMEI that does not map to a TAC of eight or six
                // digits
                devName = repository.getDeviceNameByIMEI("123456789012345");
                assertNull("Device 123456789012345 should not exist", devName);

                // Test retrieval of an invalid IMEI
                try {
                    repository.getDeviceNameByIMEI("cheddarsmonkeys");
                    fail("Attempt to find non-numeric IMEI should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException - 'cheddarsmonkeys'
                    // is not a valid IMEI combination.
                }
                try {
                    repository.getDeviceNameByIMEI("0123456789abcde");
                    fail("Attempt to find non-numeric IMEI should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException - '0123456789abcde'
                    // is not a valid IMEI combination.
                }

                // Test invalid length
                try {
                    repository.getDeviceNameByIMEI("0123456789");
                    fail("Attempt to find too short IMEI should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException - '0123456789' is
                    // not a valid IMEI combination.
                }
                try {
                    repository.getDeviceNameByIMEI("01234567890123456789");
                    fail("Attempt to find too long IMEI should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException
                    // '01234567890123456789' is not a valid IMEI combination.
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                DeviceRepositoryFactory factory =
                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                // Test retrieval of a TAC/FAC that exists
                String devName = repository.getDeviceNameByTACFAC("35061219");
                assertEquals("Device 35061219 should be Nokia 6210 Special",
                        "Nokia-6210-Special", devName);

                // Test retrieval of a TAC/FAC that falls back to a six-digit TAC
                devName = repository.getDeviceNameByTACFAC("35061235");
                assertEquals("Device 35061235 should be Nokia 6210",
                        "Nokia-6210", devName);

                // Test retrieval of a TAC/FAC that does not exist as eight or six
                // digits
                devName = repository.getDeviceNameByTACFAC("12345678");
                assertNull("Device 12345678 should not exist", devName);

                // Test retrieval of an invalid TAC/FAC
                try {
                    repository.getDeviceNameByTACFAC("cheddars");
                    fail("Attempt to find non-numeric TAC should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException - 'cheddars' is not a
                    // valid TAC/FAC combination.
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                DeviceRepositoryFactory factory =
                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                // Test retrieval of an eight-digit TAC that exists
                String devName = repository.getDeviceNameByTAC("35061220");
                assertEquals("Device 35061220 should be Nokia 6210",
                        "Nokia-6210", devName);

                // Test retrieval of an eight-digit TAC that does not exist
                devName = repository.getDeviceNameByTAC("12345678");
                assertNull("Device 12345678 should not exist.", devName);

                // Test retrieval of a six-digit TAC that does not exist
                devName = repository.getDeviceNameByTAC("123456");
                assertNull("Device 123456 should not exist.", devName);

                // Test retrieval of a six-digit TAC that exists
                devName = repository.getDeviceNameByTAC("350612");
                assertEquals("Device 350612 should be Nokia 6210",
                        "Nokia-6210", devName);

                // Test retrieval of an invalid TAC
                try {
                    repository.getDeviceNameByTAC("monkey");
                    fail("Attempt to find non-numeric TAC should " +
                            "throw IllegalArgumentException");
                } catch (IllegalArgumentException iae) {
                    // We expect an IllegalArgumentException - 'monkey' is not a
                    // valid TAC.
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                final DeviceRepositoryFactory factory =
                    DeviceRepositoryFactory.getDefaultInstance();
                final URL deviceRepositoryUrl = file.toURL();
                final DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);


                Device device = repository.getDevice((HttpHeaders) null);
                assertNull("No device should be found", device);

                MutableHttpHeaders headers =
                    HTTP_HEADERS_FACTORY.createHTTPHeaders();
                device = repository.getDevice(headers);
                assertNotNull("Valid device should be found", device);
                assertEquals("Device name should match", "PC",
                    device.getName());

                headers.addHeader("User-Agent", "Nokia3330/");
                device = repository.getDevice(headers);
                assertNotNull("Valid device should be found", device);
                assertEquals("Device name should match", "Nokia-3330",
                    device.getName());
             }
        });
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                final DeviceRepositoryFactory factory =
                    DeviceRepositoryFactory.getDefaultInstance();
                final URL deviceRepositoryUrl = file.toURL();
                final DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                final String defaultDeviceName = "Mobile";

                // Null headers mean we return null device, not the default device
                // (that's how it worked before introducing configurable default device,
                // so I'm preserving this behaviuor)
                Device device = repository.getDevice((HttpHeaders) null, defaultDeviceName);
                assertNull("No device should be found", device);

                // Empty headers cause default device to be used
                MutableHttpHeaders headers =
                    HTTP_HEADERS_FACTORY.createHTTPHeaders();
                device = repository.getDevice(headers, defaultDeviceName);
                assertNotNull("Valid device should be found", device);
                assertEquals("Device name should match", defaultDeviceName,
                    device.getName());

                // Default device should be ignoired if a valid device can be extracted from headers
                headers.addHeader("User-Agent", "Nokia3330/");
                device = repository.getDevice(headers, defaultDeviceName);
                assertNotNull("Valid device should be found", device);
                assertEquals("Device name should match", "Nokia-3330",
                    device.getName());
             }
        });
View Full Code Here

Examples of com.volantis.mcs.devices.DeviceRepository

            public void execute(File file) throws Exception {

                DeviceRepositoryFactory factory =
                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                URL uaprofURL = null;
                String deviceName =
                    repository.getDeviceNameByUAProfURL(uaprofURL);
                assertNull("Device name should not have been found",
                        deviceName);

                uaprofURL = new URL("http", "host-not-defined-anywhere.com",
                        "/Handspring/HSTR300HK");
                deviceName = repository.getDeviceNameByUAProfURL(uaprofURL);
                assertNull("Device name should not have been found",
                        deviceName);

                uaprofURL = new URL("http", "device.sprintpcs.com", "/Handspring/HSTR300HK");
                deviceName = repository.getDeviceNameByUAProfURL(uaprofURL);

                assertEquals("Device name should match",
                        "SprintPCS-HSTR-300", deviceName);
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.