hlship 2004/06/25 16:27:01
Modified: framework/src/test/hivemind/test/parse
TestDescriptorParser.java
Added: framework/src/test/hivemind/test/parse
BadConfigurationId.xml BadVersion.sdl
BadModuleId.sdl
Removed: framework/src/test/hivemind/test/parse BadId.xml
Log:
Add validation of ids parsed in module deployment descriptors.
Revision Changes Path
1.15 +64 -38
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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestDescriptorParser.java 25 Jun 2004 20:20:05 -0000 1.14
+++ TestDescriptorParser.java 25 Jun 2004 23:27:01 -0000 1.15
@@ -341,14 +341,40 @@
}
}
- public void testBadId() throws Exception
+ public void testBadConfigurationId() throws Exception
{
interceptLogging();
- parse("BadId.xml");
+ parse("BadConfigurationId.xml");
assertLoggedMessagePattern(
- "Attribute id \\(foo\\.bar\\) of element configuration-point is
not a valid id\\.");
+ "Attribute id \\(foo\\.bar\\) of element
module/configuration-point is improperly "
+ + "formatted\\. Schema and extension point ids should be
simple names with "
+ + "no punctuation\\.");
+ }
+
+ public void testBadModuleId() throws Exception
+ {
+ interceptLogging();
+
+ parse("BadModuleId.sdl");
+
+ assertLoggedMessagePattern(
+ "Attribute id \\(big bad\\) of element module is improperly "
+ + "formatted\\. Module identifiers should consist of a
period-seperated series "
+ + "of names, like a Java package\\.");
+ }
+
+ public void testBadVersion() throws Exception
+ {
+ interceptLogging();
+
+ parse("BadVersion.sdl");
+
+ assertLoggedMessagePattern(
+ "Attribute version \\(1\\.0\\.alpha\\) of element module is
improperly "
+ + "formatted\\. Version numbers should be a sequence of
three numbers "
+ + "seperated by periods\\.");
}
public void testSchemaDescription() throws Exception
@@ -395,41 +421,41 @@
assertEquals("foo", em.getElementName());
}
-
+
public void testSetPropertyRule() throws Exception
{
- ModuleDescriptor md = parse("SetPropertyRule.sdl");
-
- List points = md.getConfigurationPoints();
- ConfigurationPointDescriptor cpd =
(ConfigurationPointDescriptor)points.get(0);
- Schema s = cpd.getContributionsSchema();
- List l = s.getElementModel();
-
- ElementModel em = (ElementModel)l.get(0);
-
- List rules = em.getRules();
-
- SetPropertyRule rule = (SetPropertyRule)rules.get(0);
-
- assertEquals("foo", rule.getPropertyName());
- assertEquals("bar", rule.getValue());
- }
-
- public void testPushAttributeRule() throws Exception
- {
- ModuleDescriptor md = parse("PushAttributeRule.sdl");
-
- List points = md.getConfigurationPoints();
- ConfigurationPointDescriptor cpd =
(ConfigurationPointDescriptor)points.get(0);
- Schema s = cpd.getContributionsSchema();
- List l = s.getElementModel();
-
- ElementModel em = (ElementModel)l.get(0);
-
- List rules = em.getRules();
-
- PushAttributeRule rule = (PushAttributeRule)rules.get(0);
-
- assertEquals("foo", rule.getAttributeName());
- }
+ ModuleDescriptor md = parse("SetPropertyRule.sdl");
+
+ List points = md.getConfigurationPoints();
+ ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor)
points.get(0);
+ Schema s = cpd.getContributionsSchema();
+ List l = s.getElementModel();
+
+ ElementModel em = (ElementModel) l.get(0);
+
+ List rules = em.getRules();
+
+ SetPropertyRule rule = (SetPropertyRule) rules.get(0);
+
+ assertEquals("foo", rule.getPropertyName());
+ assertEquals("bar", rule.getValue());
+ }
+
+ public void testPushAttributeRule() throws Exception
+ {
+ ModuleDescriptor md = parse("PushAttributeRule.sdl");
+
+ List points = md.getConfigurationPoints();
+ ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor)
points.get(0);
+ Schema s = cpd.getContributionsSchema();
+ List l = s.getElementModel();
+
+ ElementModel em = (ElementModel) l.get(0);
+
+ List rules = em.getRules();
+
+ PushAttributeRule rule = (PushAttributeRule) rules.get(0);
+
+ assertEquals("foo", rule.getAttributeName());
+ }
}
1.1
jakarta-hivemind/framework/src/test/hivemind/test/parse/BadConfigurationId.xml
Index: BadConfigurationId.xml
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<module id="hivemind.test.parse" version="1.0.0">
<configuration-point id="foo.bar" occurs="1..n"/>
</module>
1.1
jakarta-hivemind/framework/src/test/hivemind/test/parse/BadVersion.sdl
Index: BadVersion.sdl
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
module (id=bad.version version="1.0.alpha")
1.1
jakarta-hivemind/framework/src/test/hivemind/test/parse/BadModuleId.sdl
Index: BadModuleId.sdl
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
module (id="big bad" version="1.0.0")
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]