Created
March 9, 2011 05:37
-
-
Save ebruchez/861743 to your computer and use it in GitHub Desktop.
Example of unit test written in Scala, with embedded XForms test document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.orbeon.oxf.xforms.analysis | |
import org.orbeon.oxf.common.Version | |
import org.scalatest.junit.AssertionsForJUnit | |
import org.orbeon.oxf.test.DocumentTestBase | |
import org.junit.{Assume, Test} | |
class ItemsetDependenciesTest extends DocumentTestBase with AssertionsForJUnit { | |
@Test def testSelectValueDependingOnItemset { | |
Assume.assumeTrue(Version.isPE) // only test this feature if we are the PE version | |
this setupDocument | |
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" | |
xmlns:xf="http://www.w3.org/2002/xforms" | |
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"> | |
<xh:head> | |
<xf:model id="model" xxf:xpath-analysis="true" xxf:encrypt-item-values="false"> | |
<xf:instance id="instance"> | |
<instance xmlns=""> | |
<selection>1 2</selection> | |
<value>1</value> | |
<value>2</value> | |
<index>1</index> | |
</instance> | |
</xf:instance> | |
</xf:model> | |
</xh:head> | |
<xh:body> | |
<xf:select id="checkbox" ref="selection" appearance="full"> | |
<xf:item> | |
<xf:label/> | |
<xf:value ref="../value[xs:integer(../index)]"/> | |
</xf:item> | |
</xf:select> | |
<xf:select1 id="value-selection" ref="index" appearance="full"> | |
<xf:item> | |
<xf:label>1</xf:label> | |
<xf:value>1</xf:value> | |
</xf:item> | |
<xf:item> | |
<xf:label>2</xf:label> | |
<xf:value>2</xf:value> | |
</xf:item> | |
</xf:select1> | |
</xh:body> | |
</xh:html> | |
assert(getControlExternalValue("checkbox") === "1") | |
assert(getControlExternalValue("value-selection") === "1") | |
assert(getItemset("checkbox") === """[["","1"]]""") | |
setControlValue("value-selection", "2") | |
assert(getControlExternalValue("checkbox") === "2") | |
assert(getItemset("checkbox") === """[["","2"]]""") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment