org.langera.freud.optional.css.cssrule.declaration.CssDeclarationJdomTest.java Source code

Java tutorial

Introduction

Here is the source code for org.langera.freud.optional.css.cssrule.declaration.CssDeclarationJdomTest.java

Source

/*
 * Copyright (c) 2011.
 * This file is part of "Freud".
 *
 * Freud is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Freud is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Freud.  If not, see <http://www.gnu.org/licenses/>.
 * @author Amir Langer  langera_at_gmail_dot_com
 */

package org.langera.freud.optional.css.cssrule.declaration;

import org.apache.commons.jxpath.JXPathContext;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public final class CssDeclarationJdomTest {
    private CssDeclarationJdom cssDeclarationJdom;

    @Test
    public void testGetKey() throws Exception {
        Assert.assertEquals("display", cssDeclarationJdom.getKey());
    }

    @Test
    public void testGetValues() throws Exception {
        Assert.assertEquals("none", cssDeclarationJdom.getValue());
    }

    @Before
    public void setUp() throws Exception {
        final SAXBuilder saxBuilder = new SAXBuilder(false);
        Document document = saxBuilder.build(ClassLoader.getSystemResourceAsStream("parsed_css_example.xml"));
        JXPathContext context = JXPathContext.newContext(document.getRootElement());
        cssDeclarationJdom = new CssDeclarationJdom(null, (Element) context.selectSingleNode("//PROPERTY"));

    }
}