You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rw...@apache.org on 2009/12/17 04:00:38 UTC
svn commit: r891525 - in
/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test:
./ framework/
Author: rwonly
Date: Thu Dec 17 03:00:37 2009
New Revision: 891525
URL: http://svn.apache.org/viewvc?rev=891525&view=rev
Log:
itest codes cleanup
Added:
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractCompositeDataValidator.java
Removed:
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java
Modified:
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractArgumentPropertyValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractListenerComponentValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractServiceReferenceValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java
geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java Thu Dec 17 03:00:37 2009
@@ -227,10 +227,10 @@
mev.setKeyValueValidator(new ValueValidator("key"), new ValueValidator("value"));
RegistrationListenerValidator rglrv = new RegistrationListenerValidator("serviceRegistered", "serviceUnregistered");
- rglrv.setTargetValidator(new RefValidator("fooRegistrationListener"));
+ rglrv.setListenerComponentValidator(new RefValidator("fooRegistrationListener"));
ServiceValidator sv = new ServiceValidator(4);
- sv.setTargetValidator(new RefValidator("foo"));
+ sv.setServiceComponentValidator(new RefValidator("foo"));
sv.addMapEntryValidator(mev);
sv.addRegistrationListenerValidator(rglrv);
sv.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, serviceComponentIds[0]));
@@ -241,7 +241,7 @@
// reference: ref2
ReferenceListenerValidator rlrv_1 = new ReferenceListenerValidator("bind", "unbind");
- rlrv_1.setTargetValidator(new RefValidator("bindingListener"));
+ rlrv_1.setListenerComponentValidator(new RefValidator("bindingListener"));
ReferenceValidator rv = new ReferenceValidator("org.apache.geronimo.blueprint.sample.InterfaceA", 100);
rv.addReferenceListenerValidator(rlrv_1);
@@ -253,7 +253,7 @@
// reference-list: ref-list
ReferenceListenerValidator rlrv_2 = new ReferenceListenerValidator("bind", "unbind");
- rlrv_2.setTargetValidator(new RefValidator("listBindingListener"));
+ rlrv_2.setListenerComponentValidator(new RefValidator("listBindingListener"));
ReferenceListValidator rlv_ref_list = new ReferenceListValidator("org.apache.geronimo.blueprint.sample.InterfaceA");
rlv_ref_list.addReferenceListenerValidator(rlrv_2);
@@ -265,7 +265,7 @@
// bean: circularReference
ReferenceListenerValidator rlrv_3 = new ReferenceListenerValidator("bind", "unbind");
- rlrv_3.setTargetValidator(new RefValidator("circularReference"));
+ rlrv_3.setListenerComponentValidator(new RefValidator("circularReference"));
ReferenceListValidator rlv_2 = new ReferenceListValidator("org.apache.geronimo.blueprint.sample.InterfaceA", 2);
rlv_2.addReferenceListenerValidator(rlrv_3);
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractArgumentPropertyValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractArgumentPropertyValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractArgumentPropertyValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractArgumentPropertyValidator.java Thu Dec 17 03:00:37 2009
@@ -23,7 +23,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-abstract class AbstractArgumentPropertyValidator extends CompositeDataValidator {
+abstract class AbstractArgumentPropertyValidator extends AbstractCompositeDataValidator {
// if not set, means do not care about the value
private ObjectValueValidator objectValueValidator = null;
Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractCompositeDataValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractCompositeDataValidator.java?rev=891525&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractCompositeDataValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractCompositeDataValidator.java Thu Dec 17 03:00:37 2009
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+
+abstract public class AbstractCompositeDataValidator {
+
+ private CompositeType type;
+ private Map<String, Object> expectValues;
+
+ protected AbstractCompositeDataValidator(CompositeType type){
+ this.type = type;
+ expectValues = new HashMap<String, Object>();
+ }
+
+ void setExpectValue(String key, Object value){
+ expectValues.put(key, value);
+ }
+
+ public void validate(CompositeData target){
+ if (!type.equals(target.getCompositeType()))
+ fail("Expect type is " + type + ", but target type is " +target.getCompositeType());
+ Set<String> keys = expectValues.keySet();
+ Iterator<String> it = keys.iterator();
+ while (it.hasNext()) {
+ String key = it.next();
+ assertEquals(expectValues.get(key), target.get(key));
+ }
+
+ }
+
+ }
\ No newline at end of file
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractListenerComponentValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractListenerComponentValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractListenerComponentValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractListenerComponentValidator.java Thu Dec 17 03:00:37 2009
@@ -25,20 +25,22 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-abstract class AbstractListenerComponentValidator extends CompositeDataValidator {
+abstract class AbstractListenerComponentValidator extends AbstractCompositeDataValidator {
+
+ // a TargetValidator can be one of BeanValidator, ReferenceValidator, RefValidator
TargetValidator listenerComponentValidator = null;
protected AbstractListenerComponentValidator(CompositeType type){
super(type);
}
- public void setTargetValidator(TargetValidator targetValidator){
+ public void setListenerComponentValidator(TargetValidator targetValidator){
this.listenerComponentValidator = targetValidator;
}
public void validate(CompositeData target){
super.validate(target);
- assertNotNull("This Validator must have a TargetValidator for listener component", listenerComponentValidator);
+ assertNotNull("This Validator must have a TargetValidator to validate listener component", listenerComponentValidator);
listenerComponentValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.LISTENER_COMPONENT)));
}
}
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractServiceReferenceValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractServiceReferenceValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractServiceReferenceValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/AbstractServiceReferenceValidator.java Thu Dec 17 03:00:37 2009
@@ -28,7 +28,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-abstract class AbstractServiceReferenceValidator extends CompositeDataValidator implements NonNullObjectValueValidator {
+abstract class AbstractServiceReferenceValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator {
private List<ReferenceListenerValidator> referenceListenerValidators = new ArrayList<ReferenceListenerValidator>();
protected AbstractServiceReferenceValidator(CompositeType type) {
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java Thu Dec 17 03:00:37 2009
@@ -29,7 +29,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class BeanValidator extends CompositeDataValidator implements NonNullObjectValueValidator, TargetValidator{
+public class BeanValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator, TargetValidator{
private boolean validateArgumentsFlag = true;
private List<BeanArgumentValidator> beanArgumentValidators = new ArrayList<BeanArgumentValidator>();
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java Thu Dec 17 03:00:37 2009
@@ -21,7 +21,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintStateMBean;
-public class BlueprintEventValidator extends CompositeDataValidator{
+public class BlueprintEventValidator extends AbstractCompositeDataValidator{
public BlueprintEventValidator(long bundleId, long extenderBundleId, int eventType){
super(BlueprintStateMBean.OSGI_BLUEPRINT_EVENT_TYPE);
setExpectValue(BlueprintStateMBean.BUNDLE_ID, bundleId);
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java Thu Dec 17 03:00:37 2009
@@ -26,7 +26,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class CollectionValidator extends CompositeDataValidator implements NonNullObjectValueValidator {
+public class CollectionValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator {
private List<ObjectValueValidator> collectionValueValidators = new ArrayList<ObjectValueValidator>();
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java Thu Dec 17 03:00:37 2009
@@ -23,7 +23,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class MapEntryValidator extends CompositeDataValidator {
+public class MapEntryValidator extends AbstractCompositeDataValidator {
NonNullObjectValueValidator keyValidator = null;
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java Thu Dec 17 03:00:37 2009
@@ -20,7 +20,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class RefValidator extends CompositeDataValidator implements NonNullObjectValueValidator, TargetValidator {
+public class RefValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator, TargetValidator {
public RefValidator(String componentId){
super(BlueprintMetadataMBean.REF_METADATA_TYPE);
setExpectValue(BlueprintMetadataMBean.COMPONENT_ID, componentId);
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java Thu Dec 17 03:00:37 2009
@@ -28,9 +28,10 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class ServiceValidator extends CompositeDataValidator implements NonNullObjectValueValidator {
-
+public class ServiceValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator {
+ // a TargetValidator can be one of BeanValidator, ReferenceValidator, RefValidator
TargetValidator serviceComponentValidator = null;
+
List<MapEntryValidator> servicePropertyValidators = new ArrayList<MapEntryValidator>();
List<RegistrationListenerValidator> registrationListenerValidators = new ArrayList<RegistrationListenerValidator>();
@@ -39,7 +40,7 @@
this.setExpectValue(BlueprintMetadataMBean.AUTO_EXPORT, autoExport);
}
- public void setTargetValidator(TargetValidator targetValidator){
+ public void setServiceComponentValidator(TargetValidator targetValidator){
this.serviceComponentValidator = targetValidator;
}
Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java?rev=891525&r1=891524&r2=891525&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java Thu Dec 17 03:00:37 2009
@@ -20,7 +20,7 @@
import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
-public class ValueValidator extends CompositeDataValidator implements NonNullObjectValueValidator{
+public class ValueValidator extends AbstractCompositeDataValidator implements NonNullObjectValueValidator{
public ValueValidator(String stringValue){
super(BlueprintMetadataMBean.VALUE_METADATA_TYPE);