From 8256917551c259df2b7e69e32cd74497e5394786 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 23 Jan 2014 12:09:30 +0100 Subject: Refactored Resource into a new ResourceLoader interface, which allows CRISTAL processes in other enviroments with complex class loading (e.g. OSGi) to supply their own resource and class loader to the kernel and its modules. Fixes #149 --- src/test/java/MainTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/MainTest.java b/src/test/java/MainTest.java index 309f0cf..2029dc2 100644 --- a/src/test/java/MainTest.java +++ b/src/test/java/MainTest.java @@ -13,7 +13,6 @@ import com.c2kernel.process.Gateway; import com.c2kernel.scripting.Script; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; -import com.c2kernel.utils.Resource; public class MainTest { @@ -28,7 +27,6 @@ public class MainTest { Logger.addLogStream(System.out, 1); Properties props = FileStringUtility.loadConfigFile(MainTest.class.getResource("properties.conf").getPath()); Gateway.init(props); - Resource.initKernelBaseURL(); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); } @@ -41,7 +39,7 @@ public class MainTest { validators.put("SM", new OutcomeValidator(getSchema("StateMachine", 0, "boot/OD/StateMachine.xsd"))); validators.put("OD", new SchemaValidator()); - String bootItems = FileStringUtility.url2String(Resource.getKernelResourceURL("boot/allbootitems.txt")); + String bootItems = FileStringUtility.url2String(Gateway.getResource().getKernelResourceURL("boot/allbootitems.txt")); StringTokenizer str = new StringTokenizer(bootItems, "\n\r"); long castorTime=0; while (str.hasMoreTokens()) { @@ -50,7 +48,7 @@ public class MainTest { int delim = thisItem.indexOf('/'); String itemType = thisItem.substring(0,delim); OutcomeValidator validator = validators.get(itemType); - String data = Resource.getTextResource(null, "boot/"+thisItem+(itemType.equals("OD")?".xsd":".xml")); + String data = Gateway.getResource().getTextResource(null, "boot/"+thisItem+(itemType.equals("OD")?".xsd":".xml")); assert data!=null; String errors = validator.validate(data); if (errors.length() > 0) { @@ -86,7 +84,7 @@ public class MainTest { } private static Schema getSchema(String name, int version, String resPath) throws ObjectNotFoundException { - return new Schema(name, version, Resource.getTextResource(null, resPath)); + return new Schema(name, version, Gateway.getResource().getTextResource(null, resPath)); } public void testScriptParsing() throws Exception { -- cgit v1.2.3