Changed meta package and added junit tests
This commit is contained in:
parent
897fe80357
commit
226c1f0425
6
todo.txt
6
todo.txt
|
@ -8,11 +8,10 @@
|
||||||
- meta add more ns and jndi ref/etc'
|
- meta add more ns and jndi ref/etc'
|
||||||
- redo eld/default converters config
|
- redo eld/default converters config
|
||||||
- tag aliases
|
- tag aliases
|
||||||
- maven plugin
|
|
||||||
- lang-el-beans.xml loading
|
- lang-el-beans.xml loading
|
||||||
- Add XML schema tags to ELD
|
- Add XML schema tags to ELD
|
||||||
- Auto generate schemas from eld
|
- Auto generate schemas from eld
|
||||||
- Basic write support (for editor)
|
- Basic write support
|
||||||
- Basic editor support
|
- Basic editor support
|
||||||
- Make converter config/loading better
|
- Make converter config/loading better
|
||||||
- Single xsd output
|
- Single xsd output
|
||||||
|
@ -28,7 +27,6 @@
|
||||||
- event listeners on all DOM tree element operations
|
- event listeners on all DOM tree element operations
|
||||||
- custom and merga'ble parse phases for speed
|
- custom and merga'ble parse phases for speed
|
||||||
- make element tree jdom api compatible
|
- make element tree jdom api compatible
|
||||||
- (DONE) change phase enum to generic (text) phases.
|
|
||||||
- Test if possible to use threadpool for executing phases
|
- Test if possible to use threadpool for executing phases
|
||||||
|
|
||||||
-- TODO for version 1.0 --
|
-- TODO for version 1.0 --
|
||||||
|
@ -36,8 +34,6 @@
|
||||||
## NON-CODE
|
## NON-CODE
|
||||||
- Add tutorial
|
- Add tutorial
|
||||||
- doc eld and x4o lang files
|
- doc eld and x4o lang files
|
||||||
- Create xslt eld to html converter
|
|
||||||
- split into multiple maven projects
|
|
||||||
|
|
||||||
##CODE
|
##CODE
|
||||||
- Add (super) tag for extending tags of other namespace
|
- Add (super) tag for extending tags of other namespace
|
||||||
|
|
10
versions.txt
10
versions.txt
|
@ -2,14 +2,20 @@
|
||||||
=== X4O versions ===
|
=== X4O versions ===
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.8.6:
|
||||||
|
- Changed to X4ODriver interface.
|
||||||
|
- Added write support
|
||||||
|
- Added ant and maven plugins
|
||||||
|
|
||||||
Version 0.8.5:
|
Version 0.8.5:
|
||||||
- Made module loading system.
|
- Made module loading system.
|
||||||
- Added XSD generator.
|
- Added eld to schema generator.
|
||||||
|
- Added eld to html generator.
|
||||||
- Cleaned xml uri nameing.
|
- Cleaned xml uri nameing.
|
||||||
- Cleaned language properties.
|
- Cleaned language properties.
|
||||||
- refactored ELD tag names.
|
- refactored ELD tag names.
|
||||||
- Made elddoc ~working.
|
- Made elddoc ~working.
|
||||||
|
- Changed phase enum to text phases.
|
||||||
|
|
||||||
Version 0.8.2:
|
Version 0.8.2:
|
||||||
- Changed packages to org.x4o
|
- Changed packages to org.x4o
|
||||||
|
|
|
@ -50,10 +50,9 @@ public abstract class X4ODriver<T> {
|
||||||
public final static String DEFAULT_LANGUAGE_VERSION = "1.0";
|
public final static String DEFAULT_LANGUAGE_VERSION = "1.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force public constructor and register the driver.
|
* Public constructor.
|
||||||
*/
|
*/
|
||||||
public X4ODriver() {
|
public X4ODriver() {
|
||||||
X4ODriverManager.registerX4ODriver(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +66,6 @@ public abstract class X4ODriver<T> {
|
||||||
abstract public String[] getLanguageVersions();
|
abstract public String[] getLanguageVersions();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected X4OLanguage buildLanguage(String version) {
|
protected X4OLanguage buildLanguage(String version) {
|
||||||
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +79,6 @@ public abstract class X4ODriver<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public X4OSchemaWriter createSchemaWriter() {
|
public X4OSchemaWriter createSchemaWriter() {
|
||||||
return createSchemaWriter(getLanguageVersionDefault());
|
return createSchemaWriter(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,28 +184,8 @@ public final class X4ODriverManager {
|
||||||
if (instance.drivers.containsKey(language)) {
|
if (instance.drivers.containsKey(language)) {
|
||||||
return instance.drivers.get(language);
|
return instance.drivers.get(language);
|
||||||
}
|
}
|
||||||
try {
|
instance.lazyInit();
|
||||||
instance.lazyInit();
|
X4ODriver<?> result = instance.createX4ODriver(language);
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
X4ODriver<?> result = null;
|
|
||||||
try {
|
|
||||||
result = instance.createX4ODriver(language);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (result==null) {
|
if (result==null) {
|
||||||
throw new IllegalArgumentException("Can't find driver for language: "+language);
|
throw new IllegalArgumentException("Can't find driver for language: "+language);
|
||||||
}
|
}
|
||||||
|
@ -213,15 +193,7 @@ public final class X4ODriverManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public List<String> getX4OLanguages() {
|
static public List<String> getX4OLanguages() {
|
||||||
try {
|
instance.lazyInit();
|
||||||
instance.lazyInit();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
List<String> result = new ArrayList<String>(10);
|
List<String> result = new ArrayList<String>(10);
|
||||||
result.addAll(instance.classdrivers.keySet());
|
result.addAll(instance.classdrivers.keySet());
|
||||||
result.addAll(instance.defaultDrivers.keySet());
|
result.addAll(instance.defaultDrivers.keySet());
|
||||||
|
@ -229,7 +201,7 @@ public final class X4ODriverManager {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lazyInit() throws IOException, SAXException {
|
private void lazyInit() {
|
||||||
if (reloadDrivers==false) {
|
if (reloadDrivers==false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -237,38 +209,44 @@ public final class X4ODriverManager {
|
||||||
reloadDrivers = false;
|
reloadDrivers = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private X4ODriver<?> createX4ODriver(String language) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
private X4ODriver<?> createX4ODriver(String language) {
|
||||||
|
String driverClassName = null;
|
||||||
if (classdrivers.containsKey(language)) {
|
if (classdrivers.containsKey(language)) {
|
||||||
String driverClassName = classdrivers.get(language);
|
driverClassName = classdrivers.get(language);
|
||||||
|
} else if (defaultDrivers.containsKey(language)) {
|
||||||
|
driverClassName = defaultDrivers.get(language);
|
||||||
|
}
|
||||||
|
if (driverClassName==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
Class<?> driverClass = X4OLanguageClassLoader.loadClass(driverClassName);
|
Class<?> driverClass = X4OLanguageClassLoader.loadClass(driverClassName);
|
||||||
X4ODriver<?> driver = (X4ODriver<?>)driverClass.newInstance();
|
X4ODriver<?> driver = (X4ODriver<?>)driverClass.newInstance();
|
||||||
|
registerX4ODriver(driver);
|
||||||
return driver;
|
return driver;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
if (defaultDrivers.containsKey(language)) {
|
|
||||||
String driverClassName = defaultDrivers.get(language);
|
|
||||||
Class<?> driverClass = X4OLanguageClassLoader.loadClass(driverClassName);
|
|
||||||
X4ODriver<?> driver = (X4ODriver<?>)driverClass.newInstance();
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all defined language drivers in classpath.
|
* Loads all defined language drivers in classpath.
|
||||||
*/
|
*/
|
||||||
private void loadLanguageDrivers() throws IOException, SAXException {
|
private void loadLanguageDrivers() {
|
||||||
|
|
||||||
logger.finer("loading x4o drivers from: "+X4O_DRIVERS_RESOURCE);
|
logger.finer("loading x4o drivers from: "+X4O_DRIVERS_RESOURCE);
|
||||||
Enumeration<URL> e = Thread.currentThread().getContextClassLoader().getResources(X4O_DRIVERS_RESOURCE);
|
try {
|
||||||
while(e.hasMoreElements()) {
|
Enumeration<URL> e = Thread.currentThread().getContextClassLoader().getResources(X4O_DRIVERS_RESOURCE);
|
||||||
URL u = e.nextElement();
|
while(e.hasMoreElements()) {
|
||||||
loadDriversXml(u.openStream());
|
URL u = e.nextElement();
|
||||||
}
|
loadDriversXml(u.openStream());
|
||||||
|
}
|
||||||
e = Thread.currentThread().getContextClassLoader().getResources("/"+X4O_DRIVERS_RESOURCE);
|
e = Thread.currentThread().getContextClassLoader().getResources("/"+X4O_DRIVERS_RESOURCE);
|
||||||
while(e.hasMoreElements()) {
|
while(e.hasMoreElements()) {
|
||||||
URL u = e.nextElement();
|
URL u = e.nextElement();
|
||||||
loadDriversXml(u.openStream());
|
loadDriversXml(u.openStream());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,8 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (skipChilderenClassRegex!=null) {
|
if (skipChilderenClassRegex!=null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||||
if (childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
return; // skip
|
||||||
return; // skip
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
createChild(parentElement,childObject);
|
createChild(parentElement,childObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
|
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -44,6 +42,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 11, 2005
|
* @version 1.0 Aug 11, 2005
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> implements X4OReader<T> {
|
abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> implements X4OReader<T> {
|
||||||
|
|
||||||
public AbstractX4OReader(X4OLanguageContext elementLanguage) {
|
public AbstractX4OReader(X4OLanguageContext elementLanguage) {
|
||||||
|
@ -57,10 +56,8 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
return X4OLanguagePropertyKeys.DEFAULT_X4O_READER_KEYS;
|
return X4OLanguagePropertyKeys.DEFAULT_X4O_READER_KEYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public T read(InputStream input, String systemId, URL basePath) throws ParserConfigurationException, SAXException, IOException {
|
public T read(InputStream input, String systemId, URL basePath) throws ParserConfigurationException, SAXException, IOException {
|
||||||
X4OLanguageContext context = readContext(input, systemId, basePath);
|
return (T)readContext(input, systemId, basePath).getRootElement().getElementObject();
|
||||||
return (T)context.getRootElement().getElementObject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,10 +72,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||||
*/
|
*/
|
||||||
public T readFile(String fileName) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
public T readFile(String fileName) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
||||||
if (fileName==null) {
|
return (T)readFileContext(fileName).getRootElement().getElementObject();
|
||||||
throw new NullPointerException("Can't convert null fileName to file object.");
|
|
||||||
}
|
|
||||||
return readFile(new File(fileName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,24 +87,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||||
*/
|
*/
|
||||||
public T readFile(File file) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
public T readFile(File file) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
||||||
if (file==null) {
|
return (T)readFileContext(file).getRootElement().getElementObject();
|
||||||
throw new NullPointerException("Can't read null file.");
|
|
||||||
}
|
|
||||||
if (file.exists()==false) {
|
|
||||||
throw new FileNotFoundException("File does not exists; "+file);
|
|
||||||
}
|
|
||||||
if (file.canRead()==false) {
|
|
||||||
throw new IOException("File exists but can't read file: "+file);
|
|
||||||
}
|
|
||||||
URL basePath = new File(file.getAbsolutePath()).toURI().toURL();
|
|
||||||
InputStream inputStream = new FileInputStream(file);
|
|
||||||
try {
|
|
||||||
return read(inputStream,file.getAbsolutePath(),basePath);
|
|
||||||
} finally {
|
|
||||||
if(inputStream!=null) {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,29 +102,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||||
*/
|
*/
|
||||||
public T readResource(String resourceName) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
public T readResource(String resourceName) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException {
|
||||||
if (resourceName==null) {
|
return (T)readResourceContext(resourceName).getRootElement().getElementObject();
|
||||||
throw new NullPointerException("Can't read null resourceName from classpath.");
|
|
||||||
}
|
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
|
||||||
if (cl == null) cl = getClass().getClassLoader(); // fallback
|
|
||||||
URL url = cl.getResource(resourceName);
|
|
||||||
if (url==null) {
|
|
||||||
throw new NullPointerException("Could not find resource on classpath: "+resourceName);
|
|
||||||
}
|
|
||||||
String baseUrl = url.toExternalForm();
|
|
||||||
int lastSlash = baseUrl.lastIndexOf('/');
|
|
||||||
if (lastSlash > 0 && (lastSlash+1) < baseUrl.length()) {
|
|
||||||
baseUrl = baseUrl.substring(0,lastSlash+1);
|
|
||||||
}
|
|
||||||
URL basePath = new URL(baseUrl);
|
|
||||||
InputStream inputStream = cl.getResourceAsStream(resourceName);
|
|
||||||
try {
|
|
||||||
return read(inputStream,url.toExternalForm(),basePath);
|
|
||||||
} finally {
|
|
||||||
if(inputStream!=null) {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,11 +115,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||||
*/
|
*/
|
||||||
public T readString(String xmlString) throws ParserConfigurationException,SAXException,IOException,NullPointerException {
|
public T readString(String xmlString) throws ParserConfigurationException,SAXException,IOException,NullPointerException {
|
||||||
if (xmlString==null) {
|
return (T)readStringContext(xmlString).getRootElement().getElementObject();
|
||||||
throw new NullPointerException("Can't read null xml string.");
|
|
||||||
}
|
|
||||||
URL basePath = new File(System.getProperty("user.dir")).toURI().toURL();
|
|
||||||
return read(new ByteArrayInputStream(xmlString.getBytes()),"inline-xml",basePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,10 +128,6 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
||||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||||
*/
|
*/
|
||||||
public T readUrl(URL url) throws ParserConfigurationException,SAXException,IOException,NullPointerException {
|
public T readUrl(URL url) throws ParserConfigurationException,SAXException,IOException,NullPointerException {
|
||||||
if (url==null) {
|
return (T)readUrlContext(url).getRootElement().getElementObject();
|
||||||
throw new NullPointerException("Can't read null url.");
|
|
||||||
}
|
|
||||||
URL basePath = new URL(url.toExternalForm().substring(0,url.toExternalForm().length()-url.getFile().length()));
|
|
||||||
return read(url.openStream(),url.toExternalForm(),basePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.X4ODriverManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultX4ODriver can be used to create language without code and type safty.
|
* DefaultX4ODriver can be used to create language without code and type safty.
|
||||||
|
@ -44,7 +43,6 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
public DefaultX4ODriver(String languageName,String languageVersion) {
|
public DefaultX4ODriver(String languageName,String languageVersion) {
|
||||||
this.languageName=languageName;
|
this.languageName=languageName;
|
||||||
this.languageVersion=languageVersion;
|
this.languageVersion=languageVersion;
|
||||||
X4ODriverManager.registerX4ODriver(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -365,14 +365,5 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
* @return The hashCode.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,9 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
||||||
* @param message The message to log to the debug output.
|
* @param message The message to log to the debug output.
|
||||||
*/
|
*/
|
||||||
private void logMessage(X4OLanguage language,String message) {
|
private void logMessage(X4OLanguage language,String message) {
|
||||||
logger.finest(message);
|
logger.finest(message+" from: "+language.getLanguageName());
|
||||||
/*
|
/*
|
||||||
if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
try {
|
try {
|
||||||
language.getLanguageConfiguration().getX4ODebugWriter().debugPhaseMessage(message, this.getClass());
|
language.getLanguageConfiguration().getX4ODebugWriter().debugPhaseMessage(message, this.getClass());
|
||||||
} catch (ElementException e) {
|
} catch (ElementException e) {
|
||||||
|
|
|
@ -37,6 +37,24 @@ import junit.framework.TestCase;
|
||||||
*/
|
*/
|
||||||
public class X4ODriverManagerTest extends TestCase {
|
public class X4ODriverManagerTest extends TestCase {
|
||||||
|
|
||||||
|
public void testDefaultLanguageVersionSelect() throws Exception {
|
||||||
|
String version = X4ODriverManager.getDefaultLanguageVersion(new String[]{"1.0","2.0","3.0"});
|
||||||
|
assertNotNull(version);
|
||||||
|
assertEquals("3.0",version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDefaultLanguageVersionEmpty() throws Exception {
|
||||||
|
String version = X4ODriverManager.getDefaultLanguageVersion(new String[]{});
|
||||||
|
assertNotNull(version);
|
||||||
|
assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION,version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDefaultLanguageVersionNull() throws Exception {
|
||||||
|
String version = X4ODriverManager.getDefaultLanguageVersion(null);
|
||||||
|
assertNotNull(version);
|
||||||
|
assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION,version);
|
||||||
|
}
|
||||||
|
|
||||||
public void testLanguageNull() throws Exception {
|
public void testLanguageNull() throws Exception {
|
||||||
String language = null;
|
String language = null;
|
||||||
Exception e = null;
|
Exception e = null;
|
||||||
|
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.io.X4OReader;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.test.TestDriver;
|
||||||
|
import org.x4o.xml.test.models.TestBean;
|
||||||
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OAbstractReaderContextTest.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 15, 2013
|
||||||
|
*/
|
||||||
|
public class X4OAbstractReaderContextTest extends TestCase {
|
||||||
|
|
||||||
|
private File copyResourceToTempFile() throws IOException {
|
||||||
|
File tempFile = File.createTempFile("test-resource", ".xml");
|
||||||
|
tempFile.deleteOnExit();
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||||
|
try {
|
||||||
|
writer.writeFile(reader.readResource("tests/attributes/test-bean.xml"), tempFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
return tempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileName() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
File xmlFile = copyResourceToTempFile();
|
||||||
|
X4OLanguageContext context = reader.readFileContext(xmlFile.getAbsolutePath());
|
||||||
|
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileNameNull() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
String nullFileName = null;
|
||||||
|
reader.readFileContext(nullFileName);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("fileName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFile() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
File xmlFile = copyResourceToTempFile();
|
||||||
|
X4OLanguageContext context = reader.readFileContext(xmlFile);
|
||||||
|
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileNull() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
File nullFile = null;
|
||||||
|
reader.readFileContext(nullFile);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("file"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileNotExists() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
File tempFile = File.createTempFile("test-file", ".xml");
|
||||||
|
tempFile.delete();
|
||||||
|
reader.readFileContext(tempFile);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",FileNotFoundException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("exists"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("File"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testReadResource() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
X4OLanguageContext context = reader.readResourceContext("tests/attributes/test-bean.xml");
|
||||||
|
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||||
|
assertNotNull(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadResourceNull() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
reader.readResourceContext(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("resourceName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadString() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
X4OLanguageContext context = reader.readStringContext(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||||
|
"<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+
|
||||||
|
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||||
|
"</root:root>"
|
||||||
|
);
|
||||||
|
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
assertEquals("987654321", ""+bean.getPrivateIntegerTypeField());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadStringNull() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
reader.readStringContext(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("string"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadUrl() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml");
|
||||||
|
X4OLanguageContext context = reader.readUrlContext(xmlUrl);
|
||||||
|
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadUrlNull() throws Exception {
|
||||||
|
TestDriver driver = TestDriver.getInstance();
|
||||||
|
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
reader.readUrlContext(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("url"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,193 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.io.X4OReader;
|
||||||
|
import org.x4o.xml.test.TestDriver;
|
||||||
|
import org.x4o.xml.test.models.TestBean;
|
||||||
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OAbstractReaderTest.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 15, 2013
|
||||||
|
*/
|
||||||
|
public class X4OAbstractReaderTest extends TestCase {
|
||||||
|
|
||||||
|
private File copyResourceToTempFile() throws IOException {
|
||||||
|
File tempFile = File.createTempFile("test-resource", ".xml");
|
||||||
|
tempFile.deleteOnExit();
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||||
|
try {
|
||||||
|
writer.writeFile(reader.readResource("tests/attributes/test-bean.xml"), tempFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
return tempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testReadResource() throws Exception {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||||
|
assertNotNull(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadResourceNull() throws Exception {
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
reader.readResource(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("resourceName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadString() throws Exception {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
TestObjectRoot root = reader.readString(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||||
|
"<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+
|
||||||
|
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||||
|
"</root:root>"
|
||||||
|
);
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
assertEquals("987654321", ""+bean.getPrivateIntegerTypeField());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadStringNull() throws Exception {
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
reader.readString(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("string"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadUrl() throws Exception {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml");
|
||||||
|
TestObjectRoot root = reader.readUrl(xmlUrl);
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadUrlNull() throws Exception {
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
reader.readUrl(null);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("url"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileName() throws Exception {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
File xmlFile = copyResourceToTempFile();
|
||||||
|
TestObjectRoot root = reader.readFile(xmlFile.getAbsolutePath());
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileNameNull() throws Exception {
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
String nullFileName = null;
|
||||||
|
reader.readFile(nullFileName);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("fileName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFile() throws Exception {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
File xmlFile = copyResourceToTempFile();
|
||||||
|
TestObjectRoot root = reader.readFile(xmlFile);
|
||||||
|
assertNotNull(root);
|
||||||
|
assertTrue(root.getTestBeans().size()>0);
|
||||||
|
TestBean bean = root.getTestBeans().get(0);
|
||||||
|
assertNotNull(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReadFileNull() throws Exception {
|
||||||
|
Exception e = null;
|
||||||
|
try {
|
||||||
|
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||||
|
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||||
|
File nullFile = null;
|
||||||
|
reader.readFile(nullFile);
|
||||||
|
} catch (Exception catchE) {
|
||||||
|
e = catchE;
|
||||||
|
}
|
||||||
|
assertNotNull("No exception",e);
|
||||||
|
assertEquals("Wrong exception class",NullPointerException.class, e.getClass());
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("null"));
|
||||||
|
assertTrue("Wrong exception message",e.getMessage().contains("file"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ public class TestBean {
|
||||||
public Character publicCharObjectField = new Character(' ');
|
public Character publicCharObjectField = new Character(' ');
|
||||||
|
|
||||||
public String publicStringObjectField = " ";
|
public String publicStringObjectField = " ";
|
||||||
public Date publicDateObjectField = new Date(0);
|
//public Date publicDateObjectField = new Date(0); // TODO add date converters
|
||||||
|
|
||||||
|
|
||||||
// private
|
// private
|
||||||
|
@ -84,7 +84,7 @@ public class TestBean {
|
||||||
private Character privateCharObjectField = new Character(' ');
|
private Character privateCharObjectField = new Character(' ');
|
||||||
|
|
||||||
private String privateStringObjectField = " ";
|
private String privateStringObjectField = " ";
|
||||||
private Date privateDateObjectField = new Date(0);
|
//private Date privateDateObjectField = new Date(0);
|
||||||
|
|
||||||
|
|
||||||
// auto gen , get/set-ers
|
// auto gen , get/set-ers
|
||||||
|
@ -269,18 +269,18 @@ public class TestBean {
|
||||||
public void setPublicStringObjectField(String publicStringObjectField) {
|
public void setPublicStringObjectField(String publicStringObjectField) {
|
||||||
this.publicStringObjectField = publicStringObjectField;
|
this.publicStringObjectField = publicStringObjectField;
|
||||||
}
|
}
|
||||||
/**
|
/*
|
||||||
* @return the publicDateObjectField
|
* @return the publicDateObjectField
|
||||||
*/
|
|
||||||
public Date getPublicDateObjectField() {
|
public Date getPublicDateObjectField() {
|
||||||
return publicDateObjectField;
|
return publicDateObjectField;
|
||||||
}
|
}*/
|
||||||
/**
|
/*
|
||||||
* @param publicDateObjectField the publicDateObjectField to set
|
* @param publicDateObjectField the publicDateObjectField to set
|
||||||
*/
|
|
||||||
public void setPublicDateObjectField(Date publicDateObjectField) {
|
public void setPublicDateObjectField(Date publicDateObjectField) {
|
||||||
this.publicDateObjectField = publicDateObjectField;
|
this.publicDateObjectField = publicDateObjectField;
|
||||||
}
|
}*/
|
||||||
/**
|
/**
|
||||||
* @return the privateIntegerTypeField
|
* @return the privateIntegerTypeField
|
||||||
*/
|
*/
|
||||||
|
@ -461,16 +461,16 @@ public class TestBean {
|
||||||
public void setPrivateStringObjectField(String privateStringObjectField) {
|
public void setPrivateStringObjectField(String privateStringObjectField) {
|
||||||
this.privateStringObjectField = privateStringObjectField;
|
this.privateStringObjectField = privateStringObjectField;
|
||||||
}
|
}
|
||||||
/**
|
/*
|
||||||
* @return the privateDateObjectField
|
* @return the privateDateObjectField
|
||||||
*/
|
|
||||||
public Date getPrivateDateObjectField() {
|
public Date getPrivateDateObjectField() {
|
||||||
return privateDateObjectField;
|
return privateDateObjectField;
|
||||||
}
|
}*/
|
||||||
/**
|
/*
|
||||||
* @param privateDateObjectField the privateDateObjectField to set
|
* @param privateDateObjectField the privateDateObjectField to set
|
||||||
*/
|
|
||||||
public void setPrivateDateObjectField(Date privateDateObjectField) {
|
public void setPrivateDateObjectField(Date privateDateObjectField) {
|
||||||
this.privateDateObjectField = privateDateObjectField;
|
this.privateDateObjectField = privateDateObjectField;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
152
x4o-driver/src/test/resources/META-INF/junit-defd/defd-lang.eld
Normal file
152
x4o-driver/src/test/resources/META-INF/junit-defd/defd-lang.eld
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<root:module
|
||||||
|
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
||||||
|
xmlns:eld="http://eld.x4o.org/xml/ns/eld-lang"
|
||||||
|
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||||
|
providerName="test.x4o.org"
|
||||||
|
name="Test Language"
|
||||||
|
id="test-module"
|
||||||
|
>
|
||||||
|
|
||||||
|
<eld:classBindingHandler id="Parent-Child" parentClass="org.x4o.xml.test.models.TestObjectParent" childClass="org.x4o.xml.test.models.TestObjectChild" addMethod="addTestObjectChild" getMethod="getTestObjectChilds">
|
||||||
|
<eld:description>Binds the TestObjectChild to the TestObjectParent</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
<eld:classBindingHandler id="Root-Child" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectChild" addMethod="addChild" getMethod="getTestObjectChilds">
|
||||||
|
<eld:description>Binds the TestBean to the TestObjectChild</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
<eld:classBindingHandler id="Root-Parent" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestObjectParent" addMethod="addParent" getMethod="getTestObjectParents">
|
||||||
|
<eld:description>Binds the TestObjectParent to the TestObjectRoot</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
<eld:classBindingHandler id="Root-Bean" parentClass="org.x4o.xml.test.models.TestObjectRoot" childClass="org.x4o.xml.test.models.TestBean" addMethod="addTestBean" getMethod="getTestBeans">
|
||||||
|
<eld:description>Binds the TestBean to the TestObjectRoot</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" addMethod="addComponent" getMethod="">
|
||||||
|
<eld:description>Binds j components.</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
<eld:classBindingHandler id="JFrame-JPanel" parentClass="javax.swing.JFrame" childClass="javax.swing.JPanel" addMethod="add" getMethod="getComponents">
|
||||||
|
<eld:description>Binds panel to frame components as unit check.</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
|
||||||
|
<eld:elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
|
<eld:description>Configs the Component based objects.</eld:description>
|
||||||
|
<eld:attribute name="bounds">
|
||||||
|
<conv:stringSplitConverter classTo="java.awt.Rectangle" split="," splitSize="4" singleToMethod="setRect" useNativeType="true">
|
||||||
|
<conv:stringSplitConverterStep fromMethod="getX" fromOrder="1" toOrder="1"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
|
<conv:stringSplitConverterStep fromMethod="getY" fromOrder="2" toOrder="2"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
|
<conv:stringSplitConverterStep fromMethod="getWidth" fromOrder="3" toOrder="3"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
|
<conv:stringSplitConverterStep fromMethod="getHeight" fromOrder="4" toOrder="4"><conv:doubleConverter/></conv:stringSplitConverterStep>
|
||||||
|
</conv:stringSplitConverter>
|
||||||
|
</eld:attribute>
|
||||||
|
</eld:elementInterface>
|
||||||
|
|
||||||
|
<eld:elementInterface id="JComponent" interfaceClass="javax.swing.JComponent">
|
||||||
|
<eld:description>Configs the JComponent based objects.</eld:description>
|
||||||
|
<eld:classBindingHandler id="JComponent-JComponent" parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents">
|
||||||
|
<eld:description>Binds the JComponent to the JComponent.</eld:description>
|
||||||
|
</eld:classBindingHandler>
|
||||||
|
</eld:elementInterface>
|
||||||
|
|
||||||
|
<eld:configuratorGlobal bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfigGlobal">
|
||||||
|
<eld:description>Test the global element configurator.</eld:description>
|
||||||
|
</eld:configuratorGlobal>
|
||||||
|
|
||||||
|
<eld:attributeHandler attributeName="tt.attr1" bean.class="org.x4o.xml.test.element.TestElementAttributeHandler" id="attrTest1">
|
||||||
|
<eld:description>Test the global element attribute1 handler.</eld:description>
|
||||||
|
</eld:attributeHandler>
|
||||||
|
<eld:attributeHandler attributeName="tt.attr2" bean.class="org.x4o.xml.test.element.TestElementAttributeHandler" id="attrTest2">
|
||||||
|
<eld:description>Test the global element attribute2 handler.</eld:description>
|
||||||
|
<eld:attributeHandlerNextAttribute attributeName="tt.attr1"/>
|
||||||
|
</eld:attributeHandler>
|
||||||
|
|
||||||
|
<eld:namespace
|
||||||
|
uri="http://test.x4o.org/xml/ns/test-root"
|
||||||
|
schemaUri="http://test.x4o.org/xml/ns/test-root-1.0.xsd"
|
||||||
|
schemaResource="test-root-1.0.xsd"
|
||||||
|
schemaPrefix="root"
|
||||||
|
description="Root namespace to have nice namespaceing."
|
||||||
|
name="Test Root Namespace"
|
||||||
|
languageRoot="true"
|
||||||
|
id="test-root"
|
||||||
|
>
|
||||||
|
<!-- Root Element for nice namespace'ing -->
|
||||||
|
<eld:element tag="root" objectClass="org.x4o.xml.test.models.TestObjectRoot">
|
||||||
|
<eld:description>The test root element.</eld:description>
|
||||||
|
</eld:element>
|
||||||
|
</eld:namespace>
|
||||||
|
|
||||||
|
<eld:namespace
|
||||||
|
uri="http://test.x4o.org/xml/ns/test-lang"
|
||||||
|
schemaUri="http://test.x4o.org/xml/ns/test-lang-1.0.xsd"
|
||||||
|
schemaResource="test-lang-1.0.xsd"
|
||||||
|
schemaPrefix="lang"
|
||||||
|
description="Test language namespace to test some/most features"
|
||||||
|
name="Test Language Namespace"
|
||||||
|
id="test-lang"
|
||||||
|
>
|
||||||
|
<eld:element tag="testNoNSRoot" objectClass="org.x4o.xml.test.models.TestObjectRoot"/>
|
||||||
|
|
||||||
|
<eld:element tag="testBean" objectClass="org.x4o.xml.test.models.TestBean">
|
||||||
|
<eld:description>The test the bean object.</eld:description>
|
||||||
|
</eld:element>
|
||||||
|
|
||||||
|
<eld:element tag="configBean" objectClass="org.x4o.xml.test.models.TestBean">
|
||||||
|
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig1">
|
||||||
|
<eld:description>The test element config.</eld:description>
|
||||||
|
</eld:configurator>
|
||||||
|
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig2"/>
|
||||||
|
<eld:elementSkipPhase name="runAttributesPhase"/>
|
||||||
|
<eld:elementSkipPhase name="transformPhase"/>
|
||||||
|
</eld:element>
|
||||||
|
|
||||||
|
<eld:element tag="parent" objectClass="org.x4o.xml.test.models.TestObjectParent"/>
|
||||||
|
<eld:element tag="child" objectClass="org.x4o.xml.test.models.TestObjectChild"/>
|
||||||
|
|
||||||
|
<eld:element tag="testObjectParent" objectClass="org.x4o.xml.test.models.TestObjectParent"/>
|
||||||
|
<eld:element tag="testObjectChild" objectClass="org.x4o.xml.test.models.TestObjectChild"/>
|
||||||
|
<eld:element tag="testBeanObjectChild" objectClass="org.x4o.xml.test.models.TestObjectChild">
|
||||||
|
<!--
|
||||||
|
<eld:element tag="testBeanObjectChild" objectClass="org.x4o.xml.models.TestObjectChild" parentNamespace="http://test.x4o.org/eld/iets.eld" elementTag="superObject"/>
|
||||||
|
<eld:elementClass tag="JTextArea" objectClassName="javax.swing.JTextArea"/>
|
||||||
|
<eld:elementClassParentElementClass namespace="http://test.x4o.org/eld/iets.eld" elementTag="superObject"/>
|
||||||
|
<eld:elementClassParentElementClass namespace="http://test.x4o.org/eld/iets.eld" elementTag="superObject2"/>
|
||||||
|
-->
|
||||||
|
</eld:element>
|
||||||
|
|
||||||
|
<eld:element tag="JFrame" objectClass="javax.swing.JFrame">
|
||||||
|
<eld:elementParent tag="root" uri="http://test.x4o.org/xml/ns/test-root"/>
|
||||||
|
</eld:element>
|
||||||
|
<eld:element tag="JFrameContentPane" elementClass="org.x4o.xml.test.element.ContentPaneElement"/>
|
||||||
|
<eld:element tag="JLabel" objectClass="javax.swing.JLabel"/>
|
||||||
|
<eld:element tag="JPanel" objectClass="javax.swing.JPanel"/>
|
||||||
|
<eld:element tag="JTextField" objectClass="javax.swing.JTextField"/>
|
||||||
|
<eld:element tag="JTextArea" objectClass="javax.swing.JTextArea"/>
|
||||||
|
<eld:element tag="JScrollPane" objectClass="javax.swing.JScrollPane"/>
|
||||||
|
|
||||||
|
</eld:namespace>
|
||||||
|
</root:module>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<modules version="1.0"
|
||||||
|
xmlns="http://language.x4o.org/xml/ns/modules"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://language.x4o.org/xml/ns/modules http://language.x4o.org/xml/ns/modules-1.0.xsd"
|
||||||
|
>
|
||||||
|
<language version="1.0">
|
||||||
|
<eld-resource>defd-lang.eld</eld-resource>
|
||||||
|
</language>
|
||||||
|
</modules>
|
|
@ -30,4 +30,5 @@
|
||||||
>
|
>
|
||||||
<driver language="test" className="org.x4o.xml.test.TestDriver"/>
|
<driver language="test" className="org.x4o.xml.test.TestDriver"/>
|
||||||
<driver language="swixml" className="org.x4o.xml.test.swixml.SwiXmlDriver"/>
|
<driver language="swixml" className="org.x4o.xml.test.swixml.SwiXmlDriver"/>
|
||||||
|
<defaultDriver language="junit-defp"/>
|
||||||
</drivers>
|
</drivers>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.x4o.xml.lang.X4OLanguageModuleLoaderException;
|
import org.x4o.xml.lang.X4OLanguageModuleLoaderException;
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElement;
|
import org.x4o.xml.element.AbstractElement;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
|
@ -22,10 +22,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The X4O XML Meta Language Loader.
|
* The X4O XML Meta Language.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta;
|
package org.x4o.xml.lang.meta;
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004-2012, Willem Cazander
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares a property of a java bean.
|
|
||||||
* The property should be Comparable.
|
|
||||||
*
|
|
||||||
* @author Willem Cazander
|
|
||||||
* @version 1.0 Jan 11, 2006
|
|
||||||
*/
|
|
||||||
public class BeanPropertyComparator<T> implements Comparator<T> {
|
|
||||||
|
|
||||||
/** The propery of the bean to compare. */
|
|
||||||
private String property = null;
|
|
||||||
/** The logger to log to. */
|
|
||||||
private Logger logger = null;
|
|
||||||
/** The ascending */
|
|
||||||
private boolean ascending = true;
|
|
||||||
|
|
||||||
private DefaultElementObjectPropertyValue helper = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The constructor inits the logger.
|
|
||||||
*/
|
|
||||||
public BeanPropertyComparator() {
|
|
||||||
logger = Logger.getLogger(BeanPropertyComparator.class.getName());
|
|
||||||
helper = new DefaultElementObjectPropertyValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an BeanPropertyComparator with an property
|
|
||||||
* @param property The property to compare to.
|
|
||||||
*/
|
|
||||||
public BeanPropertyComparator(String property) {
|
|
||||||
this();
|
|
||||||
setProperty(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an BeanPropertyComparator with an property
|
|
||||||
* @param property
|
|
||||||
*/
|
|
||||||
public BeanPropertyComparator(String property,boolean ascending) {
|
|
||||||
this();
|
|
||||||
setProperty(property);
|
|
||||||
setAscending(ascending);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares 2 objects by there Comparable property.
|
|
||||||
*
|
|
||||||
* @param o1 Object 1
|
|
||||||
* @param o2 Object 2
|
|
||||||
* @return the differce between the objects.
|
|
||||||
*/
|
|
||||||
public int compare(Object o1,Object o2) throws ClassCastException {
|
|
||||||
|
|
||||||
Comparable<Object> c1 = getComparableProperty(o1);
|
|
||||||
Comparable<Object> c2 = getComparableProperty(o2);
|
|
||||||
|
|
||||||
if(c1==null && c2==null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(c1==null) {
|
|
||||||
if(ascending) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(c2==null) {
|
|
||||||
if(ascending) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ascending) {
|
|
||||||
return c1.compareTo(c2);
|
|
||||||
} else {
|
|
||||||
return c2.compareTo(c1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Comparable property of the object.
|
|
||||||
* @param object The object to get the property field of.
|
|
||||||
* @return Returns the Comparable casted object of the property field of the object.
|
|
||||||
* @throws ClassCastException
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private Comparable<Object> getComparableProperty(Object object) throws ClassCastException {
|
|
||||||
|
|
||||||
if(property==null) {
|
|
||||||
throw new IllegalStateException("property is not set.");
|
|
||||||
}
|
|
||||||
Object result = null;
|
|
||||||
try {
|
|
||||||
result = helper.getProperty(object,property);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Comparable<Object> c = (Comparable<Object>)result;
|
|
||||||
return c;
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
logger.log(Level.WARNING,"property:"+property+" is not Comparable",e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the property.
|
|
||||||
*/
|
|
||||||
public String getProperty() {
|
|
||||||
return property;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param property The property to set.
|
|
||||||
*/
|
|
||||||
public void setProperty(String property) {
|
|
||||||
if(property==null) {
|
|
||||||
throw new NullPointerException("property may not be null");
|
|
||||||
}
|
|
||||||
this.property = property;
|
|
||||||
logger.finest("property="+property);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the ascending.
|
|
||||||
*/
|
|
||||||
public boolean isAscending() {
|
|
||||||
return ascending;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ascending The ascending to set.
|
|
||||||
*/
|
|
||||||
public void setAscending(boolean ascending) {
|
|
||||||
this.ascending = ascending;
|
|
||||||
logger.finest("ascending="+ascending);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004-2012, Willem Cazander
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The X4O XML Meta Language Classes.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @since 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.x4o.xml.meta.lang;
|
|
|
@ -34,7 +34,7 @@
|
||||||
>
|
>
|
||||||
<eld:description>The x4o meta language lets you do special xml tricks.</eld:description>
|
<eld:description>The x4o meta language lets you do special xml tricks.</eld:description>
|
||||||
|
|
||||||
<eld:attributeHandler id="global-el-id" attributeName="el.id" bean.class="org.x4o.xml.meta.lang.ELIDAttributeHandler">
|
<eld:attributeHandler id="global-el-id" attributeName="el.id" bean.class="org.x4o.xml.lang.meta.ELIDAttributeHandler">
|
||||||
<eld:description>Lets you bind object into the expression language context.</eld:description>
|
<eld:description>Lets you bind object into the expression language context.</eld:description>
|
||||||
</eld:attributeHandler>
|
</eld:attributeHandler>
|
||||||
<eld:namespace
|
<eld:namespace
|
||||||
|
@ -54,20 +54,20 @@
|
||||||
</eld:description>
|
</eld:description>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
<eld:element tag="elReference" elementClass="org.x4o.xml.meta.lang.ELReferenceElement">
|
<eld:element tag="elReference" elementClass="org.x4o.xml.lang.meta.ELReferenceElement">
|
||||||
<eld:description>
|
<eld:description>
|
||||||
Used to get a reference of an Object into the Element tree.
|
Used to get a reference of an Object into the Element tree.
|
||||||
Mostly used in combination with the el.id tag.
|
Mostly used in combination with the el.id tag.
|
||||||
</eld:description>
|
</eld:description>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
<eld:element tag="parentObject" elementClass="org.x4o.xml.meta.lang.ParentObjectElement">
|
<eld:element tag="parentObject" elementClass="org.x4o.xml.lang.meta.ParentObjectElement">
|
||||||
<eld:description>
|
<eld:description>
|
||||||
Hack in ElementTree, fills this Element with the ElementObject of his parent Element.
|
Hack in ElementTree, fills this Element with the ElementObject of his parent Element.
|
||||||
</eld:description>
|
</eld:description>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
<eld:element tag="property" elementClass="org.x4o.xml.meta.lang.PropertyElement">
|
<eld:element tag="property" elementClass="org.x4o.xml.lang.meta.PropertyElement">
|
||||||
<eld:description>
|
<eld:description>
|
||||||
Set an property value on the object of the parent Element.
|
Set an property value on the object of the parent Element.
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
</eld:description>
|
</eld:description>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
<eld:element tag="method" elementClass="org.x4o.xml.meta.lang.MethodElement">
|
<eld:element tag="method" elementClass="org.x4o.xml.lang.meta.MethodElement">
|
||||||
<eld:description>
|
<eld:description>
|
||||||
Executes an Method of an Object.
|
Executes an Method of an Object.
|
||||||
</eld:description>
|
</eld:description>
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta.test;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.X4ODriverManager;
|
import org.x4o.xml.X4ODriverManager;
|
||||||
import org.x4o.xml.io.X4OReaderContext;
|
import org.x4o.xml.io.X4OReaderContext;
|
||||||
import org.x4o.xml.io.X4OWriterContext;
|
import org.x4o.xml.io.X4OWriterContext;
|
||||||
|
|
||||||
public class MTestDriver extends X4ODriver {
|
public class MTestDriver extends X4ODriver<Object> {
|
||||||
|
|
||||||
public static final String LANGUAGE_NAME = "mtest";
|
public static final String LANGUAGE_NAME = "mtest";
|
||||||
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import org.x4o.xml.element.DefaultElement;
|
||||||
|
import org.x4o.xml.element.Element;
|
||||||
|
import org.x4o.xml.io.X4OReaderContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the parent object meta element.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 15, 2012
|
||||||
|
*/
|
||||||
|
public class ParentObjectTest extends TestCase {
|
||||||
|
|
||||||
|
public void testParentElement() throws Exception {
|
||||||
|
X4OLanguageContext context = null;
|
||||||
|
MTestDriver driver = new MTestDriver();
|
||||||
|
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||||
|
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||||
|
try {
|
||||||
|
context = reader.readResourceContext("junit/test-meta-parent-element.xml");
|
||||||
|
assertEquals(1,context.getRootElement().getChilderen().size());
|
||||||
|
Element childElement = context.getRootElement().getChilderen().get(0);
|
||||||
|
JLabel test = (JLabel)childElement.getElementObject();
|
||||||
|
assertEquals("parentTest",test.getText());
|
||||||
|
} finally {
|
||||||
|
reader.releaseContext(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParentObjectElement() throws Exception {
|
||||||
|
DefaultElement ep = new DefaultElement();
|
||||||
|
ParentObjectElement e = new ParentObjectElement();
|
||||||
|
Object o;
|
||||||
|
|
||||||
|
// test non parent
|
||||||
|
o = e.getElementObject();
|
||||||
|
assertNull(o);
|
||||||
|
e.setElementObject("test");
|
||||||
|
o = e.getElementObject();
|
||||||
|
assertNull(o);
|
||||||
|
|
||||||
|
// test parent
|
||||||
|
e.setParent(ep);
|
||||||
|
o = e.getElementObject();
|
||||||
|
assertNull(o);
|
||||||
|
e.setElementObject("test");
|
||||||
|
o = e.getElementObject();
|
||||||
|
assertEquals("test",o);
|
||||||
|
o = ep.getElementObject();
|
||||||
|
assertEquals("test",o);
|
||||||
|
assertEquals(e.getElementObject(),ep.getElementObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,14 +21,13 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.x4o.xml.meta;
|
package org.x4o.xml.lang.meta;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.x4o.xml.io.X4OReaderContext;
|
import org.x4o.xml.io.X4OReaderContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
import org.x4o.xml.meta.test.MTestDriver;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ public class ReferenceStoreTest extends TestCase {
|
||||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||||
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||||
try {
|
try {
|
||||||
context = reader.readResourceContext("tests/meta-generic.xml");
|
context = reader.readResourceContext("junit/test-meta-generic.xml");
|
||||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||||
} finally {
|
} finally {
|
||||||
reader.releaseContext(context);
|
reader.releaseContext(context);
|
||||||
|
@ -59,7 +58,7 @@ public class ReferenceStoreTest extends TestCase {
|
||||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||||
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||||
try {
|
try {
|
||||||
context = reader.readResourceContext("tests/reference/store-ref.xml");
|
context = reader.readResourceContext("junit/test-meta-reference.xml");
|
||||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||||
} finally {
|
} finally {
|
||||||
reader.releaseContext(context);
|
reader.releaseContext(context);
|
||||||
|
@ -72,7 +71,7 @@ public class ReferenceStoreTest extends TestCase {
|
||||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||||
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
|
||||||
try {
|
try {
|
||||||
context = reader.readResourceContext("tests/reference/store-ref.xml");
|
context = reader.readResourceContext("junit/test-meta-reference.xml");
|
||||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
||||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
|
@ -30,6 +30,6 @@
|
||||||
>
|
>
|
||||||
<language version="1.0">
|
<language version="1.0">
|
||||||
<eld-resource>mtest-lang.eld</eld-resource>
|
<eld-resource>mtest-lang.eld</eld-resource>
|
||||||
<sibling-loader>org.x4o.xml.meta.MetaLanguageSiblingLoader</sibling-loader>
|
<sibling-loader>org.x4o.xml.lang.meta.MetaLanguageSiblingLoader</sibling-loader>
|
||||||
</language>
|
</language>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (c) 2004-2012, Willem Cazander
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<tree:root
|
||||||
|
xmlns:tree="http://mtest.x4o.org/xml/ns/mtest-root"
|
||||||
|
xmlns:mt="http://mtest.x4o.org/xml/ns/mtest-lang"
|
||||||
|
xmlns:x4o="http://meta.x4o.org/xml/ns/meta-lang"
|
||||||
|
>
|
||||||
|
<mt:JLabel>
|
||||||
|
<x4o:parentObject>
|
||||||
|
<x4o:property name="text" value="parentTest"/>
|
||||||
|
</x4o:parentObject>
|
||||||
|
</mt:JLabel>
|
||||||
|
</tree:root>
|
Loading…
Reference in a new issue