Package com.volantis.devrep.repository.impl.accessors

Examples of com.volantis.devrep.repository.impl.accessors.AbstractDeviceRepositoryAccessor


        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                final Locale locale = Locale.getDefault();

                // Create a test connection
                RepositoryConnection connection = createConnection();

                // ------------------------------------------------------------
                // boolean
                // ------------------------------------------------------------
                DefaultPolicyDescriptor descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "mmssupp", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (boolean)",
                        descriptor.getPolicyDescriptiveName(),
                        "Supports MMS");
                assertEquals("Help should match (boolean)",
                        descriptor.getPolicyHelp(),
                        "Indicates whether the device supports the Multimedia" +
                        " Messaging Service (MMS)");
                assertEquals("Category should match (boolean)",
                        descriptor.getCategoryName(),
                        "system");
                // Ensure the type is of the correct type (try a cast!)
                BooleanPolicyType booleanType =
                        (BooleanPolicyType) descriptor.getPolicyType();

                // ------------------------------------------------------------
                // int
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "cpuclock", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (int)",
                        descriptor.getPolicyDescriptiveName(),
                        "Processor clock rate");
                assertEquals("Help should match (int)",
                        descriptor.getPolicyHelp(),
                        "Processor speed in MHz. A value -1 indicates that the" +
                        " speed is unknown");
                assertEquals("Category should match (int)",
                        descriptor.getCategoryName(),
                        "system");
                // Ensure the type is of the correct type (try a cast!)
                IntPolicyType intType = (IntPolicyType) descriptor.getPolicyType();

                // ------------------------------------------------------------
                // range
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "localsec", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (range)",
                        descriptor.getPolicyDescriptiveName(),
                        "Local data security");
                assertEquals("Help should match (range)",
                        descriptor.getPolicyHelp(),
                        "An indication of the level of security built into the" +
                        " device for securing user data");
                assertEquals("Category should match (range)",
                        descriptor.getCategoryName(),
                        "security");
                // Ensure the type is of the correct type (try a cast!)
                RangePolicyType rangeType = (RangePolicyType) descriptor.getPolicyType();
                assertEquals("Max should match", 100, rangeType.getMaxInclusive());
                assertEquals("Min should match", -1, rangeType.getMinInclusive());

                // ------------------------------------------------------------
                // selection
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "J2MEconf", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (selection)",
                        descriptor.getPolicyDescriptiveName(),
                        "J2ME configuration");
                assertEquals("Help should match (selection)",
                        descriptor.getPolicyHelp(),
                        "Describes the specific J2ME configuration implemented" +
                        " on the device");
                assertEquals("Category should match (selection)",
                        descriptor.getCategoryName(),
                        "system");
                // Ensure the type is of the correct type (try a cast!)
                SelectionPolicyType selectionType =
                        (SelectionPolicyType) descriptor.getPolicyType();
                String[] expected = new String[]{"none", "CLDC-1.0", "CDC-1.0"};
                List keywords = selectionType.getKeywords();
                int size = keywords.size();
                for (int i = 0; i < size; i++) {
                    assertEquals("Keyword " + i + " should match",
                            (String) keywords.get(i),
                            expected[i]);
                }

                // ------------------------------------------------------------
                // text
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "cpumfgr", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (text)",
                        descriptor.getPolicyDescriptiveName(),
                        "Processor manufacturer");
                assertEquals("Help should match (text)",
                        descriptor.getPolicyHelp(),
                        "The manufacturer of the device processor");
                assertEquals("Category should match (text)",
                        descriptor.getCategoryName(),
                        "system");
                // Ensure the type is of the correct type (try a cast!)
                TextPolicyType textType = (TextPolicyType) descriptor.getPolicyType();

                // ------------------------------------------------------------
                // structure
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(connection,
                                "protocol.wml.emulate.bigTag", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (structure)",
                        descriptor.getPolicyDescriptiveName(),
                        "Emulate WML big tag");
                assertEquals("Help should match (structure)",
                        descriptor.getPolicyHelp(),
                        "Controls markup or textual substitution for the WML" +
                        " <big> element");
                assertEquals("Category should match (structure)",
                        descriptor.getCategoryName(),
                        "protocol");
                // Ensure the type is of the correct type (try a cast!)
                StructurePolicyType structureType =
                        (StructurePolicyType) descriptor.getPolicyType();

                Map fields = structureType.getFieldTypes();
                Set keys = fields.keySet();
                String[] expectedKeys = new String[]{
                    "enable", "prefix", "suffix", "altTag"
                };
                size = expectedKeys.length;
                for (int i = 0; i < size; i++) {
                    assertTrue("Key " + i + " should be in the key set",
                            keys.contains(expectedKeys[i]));
                    assertNotNull("Key " + i + " should map to a non-null value",
                            fields.get(expectedKeys[i]));
                }

                // ------------------------------------------------------------
                // ordered set
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(
                                connection, "protocol", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (ordered set)",
                        descriptor.getPolicyDescriptiveName(),
                        "Protocol");
                assertEquals("Help should match (ordered set)",
                        descriptor.getPolicyHelp(),
                        "The protocol (markup language) to be used to" +
                        " communicate with the browser");
                assertEquals("Category should match (ordered set)",
                        descriptor.getCategoryName(),
                        "browser");
                // Ensure the type is of the correct type (try a cast!)
                OrderedSetPolicyType orderedSetType =
                        (OrderedSetPolicyType) descriptor.getPolicyType();
                PolicyType memberType = orderedSetType.getMemberPolicyType();
                assertTrue("Type of set values should match",
                        memberType instanceof SelectionPolicyType);

                // ------------------------------------------------------------
                // unordered set
                // ------------------------------------------------------------
                descriptor = (DefaultPolicyDescriptor)
                        accessor.retrievePolicyDescriptor(connection,
                                "UAProf.Push-Accept", locale);
                // Ensure the names and help match as expected
                assertEquals("Descriptive name should match (unordered set)",
                        descriptor.getPolicyDescriptiveName(),
                        "Push content types supported");
                assertEquals("Help should match (unordered set)",
                        descriptor.getPolicyHelp(),
                        "List of content types the device supports for push");
                assertEquals("Category should match (unordered set)",
                        descriptor.getCategoryName(),
                        "message");
                // Ensure the type is of the correct type (try a cast!)
                UnorderedSetPolicyType unorderedSetType =
                        (UnorderedSetPolicyType) descriptor.getPolicyType();
                memberType = unorderedSetType.getMemberPolicyType();
                assertTrue("Type of set values should match",
                        memberType instanceof TextPolicyType);

                {
                    // -------------------------------------------------------
                    // fallback (fake)
                    // -------------------------------------------------------
                    descriptor = (DefaultPolicyDescriptor)
                            accessor.retrievePolicyDescriptor(connection,
                                    "fallback", locale);
                    // Ensure the names and help match as expected
                    assertEquals("Descriptive name should match (fallback)",
                            descriptor.getPolicyDescriptiveName(), "fallback");
                    assertEquals("Help should match (fallback)",
View Full Code Here


        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.addDevice(createConnection(),
                            new DefaultDevice("PC-MacOS", new HashMap(), null));

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
                    // Expected condition
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                RUNTIME_REPOSITORY_CREATOR);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.removeDevice(createConnection(), "PC");

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
                    // Expected condition
                }
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                DefaultDevice master = accessor.retrieveDevice(createConnection(),
                        "Master");
                assertEquals("", "Master", master.getName());

                assertNull("No TACs should be defined for Master",
                        master.getTACValues());

                int count = 0;
                for (Iterator iter = master.getPolicyNames(); iter.hasNext(); iter.next()) {
//                    final String name = (String) iter.next();
//                    System.out.println(
//                        name + " -> " + master.getPolicyValue(name));
                    count++;
                }
                assertEquals(289, count);
                assertEquals("Unexpected download value",
                        "false", master.getPolicyValue("download"));
                assertEquals("Unexpected UAProf.CcppAccept value",
                        "text/html,image/jpeg,image/gif",
                        master.getPolicyValue("UAProf.CcppAccept"));
                assertEquals("Unexpected protocol.wml.emulate.cardTitle.enable",
                        "false",
                        master.getPolicyValue("protocol.wml.emulate.cardTitle.enable"));

                // Check a device which is expected to have TACs
                DefaultDevice nokia = accessor.retrieveDevice(createConnection(),
                        "Nokia-6210");
                assertEquals("Name should be as expected",
                        "Nokia-6210", nokia.getName());
                Set tacs = nokia.getTACValues();
                assertEquals("Nokia-6210 should have two TACs",
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.renameDevice(createConnection(),
                            ROOT_DEVICE_NAME,
                            "NewName");

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.removePolicy(createConnection(),
                            ROOT_DEVICE_NAME);

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
                    // Expected condition
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                RUNTIME_REPOSITORY_CREATOR);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                Set expectedDeviceNames = new HashSet();
                Set actualDeviceNames = new HashSet();
                RepositoryEnumeration nameEnum =
                    accessor.enumerateDeviceNames(createConnection());

                String[] deviceNames = getExpectedDeviceNames();

                for (int i = 0; i < deviceNames.length; i++) {
                    expectedDeviceNames.add(deviceNames[i]);
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                RUNTIME_REPOSITORY_CREATOR);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                Map expectedFallbacks = getExpectedDeviceFallbacks();
                Map actualFallbacks = new HashMap();

                RepositoryEnumeration fallbackEnum =
                    accessor.enumerateDeviceFallbacks(createConnection());

                while (fallbackEnum.hasNext()) {
                    String[] fallback = (String[])fallbackEnum.next();

                    actualFallbacks.put(fallback[0], fallback[1]);
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.updatePolicyName(createConnection(),
                            "java",
                            "beanies");

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
View Full Code Here

        TemporaryFileManager manager = new TemporaryFileManager(
                RUNTIME_REPOSITORY_CREATOR);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                if (deviceName == null) {
                    throw new IllegalArgumentException("test case fault");
                }

                DefaultDevice expectedDevice =
                    getExpectedDevice(deviceName);
                DefaultDevice actualDevice =
                    accessor.retrieveDevice(createConnection(), deviceName);

                assertEquals(expectedDevice, actualDevice);
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.volantis.devrep.repository.impl.accessors.AbstractDeviceRepositoryAccessor

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.