Package org.apache.qpid.server.model.testmodel

Examples of org.apache.qpid.server.model.testmodel.TestRootCategory


        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.DEFAULTED_VALUE, "override");

        TestRootCategory object = _model.getObjectFactory().create(TestRootCategory.class,
                                                                   attributes);

        assertEquals(objectName, object.getName());
        assertEquals("override", object.getDefaultedValue());

    }
View Full Code Here


        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.DEFAULTED_VALUE, "override");

        TestRootCategory object = _model.getObjectFactory().create(TestRootCategory.class,
                                                                   attributes);

        assertEquals(objectName, object.getName());
        assertEquals("override", object.getDefaultedValue());

        object.setAttributes(Collections.singletonMap(TestRootCategory.DEFAULTED_VALUE, null));
        assertEquals(TestRootCategory.DEFAULTED_VALUE_DEFAULT, object.getDefaultedValue());
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.ENUM_VALUE, TestEnum.TEST_ENUM1.name());

        TestRootCategory object1 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        assertEquals(objectName, object1.getName());
        assertEquals(TestEnum.TEST_ENUM1, object1.getEnumValue());
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.ENUM_VALUE, TestEnum.TEST_ENUM1);

        TestRootCategory object1 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        assertEquals(objectName, object1.getName());
        assertEquals(TestEnum.TEST_ENUM1, object1.getEnumValue());
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.STRING_VALUE, contextToken);

        TestRootCategory object1 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        assertEquals(objectName, object1.getName());
        assertEquals("myValue", object1.getStringValue());

        // System property set empty string

        System.setProperty(sysPropertyName, "");
        TestRootCategory object2 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        assertEquals("", object2.getStringValue());

        // System property not set
        System.clearProperty(sysPropertyName);

        TestRootCategory object3 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        // yields the unexpanded token - not sure if this is really useful behaviour?
        assertEquals(contextToken, object3.getStringValue());
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(TestRootCategory.MAP_VALUE, contextToken);

        TestRootCategory object1 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);

        assertEquals(objectName, object1.getName());
        assertEquals(expectedMap, object1.getMapValue());

        // System property not set
        System.clearProperty(sysPropertyName);
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);


        TestRootCategory object = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);


        assertTrue("context default not in contextKeys",
                   object.getContextKeys(true).contains(TestRootCategory.TEST_CONTEXT_DEFAULT));
        assertEquals(object.getContextValue(String.class, TestRootCategory.TEST_CONTEXT_DEFAULT), "default");

        setTestSystemProperty(TestRootCategory.TEST_CONTEXT_DEFAULT, "notdefault");
        assertTrue("context default not in contextKeys",
                   object.getContextKeys(true).contains(TestRootCategory.TEST_CONTEXT_DEFAULT));
        assertEquals(object.getContextValue(String.class, TestRootCategory.TEST_CONTEXT_DEFAULT), "notdefault");
    }
View Full Code Here

        Map<String, Object> attributes = new HashMap<>();
        attributes.put(ConfiguredObject.NAME, objectName);
        attributes.put(ConfiguredObject.CONTEXT, Collections.singletonMap("myReplacement", "myValue"));
        attributes.put(TestRootCategory.STRING_VALUE, contextToken);

        TestRootCategory object1 = _model.getObjectFactory().create(TestRootCategory.class,
                                                                    attributes);
        // Check the object's context itself
        assertTrue(object1.getContext().containsKey("myReplacement"));
        assertEquals("myValue", object1.getContext().get("myReplacement"));

        assertEquals(objectName, object1.getName());
        assertEquals("myValue", object1.getStringValue());
    }
View Full Code Here

    }

    public void testCreationOfObjectWithInvalidInterpolatedValues()
    {
        final String parentName = "parent";
        TestRootCategory parent =
                _model.getObjectFactory().create(TestRootCategory.class,
                                                 Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
                                                                                          parentName)
                                                );

        parent.setAttributes(Collections.singletonMap(ConfiguredObject.CONTEXT,
                                                      Collections.singletonMap("contextVal", "foo")));

        final Map<String, Object> attributes = new HashMap<>();
        attributes.put("intValue", "${contextVal}");
        attributes.put("name", "child");
        attributes.put("integerSet", "[ ]");
        attributes.put(ConfiguredObject.TYPE, "test");

        try
        {
            _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
            fail("creation of child object should have failed due to invalid value");
        }
        catch (IllegalArgumentException e)
        {
            // PASS
            String message = e.getMessage();
            assertTrue("Message does not contain the attribute name", message.contains("intValue"));
            assertTrue("Message does not contain the non-interpolated value", message.contains("contextVal"));
            assertTrue("Message does not contain the interpolated value", message.contains("foo"));

        }

        assertTrue("Child should not have been registered with parent",
                   parent.getChildren(TestChildCategory.class).isEmpty());
    }
View Full Code Here

    }

    public void testCreationOfObjectWithInvalidDefaultValues()
    {
        final String parentName = "parent";
        TestRootCategory parent =
                _model.getObjectFactory().create(TestRootCategory.class,
                                                 Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
                                                                                          parentName)
                                                );

        final Map<String, Object> attributes = new HashMap<>();
        attributes.put("intValue", "1");
        attributes.put("name", "child");
        attributes.put(ConfiguredObject.TYPE, "test");

        try
        {
            _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
            fail("creation of child object should have failed due to invalid value");
        }
        catch (IllegalArgumentException e)
        {
            // PASS
            String message = e.getMessage();
            assertTrue("Message does not contain the attribute name", message.contains("integerSet"));
            assertTrue("Message does not contain the error value", message.contains("foo"));

        }

        assertTrue("Child should not have been registered with parent",
                   parent.getChildren(TestChildCategory.class).isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.model.testmodel.TestRootCategory

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.