X4O Formatted x4o driver tests cases
This commit is contained in:
parent
bd4a04a813
commit
ed096a1427
74 changed files with 1640 additions and 1453 deletions
|
|
@ -38,28 +38,28 @@ import org.x4o.xml.lang.X4OLanguageSessionLocal;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class X4ODriverManagerTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultLanguageVersionSelect() throws Exception {
|
||||
String version = X4ODriverManager.getDefaultLanguageVersion(new String[]{"1.0","2.0","3.0"});
|
||||
String version = X4ODriverManager.getDefaultLanguageVersion(new String[] { "1.0", "2.0", "3.0" });
|
||||
Assertions.assertNotNull(version);
|
||||
Assertions.assertEquals("3.0",version);
|
||||
Assertions.assertEquals("3.0", version);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultLanguageVersionEmpty() throws Exception {
|
||||
String version = X4ODriverManager.getDefaultLanguageVersion(new String[]{});
|
||||
String version = X4ODriverManager.getDefaultLanguageVersion(new String[] {});
|
||||
Assertions.assertNotNull(version);
|
||||
Assertions.assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION,version);
|
||||
Assertions.assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION, version);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultLanguageVersionNull() throws Exception {
|
||||
String version = X4ODriverManager.getDefaultLanguageVersion(null);
|
||||
Assertions.assertNotNull(version);
|
||||
Assertions.assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION,version);
|
||||
Assertions.assertEquals(X4ODriver.DEFAULT_LANGUAGE_VERSION, version);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguageNull() throws Exception {
|
||||
String language = null;
|
||||
|
|
@ -73,7 +73,7 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("language"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguageEmpty() throws Exception {
|
||||
String language = "";
|
||||
|
|
@ -87,7 +87,7 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(IllegalArgumentException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("language"), "Error message string is missing language");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguageVersionNonExcisting() throws Exception {
|
||||
String languageTest = "test";
|
||||
|
|
@ -101,26 +101,23 @@ public class X4ODriverManagerTest {
|
|||
e = catchE;
|
||||
}
|
||||
Assertions.assertNotNull(e);
|
||||
/* TODO
|
||||
assertNotNull(e);
|
||||
assertNotNull(e.getCause());
|
||||
assertNotNull(e.getCause().getCause());
|
||||
assertEquals(X4OPhaseException.class, e.getCause().getClass());
|
||||
assertEquals(X4OLanguageLoaderException.class, e.getCause().getCause().getClass());
|
||||
assertTrue("Error message string is missing language",e.getMessage().contains("language"));
|
||||
assertTrue("Error message string is missing test",e.getMessage().contains("test"));
|
||||
assertTrue("Error message string is missing modules",e.getMessage().contains("modules"));
|
||||
assertTrue("Error message string is missing 2.0",e.getMessage().contains("2.0"));
|
||||
*/
|
||||
/*
|
||||
* TODO assertNotNull(e); assertNotNull(e.getCause()); assertNotNull(e.getCause().getCause()); assertEquals(X4OPhaseException.class,
|
||||
* e.getCause().getClass()); assertEquals(X4OLanguageLoaderException.class, e.getCause().getCause().getClass());
|
||||
* assertTrue("Error message string is missing language",e.getMessage().contains("language"));
|
||||
* assertTrue("Error message string is missing test",e.getMessage().contains("test"));
|
||||
* assertTrue("Error message string is missing modules",e.getMessage().contains("modules"));
|
||||
* assertTrue("Error message string is missing 2.0",e.getMessage().contains("2.0"));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguageCount() throws Exception {
|
||||
List<String> languages = X4ODriverManager.getX4OLanguages();
|
||||
Assertions.assertNotNull(languages);
|
||||
Assertions.assertFalse(languages.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguageNames() throws Exception {
|
||||
List<String> languages = X4ODriverManager.getX4OLanguages();
|
||||
|
|
@ -129,17 +126,17 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertTrue(languages.contains("eld"), "eld language is missing");
|
||||
Assertions.assertTrue(languages.contains("test"), "test language is missing");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLanguagesLoopSpeed() throws Exception {
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i=0;i<100;i++) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
testLanguageCount();
|
||||
}
|
||||
long loopTime = System.currentTimeMillis() - startTime;
|
||||
Assertions.assertEquals(true, loopTime<500, "Language list loop is slow;"+loopTime);
|
||||
Assertions.assertEquals(true, loopTime < 500, "Language list loop is slow;" + loopTime);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRegisterDriverNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -152,15 +149,22 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRegisterDriverNameNull() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return null; }
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
|
|
@ -169,15 +173,22 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRegisterDriverNameEmpty() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return ""; }
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
|
|
@ -186,15 +197,22 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(IllegalArgumentException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("empty"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRegisterDriverVersionNull() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return null; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
|
|
@ -203,15 +221,22 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRegisterDriverVersionEmpty() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.registerX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{}; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
|
|
@ -220,7 +245,7 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(IllegalArgumentException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("empty"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeregisterDriverNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -233,15 +258,22 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeregisterDriverNameNull() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriverManager.deregisterX4ODriver(new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return null; }
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
|
|
@ -250,14 +282,21 @@ public class X4ODriverManagerTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass(), "Wrong exception class");
|
||||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeregisterDriverInstance() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
X4ODriver<?> driver = new X4ODriver<Object>() {
|
||||
@Override public String[] getLanguageVersions() { return new String[]{"1.0"}; }
|
||||
@Override public String getLanguageName() { return "junit-driver-test"; }
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return new String[] { "1.0" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return "junit-driver-test";
|
||||
}
|
||||
};
|
||||
X4ODriverManager.registerX4ODriver(driver);
|
||||
Assertions.assertEquals(driver.hashCode(), X4ODriverManager.getX4ODriver("junit-driver-test").hashCode());
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ import org.x4o.xml.lang.phase.X4OPhaseType;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class DefaultObjectConverterProviderTest {
|
||||
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterClone() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
for (ObjectConverter conv:p.getObjectConverters()) {
|
||||
for (ObjectConverter conv : p.getObjectConverters()) {
|
||||
Assertions.assertNotNull(conv);
|
||||
ObjectConverter clone = conv.clone();
|
||||
Assertions.assertNotNull(clone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterBoolean() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -60,14 +60,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("true", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(Boolean.class,result.getClass(), "Result is not Boolean.class");
|
||||
Assertions.assertEquals(true,result, "Result is not true");
|
||||
Assertions.assertEquals(Boolean.class, result.getClass(), "Result is not Boolean.class");
|
||||
Assertions.assertEquals(true, result, "Result is not true");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("true",resultBack, "resultBack is not true");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("true", resultBack, "resultBack is not true");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterInteger() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -75,14 +75,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("123", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(Integer.class,result.getClass(), "Result is not Integer.class");
|
||||
Assertions.assertEquals(123,result, "Result is not 123");
|
||||
Assertions.assertEquals(Integer.class, result.getClass(), "Result is not Integer.class");
|
||||
Assertions.assertEquals(123, result, "Result is not 123");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("123",resultBack, "resultBack is not 123");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("123", resultBack, "resultBack is not 123");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterFloat() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -90,14 +90,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("123.23", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(Float.class,result.getClass(), "Result is not Float.class");
|
||||
Assertions.assertEquals(123.23F,result, "Result is not 123.23");
|
||||
Assertions.assertEquals(Float.class, result.getClass(), "Result is not Float.class");
|
||||
Assertions.assertEquals(123.23F, result, "Result is not 123.23");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("123.23",resultBack, "resultBack is not 123.23");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("123.23", resultBack, "resultBack is not 123.23");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterLong() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -105,14 +105,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("12323", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(Long.class,result.getClass(), "Result is not Long.class");
|
||||
Assertions.assertEquals(12323L,result, "Result is not 12323");
|
||||
Assertions.assertEquals(Long.class, result.getClass(), "Result is not Long.class");
|
||||
Assertions.assertEquals(12323L, result, "Result is not 12323");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("12323",resultBack, "resultBack is not 12323");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("12323", resultBack, "resultBack is not 12323");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterDouble() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -120,14 +120,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("1232.3", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(Double.class,result.getClass(), "Result is not Double.class");
|
||||
Assertions.assertEquals(1232.3D,result, "Result is not 1232.3");
|
||||
Assertions.assertEquals(Double.class, result.getClass(), "Result is not Double.class");
|
||||
Assertions.assertEquals(1232.3D, result, "Result is not 1232.3");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("1232.3",resultBack, "resultBack is not 1232.3");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("1232.3", resultBack, "resultBack is not 1232.3");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterUrl() throws Exception {
|
||||
DefaultObjectConverterProvider p = new DefaultObjectConverterProvider(true);
|
||||
|
|
@ -135,14 +135,14 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertNotNull(conv);
|
||||
Object result = conv.convertTo("http://www.x4o.org", locale);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(URL.class,result.getClass(), "Result is not Url.class");
|
||||
Assertions.assertEquals(new URL("http://www.x4o.org"),result, "Result is not http://www.x4o.org");
|
||||
Assertions.assertEquals(URL.class, result.getClass(), "Result is not Url.class");
|
||||
Assertions.assertEquals(new URL("http://www.x4o.org"), result, "Result is not http://www.x4o.org");
|
||||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertNotNull(resultBack);
|
||||
Assertions.assertEquals(String.class,resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("http://www.x4o.org",resultBack, "resultBack is not http://www.x4o.org");
|
||||
Assertions.assertEquals(String.class, resultBack.getClass(), "resultBack is not String.class");
|
||||
Assertions.assertEquals("http://www.x4o.org", resultBack, "resultBack is not http://www.x4o.org");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterUrlException() throws Exception {
|
||||
URLConverter conv = new URLConverter();
|
||||
|
|
@ -158,7 +158,7 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertEquals(MalformedURLException.class, e.getCause().getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("error"), "Error message string is missing error");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterEnum() throws Exception {
|
||||
EnumConverter convOrg = new EnumConverter();
|
||||
|
|
@ -170,16 +170,16 @@ public class DefaultObjectConverterProviderTest {
|
|||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertEquals("XML_READ", resultBack.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterEnumError() throws Exception {
|
||||
EnumConverter convOrg = new EnumConverter();
|
||||
convOrg.setEnumClass(X4OPhaseType.class.getName());
|
||||
ObjectConverter conv = convOrg.clone();
|
||||
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
conv.convertTo("nonEnumError", locale);
|
||||
conv.convertTo("nonEnumError", locale);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
|
@ -187,13 +187,13 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertEquals(ObjectConverterException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("EnumError"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterEnumNullError() throws Exception {
|
||||
EnumConverter conv = new EnumConverter();
|
||||
Exception e = null;
|
||||
try {
|
||||
conv.convertTo("nonEnumError", locale);
|
||||
conv.convertTo("nonEnumError", locale);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ public class DefaultObjectConverterProviderTest {
|
|||
Assertions.assertEquals(ObjectConverterException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("enumClass"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterClass() throws Exception {
|
||||
ClassConverter classOrg = new ClassConverter();
|
||||
|
|
@ -212,12 +212,12 @@ public class DefaultObjectConverterProviderTest {
|
|||
Object resultBack = conv.convertBack(result, locale);
|
||||
Assertions.assertEquals("java.lang.Object", resultBack.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConverterClassError() throws Exception {
|
||||
ClassConverter classOrg = new ClassConverter();
|
||||
ObjectConverter conv = classOrg.clone();
|
||||
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
conv.convertTo("java.lang.ObjectError", locale);
|
||||
|
|
|
|||
|
|
@ -40,63 +40,63 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class AttributeBeanTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeanBody() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/attributes/test-body.xml");
|
||||
Assertions.assertNotNull(root);
|
||||
List<TestObjectChild> childs = root.getTestObjectChilds();
|
||||
Assertions.assertEquals(2,childs.size());
|
||||
Assertions.assertEquals(2, childs.size());
|
||||
TestObjectChild child0 = childs.get(0);
|
||||
TestObjectChild child1 = childs.get(1);
|
||||
Assertions.assertEquals("attr-name-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕",child0.getName());
|
||||
Assertions.assertEquals("body-name-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕",child1.getName());
|
||||
Assertions.assertEquals("attr-name-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", child0.getName());
|
||||
Assertions.assertEquals("body-name-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", child1.getName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeanProperties() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertNotNull(root.getTestBeans());
|
||||
Assertions.assertEquals(2, root.getTestBeans().size());
|
||||
TestBean b = root.getTestBeans().get(0);
|
||||
TestBean beanPublic = root.getTestBeans().get(1);
|
||||
|
||||
Assertions.assertEquals(123 ,0+ b.getPrivateIntegerTypeField());
|
||||
Assertions.assertEquals(123 ,0+ b.getPrivateIntegerObjectField());
|
||||
|
||||
Assertions.assertEquals(123l ,0+ b.getPrivateLongTypeField());
|
||||
Assertions.assertEquals(123l ,0+ b.getPrivateLongObjectField());
|
||||
|
||||
Assertions.assertEquals(123.45d ,0+ b.getPrivateDoubleTypeField());
|
||||
Assertions.assertEquals(123.45d ,0+ b.getPrivateDoubleObjectField());
|
||||
|
||||
Assertions.assertEquals(123.45f ,0+ b.getPrivateFloatTypeField());
|
||||
Assertions.assertEquals(123.45f ,0+ b.getPrivateFloatObjectField());
|
||||
|
||||
Assertions.assertEquals(67 ,0+ b.getPrivateByteTypeField());
|
||||
Assertions.assertEquals(67 ,0+ b.getPrivateByteObjectField());
|
||||
|
||||
Assertions.assertEquals(true, b.isPrivateBooleanTypeField());
|
||||
Assertions.assertEquals(new Boolean(true), b.getPrivateBooleanObjectField());
|
||||
|
||||
Assertions.assertEquals('W' ,0+ b.getPrivateCharTypeField());
|
||||
Assertions.assertEquals('C' ,0+ b.getPrivateCharObjectField());
|
||||
|
||||
Assertions.assertEquals("x4o-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕" ,b.getPrivateStringObjectField());
|
||||
//Assertions.assertEquals("x4o-ᒡᒢᑊᒻᒻᓫᔿ" ,b.getPrivateStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ()); // SAX fails
|
||||
Assertions.assertEquals("x4o-仙上主天" ,b.getPrivateStringObjectFieldUnicode仙上主天());
|
||||
|
||||
//TODO: add again: assertEquals(true ,null!=b.getPrivateDateObjectField());
|
||||
|
||||
Assertions.assertEquals("x4o-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕" ,beanPublic.publicStringObjectField);
|
||||
//Assertions.assertEquals("x4o-ᒡᒢᑊᒻᒻᓫᔿ" ,beanPublic.publicStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ); // SAX fails
|
||||
Assertions.assertEquals("x4o-仙上主天" ,beanPublic.publicStringObjectFieldUnicode仙上主天);
|
||||
|
||||
Assertions.assertEquals(123, 0 + b.getPrivateIntegerTypeField());
|
||||
Assertions.assertEquals(123, 0 + b.getPrivateIntegerObjectField());
|
||||
|
||||
Assertions.assertEquals(123l, 0 + b.getPrivateLongTypeField());
|
||||
Assertions.assertEquals(123l, 0 + b.getPrivateLongObjectField());
|
||||
|
||||
Assertions.assertEquals(123.45d, 0 + b.getPrivateDoubleTypeField());
|
||||
Assertions.assertEquals(123.45d, 0 + b.getPrivateDoubleObjectField());
|
||||
|
||||
Assertions.assertEquals(123.45f, 0 + b.getPrivateFloatTypeField());
|
||||
Assertions.assertEquals(123.45f, 0 + b.getPrivateFloatObjectField());
|
||||
|
||||
Assertions.assertEquals(67, 0 + b.getPrivateByteTypeField());
|
||||
Assertions.assertEquals(67, 0 + b.getPrivateByteObjectField());
|
||||
|
||||
Assertions.assertEquals(true, b.isPrivateBooleanTypeField());
|
||||
Assertions.assertEquals(new Boolean(true), b.getPrivateBooleanObjectField());
|
||||
|
||||
Assertions.assertEquals('W', 0 + b.getPrivateCharTypeField());
|
||||
Assertions.assertEquals('C', 0 + b.getPrivateCharObjectField());
|
||||
|
||||
Assertions.assertEquals("x4o-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", b.getPrivateStringObjectField());
|
||||
// Assertions.assertEquals("x4o-ᒡᒢᑊᒻᒻᓫᔿ" ,b.getPrivateStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ()); // SAX fails
|
||||
Assertions.assertEquals("x4o-仙上主天", b.getPrivateStringObjectFieldUnicode仙上主天());
|
||||
|
||||
// TODO: add again: assertEquals(true ,null!=b.getPrivateDateObjectField());
|
||||
|
||||
Assertions.assertEquals("x4o-𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", beanPublic.publicStringObjectField);
|
||||
// Assertions.assertEquals("x4o-ᒡᒢᑊᒻᒻᓫᔿ" ,beanPublic.publicStringObjectFieldUnicodeᒡᒢᑊᒻᒻᓫᔿ); // SAX fails
|
||||
Assertions.assertEquals("x4o-仙上主天", beanPublic.publicStringObjectFieldUnicode仙上主天);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class EmptyXmlTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testFileNotFound() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -50,9 +50,9 @@ public class EmptyXmlTest {
|
|||
Assertions.assertEquals(true, e.getMessage().contains("non-excisting-file.xml"));
|
||||
return;
|
||||
}
|
||||
Assertions.assertEquals(true,false);
|
||||
Assertions.assertEquals(true, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResourceNotFound() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -60,25 +60,25 @@ public class EmptyXmlTest {
|
|||
try {
|
||||
reader.readResource("tests/empty-xml/non-excisting-resource.xml");
|
||||
} catch (NullPointerException e) {
|
||||
Assertions.assertEquals(true,e.getMessage().contains("Could not find resource"));
|
||||
Assertions.assertEquals(true, e.getMessage().contains("Could not find resource"));
|
||||
return;
|
||||
}
|
||||
Assertions.assertEquals(true,false);
|
||||
Assertions.assertEquals(true, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResourceParsing() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
try {
|
||||
reader.readResource("tests/empty-xml/empty-test.xml");
|
||||
reader.readResource("tests/empty-xml/empty-test.xml");
|
||||
} catch (SAXException e) {
|
||||
// Assertions.assertEquals("No ElementNamespace found for empty namespace.", e.getMessage());
|
||||
return;
|
||||
}
|
||||
Assertions.assertEquals(true,false);
|
||||
Assertions.assertEquals(true, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResourceEmptyReal() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -86,12 +86,12 @@ public class EmptyXmlTest {
|
|||
try {
|
||||
reader.readResource("tests/empty-xml/empty-real.xml");
|
||||
} catch (SAXException e) {
|
||||
Assertions.assertEquals(true,e.getMessage().contains("Premature end of file."));
|
||||
Assertions.assertEquals(true, e.getMessage().contains("Premature end of file."));
|
||||
return;
|
||||
}
|
||||
Assertions.assertEquals(true,false);
|
||||
Assertions.assertEquals(true, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResourceEmptyXml() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -100,29 +100,29 @@ public class EmptyXmlTest {
|
|||
reader.readResource("tests/empty-xml/empty-xml.xml");
|
||||
} catch (SAXException e) {
|
||||
boolean hasError = e.getMessage().contains("Premature end of file."); // java6+ sax message
|
||||
if (hasError==false) {
|
||||
if (hasError == false) {
|
||||
hasError = e.getMessage().contains("A well-formed document requires a root element."); // xercesImpl sax message
|
||||
}
|
||||
Assertions.assertEquals(true,hasError);
|
||||
Assertions.assertEquals(true, hasError);
|
||||
return;
|
||||
}
|
||||
Assertions.assertEquals(true,false);
|
||||
Assertions.assertEquals(true, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEmptyX40() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
Assertions.assertNotNull(driver);
|
||||
|
||||
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
Assertions.assertNotNull(reader);
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/empty-xml/empty-x4o.xml");
|
||||
Assertions.assertNotNull(root);
|
||||
|
||||
Assertions.assertEquals(true,root.getTestBeans().isEmpty());
|
||||
Assertions.assertEquals(true,root.getTestObjectChilds().isEmpty());
|
||||
Assertions.assertEquals(true,root.getTestObjectParents().isEmpty());
|
||||
Assertions.assertEquals(true,root.getTestObjects().isEmpty());
|
||||
|
||||
Assertions.assertEquals(true, root.getTestBeans().isEmpty());
|
||||
Assertions.assertEquals(true, root.getTestObjectChilds().isEmpty());
|
||||
Assertions.assertEquals(true, root.getTestObjectParents().isEmpty());
|
||||
Assertions.assertEquals(true, root.getTestObjects().isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 May 1, 2011
|
||||
*/
|
||||
public class NamespaceUriTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleUri() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -46,10 +46,10 @@ public class NamespaceUriTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "tests/namespace/uri-simple.xml");
|
||||
Assertions.assertEquals(true,session.getRootElement().getChilderen().size()==1);
|
||||
Assertions.assertEquals(true, session.getRootElement().getChilderen().size() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEmptyUri() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -58,10 +58,10 @@ public class NamespaceUriTest {
|
|||
reader.setProperty(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI, "http://test.junit.x4o.org/xml/ns/junit-test-lang");
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "tests/namespace/uri-empty.xml");
|
||||
Assertions.assertEquals(true,session.getRootElement().getChilderen().size()==1);
|
||||
Assertions.assertEquals(true, session.getRootElement().getChilderen().size() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSchemaUri() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -69,7 +69,7 @@ public class NamespaceUriTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "tests/namespace/uri-schema.xml");
|
||||
Assertions.assertEquals(true,session.getRootElement().getChilderen().size()==1);
|
||||
Assertions.assertEquals(true, session.getRootElement().getChilderen().size() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Aug 26, 2012
|
||||
*/
|
||||
public class X4ODebugWriterTest {
|
||||
|
||||
|
||||
private File createDebugFile() throws IOException {
|
||||
File debugFile = File.createTempFile("test-debug", ".xml");
|
||||
debugFile.deleteOnExit();
|
||||
return debugFile;
|
||||
}
|
||||
|
||||
|
||||
static public String readFile(File file) throws IOException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),Charset.forName("UTF-8")));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = br.readLine();
|
||||
|
|
@ -70,13 +70,13 @@ public class X4ODebugWriterTest {
|
|||
line = br.readLine();
|
||||
}
|
||||
String out = sb.toString();
|
||||
//System.out.println(out);
|
||||
// System.out.println(out);
|
||||
return out;
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDebugOutputReader() throws Exception {
|
||||
File debugFile = createDebugFile();
|
||||
|
|
@ -89,18 +89,18 @@ public class X4ODebugWriterTest {
|
|||
reader.readResource("tests/attributes/test-bean.xml");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Assertions.assertTrue(debugFile.exists(), "Debug file does not exists.");
|
||||
String debug = readFile(debugFile);
|
||||
Assertions.assertNotNull(debug);
|
||||
Assertions.assertFalse(debug.length()==0, "no debug content");
|
||||
Assertions.assertTrue(debug.length()>20, "debug content to small");
|
||||
|
||||
//System.out.println("=================== Reader Output ======================");
|
||||
//System.out.println(debug);
|
||||
Assertions.assertFalse(debug.length() == 0, "no debug content");
|
||||
Assertions.assertTrue(debug.length() > 20, "debug content to small");
|
||||
|
||||
// System.out.println("=================== Reader Output ======================");
|
||||
// System.out.println(debug);
|
||||
debugFile.delete();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDebugOutputWriter() throws Exception {
|
||||
File debugFile = createDebugFile();
|
||||
|
|
@ -109,20 +109,20 @@ public class X4ODebugWriterTest {
|
|||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||
TestObjectRoot object = reader.readResource("tests/attributes/test-bean.xml");
|
||||
|
||||
|
||||
try (OutputStream out = new FileOutputStream(debugFile)) {
|
||||
writer.setProperty(DefaultX4OWriter.DEBUG_OUTPUT_STREAM, out);
|
||||
writer.writeFile(object, writeFile);
|
||||
}
|
||||
|
||||
|
||||
Assertions.assertTrue(debugFile.exists(), "Debug file does not exists.");
|
||||
String debug = readFile(debugFile);
|
||||
Assertions.assertNotNull(debug);
|
||||
Assertions.assertFalse(debug.length()==0, "no debug content");
|
||||
Assertions.assertTrue(debug.length()>20, "debug content to small");
|
||||
|
||||
//System.out.println("=================== Writer Output ======================");
|
||||
//System.out.println(debug);
|
||||
Assertions.assertFalse(debug.length() == 0, "no debug content");
|
||||
Assertions.assertTrue(debug.length() > 20, "debug content to small");
|
||||
|
||||
// System.out.println("=================== Writer Output ======================");
|
||||
// System.out.println(debug);
|
||||
debugFile.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 27, 2012
|
||||
*/
|
||||
public class X4OEntityResolverTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testElementLangugeNull() throws Exception {
|
||||
Exception e = null;
|
||||
try {
|
||||
new X4OEntityResolver(null,null);
|
||||
new X4OEntityResolver(null, null);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ public class X4OEntityResolverTest {
|
|||
Assertions.assertEquals(NullPointerException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("null"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResolve() throws Exception {
|
||||
X4ODriver<?> driver = new CelDriver();
|
||||
|
|
@ -68,19 +68,19 @@ public class X4OEntityResolverTest {
|
|||
try (X4OLanguageSession session = language.createLanguageSession()) {
|
||||
X4OLanguageLocal.class.cast(language).init(session);
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(session, DefaultX4OReader.DEFAULT_PROPERTY_CONFIG);
|
||||
InputSource input = resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd");
|
||||
InputSource input = resolver.resolveEntity("", "http://cel.x4o.org/xml/ns/cel-root-1.0.xsd");
|
||||
Assertions.assertNotNull(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResolveMissing() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
||||
// NOTE: this session is not inited, see fix code above.
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageSession(),DefaultX4OReader.DEFAULT_PROPERTY_CONFIG);
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageSession(), DefaultX4OReader.DEFAULT_PROPERTY_CONFIG);
|
||||
Exception e = null;
|
||||
try {
|
||||
resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-missing-resource");
|
||||
resolver.resolveEntity("", "http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-missing-resource");
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
|
@ -88,35 +88,35 @@ public class X4OEntityResolverTest {
|
|||
Assertions.assertEquals(SAXException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("missing-resource"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResolveProperty() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
||||
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
||||
SAX3PropertyConfig conf = new SAX3PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/");
|
||||
SAX3PropertyConfig conf = new SAX3PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG, SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "reader/x4o/");
|
||||
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(language, conf);
|
||||
Exception e = null;
|
||||
InputSource input = null;
|
||||
try {
|
||||
input = resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd");
|
||||
input = resolver.resolveEntity("", "http://cel.x4o.org/xml/ns/cel-root-1.0.xsd");
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
Assertions.assertNull(e);
|
||||
Assertions.assertNotNull(input);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testResolvePropertyNull() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
||||
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
||||
SAX3PropertyConfig conf = new SAX3PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/");
|
||||
SAX3PropertyConfig conf = new SAX3PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG, SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "reader/x4o/");
|
||||
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
||||
X4OEntityResolver resolver = new X4OEntityResolver(language, conf);
|
||||
Exception e = null;
|
||||
try {
|
||||
resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-null");
|
||||
resolver.resolveEntity("", "http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-null");
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ public class X4OEntityResolverTest {
|
|||
Assertions.assertEquals(SAXException.class, e.getClass());
|
||||
Assertions.assertTrue(e.getMessage().contains("null"));
|
||||
}
|
||||
|
||||
|
||||
public class TestEntityResolver implements EntityResolver {
|
||||
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
|
||||
|
|
@ -134,6 +134,6 @@ public class X4OEntityResolverTest {
|
|||
return new InputSource();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,31 +38,31 @@ import org.x4o.xml.test.TestDriver;
|
|||
* @version 1.0 Jan 20, 2012
|
||||
*/
|
||||
public class X4OParserConfigurationTest {
|
||||
|
||||
|
||||
static TestDriver driver;
|
||||
static X4OLanguageConfiguration config;
|
||||
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
driver = TestDriver.getInstance();
|
||||
config = driver.createLanguage().getLanguageConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParserConfigurationLanguage() {
|
||||
Assertions.assertEquals("test",driver.getLanguageName());
|
||||
Assertions.assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_MODULES_FILE,config.getLanguageResourceModulesFileName());
|
||||
Assertions.assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_PATH_PREFIX,config.getLanguageResourcePathPrefix());
|
||||
Assertions.assertEquals("test", driver.getLanguageName());
|
||||
Assertions.assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_MODULES_FILE, config.getLanguageResourceModulesFileName());
|
||||
Assertions.assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_PATH_PREFIX, config.getLanguageResourcePathPrefix());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParserConfigurationElement() {
|
||||
Assertions.assertNotNull(config.getDefaultElement());
|
||||
Assertions.assertTrue(Element.class.isAssignableFrom(config.getDefaultElement()), "No Element Interface");
|
||||
|
||||
|
||||
Assertions.assertNotNull(config.getDefaultElementClass());
|
||||
Assertions.assertTrue(ElementClass.class.isAssignableFrom(config.getDefaultElementClass()), "No ElementClass Interface");
|
||||
|
||||
|
||||
Assertions.assertNotNull(config.getDefaultElementClassAttribute());
|
||||
Assertions.assertTrue(ElementClassAttribute.class.isAssignableFrom(config.getDefaultElementClassAttribute()), "No ElementClassAttribute Interface");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,50 +35,41 @@ import org.x4o.xml.lang.phase.X4OPhaseType;
|
|||
import org.x4o.xml.test.TestDriver;
|
||||
|
||||
/**
|
||||
* Tests some code for testing x4o phases.
|
||||
* *
|
||||
* Tests some code for testing x4o phases. *
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 15, 2009
|
||||
*/
|
||||
public class X4OPhaseManagerTest {
|
||||
|
||||
|
||||
static boolean phaseRunned = false;
|
||||
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
phaseRunned = false;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPhases() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OLanguageSession context = driver.createLanguage().createLanguageSession();
|
||||
DefaultX4OPhaseManager manager = (DefaultX4OPhaseManager)context.getLanguage().getPhaseManager();
|
||||
DefaultX4OPhaseManager manager = (DefaultX4OPhaseManager) context.getLanguage().getPhaseManager();
|
||||
Collection<X4OPhase> phasesAll = manager.getAllPhases();
|
||||
List<X4OPhase> phases = manager.getOrderedPhases(X4OPhaseType.XML_READ);
|
||||
Assertions.assertNotNull(phases);
|
||||
Assertions.assertFalse(phases.isEmpty());
|
||||
Assertions.assertNotNull(phasesAll);
|
||||
Assertions.assertFalse(phasesAll.isEmpty());
|
||||
for (X4OPhase phase:phases) {
|
||||
for (X4OPhase phase : phases) {
|
||||
Assertions.assertNotNull(phase);
|
||||
Assertions.assertNotNull(phase.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void testPhaseManager() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
ElementLanguage context = driver.createLanguageSession();
|
||||
X4OPhaseManager manager = context.getLanguage().getPhaseManager();
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
manager.addX4OPhaseHandler(null);
|
||||
} catch (NullPointerException ee) {
|
||||
e = ee;
|
||||
}
|
||||
Assertions.assertEquals(true, e!=null );
|
||||
}
|
||||
*/
|
||||
* public void testPhaseManager() throws Exception { TestDriver driver = TestDriver.getInstance(); ElementLanguage context = driver.createLanguageSession();
|
||||
* X4OPhaseManager manager = context.getLanguage().getPhaseManager();
|
||||
*
|
||||
* Exception e = null; try { manager.addX4OPhaseHandler(null); } catch (NullPointerException ee) { e = ee; } Assertions.assertEquals(true, e!=null ); }
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Aug 22, 2012
|
||||
*/
|
||||
public class EldValidatingTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidation() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
//reader.getContentConfig().setProperty("",true);
|
||||
// reader.getContentConfig().setProperty("",true);
|
||||
reader.setProperty(DefaultX4OReader.VALIDATION_INPUT_DOC, true);
|
||||
//parser.setProperty(DefaultX4OReader.VALIDATION_SCHEMA_PATH, "/tmp");
|
||||
// parser.setProperty(DefaultX4OReader.VALIDATION_SCHEMA_PATH, "/tmp");
|
||||
try {
|
||||
// TODO: reader.readResource("META-INF/eld/eld-lang.eld");
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -36,66 +36,54 @@ import org.x4o.xml.lang.task.run.X4OTaskRunner;
|
|||
import org.x4o.xml.test.TestDriver;
|
||||
|
||||
/**
|
||||
* Test for eld doc generation
|
||||
* Test for eld doc generation
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 26, 2010
|
||||
*/
|
||||
public class X4OWriteLanguageDocExecutorTest {
|
||||
|
||||
|
||||
private File createOutputPath(String dir) throws Exception {
|
||||
File result = new File("target/tests"+File.separator+dir);
|
||||
if (result.exists()==false) {
|
||||
File result = new File("target/tests" + File.separator + dir);
|
||||
if (result.exists() == false) {
|
||||
result.mkdirs();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void testDoc(String language,String outputPostfix) throws Exception {
|
||||
|
||||
public void testDoc(String language, String outputPostfix) throws Exception {
|
||||
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language);
|
||||
X4OLanguageTask task = driver.getLanguageTask(EldDocLanguageTask.TASK_ID);
|
||||
SAX3PropertyConfig config = task.createTaskConfig();
|
||||
File outputPath = createOutputPath(outputPostfix);
|
||||
config.setProperty(EldDocWriter.OUTPUT_PATH,outputPath);
|
||||
config.setProperty(EldDocWriter.OUTPUT_PATH, outputPath);
|
||||
X4OTaskRunner.runTaskLanguage(task, driver.createLanguage(), config);
|
||||
Assertions.assertTrue(outputPath.exists());
|
||||
Assertions.assertTrue(outputPath.list()!=null);
|
||||
Assertions.assertTrue(outputPath.list().length>2);
|
||||
Assertions.assertTrue(outputPath.list() != null);
|
||||
Assertions.assertTrue(outputPath.list().length > 2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCelDoc() throws Exception {
|
||||
testDoc(CelDriver.LANGUAGE_NAME,"junit-doc-cel");
|
||||
testDoc(CelDriver.LANGUAGE_NAME, "junit-doc-cel");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEldDoc() throws Exception {
|
||||
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
|
||||
testDoc(EldDriver.LANGUAGE_NAME, "junit-doc-eld");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnitDoc() throws Exception {
|
||||
testDoc(TestDriver.LANGUAGE_NAME,"junit-doc-test");
|
||||
testDoc(TestDriver.LANGUAGE_NAME, "junit-doc-test");
|
||||
}
|
||||
/*
|
||||
@Test
|
||||
public void testSwiXml2Doc() throws Exception {
|
||||
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
|
||||
EldDocLanguageTask writer = new EldDocLanguageTask();
|
||||
writer.setBasePath(createOutputTargetPath("junit-swixml2"));
|
||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
|
||||
writer.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwiXml3Doc() throws Exception {
|
||||
testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld");
|
||||
EldDocLanguageTask writer = new EldDocLanguageTask();
|
||||
writer.setBasePath(createOutputTargetPath("junit-swixml3"));
|
||||
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
|
||||
writer.execute();
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* @Test public void testSwiXml2Doc() throws Exception { testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld"); EldDocLanguageTask writer = new
|
||||
* EldDocLanguageTask(); writer.setBasePath(createOutputTargetPath("junit-swixml2")); writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
* writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2); writer.execute(); }
|
||||
*
|
||||
* @Test public void testSwiXml3Doc() throws Exception { testDoc(EldDriver.LANGUAGE_NAME,"junit-doc-eld"); EldDocLanguageTask writer = new
|
||||
* EldDocLanguageTask(); writer.setBasePath(createOutputTargetPath("junit-swixml3")); writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
|
||||
* writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3); writer.execute(); }
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,72 +49,72 @@ import org.x4o.xml.test.swixml.SwiXmlDriver;
|
|||
public class EldXsdLanguageTaskTest {
|
||||
|
||||
private File createOutputPath(String dir) throws Exception {
|
||||
File result = new File("target/tests"+File.separator+dir);
|
||||
if (result.exists()==false) {
|
||||
File result = new File("target/tests" + File.separator + dir);
|
||||
if (result.exists() == false) {
|
||||
result.mkdirs();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
private File testSchema(String language,String outputPostfix,Map<String,Object> props) throws Exception {
|
||||
private File testSchema(String language, String outputPostfix, Map<String, Object> props) throws Exception {
|
||||
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language);
|
||||
X4OLanguageTask task = driver.getLanguageTask(EldXsdLanguageTask.TASK_ID);
|
||||
SAX3PropertyConfig config = task.createTaskConfig();
|
||||
File outputPath = createOutputPath(outputPostfix);
|
||||
config.setProperty(EldXsdWriter.OUTPUT_PATH,outputPath);
|
||||
config.setProperty(EldXsdWriter.OUTPUT_DOCUMENTATION,false);
|
||||
config.setProperty(SAX3WriterXml.PROLOG_LICENCE_FILE,new File("../licence.txt"));
|
||||
config.setProperty(SAX3WriterXml.PROLOG_USER_COMMENT,"Generated by junit-test-run in class: "+this.getClass().getSimpleName());
|
||||
if (props!=null) {
|
||||
for (String key:props.keySet()) {
|
||||
File outputPath = createOutputPath(outputPostfix);
|
||||
config.setProperty(EldXsdWriter.OUTPUT_PATH, outputPath);
|
||||
config.setProperty(EldXsdWriter.OUTPUT_DOCUMENTATION, false);
|
||||
config.setProperty(SAX3WriterXml.PROLOG_LICENCE_FILE, new File("../licence.txt"));
|
||||
config.setProperty(SAX3WriterXml.PROLOG_USER_COMMENT, "Generated by junit-test-run in class: " + this.getClass().getSimpleName());
|
||||
if (props != null) {
|
||||
for (String key : props.keySet()) {
|
||||
Object value = props.get(key);
|
||||
config.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
X4OTaskRunner.runTaskLanguage(task, driver.createLanguage(), config);
|
||||
Assertions.assertTrue(outputPath.exists());
|
||||
Assertions.assertTrue(outputPath.list()!=null);
|
||||
Assertions.assertTrue(outputPath.list() != null);
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEldSchema() throws Exception {
|
||||
File outputPath = testSchema(EldDriver.LANGUAGE_NAME,"junit-xsd-eld",null);
|
||||
Assertions.assertTrue(outputPath.list().length>2);
|
||||
File outputPath = testSchema(EldDriver.LANGUAGE_NAME, "junit-xsd-eld", null);
|
||||
Assertions.assertTrue(outputPath.list().length > 2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEldCoreSchema() throws Exception {
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME,"junit-xsd-cel",null);
|
||||
Assertions.assertTrue(outputPath.list().length>1);
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME, "junit-xsd-cel", null);
|
||||
Assertions.assertTrue(outputPath.list().length > 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSwiXmlSchema() throws Exception {
|
||||
File outputPath = testSchema(SwiXmlDriver.LANGUAGE_NAME,"junit-xsd-swixml",null);
|
||||
Assertions.assertTrue(outputPath.list().length>1);
|
||||
File outputPath = testSchema(SwiXmlDriver.LANGUAGE_NAME, "junit-xsd-swixml", null);
|
||||
Assertions.assertTrue(outputPath.list().length > 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFilterNamespace() throws Exception {
|
||||
Map<String,Object> props = new HashMap<String,Object>();
|
||||
Map<String, Object> props = new HashMap<String, Object>();
|
||||
props.put(EldXsdWriter.FILTER_NAMESPACE, EldModuleLoaderCore.CEL_ROOT_URI);
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME,"junit-one-ns",props);
|
||||
Assertions.assertTrue(outputPath.list().length==1);
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME, "junit-one-ns", props);
|
||||
Assertions.assertTrue(outputPath.list().length == 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFilterElement() throws Exception {
|
||||
Map<String,Object> props = new HashMap<String,Object>();
|
||||
Map<String, Object> props = new HashMap<String, Object>();
|
||||
props.put(EldXsdWriter.FILTER_NAMESPACE, EldModuleLoaderCore.CEL_CORE_URI);
|
||||
props.put(EldXsdWriter.FILTER_ELEMENT, "elementInterface");
|
||||
props.put(EldXsdWriter.PROLOG_GENERATED_ENABLE, false);
|
||||
props.put(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE, false);
|
||||
props.put(SAX3WriterXml.PROLOG_LICENCE_ENABLE,false);
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME,"junit-one-element",props);
|
||||
Assertions.assertTrue(outputPath.list().length==1);
|
||||
|
||||
props.put(SAX3WriterXml.PROLOG_LICENCE_ENABLE, false);
|
||||
File outputPath = testSchema(CelDriver.LANGUAGE_NAME, "junit-one-element", props);
|
||||
Assertions.assertTrue(outputPath.list().length == 1);
|
||||
|
||||
String text = X4OWriterTest.readFile(new File("target/tests/junit-one-element/cel-core-1.0.xsd"));
|
||||
Assertions.assertNotNull(text);
|
||||
Assertions.assertTrue(text.contains("elementInterface"));
|
||||
|
|
@ -122,7 +122,7 @@ public class EldXsdLanguageTaskTest {
|
|||
Assertions.assertFalse(text.contains("attributeAlias"));
|
||||
Assertions.assertFalse(text.contains("bindingHandler"));
|
||||
Assertions.assertFalse(text.contains("classConverter"));
|
||||
|
||||
Assertions.assertTrue(text.length()<10000);
|
||||
|
||||
Assertions.assertTrue(text.length() < 10000);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,62 +38,62 @@ import org.x4o.xml.test.models.TestObjectChild;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class DefaultElementObjectPropertyValueTest {
|
||||
|
||||
|
||||
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
|
||||
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
// enable all logs
|
||||
InputStream loggingProperties = DefaultElementObjectPropertyValueTest.class.getResourceAsStream("/META-INF/logging.properties");
|
||||
LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
LogManager.getLogManager().readConfiguration(loggingProperties);
|
||||
loggingProperties.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNullValue() throws Exception {
|
||||
|
||||
TestObjectChild obj = new TestObjectChild();
|
||||
obj.setName("test");
|
||||
|
||||
|
||||
Assertions.assertEquals("test", obj.getName()); // test org value
|
||||
Assertions.assertEquals("test", helper.getProperty(obj, "name")); // test null get value
|
||||
|
||||
|
||||
helper.setProperty(obj, "name", null);
|
||||
|
||||
|
||||
Assertions.assertEquals(null, obj.getName()); // test null value
|
||||
Assertions.assertEquals(null, helper.getProperty(obj, "name")); // test null get value
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIntegerValue() throws Exception {
|
||||
TestObjectChild obj = new TestObjectChild();
|
||||
helper.setProperty(obj, "price", 666);
|
||||
|
||||
Assertions.assertEquals(666,helper.getProperty(obj, "price"));
|
||||
|
||||
Assertions.assertEquals(666, helper.getProperty(obj, "price"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testException() throws Exception {
|
||||
TestObjectChild obj = new TestObjectChild();
|
||||
helper.setProperty(obj, "price", 666);
|
||||
|
||||
|
||||
boolean error = false;
|
||||
try {
|
||||
helper.getProperty(obj, "price2");
|
||||
} catch (ElementObjectPropertyValueException not) {
|
||||
error = true;
|
||||
}
|
||||
Assertions.assertEquals(true,error);
|
||||
Assertions.assertEquals(true, error);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChinees() throws Exception {
|
||||
TestBean obj = new TestBean();
|
||||
|
||||
|
||||
helper.setProperty(obj, "privateStringObjectField", "foo");
|
||||
Assertions.assertEquals("foo",helper.getProperty(obj, "privateStringObjectField"));
|
||||
|
||||
Assertions.assertEquals("foo", helper.getProperty(obj, "privateStringObjectField"));
|
||||
|
||||
helper.setProperty(obj, "privateStringObjectFieldUnicode仙上主天", "bar");
|
||||
Assertions.assertEquals("bar",helper.getProperty(obj, "privateStringObjectFieldUnicode仙上主天"));
|
||||
Assertions.assertEquals("bar", helper.getProperty(obj, "privateStringObjectFieldUnicode仙上主天"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Apr 28, 2013
|
||||
*/
|
||||
public class X4OConnectionTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testReaderPropertyFailRead() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -51,7 +51,7 @@ public class X4OConnectionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("key"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("No"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReaderPropertyFail() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -67,7 +67,7 @@ public class X4OConnectionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("key"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("No"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriterPropertyFail() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Apr 15, 2013
|
||||
*/
|
||||
public class X4OReaderSessionTest {
|
||||
|
||||
|
||||
private File copyResourceToTempFile() throws IOException {
|
||||
File tempFile = File.createTempFile("test-resource", ".xml");
|
||||
tempFile.deleteOnExit();
|
||||
|
|
@ -56,7 +56,7 @@ public class X4OReaderSessionTest {
|
|||
}
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileName() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -64,11 +64,11 @@ public class X4OReaderSessionTest {
|
|||
File xmlFile = copyResourceToTempFile();
|
||||
TestObjectRoot root = reader.readFile(xmlFile.getAbsolutePath());
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNameNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -85,7 +85,7 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("fileName"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFile() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -93,11 +93,11 @@ public class X4OReaderSessionTest {
|
|||
File xmlFile = copyResourceToTempFile();
|
||||
TestObjectRoot root = reader.readFile(xmlFile);
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -114,7 +114,7 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("file"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNotExists() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -132,7 +132,7 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("exists"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("File"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNotReadable() throws Exception {
|
||||
if (File.separatorChar != '/') {
|
||||
|
|
@ -151,7 +151,7 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("exists"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("read"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadResource() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -159,7 +159,7 @@ public class X4OReaderSessionTest {
|
|||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
Assertions.assertNotNull(root);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadResourceNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -175,24 +175,21 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("resourceName"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadString() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
TestObjectRoot root = reader.readString(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||
"<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"+
|
||||
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||
"</root:root>"
|
||||
);
|
||||
TestObjectRoot root = reader.readString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"
|
||||
+ "<testBean privateIntegerTypeField=\"987654321\"/>" + "</root:root>");
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
Assertions.assertEquals("987654321", ""+bean.getPrivateIntegerTypeField());
|
||||
Assertions.assertEquals("987654321", "" + bean.getPrivateIntegerTypeField());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadStringNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -208,7 +205,7 @@ public class X4OReaderSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("string"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadUrl() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -216,11 +213,11 @@ public class X4OReaderSessionTest {
|
|||
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml");
|
||||
TestObjectRoot root = reader.readUrl(xmlUrl);
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadUrlNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
* @version 1.0 Apr 15, 2013
|
||||
*/
|
||||
public class X4OReaderTest {
|
||||
|
||||
|
||||
private File copyResourceToTempFile() throws IOException {
|
||||
File tempFile = File.createTempFile("test-resource", ".xml");
|
||||
tempFile.deleteOnExit();
|
||||
|
|
@ -56,7 +56,7 @@ public class X4OReaderTest {
|
|||
}
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadInputStream() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -71,11 +71,11 @@ public class X4OReaderTest {
|
|||
inputStream.close();
|
||||
}
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadResource() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -83,7 +83,7 @@ public class X4OReaderTest {
|
|||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
Assertions.assertNotNull(root);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadResourceNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -99,24 +99,21 @@ public class X4OReaderTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("resourceName"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
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.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"+
|
||||
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||
"</root:root>"
|
||||
);
|
||||
TestObjectRoot root = reader.readString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<root:root xmlns:root=\"http://test.junit.x4o.org/xml/ns/junit-test-root\" xmlns=\"http://test.junit.x4o.org/xml/ns/junit-test-lang\">"
|
||||
+ "<testBean privateIntegerTypeField=\"987654321\"/>" + "</root:root>");
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
Assertions.assertEquals("987654321", ""+bean.getPrivateIntegerTypeField());
|
||||
Assertions.assertEquals("987654321", "" + bean.getPrivateIntegerTypeField());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadStringNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -132,7 +129,7 @@ public class X4OReaderTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("string"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadUrl() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -140,11 +137,11 @@ public class X4OReaderTest {
|
|||
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml");
|
||||
TestObjectRoot root = reader.readUrl(xmlUrl);
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadUrlNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -160,7 +157,7 @@ public class X4OReaderTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("url"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileName() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -168,11 +165,11 @@ public class X4OReaderTest {
|
|||
File xmlFile = copyResourceToTempFile();
|
||||
TestObjectRoot root = reader.readFile(xmlFile.getAbsolutePath());
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNameNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -189,7 +186,7 @@ public class X4OReaderTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("fileName"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFile() throws Exception {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
|
|
@ -197,11 +194,11 @@ public class X4OReaderTest {
|
|||
File xmlFile = copyResourceToTempFile();
|
||||
TestObjectRoot root = reader.readFile(xmlFile);
|
||||
Assertions.assertNotNull(root);
|
||||
Assertions.assertTrue(root.getTestBeans().size()>0);
|
||||
Assertions.assertTrue(root.getTestBeans().size() > 0);
|
||||
TestBean bean = root.getTestBeans().get(0);
|
||||
Assertions.assertNotNull(bean);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadFileNull() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Apr 28, 2013
|
||||
*/
|
||||
public class X4OWriterSessionTest {
|
||||
|
||||
|
||||
private File createOutputFile() throws IOException {
|
||||
File outputFile = File.createTempFile("test-writer-context", ".xml");
|
||||
outputFile.deleteOnExit();
|
||||
return outputFile;
|
||||
}
|
||||
|
||||
|
||||
private X4OLanguageSession createContext() throws SAXException, X4OConnectionException, IOException {
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
|
|
@ -57,7 +57,7 @@ public class X4OWriterSessionTest {
|
|||
X4OLanguageSession context = driver.createLanguage().createLanguageSession();
|
||||
Element rootElement = null;
|
||||
try {
|
||||
rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();
|
||||
rootElement = (Element) context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new SAXException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
|
@ -67,7 +67,7 @@ public class X4OWriterSessionTest {
|
|||
context.setRootElement(rootElement);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFile() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
|
|
@ -75,7 +75,7 @@ public class X4OWriterSessionTest {
|
|||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
writer.writeFileSession(createContext(), outputFile);
|
||||
String text = X4OWriterTest.readFile( outputFile );
|
||||
String text = X4OWriterTest.readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
@ -83,7 +83,7 @@ public class X4OWriterSessionTest {
|
|||
Assertions.assertTrue(text.contains("<junit-test-lang:parent name=\"test-bean.xml\"/>"));
|
||||
Assertions.assertTrue(text.contains("<junit-test-lang:configBean"), text);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFileNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -100,15 +100,15 @@ public class X4OWriterSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("file"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFileName() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
|
||||
writer.writeFileSession(createContext(), outputFile.getAbsolutePath());
|
||||
String text = X4OWriterTest.readFile( outputFile );
|
||||
String text = X4OWriterTest.readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
@ -116,7 +116,7 @@ public class X4OWriterSessionTest {
|
|||
Assertions.assertTrue(text.contains("<junit-test-lang:parent name=\"test-bean.xml\"/>"));
|
||||
Assertions.assertTrue(text.contains("<junit-test-lang:configBean"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFileNameNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
|
|
@ -133,20 +133,20 @@ public class X4OWriterSessionTest {
|
|||
Assertions.assertTrue(e.getMessage().contains("null"), "Wrong exception message");
|
||||
Assertions.assertTrue(e.getMessage().contains("fileName"), "Wrong exception message");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteStream() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
|
||||
OutputStream outputStream = new FileOutputStream(outputFile);
|
||||
try {
|
||||
writer.writeSession(createContext(),outputStream);
|
||||
writer.writeSession(createContext(), outputStream);
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
||||
String text = X4OWriterTest.readFile( outputFile );
|
||||
String text = X4OWriterTest.readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
|
|||
|
|
@ -48,15 +48,15 @@ import org.x4o.xml.test.swixml.SwingEngine;
|
|||
* @version 1.0 Apr 28, 2013
|
||||
*/
|
||||
public class X4OWriterTest {
|
||||
|
||||
|
||||
private File createOutputFile() throws IOException {
|
||||
File outputFile = File.createTempFile("test-writer", ".xml");
|
||||
outputFile.deleteOnExit();
|
||||
return outputFile;
|
||||
}
|
||||
|
||||
|
||||
static public String readFile(File file) throws IOException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),Charset.forName("UTF-8")));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = br.readLine();
|
||||
|
|
@ -66,48 +66,48 @@ public class X4OWriterTest {
|
|||
line = br.readLine();
|
||||
}
|
||||
String out = sb.toString();
|
||||
//System.out.println(out);
|
||||
// System.out.println(out);
|
||||
return out;
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriterSwiXmlOutput() throws Exception {
|
||||
Accelerator3 ac3 = new Accelerator3(false);
|
||||
SwingEngine engine = new SwingEngine(ac3);
|
||||
|
||||
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<Component> driver = SwiXmlDriver.getInstance();
|
||||
X4OReader<Component> reader = driver.createReader();
|
||||
X4OWriter<Component> writer = driver.createWriter(SwiXmlDriver.LANGUAGE_VERSION_3);
|
||||
|
||||
//reader.setProperty(key, value);
|
||||
//writer.setProperty(key, value);
|
||||
|
||||
|
||||
// reader.setProperty(key, value);
|
||||
// writer.setProperty(key, value);
|
||||
|
||||
reader.addELBeanInstance(SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE, engine);
|
||||
Component root = reader.readResource("tests/swixml/swixml-accelerator-3.0.xml");
|
||||
writer.writeFile(root, outputFile);
|
||||
|
||||
|
||||
Assertions.assertTrue(outputFile.exists(), "Debug file does not exists.");
|
||||
|
||||
//String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||
//System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath());
|
||||
|
||||
|
||||
// String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||
// System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath());
|
||||
|
||||
outputFile.delete();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFile() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
writer.writeFile(root, outputFile);
|
||||
String text = readFile( outputFile );
|
||||
String text = readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
@ -115,17 +115,17 @@ public class X4OWriterTest {
|
|||
Assertions.assertTrue(text.contains("<junit-test-lang:parent name=\"test-bean.xml\"/>"));
|
||||
Assertions.assertTrue(text.contains("<junit-test-lang:configBean"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteFileName() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
writer.writeFile(root, outputFile.getAbsolutePath());
|
||||
String text = readFile( outputFile );
|
||||
String text = readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
@ -133,24 +133,24 @@ public class X4OWriterTest {
|
|||
Assertions.assertTrue(text.contains("<junit-test-lang:parent name=\"test-bean.xml\"/>"));
|
||||
Assertions.assertTrue(text.contains("<junit-test-lang:configBean"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteStream() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OReader<TestObjectRoot> reader = driver.createReader();
|
||||
X4OWriter<TestObjectRoot> writer = driver.createWriter();
|
||||
|
||||
|
||||
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
|
||||
OutputStream outputStream = new FileOutputStream(outputFile);
|
||||
try {
|
||||
writer.write(root,outputStream);
|
||||
writer.write(root, outputStream);
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
|
||||
writer.writeFile(root, outputFile.getAbsolutePath());
|
||||
String text = readFile( outputFile );
|
||||
String text = readFile(outputFile);
|
||||
outputFile.delete();
|
||||
|
||||
Assertions.assertTrue(text.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
|
||||
|
|
|
|||
|
|
@ -45,16 +45,16 @@ public class DefaultX4OLanguageLoaderTest {
|
|||
static X4OLanguageLocal language;
|
||||
static X4OLanguageSession session;
|
||||
static DefaultX4OLanguageLoader loader;
|
||||
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
driver = TestDriver.getInstance();
|
||||
language = (X4OLanguageLocal)driver.createLanguage();
|
||||
language = (X4OLanguageLocal) driver.createLanguage();
|
||||
session = language.createLanguageSession();
|
||||
language.init(session);
|
||||
loader = (DefaultX4OLanguageLoader)language.getLanguageConfiguration().getDefaultLanguageLoader().newInstance();
|
||||
loader = (DefaultX4OLanguageLoader) language.getLanguageConfiguration().getDefaultLanguageLoader().newInstance();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLoadingDuplicate() throws Exception {
|
||||
Exception e = null;
|
||||
|
|
@ -66,75 +66,75 @@ public class DefaultX4OLanguageLoaderTest {
|
|||
Assertions.assertNotNull(e, "no duplicate module exception");
|
||||
Assertions.assertTrue(e.getMessage().contains("test"), "wrong module id.");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testModulesSimple() throws Exception {
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-simple.xml");
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-simple.xml");
|
||||
Assertions.assertNotNull(in);
|
||||
List<VersionedResources> result = loader.loadLanguageModulesXml(in, "test-modules-simple.xml");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
Assertions.assertTrue(result.size()==1, "Simple test returned non-one result: "+result.size());
|
||||
Assertions.assertTrue(result.size() == 1, "Simple test returned non-one result: " + result.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testModulesFull() throws Exception {
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-full.xml");
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-full.xml");
|
||||
Assertions.assertNotNull(in);
|
||||
List<VersionedResources> result = loader.loadLanguageModulesXml(in, "test-modules-full.xml");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
VersionedResources vr = result.get(0);
|
||||
Assertions.assertTrue(vr.eldResources.size()>1);
|
||||
Assertions.assertTrue(vr.moduleLoaders.size()>1);
|
||||
Assertions.assertTrue(vr.elbResources.size()>1);
|
||||
Assertions.assertTrue(vr.siblingLoaders.size()==1);
|
||||
Assertions.assertTrue(vr.eldResources.size() > 1);
|
||||
Assertions.assertTrue(vr.moduleLoaders.size() > 1);
|
||||
Assertions.assertTrue(vr.elbResources.size() > 1);
|
||||
Assertions.assertTrue(vr.siblingLoaders.size() == 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testModulesDuplicateLoaderNoError() throws Exception {
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-loader.xml");
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-loader.xml");
|
||||
Assertions.assertNotNull(in);
|
||||
List<VersionedResources> result = loader.loadLanguageModulesXml(in, "test-modules-err-loader.xml");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testModulesDuplicateLoader() throws Exception {
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-loader.xml");
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-loader.xml");
|
||||
Assertions.assertNotNull(in);
|
||||
List<VersionedResources> result = loader.loadLanguageModulesXml(in, "test-modules-err-loader.xml");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
|
||||
Exception e=null;
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
loader.validateModules(result);
|
||||
} catch (Exception ee) {
|
||||
e=ee;
|
||||
e = ee;
|
||||
}
|
||||
Assertions.assertNotNull(e);
|
||||
Assertions.assertTrue(e.getMessage().contains("Duplicate"), "No 'Duplicate' found in message: "+e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("module-loader"), "No 'module-loader' found in message: "+e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("Duplicate"), "No 'Duplicate' found in message: " + e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("module-loader"), "No 'module-loader' found in message: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testModulesDuplicateSiblingLoader() throws Exception {
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-sibling.xml");
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("tests/modules/test-modules-err-sibling.xml");
|
||||
Assertions.assertNotNull(in);
|
||||
List<VersionedResources> result = loader.loadLanguageModulesXml(in, "test-modules-err-sibling.xml");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
|
||||
Exception e=null;
|
||||
|
||||
Exception e = null;
|
||||
try {
|
||||
loader.validateModules(result);
|
||||
} catch (Exception ee) {
|
||||
e=ee;
|
||||
e = ee;
|
||||
}
|
||||
Assertions.assertNotNull(e);
|
||||
Assertions.assertTrue(e.getMessage().contains("Duplicate"), "No 'Duplicate' found in message: "+e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("sibling-loader"), "No 'sibling-loader' found in message: "+e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("Duplicate"), "No 'Duplicate' found in message: " + e.getMessage());
|
||||
Assertions.assertTrue(e.getMessage().contains("sibling-loader"), "No 'sibling-loader' found in message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ import org.junit.jupiter.api.Test;
|
|||
* @version 1.0 Aug 27, 2012
|
||||
*/
|
||||
public class X4OLanguageClassLoaderTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testLoadObject() throws Exception {
|
||||
Object o = X4OLanguageClassLoader.newInstance("java.lang.Object");
|
||||
Assertions.assertNotNull(o);
|
||||
Assertions.assertEquals(Object.class, o.getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tesNullThread() throws Exception {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
|
|
|
|||
|
|
@ -28,19 +28,19 @@ import org.x4o.xml.X4ODriverManager;
|
|||
public class MTestDriver extends X4ODriver<Object> {
|
||||
|
||||
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 };
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return LANGUAGE_NAME;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return LANGUAGE_VERSIONS;
|
||||
}
|
||||
|
||||
|
||||
static public MTestDriver getInstance() {
|
||||
return (MTestDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||
return (MTestDriver) X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.x4o.xml.lang.phase.X4OPhaseLanguageRead;
|
|||
* @version 1.0 Apr 15, 2012
|
||||
*/
|
||||
public class ParentObjectTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testParentElement() throws Exception {
|
||||
MTestDriver driver = new MTestDriver();
|
||||
|
|
@ -47,35 +47,35 @@ public class ParentObjectTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "junit/test-meta-parent-element.xml");
|
||||
Assertions.assertEquals(1,session.getRootElement().getChilderen().size());
|
||||
Assertions.assertEquals(1, session.getRootElement().getChilderen().size());
|
||||
Element childElement = session.getRootElement().getChilderen().get(0);
|
||||
JLabel test = (JLabel)childElement.getElementObject();
|
||||
Assertions.assertEquals("parentTest",test.getText());
|
||||
JLabel test = (JLabel) childElement.getElementObject();
|
||||
Assertions.assertEquals("parentTest", test.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParentObjectElement() throws Exception {
|
||||
DefaultElement ep = new DefaultElement();
|
||||
ParentObjectElement e = new ParentObjectElement();
|
||||
Object o;
|
||||
|
||||
|
||||
// test non parent
|
||||
o = e.getElementObject();
|
||||
Assertions.assertNull(o);
|
||||
e.setElementObject("test");
|
||||
o = e.getElementObject();
|
||||
Assertions.assertNull(o);
|
||||
|
||||
|
||||
// test parent
|
||||
e.setParent(ep);
|
||||
o = e.getElementObject();
|
||||
Assertions.assertNull(o);
|
||||
e.setElementObject("test");
|
||||
o = e.getElementObject();
|
||||
Assertions.assertEquals("test",o);
|
||||
Assertions.assertEquals("test", o);
|
||||
o = ep.getElementObject();
|
||||
Assertions.assertEquals("test",o);
|
||||
Assertions.assertEquals(e.getElementObject(),ep.getElementObject());
|
||||
Assertions.assertEquals("test", o);
|
||||
Assertions.assertEquals(e.getElementObject(), ep.getElementObject());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.x4o.xml.lang.phase.X4OPhaseLanguageRead;
|
|||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class ReferenceStoreTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testMetaGeneric() throws Exception {
|
||||
MTestDriver driver = new MTestDriver();
|
||||
|
|
@ -45,10 +45,10 @@ public class ReferenceStoreTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "junit/test-meta-generic.xml");
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLoadClass() throws Exception {
|
||||
MTestDriver driver = new MTestDriver();
|
||||
|
|
@ -56,10 +56,10 @@ public class ReferenceStoreTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "junit/test-meta-reference.xml");
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreRef() throws Exception {
|
||||
MTestDriver driver = new MTestDriver();
|
||||
|
|
@ -67,10 +67,10 @@ public class ReferenceStoreTest {
|
|||
reader.addPhaseSkip(X4OPhaseLanguageRead.READ_RELEASE);
|
||||
try (X4OLanguageSession session = reader.createLanguageSession()) {
|
||||
reader.readResourceSession(session, "junit/test-meta-reference.xml");
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(),session.getRootElement().getChilderen().get(3).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
||||
Assertions.assertEquals(Date.class.getName(), session.getRootElement().getChilderen().get(3).getElementObject().getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue