Package com.hp.jena3.rules.grammar.tests

Source Code of com.hp.jena3.rules.grammar.tests.TestParsingEntityName

/*
  (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
   All rights reserved.
   $Id$
*/


/*
   (c) Copyright 2008 Hewlett-Packard Development Company, LP
   All rights reserved.
   $Id$
*/

package com.hp.jena3.rules.grammar.tests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.hp.jena.rules.ast.EntityName;
import com.hp.jena3.rules.grammar.ParseException;

import static com.hp.jena3.rules.grammar.tests.Utils.*;

public class TestParsingEntityName
    {
    @Test public void ensureCanParseEmptyEntityName() throws ParseException
        {
        EntityName e = parserOn( "" ).entityName();
        assertEquals( null, e.getIRI() );
        assertEquals( labels( "" ), e.getLabels() );
        }

    @Test public void ensureCanParseIRIEntityName() throws ParseException
        {
        EntityName e = parserOn( "my:name" ).entityName();
        assertEquals( "my:name", e.getIRI() );
        assertEquals( labels( "" ), e.getLabels() );
        }

    @Test public void ensureCanParseLabelEntityName() throws ParseException
        {
        EntityName e = parserOn( "'hello'" ).entityName();
        assertEquals( null, e.getIRI() );
        assertEquals( labels( "hello" ), e.getLabels() );
        }

    @Test public void ensureCanParseLabelWithLanguageEntityName() throws ParseException
        {
        EntityName e = parserOn( "'chat'@fr" ).entityName();
        assertEquals( null, e.getIRI() );
        assertEquals( labels( "chat@fr"), e.getLabels() );
        }

    @Test public void ensureCanParseIRIAndLabelEntityName() throws ParseException
        {
        EntityName e = parserOn( "my:thing 'which-is-mine'" ).entityName();
        assertEquals( "my:thing", e.getIRI() );
        assertEquals( labels( "which-is-mine" ), e.getLabels() );
        }

    @Test public void ensureCanParseManyLabelsEntityName() throws ParseException
        {
        EntityName e = parserOn( "'hello', 'world', 'again'@en" ).entityName();
        assertEquals( null, e.getIRI() );
        assertEquals( labels( "hello world again@en" ), e.getLabels() );
        }
    }
TOP

Related Classes of com.hp.jena3.rules.grammar.tests.TestParsingEntityName

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.