[jboss-cvs] JBossAS SVN: r101127 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/profile/metadata and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 18 12:17:41 EST 2010


Author: emuckenhuber
Date: 2010-02-18 12:17:40 -0500 (Thu, 18 Feb 2010)
New Revision: 101127

Added:
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapability.java
Removed:
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapbility.java
Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralRequirement.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfile.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java
Log:
update testcase

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -48,6 +48,15 @@
       return super.equals(requirement);
    }
    
+   public boolean isConsistent(ProfileCapability other)
+   {
+      if(other != null && other instanceof AbstractProfileKeyCapability)
+      {
+         return getName().equals(AbstractProfileKeyCapability.class.cast(other)) == false;
+      }
+      return true;
+   }
+   
    @Override
    public boolean equals(Object obj)
    {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -84,6 +84,15 @@
       return false;
    }
    
+   public boolean isConsistent(ProfileCapability other)
+   {
+      if(other != null && other instanceof FeatureCapability)
+      {
+         return getNsUri().equals((FeatureCapability.class.cast(other))) == false;
+      }
+      return true;
+   }
+   
    @Override
    public void visit(ProfileMetaDataVisitor visitor)
    {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -164,10 +164,10 @@
             final DependencyMode mode = getDependencyMode(requirement);
             final ProfileNode depenencyNode = getNode(dependencyKey);
             final ProfileDependencyContext dependencyContext = registry.getProfile(dependencyKey);
+
+            // Add the dependency context
+            addDependencyContext(dependencyContext);
             
-            // TODO consistency check
-            this.includedContexts.add(dependencyContext);
-            
             if(root || mode == DependencyMode.RESOLVE || dependencyContext.isOnDemandEnabled())
             {
                // Resolve
@@ -201,7 +201,7 @@
       }
    }
    
-   public ProfileKey internalResolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
+   protected ProfileKey internalResolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
    {
       // Resolve the requirements based on the exposed capabilities
       final boolean trace = log.isTraceEnabled();
@@ -235,6 +235,37 @@
       return resolved;
    }
    
