You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by hl...@apache.org on 2004/06/15 22:48:19 UTC
cvs commit: jakarta-hivemind/framework/src/test/hivemind/test FrameworkTestCase.java
hlship 2004/06/15 13:48:19
Modified: framework/src/test/hivemind/test/parse
TestDescriptorParser.java
framework/src/java/org/apache/hivemind/parse
ParseStrings.properties ParseMessages.java
DescriptorParser.java
framework/src/java/org/apache/hivemind/impl
RegistryBuilder.java RegistryAssemblyImpl.java
ImplStrings.properties ImplMessages.java
RegistryImpl.java
framework/src/test/hivemind/test/impl
TestRegistryAssemblyImpl.java
framework/src/test/hivemind/test FrameworkTestCase.java
Log:
Split out many messages out of HiveMindMessages.properties and into per-package properties files (more to come).
Begin excising location-related portions of messages (as location reporting is a function of the ErrorHandler).
Revision Changes Path
1.13 +3 -4 jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java
Index: TestDescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TestDescriptorParser.java 19 May 2004 15:08:47 -0000 1.12
+++ TestDescriptorParser.java 15 Jun 2004 20:48:18 -0000 1.13
@@ -323,7 +323,7 @@
parse("BadAttribute.xml");
- assertLoggedMessagePattern("Unknown attribute 'bad-attribute' in element module/schema \\(at .*\\)");
+ assertLoggedMessagePattern("Unknown attribute 'bad-attribute' in element module/schema\\.");
}
public void testMissingAttribute() throws Exception
@@ -349,8 +349,7 @@
parse("BadId.xml");
assertLoggedMessagePattern(
- "Attribute id \\(foo\\.bar\\) of element configuration-point "
- + "\\(at .*/BadId\\.xml.*\\) is not a valid id\\.");
+ "Attribute id \\(foo\\.bar\\) of element configuration-point is not a valid id\\.");
}
public void testSchemaDescription() throws Exception
1.3 +2 -2 jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties
Index: ParseStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ParseStrings.properties 15 Jun 2004 20:35:55 -0000 1.2
+++ ParseStrings.properties 15 Jun 2004 20:48:18 -0000 1.3
@@ -18,8 +18,8 @@
unable-to-resolve-schema=Unable to resolve reference to schema ''{0}''.
not-module=Document element should be module not {0} (at {1}).
required-attribute=Missing required attribute ''{0}'' in element {1} (at {2}).
-unknown-attribute=Unknown attribute ''{0}'' in element {1} (at {2}).
-invalid-id-format=Attribute {0} ({1}) of element {2} (at {3}) is not a valid id.
+unknown-attribute=Unknown attribute ''{0}'' in element {1}.
+invalid-id-format=Attribute {0} ({1}) of element {2} is not a valid id.
boolean-attribute=''{0}'' is not a valid value for attribute {1} of {2}. Expected values are ''true'' or ''false''.
invalid-attribute-value=''{0}'' is not a valid value for attribute ''{1}'' of {2}.
invalid-numeric-value=''{0}'' (attribute {1} of {2}) can not be converted to a numeric value.
1.4 +4 -10 jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java
Index: ParseMessages.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParseMessages.java 15 Jun 2004 20:35:55 -0000 1.3
+++ ParseMessages.java 15 Jun 2004 20:48:18 -0000 1.4
@@ -65,20 +65,14 @@
return _formatter.format("required-attribute", name, path, location);
}
- public static String unknownAttribute(String name, String path, Location location)
+ public static String unknownAttribute(String name, String path)
{
- return _formatter.format("unknown-attribute", name, path, location);
+ return _formatter.format("unknown-attribute", name, path);
}
- public static String invalidIdFormat(
- String attributeName,
- String value,
- String elementName,
- Location location)
+ public static String invalidIdFormat(String attributeName, String value, String elementName)
{
- return _formatter.format(
- "invalid-id-format",
- new Object[] { attributeName, value, elementName, location });
+ return _formatter.format("invalid-id-format", attributeName, value, elementName);
}
public static String booleanAttribute(String value, String name, String path)
1.20 +10 -7 jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
Index: DescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DescriptorParser.java 15 Jun 2004 20:35:55 -0000 1.19
+++ DescriptorParser.java 15 Jun 2004 20:48:18 -0000 1.20
@@ -713,7 +713,11 @@
String name = (String) i.next();
if (!epi.isKnown(name))
- LOG.error(ParseMessages.unknownAttribute(name, getElementPath(), getLocation()));
+ _errorHandler.error(
+ LOG,
+ ParseMessages.unknownAttribute(name, getElementPath()),
+ getLocation(),
+ null);
}
// Now check that all required attributes have been specified.
@@ -1174,12 +1178,11 @@
return result;
if (result.indexOf('.') >= 0)
- LOG.error(
- ParseMessages.invalidIdFormat(
- attributeName,
- result,
- peekElementName(),
- getLocation()));
+ _errorHandler.error(
+ LOG,
+ ParseMessages.invalidIdFormat(attributeName, result, peekElementName()),
+ getLocation(),
+ null);
return result;
}
1.14 +9 -3 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
Index: RegistryBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RegistryBuilder.java 15 Jun 2004 20:35:55 -0000 1.13
+++ RegistryBuilder.java 15 Jun 2004 20:48:19 -0000 1.14
@@ -154,7 +154,7 @@
* RegistryAssembly used by the module descriptor parser(s).
*/
- private RegistryAssemblyImpl _registryAssembly = new RegistryAssemblyImpl();
+ private RegistryAssemblyImpl _registryAssembly;
public RegistryBuilder()
{
@@ -164,6 +164,8 @@
public RegistryBuilder(ErrorHandler handler)
{
_errorHandler = handler;
+
+ _registryAssembly = new RegistryAssemblyImpl(handler);
}
/**
@@ -662,7 +664,7 @@
if (point.getServiceConstructor() != null)
continue;
- LOG.error(ImplMessages.missingService(point));
+ _errorHandler.error(LOG, ImplMessages.missingService(point), null, null);
}
}
@@ -706,7 +708,11 @@
continue;
}
- LOG.error(ImplMessages.wrongNumberOfContributions(point, count, expected));
+ _errorHandler.error(
+ LOG,
+ ImplMessages.wrongNumberOfContributions(point, count, expected),
+ point.getLocation(),
+ null);
}
}
1.5 +12 -1 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryAssemblyImpl.java
Index: RegistryAssemblyImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryAssemblyImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RegistryAssemblyImpl.java 5 Jun 2004 19:09:12 -0000 1.4
+++ RegistryAssemblyImpl.java 15 Jun 2004 20:48:19 -0000 1.5
@@ -22,6 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ClassResolver;
+import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.HiveMind;
import org.apache.hivemind.Resource;
import org.apache.hivemind.parse.DescriptorParser;
@@ -40,6 +41,12 @@
private List _runnables = new ArrayList();
private Map _schemas = new HashMap();
private List _queuedModules = new ArrayList();
+ private ErrorHandler _errorHandler;
+
+ public RegistryAssemblyImpl(ErrorHandler errorHandler)
+ {
+ _errorHandler = errorHandler;
+ }
private static class QueuedModule
{
@@ -64,7 +71,11 @@
if (existing != null)
{
- LOG.error(ImplMessages.duplicateSchema(schemaId, schema, existing));
+ _errorHandler.error(
+ LOG,
+ ImplMessages.duplicateSchema(schemaId, existing),
+ schema.getLocation(),
+ null);
return;
}
1.3 +2 -2 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
Index: ImplStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ImplStrings.properties 15 Jun 2004 20:35:55 -0000 1.2
+++ ImplStrings.properties 15 Jun 2004 20:48:19 -0000 1.3
@@ -28,7 +28,7 @@
null-interceptor=Service {0} generated a null interceptor (for service extension point {1}).
interceptor-does-not-implement-interface=The service interceptor ({0}) generated by service {1} for service extension point {2} does not implement the {3} interface defined by the extension point.
unable-to-read-messages=Unable to read message properties from {0}.
-duplicate-schema=Schema {0} (at {1}) conflicts with existing schema at {2}.
+duplicate-schema=Schema {0} conflicts with existing schema at {1}.
unable-to-parse=Unable to parse module deployment descriptor {0}: {1}
unable-to-find-modules=Unable to locate HiveMind module deployment descriptors in {0}: {1}
duplicate-module-id=Module {0} is duplicated! Definition in {2} has been ignored in favor of existing definition from {1}.
@@ -43,7 +43,7 @@
wrong-number-of-contributions=Configuration extension point {0} contains {1,choice,0#no contributions|1#one contribution|1<{1,number,integer} contributions} but expects {2} contribution.
no-such-configuration=Configuration point {0} does not exist.
-no-such-symbol=No value available for symbol ''{0}'' (at {1}).
+no-such-symbol=No value available for symbol ''{0}''.
symbol-source-contribution=symbol source
unknown-attribute=Attribute ''{0}'' is not defined in the schema.
missing-attribute=Attribute ''{0}'' is required but no value was provided.
1.8 +3 -4 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
Index: ImplMessages.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ImplMessages.java 15 Jun 2004 20:35:55 -0000 1.7
+++ ImplMessages.java 15 Jun 2004 20:48:19 -0000 1.8
@@ -150,12 +150,11 @@
return _formatter.format("unable-to-read-messages", url);
}
- public static String duplicateSchema(String schemaId, Schema newSchema, Schema existingSchema)
+ public static String duplicateSchema(String schemaId, Schema existingSchema)
{
return _formatter.format(
"duplicate-schema",
schemaId,
- newSchema.getLocation(),
existingSchema.getLocation());
}
@@ -241,9 +240,9 @@
return _formatter.format("no-such-configuration", pointId);
}
- public static String noSuchSymbol(String name, Location location)
+ public static String noSuchSymbol(String name)
{
- return _formatter.format("no-such-symbol", name, location);
+ return _formatter.format("no-such-symbol", name);
}
public static String symbolSourceContribution()
1.11 +1 -1 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java
Index: RegistryImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- RegistryImpl.java 10 Jun 2004 19:49:39 -0000 1.10
+++ RegistryImpl.java 15 Jun 2004 20:48:19 -0000 1.11
@@ -308,7 +308,7 @@
if (value != null)
return value;
- LOG.error(ImplMessages.noSuchSymbol(name, location));
+ _errorHandler.error(LOG, ImplMessages.noSuchSymbol(name), location, null);
return "${" + name + "}";
}
1.4 +8 -7 jakarta-hivemind/framework/src/test/hivemind/test/impl/TestRegistryAssemblyImpl.java
Index: TestRegistryAssemblyImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/impl/TestRegistryAssemblyImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestRegistryAssemblyImpl.java 25 May 2004 22:31:41 -0000 1.3
+++ TestRegistryAssemblyImpl.java 15 Jun 2004 20:48:19 -0000 1.4
@@ -17,6 +17,7 @@
import org.apache.hivemind.Location;
import org.apache.hivemind.Resource;
import org.apache.hivemind.impl.DefaultClassResolver;
+import org.apache.hivemind.impl.DefaultErrorHandler;
import org.apache.hivemind.impl.LocationImpl;
import org.apache.hivemind.impl.RegistryAssemblyImpl;
import org.apache.hivemind.schema.Schema;
@@ -45,7 +46,7 @@
public void testAddSchema()
{
- RegistryAssemblyImpl ra = new RegistryAssemblyImpl();
+ RegistryAssemblyImpl ra = new RegistryAssemblyImpl(new DefaultErrorHandler());
MockControl control = MockControl.createStrictControl(Schema.class);
Schema s = (Schema) control.getMock();
@@ -60,7 +61,7 @@
public void testAddDupeSchema() throws Exception
{
- RegistryAssemblyImpl ra = new RegistryAssemblyImpl();
+ RegistryAssemblyImpl ra = new RegistryAssemblyImpl(new DefaultErrorHandler());
MockControl c1 = MockControl.createStrictControl(Schema.class);
MockControl c2 = MockControl.createStrictControl(Schema.class);
@@ -79,13 +80,13 @@
s2.getLocation();
c2.setReturnValue(l2);
- c1.replay();
- c2.replay();
+ c1.replay();
+ c2.replay();
ra.addSchema("foo.bar", s1);
ra.addSchema("foo.bar", s2);
- assertLoggedMessagePattern("Schema foo.bar \\(at classpath:/foo/bar, line 97\\) conflicts with existing schema at classpath:/foo/bar, line 20\\.");
+ assertLoggedMessagePattern("Schema foo.bar conflicts with existing schema at classpath:/foo/bar, line 20\\.");
assertSame(s1, ra.getSchema("foo.bar"));
@@ -95,7 +96,7 @@
public void testAddPostProcessor()
{
- RegistryAssemblyImpl ra = new RegistryAssemblyImpl();
+ RegistryAssemblyImpl ra = new RegistryAssemblyImpl(new DefaultErrorHandler());
TestRunnable r = new TestRunnable();
1.8 +5 -3 jakarta-hivemind/framework/src/test/hivemind/test/FrameworkTestCase.java
Index: FrameworkTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/FrameworkTestCase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FrameworkTestCase.java 10 Jun 2004 19:49:40 -0000 1.7
+++ FrameworkTestCase.java 15 Jun 2004 20:48:19 -0000 1.8
@@ -43,9 +43,11 @@
protected ModuleDescriptor parse(String file) throws Exception
{
Resource location = getResource(file);
+ DefaultErrorHandler eh = new DefaultErrorHandler();
- RegistryAssemblyImpl assembly = new RegistryAssemblyImpl();
- DescriptorParser p = new DescriptorParser(new DefaultErrorHandler(), assembly);
+ RegistryAssemblyImpl assembly = new RegistryAssemblyImpl(eh);
+
+ DescriptorParser p = new DescriptorParser(eh, assembly);
ModuleDescriptor result = p.parse(location, _resolver);
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org