Package org.apache.torque.generator.qname

Examples of org.apache.torque.generator.qname.QualifiedName


     * @return the value of the option (can be null), or null if no matching
     *         option exists.
     */
    public Option getInHierarchy(QualifiedName key)
    {
        QualifiedName globalKey = globalScope.getKeyInHierarchy(key);
        Option globalOption = globalScope.get(globalKey);
        return globalOption;
    }


     * @param name the name of the option, must not be empty.
     * @param value the value of the option, may be null.
     */
    public OptionImpl(String namespace, String name, Object value)
    {
        this.qualifiedName = new QualifiedName(namespace, name);
        this.value = value;
    }

     * @throws IllegalArgumentException if qualifiedName is not a legal
     *         QualifiedName.
     */
    public OptionImpl(String qualifiedName, Object value)
    {
        this(new QualifiedName(qualifiedName, Namespace.ROOT_NAMESPACE), value);
    }

     */
    @Test
    public void testConstructor()
    {
        Variable variable = new Variable(
                new QualifiedName("generator", "org.apache.torque"),
                "value",
                Variable.Scope.FILE);
        assertEquals(
                new Namespace("org.apache.torque"),
                variable.getName().getNamespace());
        assertEquals("generator", variable.getName().getName());
        assertEquals("value", variable.getValue());
        assertEquals(Variable.Scope.FILE, variable.getScope());

        try
        {
            variable = new Variable(
                    null,
                    "value",
                    Variable.Scope.CHILDREN);
            fail("NullPointerException expected");
        }
        catch (NullPointerException e)
        {
            // expected
        }

        try
        {
            variable = new Variable(
                    new QualifiedName("org.apache.torque", "generator"),
                    new Object(),
                    null);
            fail("NullPointerException expected");
        }
        catch (NullPointerException e)
        {
        }

        variable = new Variable(
                new QualifiedName("org.apache.torque", "generator"),
                null,
                Variable.Scope.GLOBAL);
        assertNull(variable.getValue());
    }

    @Test
    public void testVariableScopePrecedence()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");

        // fill store
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GENERATOR",

    public void testNamespaceVisibility()
    {
        VariableStore store = new VariableStore();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.name"),
                "org.apache.FILE",
                Variable.Scope.FILE));
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");
        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());

        store.clear();
        store.set(new Variable(
                new QualifiedName("org.apache.name"),
                "org.apache.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque.FILE",
                Variable.Scope.FILE));
        assertEquals(
                "org.apache.torque.FILE",
                store.getInHierarchy(qualifiedName).getValue());

    public void testGetInHierarchy()
    {
        VariableStore store = new VariableStore();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque",
                Variable.Scope.OUTLET));
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");
        assertEquals(
                "org.apache.torque",
                store.getInHierarchy(qualifiedName).getValue());
        qualifiedName
            = new QualifiedName("org.apache.torque.generator.name");
        assertEquals(
                "org.apache.torque",
                store.getInHierarchy(qualifiedName).getValue());
        qualifiedName
            = new QualifiedName("org.apache.name");
        assertNull(store.getInHierarchy(qualifiedName));
    }

    public void testGetContents()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.generator"),
                "org.apache.torque.generator",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.children1"),
                "org.apache.torque.children1",
                Variable.Scope.CHILDREN));
        store.startOutlet();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.children2"),
                "org.apache.torque.children2",
                Variable.Scope.CHILDREN));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.file"),
                "org.apache.torque.file",
                Variable.Scope.FILE));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.global"),
                "org.apache.torque.global",
                Variable.Scope.GLOBAL));

        QualifiedNameMap<Variable> storeContent = store.getContent();
        assertEquals("storeContent should contain 5 entries",
                5,
                storeContent.size());

        {
            Variable variable
                    = storeContent.get(
                        new QualifiedName("org.apache.torque.generator"));
            assertEquals(
                    "org.apache.torque.generator",
                    variable.getValue());
        }
        {
            Variable variable
                    = storeContent.get(
                        new QualifiedName("org.apache.torque.children1"));
            assertEquals(
                    "org.apache.torque.children1",
                    variable.getValue());
        }
        {
            Variable variable
                    = storeContent.get(
                        new QualifiedName("org.apache.torque.children2"));
            assertEquals(
                    "org.apache.torque.children2",
                    variable.getValue());
        }
        {
            Variable variable
                    = storeContent.get(
                        new QualifiedName("org.apache.torque.file"));
            assertEquals(
                    "org.apache.torque.file",
                    variable.getValue());
        }
        {
            Variable variable
                    = storeContent.get(
                        new QualifiedName("org.apache.torque.global"));
            assertEquals(
                    "org.apache.torque.global",
                    variable.getValue());
        }
    }

    public void testRemove()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");

        // fill store
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GENERATOR",

    @Test
    public void testGetOutlets() throws ConfigurationException
    {
        List<Outlet> outlets = new ArrayList<Outlet>();
        outlets.add(new JavaOutlet(
                new QualifiedName("test.outlet.0")));
        outlets.add(new PackageToPathOutlet(
                new QualifiedName("test.outlet.1")));
        List<MergepointMapping> mergepointMappings
                = new ArrayList<MergepointMapping>();

        OutletConfiguration outletConfiguration = new OutletConfiguration(
                outlets,
                mergepointMappings,
                unitDescriptor);
        outletConfiguration.resolveMergepointMappings();

        assertEquals(2, outletConfiguration.getOutlets().size());
        assertEquals(
                outlets.get(0),
                outletConfiguration.getOutlets().get(
                        new QualifiedName("test.outlet.0")));
        assertEquals(
                outlets.get(1),
                outletConfiguration.getOutlets().get(
                        new QualifiedName("test.outlet.1")));
    }

TOP

Related Classes of org.apache.torque.generator.qname.QualifiedName

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.