001 /* 002 * Copyright 2009 - 2010 JEuclid, http://jeuclid.sf.net 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 /* $Id: MoTest.java,v 92b6a7c39d7f 2010/08/11 20:23:17 max $ */ 018 019 package net.sourceforge.jeuclid.test.elements; 020 021 import net.sourceforge.jeuclid.DOMBuilder; 022 import net.sourceforge.jeuclid.MathMLParserSupport; 023 import net.sourceforge.jeuclid.elements.presentation.token.Mo; 024 025 import org.junit.Assert; 026 import org.junit.Test; 027 import org.w3c.dom.Document; 028 import org.w3c.dom.mathml.MathMLDocument; 029 import org.w3c.dom.mathml.MathMLMathElement; 030 031 /** 032 * Various tests for the {@link Mo} Element. 033 * 034 * @version $Revision: 92b6a7c39d7f $ 035 */ 036 public class MoTest { 037 /** 038 * Tests JEuclid MO Extensions. 039 * 040 * @throws Exception 041 * if anything goes wrong. 042 */ 043 @Test 044 public void testMOExtensions() throws Exception { 045 final Document doc = MathMLParserSupport 046 .parseString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" 047 + "<math mode='display' " 048 + "xmlns='http://www.w3.org/1998/Math/MathML' " 049 + "xmlns:jattr='http://jeuclid.sf.net/ns/ext'>" 050 + "<mo stretchy='true'>X</mo>" 051 + "<mo jattr:stretchy='horizontal'>X</mo>" 052 + "<mo jattr:stretchy='vertical'>X</mo>" 053 + "<mo jattr:stretchy='true'>X</mo>" + "</math>"); 054 final MathMLDocument docElement = DOMBuilder.getInstance() 055 .createJeuclidDom(doc); 056 057 final MathMLMathElement mathElement = (MathMLMathElement) docElement 058 .getFirstChild(); 059 060 final Mo mo = (Mo) mathElement 061 .getChildNodes().item(0); 062 Assert.assertNotNull(mo); 063 Assert.assertTrue(Boolean.parseBoolean(mo.getStretchy())); 064 Assert.assertEquals(mo.getExtendedStretchy(), "true"); 065 final Mo mo2 = (Mo) mathElement.getChildNodes().item(1); 066 Assert.assertNotNull(mo2); 067 Assert.assertTrue(Boolean.parseBoolean(mo2.getStretchy())); 068 Assert.assertEquals(mo2.getExtendedStretchy(), "horizontal"); 069 final Mo mo3 = (Mo) mathElement.getChildNodes().item(2); 070 Assert.assertNotNull(mo3); 071 Assert.assertTrue(Boolean.parseBoolean(mo3.getStretchy())); 072 Assert.assertEquals(mo3.getExtendedStretchy(), "vertical"); 073 final Mo mo4 = (Mo) mathElement.getChildNodes().item(3); 074 Assert.assertNotNull(mo4); 075 Assert.assertTrue(Boolean.parseBoolean(mo4.getStretchy())); 076 Assert.assertEquals(mo4.getExtendedStretchy(), "true"); 077 } 078 079 }