<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#copied {background-color:#ccccff;}
tr.alt #copied {background-color:#bbbbf7;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>asxsd/trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas</tt></b></td></tr>
<tr><td><tt><a href="#file1"><span id="added">SchemaTestCase.java</span></a></tt> </td><td></td><td align="right" id="added">+55</td><td></td><td nowrap="nowrap" align="right">added 139</td></tr>
</table>
<pre class="comment">
framework for unit testing schema files
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas</span><br />
<div class="fileheader" id="added"><big><b>SchemaTestCase.java</b></big> <small id="info">added at 139</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/SchemaTestCase.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/SchemaTestCase.java        2007-09-05 21:09:47 UTC (rev 139)
@@ -0,0 +1,55 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.schemas;
+
+import java.io.IOException;
+import java.net.URL;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.util.XSDResourceFactoryImpl;
+import org.eclipse.xsd.util.XSDResourceImpl;
+import uk.co.badgersinfoil.asxsd.MappingCodeGenerator;
+import uk.co.badgersinfoil.metaas.ActionScriptFactory;
+import uk.co.badgersinfoil.metaas.ActionScriptProject;
+import junit.framework.TestCase;
+
+public abstract class SchemaTestCase extends TestCase {
+        static {
+                Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
+        }
+        
+        protected ActionScriptProject project;
+        
+        protected void setUp() throws IOException {
+                String cname = getClass().getName();
+                cname = cname.substring(cname.lastIndexOf('.')+1);
+                project = processSchema(cname);
+        }
+
+        private ActionScriptProject processSchema(String fileNameFragment) throws IOException {
+                ActionScriptFactory fact = new ActionScriptFactory();
+                ActionScriptProject project = fact.newEmptyASProject(".");
+                MappingCodeGenerator generator = new MappingCodeGenerator(project);
+                XSDSchema schema = loadTestSchemaResource(fileNameFragment);
+                generator.processSchema(schema);
+                return project;
+        }
+
+        private XSDSchema loadTestSchemaResource(String fileNameFragment) throws IOException {
+                String res = "xsd/"+fileNameFragment+".xsd";
+                URL url = getClass().getClassLoader().getResource(res);
+                if (url == null) {
+                        throw new IOException("Resource not found: "+res);
+                }
+                return loadSchema(url.toString());
+        }
+
+        private static XSDSchema loadSchema(String uri) throws IOException {
+                ResourceSet resourceSet = new ResourceSetImpl();
+                XSDResourceImpl resource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd"));
+                resource.setURI(URI.createURI(uri));
+                resource.load(resourceSet.getLoadOptions());
+                return resource.getSchema();
+        }
+}
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>