/ojc-core/component-common/xmlbeans/xbean-src/2.3.0/xmlbeans/test/src/tools/inst2xsd/detailed/Inst2XsdDetailedOptionsTest.java

https://bitbucket.org/pymma/openesb-components · Java · 425 lines · 352 code · 53 blank · 20 comment · 0 complexity · 8cae7e4a73a1801c1865f8330a59c99c MD5 · raw file

  1. /* Copyright 2004 The Apache Software Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. package tools.inst2xsd.detailed;
  16. import tools.inst2xsd.common.Inst2XsdTestBase;
  17. import org.apache.xmlbeans.impl.inst2xsd.Inst2XsdOptions;
  18. import org.apache.xmlbeans.impl.inst2xsd.Inst2Xsd;
  19. import java.io.File;
  20. import java.io.IOException;
  21. import org.apache.xmlbeans.XmlObject;
  22. import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
  23. public class Inst2XsdDetailedOptionsTest extends Inst2XsdTestBase {
  24. public Inst2XsdDetailedOptionsTest(String name) {
  25. super(name);
  26. }
  27. public void test_simpleContentString_Russian() throws Exception {
  28. Inst2XsdOptions opt = common.getRussianOptions();
  29. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  30. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  31. checkLength(api, 1);
  32. log(api);
  33. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  34. "-design", "rd",
  35. "-simple-content-types", "string",
  36. "-outDir", OPTION_CASES_DIR,
  37. "-outPrefix", "base",
  38. BASEXML});
  39. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  40. log("Compare: Command Line to API");
  41. compare(api[0], cmdLine);
  42. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_rd_scs0.xsd"));
  43. log("Compare: Expected to API");
  44. compare(api[0], exp);
  45. }
  46. public void test_simpleContentString_Salami() throws Exception {
  47. Inst2XsdOptions opt = common.getSalamiOptions();
  48. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  49. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  50. checkLength(api, 1);
  51. log(api);
  52. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  53. "-design", "ss",
  54. "-simple-content-types", "string",
  55. "-outDir", OPTION_CASES_DIR,
  56. "-outPrefix", "base",
  57. BASEXML});
  58. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  59. log("Compare: Command Line to API");
  60. compare(api[0], cmdLine);
  61. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_ss_scs0.xsd"));
  62. log("Compare: Expected to API");
  63. compare(api[0], exp);
  64. }
  65. public void test_simpleContentString_Venetian() throws Exception {
  66. Inst2XsdOptions opt = common.getVenetianOptions();
  67. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  68. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  69. checkLength(api, 1);
  70. log(api);
  71. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  72. "-design", "vb",
  73. "-simple-content-types", "string",
  74. "-outDir", OPTION_CASES_DIR,
  75. "-outPrefix", "base",
  76. BASEXML});
  77. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  78. log("Compare: Command Line to API");
  79. compare(api[0], cmdLine);
  80. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_vb_scs0.xsd"));
  81. log("Compare: Expected to API");
  82. compare(api[0], exp);
  83. }
  84. public void test_simpleContentSmart_Russian() throws Exception {
  85. Inst2XsdOptions opt = common.getRussianOptions();
  86. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  87. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  88. checkLength(api, 1);
  89. log(api);
  90. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  91. "-design", "rd",
  92. "-simple-content-types", "smart",
  93. "-outDir", OPTION_CASES_DIR,
  94. "-outPrefix", "base",
  95. BASEXML});
  96. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  97. log("Compare: Command Line to API");
  98. compare(api[0], cmdLine);
  99. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_rd0.xsd"));
  100. log("Compare: Expected to API");
  101. compare(api[0], exp);
  102. }
  103. public void test_simpleContentSmart_Salami() throws Exception {
  104. Inst2XsdOptions opt = common.getSalamiOptions();
  105. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  106. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  107. checkLength(api, 1);
  108. log(api);
  109. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  110. "-design", "ss",
  111. "-simple-content-types", "smart",
  112. "-outDir", OPTION_CASES_DIR,
  113. "-outPrefix", "base",
  114. BASEXML});
  115. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  116. log("Compare: Command Line to API");
  117. compare(api[0], cmdLine);
  118. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_ss0.xsd"));
  119. log("Compare: Expected to API");
  120. compare(api[0], exp);
  121. }
  122. public void test_simpleContentSmart_Venetian() throws Exception {
  123. Inst2XsdOptions opt = common.getVenetianOptions();
  124. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  125. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  126. checkLength(api, 1);
  127. log(api);
  128. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  129. "-design", "vb",
  130. "-simple-content-types", "smart",
  131. "-outDir", OPTION_CASES_DIR,
  132. "-outPrefix", "base",
  133. BASEXML});
  134. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  135. log("Compare: Command Line to API");
  136. compare(api[0], cmdLine);
  137. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_vb0.xsd"));
  138. log("Compare: Expected to API");
  139. compare(api[0], exp);
  140. }
  141. public void test_simpleContentSmart_NeverEnum_Russian() throws Exception {
  142. Inst2XsdOptions opt = common.getRussianOptions();
  143. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  144. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  145. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  146. checkLength(api, 1);
  147. log(api);
  148. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  149. "-design", "rd",
  150. "-enumerations", "never",
  151. "-simple-content-types", "smart",
  152. "-outDir", OPTION_CASES_DIR,
  153. "-outPrefix", "base",
  154. BASEXML});
  155. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  156. log("Compare: Command Line to API");
  157. compare(api[0], cmdLine);
  158. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_rd_eN0.xsd"));
  159. log("Compare: Expected to API");
  160. compare(api[0], exp);
  161. }
  162. public void test_simpleContentSmart_NeverEnum_Salami() throws Exception {
  163. Inst2XsdOptions opt = common.getSalamiOptions();
  164. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  165. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  166. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  167. checkLength(api, 1);
  168. log(api);
  169. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  170. "-design", "ss",
  171. "-enumerations", "never",
  172. "-simple-content-types", "smart",
  173. "-outDir", OPTION_CASES_DIR,
  174. "-outPrefix", "base",
  175. BASEXML});
  176. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  177. log("Compare: Command Line to API");
  178. compare(api[0], cmdLine);
  179. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_ss_eN0.xsd"));
  180. log("Compare: Expected to API");
  181. compare(api[0], exp);
  182. }
  183. public void test_simpleContentSmart_NeverEnum_Venetian() throws Exception {
  184. Inst2XsdOptions opt = common.getVenetianOptions();
  185. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  186. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  187. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  188. checkLength(api, 1);
  189. log(api);
  190. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  191. "-design", "vb",
  192. "-enumerations", "never",
  193. "-simple-content-types", "smart",
  194. "-outDir", OPTION_CASES_DIR,
  195. "-outPrefix", "base",
  196. BASEXML});
  197. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  198. log("Compare: Command Line to API");
  199. compare(api[0], cmdLine);
  200. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_vb_eN0.xsd"));
  201. log("Compare: Expected to API");
  202. compare(api[0], exp);
  203. }
  204. public void test_simpleContentString_NeverEnum_Russian() throws Exception {
  205. Inst2XsdOptions opt = common.getRussianOptions();
  206. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  207. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  208. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  209. checkLength(api, 1);
  210. log(api);
  211. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  212. "-design", "rd",
  213. "-enumerations", "never",
  214. "-simple-content-types", "string",
  215. "-outDir", OPTION_CASES_DIR,
  216. "-outPrefix", "base",
  217. BASEXML});
  218. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  219. log("Compare: Command Line to API");
  220. compare(api[0], cmdLine);
  221. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_rd_scs_eN0.xsd"));
  222. log("Compare: Expected to API");
  223. compare(api[0], exp);
  224. }
  225. public void test_simpleContentString_NeverEnum_Salami() throws Exception {
  226. Inst2XsdOptions opt = common.getSalamiOptions();
  227. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  228. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  229. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  230. checkLength(api, 1);
  231. log(api);
  232. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  233. "-design", "ss",
  234. "-enumerations", "never",
  235. "-simple-content-types", "string",
  236. "-outDir", OPTION_CASES_DIR,
  237. "-outPrefix", "base",
  238. BASEXML});
  239. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  240. log("Compare: Command Line to API");
  241. compare(api[0], cmdLine);
  242. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_ss_scs_eN0.xsd"));
  243. log("Compare: Expected to API");
  244. compare(api[0], exp);
  245. }
  246. public void test_simpleContentString_NeverEnum_Venetian() throws Exception {
  247. Inst2XsdOptions opt = common.getVenetianOptions();
  248. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  249. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  250. XmlObject[] api = runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)}, opt);
  251. checkLength(api, 1);
  252. log(api);
  253. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  254. "-design", "vb",
  255. "-enumerations", "never",
  256. "-simple-content-types", "string",
  257. "-outDir", OPTION_CASES_DIR,
  258. "-outPrefix", "base",
  259. BASEXML});
  260. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  261. log("Compare: Command Line to API");
  262. compare(api[0], cmdLine);
  263. XmlObject exp = XmlObject.Factory.parse(new File(OPTION_CASES_DIR + "base_vb_scs_eN0.xsd"));
  264. log("Compare: Expected to API");
  265. compare(api[0], exp);
  266. }
  267. //TODO: move to checkin - cursor issue
  268. public void test_simpleContentSmart() throws Exception {
  269. Inst2XsdOptions opt = common.getDefaultInstOptions();
  270. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
  271. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(XmlObject.Factory.parse(common.base), opt));
  272. checkLength(sDoc, 1);
  273. XmlObject exp = XmlObject.Factory.parse(common.base_expected_venetian, common.getXmlOptions());
  274. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  275. "-simple-content-types", "smart",
  276. "-outDir", OPTION_CASES_DIR,
  277. "-outPrefix", "base",
  278. BASEXML});
  279. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  280. compare(sDoc[0], exp);
  281. compare(cmdLine, exp);
  282. }
  283. //TODO: move to checkin - cursor issue
  284. public void test_neverEnum() throws Exception {
  285. Inst2XsdOptions opt = common.getVenetianOptions();
  286. opt.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
  287. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(XmlObject.Factory.parse(common.base), opt));
  288. checkLength(sDoc, 1);
  289. XmlObject exp = XmlObject.Factory.parse(common.base_expected_venetian, common.getXmlOptions());
  290. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  291. "-enumerations", "never",
  292. "-outDir", OPTION_CASES_DIR,
  293. "-outPrefix", "base",
  294. BASEXML});
  295. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  296. compare(sDoc[0], exp);
  297. compare(cmdLine, exp);
  298. }
  299. //TODO: move to checkin - cursor issue
  300. public void test_simpleContentString() throws Exception {
  301. Inst2XsdOptions opt = common.getDefaultInstOptions();
  302. opt.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
  303. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(XmlObject.Factory.parse(common.base), opt));
  304. checkLength(sDoc, 1);
  305. String stringContent = "<xs:schema attributeFormDefault =\"unqualified\" elementFormDefault=\"qualified\" " +
  306. "targetNamespace=\"baseNamespace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
  307. "<xs:element name=\"a\" type=\"bas:aType\" xmlns:bas=\"baseNamespace\"/>" +
  308. "<xs:complexType name=\"aType\">" +
  309. "<xs:sequence>" +
  310. "<xs:element type=\"xs:string\" name=\"b\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"/>" +
  311. "<xs:element type=\"xs:string\" name=\"c\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"/>" +
  312. "<xs:element type=\"xs:string\" name=\"d\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"/>" +
  313. "</xs:sequence>" +
  314. "</xs:complexType>" +
  315. "</xs:schema>";
  316. XmlObject exp = XmlObject.Factory.parse(stringContent, common.getXmlOptions());
  317. compare(sDoc[0], exp);
  318. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  319. "-simple-content-types", "string",
  320. "-outDir", OPTION_CASES_DIR,
  321. "-outPrefix", "base",
  322. BASEXML});
  323. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  324. compare(sDoc[0], exp);
  325. compare(cmdLine, exp);
  326. }
  327. //TODO: move to checkin - cursor issue
  328. public void test_RussianDesign() throws Exception {
  329. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(XmlObject.Factory.parse(common.base),
  330. common.getRussianOptions()));
  331. checkLength(sDoc, 1);
  332. XmlObject exp = XmlObject.Factory.parse(common.base_expected_russian, common.getXmlOptions());
  333. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  334. "-design", "rd",
  335. "-outDir", OPTION_CASES_DIR,
  336. "-outPrefix", "base",
  337. BASEXML});
  338. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  339. compare(sDoc[0], exp);
  340. compare(cmdLine, exp);
  341. }
  342. //TODO: move to checkin - cursor issue
  343. public void test_SalamiDesign() throws Exception {
  344. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(XmlObject.Factory.parse(common.base),
  345. common.getSalamiOptions()));
  346. checkLength(sDoc, 1);
  347. XmlObject exp = XmlObject.Factory.parse(common.base_expected_salami, common.getXmlOptions());
  348. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  349. "-design", "ss",
  350. "-outDir", OPTION_CASES_DIR,
  351. "-outPrefix", "base",
  352. BASEXML});
  353. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  354. compare(sDoc[0], exp);
  355. compare(cmdLine, exp);
  356. }
  357. //TODO: move to checkin - cursor issue
  358. public void test_VenetianDesign() throws Exception {
  359. SchemaDocument[] sDoc = getSchemaDoc(runInst2Xsd(new XmlObject[]{XmlObject.Factory.parse(common.base)},
  360. common.getVenetianOptions()));
  361. checkLength(sDoc, 1);
  362. XmlObject exp = XmlObject.Factory.parse(common.base_expected_venetian, common.getXmlOptions());
  363. Inst2Xsd.main(new String[]{"-validate", "-verbose",
  364. "-design", "vb",
  365. "-outDir", OPTION_CASES_DIR,
  366. "-outPrefix", "base",
  367. BASEXML});
  368. XmlObject cmdLine = XmlObject.Factory.parse(new File(EXPBASEXML));
  369. compare(sDoc[0], exp);
  370. compare(cmdLine, exp);
  371. }
  372. }