use of org.eclipse.wst.xml.core.internal.contentmodel.basic.CMDataTypeImpl in project webtools.sourceediting by eclipse.
the class ElementImplTests method testCMAttrWithNullImpliedValue.
public void testCMAttrWithNullImpliedValue() {
IDOMModel model = null;
try {
model = (IDOMModel) getModelForRead("testfiles/time.xml");
if (model != null) {
IDOMDocument document = model.getDocument();
final String ATTR_NAME = "second";
// Setup a ModelQueryAdapter whose sole purpose it to provide a attribute declaration with a null implied value
document.addAdapter(new ModelQueryAdapter() {
public boolean isAdapterForType(Object type) {
return type.equals(ModelQueryAdapter.class);
}
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
}
public CMDocumentCache getCMDocumentCache() {
return null;
}
public org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver getIdResolver() {
return null;
}
public ModelQuery getModelQuery() {
return new ModelQueryImpl(null) {
/* (non-Javadoc)
* @see org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl#getCMElementDeclaration(org.w3c.dom.Element)
*/
public CMElementDeclaration getCMElementDeclaration(Element element) {
final CMElementDeclaration decl = new CMElementDeclarationImpl(null, null);
CMNamedNodeMapImpl map = (CMNamedNodeMapImpl) decl.getAttributes();
map.put(new CMAttributeDeclarationImpl(ATTR_NAME, CMAttributeDeclaration.OPTIONAL, new CMDataTypeImpl(ATTR_NAME, (String) null)));
return decl;
}
};
}
public void release() {
}
public void setIdResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver newIdResolver) {
}
});
Element element = document.getDocumentElement();
assertNotNull(element);
// Default value should be 0
assertEquals("", element.getAttribute(ATTR_NAME));
}
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
Aggregations