+   protected void addDependencyContext(final ProfileDependencyContext context)
+   {
+      if(this.includedContexts.contains(context))
+      {
+         return;
+      }
+      final Collection<ProfileCapability> capabilities = context.getCapabilities();
+      if(capabilities != null && capabilities.isEmpty() == false)
+      {
+         for(final ProfileCapability capability : capabilities)
+         {
+            for(final ProfileDependencyContext included : this.includedContexts)
+            {
+               final Collection<ProfileCapability> includedCapabilities = included.getCapabilities();
+               if(includedCapabilities != null && includedCapabilities.isEmpty() == false)
+               {
+                  for(final ProfileCapability other : includedCapabilities)
+                  {
+                     if(capability.isConsistent(other) == false)
+                     {
+                        throw new IllegalStateException(context.getName() + " has an incosistent capability " + capability + " with module "
+                              + included.getName() + " / " + other);
+                     }
+                  }
+               }
+            }
+         }
+      }
+      this.includedContexts.add(context);
+   }
+   
    /**
     * Sort the included profile nodes and check if we can include
     * some additional activation callbacks.

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -29,6 +29,7 @@
 
 import org.jboss.profileservice.metadata.helpers.AbstractProfileCapability;
 import org.jboss.profileservice.metadata.helpers.AbstractProfileRequirement;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
 import org.jboss.profileservice.spi.virtual.VirtualDeployment;
@@ -170,6 +171,12 @@
       this.requires = requires;
    }
    
+   public boolean isConsistent(ProfileCapability other)
+   {
+      // TODO
+      return true;
+   }
+   
    @Override
    public boolean resolves(ProfileRequirement requirement)
    {

Copied: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapability.java (from rev 101111, projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapbility.java)
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapability.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapability.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -0,0 +1,144 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.resolver.dependency.support;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at XmlType(propOrder = {"name", "properties"})
+public class GeneralCapability implements ProfileCapability
+{
+
+   private String name;
+   private Set<Property> properties;
+
+   @XmlAttribute(name = "name")
+   public String getName()
+   {
+      return name;
+   }
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   @XmlElement(name="property")
+   public Set<Property> getProperties()
+   {
+      return properties;
+   }
+   public void setProperties(Set<Property> xmlProps)
+   {
+      this.properties = xmlProps;
+   }
+   
+   public boolean resolves(ProfileRequirement r)
+   {
+      if(r != null && r instanceof GeneralRequirement)
+      {
+         GeneralRequirement requirement = GeneralRequirement.class.cast(r);
+         if(name.equals(requirement.getName()))
+         {
+            boolean resolved = true;
+            for(Property property : requirement.getProperties())
+            {
+               if(resolveProperty(property) == false)
+               {
+                  resolved = false;
+               }
+            }
+            if(resolved)
+            {
+               return true;
+            }
+         }
+      }
+      return false;
+   }
+
+   public boolean isConsistent(ProfileCapability other)
+   {
+      if(other != null && other instanceof GeneralCapability)
+      {
+         final GeneralCapability capability = GeneralCapability.class.cast(other);
+         if(getName().equals(capability.getName()))
+         {
+            if(properties != null && properties.isEmpty() == false)
+            {
+               for(final Property property : properties)
+               {
+                  Collection<Property> others = capability.getProperties();
+                  if(others != null && others.isEmpty() == false)
+                  {
+                     for(final Property otherProperty : others)
+                     {
+                        // check if the property is exposed by the other profile as well
+                        if(property.getKey().equals(otherProperty.getKey()) && 
+                              property.getValue().equals(otherProperty.getValue()))
+                        {
+                           // inconsistent
+                           return false;
+                        }
+                     }
+                  }
+               }
+            }
+         }
+      }
+      return true;
+   }
+   
+   protected boolean resolveProperty(Property property)
+   {
+      boolean resolved = false;
+      for(Property myProperty : getProperties())
+      {
+         if(myProperty.getKey().equals(property.getKey())
+               && myProperty.getValue().equals(property.getValue()))
+         {
+            resolved = true;
+         }
+      }
+      return resolved;
+   }
+   
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer(getClass().getSimpleName());
+      buffer.append("{name=").append(name);
+      buffer.append(", properties=").append(properties).append("}");
+      return buffer.toString();
+   }
+   
+}
+

Deleted: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapbility.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapbility.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralCapbility.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -1,104 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2010, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.profileservice.resolver.dependency.support;
-
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.jboss.profileservice.spi.dependency.ProfileCapability;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
- at XmlType(propOrder = {"name", "properties"})
-public class GeneralCapbility implements ProfileCapability
-{
-
-   private String name;
-   private Set<Property> properties;
-
-   @XmlAttribute(name = "name")
-   public String getName()
-   {
-      return name;
-   }
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   @XmlElement(name="property")
-   public Set<Property> getProperties()
-   {
-      return properties;
-   }
-   public void setProperties(Set<Property> xmlProps)
-   {
-      this.properties = xmlProps;
-   }
-   
-   public boolean resolves(ProfileRequirement r)
-   {
-      if(r != null && r instanceof GeneralRequirement)
-      {
-         GeneralRequirement requirement = GeneralRequirement.class.cast(r);
-         if(name.equals(requirement.getName()))
-         {
-            boolean resolved = true;
-            for(Property property : requirement.getProperties())
-            {
-               if(resolveProperty(property) == false)
-               {
-                  resolved = false;
-               }
-            }
-            if(resolved)
-            {
-               return true;
-            }
-         }
-      }
-      return false;
-   }
-
-   protected boolean resolveProperty(Property property)
-   {
-      boolean resolved = false;
-      for(Property myProperty : getProperties())
-      {
-         if(myProperty.getKey().equals(property.getKey())
-               && myProperty.getValue().equals(property.getValue()))
-         {
-            resolved = true;
-         }
-      }
-      return resolved;
-   }
-   
-   
-}
-

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralRequirement.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/dependency/support/GeneralRequirement.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -70,34 +70,6 @@
       return DependencyMode.RESOLVE;
    }
 
-   public boolean isConsistent(ProfileRequirement other)
-   {
-      if(other == this)
-         return true;
-      if(other != null && other instanceof GeneralRequirement)
-      {
-         GeneralRequirement requirement = GeneralRequirement.class.cast(other);
-         if(name.equals(requirement.name))
-         {
-            for(Property myProperty : properties)
-            {
-               for(Property otherProperty : requirement.properties)
-               {
-                  if(myProperty.getKey().equals(otherProperty.getKey()))
-                  {
-                     if(myProperty.getValue().equals(otherProperty.getValue()) == false)
-                     {
-                        // inconsistent
-                        return false;
-                     }
-                  }
-               }
-            }
-         }
-      }
-      return true;
-   }
-
    public boolean isOptional()
    {
       return false;
@@ -111,6 +83,5 @@
       return buffer.toString();
    }
    
-   
 }
 

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfile.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfile.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -33,7 +33,7 @@
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.test.profileservice.resolver.dependency.support.GeneralCapbility;
+import org.jboss.test.profileservice.resolver.dependency.support.GeneralCapability;
 import org.jboss.test.profileservice.resolver.dependency.support.GeneralRequirement;
 
 /**
@@ -90,7 +90,7 @@
     * 
     * @return the capabilities.
     */
-   @XmlElement(name = "capability", type = GeneralCapbility.class)
+   @XmlElement(name = "capability", type = GeneralCapability.class)
    public List<ProfileCapability> getCapabilities()
    {
       return capabilities;

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -55,6 +55,20 @@
       assertTrue(resolved.contains("apache-webservices"));
    }
    
+   public void testInConsistent() throws Exception
+   {
+      try
+      {
+         resolveServices("capabilities.xml", "apache-webservices", "jboss-webservices");
+      }
+      catch(IllegalStateException e)
+      {
+         log.debug(e);
+         return;
+      }
+      fail("");
+   }
+   
    protected List<String> resolveServices(String file, String... services) throws Exception
    {
       parse(file);

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -38,5 +38,16 @@
     */
    boolean resolves(ProfileRequirement requirement);
 
+   /**
+    * Check whether this capability is consistent with another capability.<p>
+    *
+    * Since the capabilties are within one shared 'domain' capabilties have to 
+    * be unique.
+    * 
+    * @param other the other capability
+    * @return true when consistent, false when inconsistent
+    */
+   boolean isConsistent(ProfileCapability other);
+   
 }
 

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java	2010-02-18 17:12:34 UTC (rev 101126)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java	2010-02-18 17:17:40 UTC (rev 101127)
@@ -43,14 +43,6 @@
     * @return if this requirement is optional
     */
    boolean isOptional();
- 
-   /**
-    * Check whether this requirement is consistent with another requirement.<p>
-    * 
-    * @param other the other capability
-    * @return true when consistent, false when inconsistent
-    */
-   boolean isConsistent(ProfileRequirement other);
    
 }
 




More information about the jboss-cvs-commits mailing list