| 1 |
package com.thaiopensource.relaxng.jaxp; |
| 2 |
|
| 3 |
import com.thaiopensource.xml.util.WellKnownNamespaces; |
| 4 |
import org.testng.Assert; |
| 5 |
import org.testng.annotations.Test; |
| 6 |
|
| 7 |
import javax.xml.XMLConstants; |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
public class XMLSyntaxSchemaFactoryTest extends SchemaFactoryImplTest { |
| 13 |
|
| 14 |
private static final String NS = XMLConstants.RELAXNG_NS_URI; |
| 15 |
|
| 16 |
public XMLSyntaxSchemaFactoryTest() { |
| 17 |
super(XMLSyntaxSchemaFactory.class); |
| 18 |
} |
| 19 |
|
| 20 |
@Test |
| 21 |
public void testIsSchemaLanguageSupported() { |
| 22 |
Assert.assertTrue(factory().isSchemaLanguageSupported(NS)); |
| 23 |
Assert.assertTrue(factory().isSchemaLanguageSupported(XMLSyntaxSchemaFactory.SCHEMA_LANGUAGE)); |
| 24 |
Assert.assertTrue(factory().isSchemaLanguageSupported(WellKnownNamespaces.RELAX_NG)); |
| 25 |
Assert.assertFalse(factory().isSchemaLanguageSupported(CompactSyntaxSchemaFactory.SCHEMA_LANGUAGE)); |
| 26 |
} |
| 27 |
|
| 28 |
protected String element(String name, String[] contentPatterns) { |
| 29 |
StringBuilder builder = new StringBuilder(); |
| 30 |
builder.append("<element xmlns='" + NS + "' name='") |
| 31 |
.append(name) |
| 32 |
.append("'>"); |
| 33 |
for (int i = 0; i < contentPatterns.length; i++) |
| 34 |
builder.append(contentPatterns[i]); |
| 35 |
if (contentPatterns.length == 0) |
| 36 |
builder.append("<empty/>"); |
| 37 |
builder.append("</element>"); |
| 38 |
return builder.toString(); |
| 39 |
} |
| 40 |
|
| 41 |
protected String attribute(String name) { |
| 42 |
return "<attribute name='" + name + "'/>"; |
| 43 |
} |
| 44 |
|
| 45 |
protected String externalRef(String uri) { |
| 46 |
return "<externalRef xmlns='" + NS + "' href='" + uri + "'/>"; |
| 47 |
} |
| 48 |
|
| 49 |
protected String getLSType() { |
| 50 |
return NS; |
| 51 |
} |
| 52 |
} |