Author: thomas.heute(a)jboss.com
Date: 2008-02-01 08:28:54 -0500 (Fri, 01 Feb 2008)
New Revision: 227
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Compatibility.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityInconsistencyException.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityLevel.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Environment.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentCompatibility.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentIncompatibility.java
src/server/trunk/server-service/server-model/src/test/java/org/
src/server/trunk/server-service/server-model/src/test/java/org/jboss/
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/model/
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/model/CompatibilityTestCase.java
Removed:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java
Modified:
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRArtifactImpl.java
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/NodeFactory.java
src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityList.java
Log:
CompatibilityList rough implementation
Modified:
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRArtifactImpl.java
===================================================================
---
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRArtifactImpl.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRArtifactImpl.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -35,8 +35,13 @@
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portletswap.jcr.JCRService;
import org.jboss.portletswap.model.Artifact;
+import org.jboss.portletswap.model.CompatibilityList;
import org.jboss.portletswap.model.Type;
import org.jboss.portletswap.model.Version;
+import org.jboss.portletswap.model.compatibility.Compatibility;
+import org.jboss.portletswap.model.compatibility.Environment;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentCompatibility;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentIncompatibility;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -118,7 +123,67 @@
Version version = new JCRVersionImpl(versionNode);
artifact.setVersion(version);
+ Node compatibilityListNode = null;
+ try
+ {
+ compatibilityListNode = node.getNode("ps:compatibilityList");
+ }
+ catch (PathNotFoundException e)
+ {
+ // ignore
+ }
+
+ if (compatibilityListNode != null)
+ {
+ CompatibilityList compatibilityList = new CompatibilityList();
+ it = compatibilityListNode.getNodes("ps:compatibility");
+ while (it.hasNext())
+ {
+ Node tmpNode = it.nextNode();
+ Node tmpVersionNode = tmpNode.getNode("ps:asVersion");
+ int major =
(int)tmpVersionNode.getProperty("ps:major").getValue().getLong();
+ int minor =
(int)tmpVersionNode.getProperty("ps:minor").getValue().getLong();
+ int patch =
(int)tmpVersionNode.getProperty("ps:patch").getValue().getLong();
+ String prefix =
tmpVersionNode.getProperty("ps:prefix").getValue().getString();
+ String suffix =
tmpVersionNode.getProperty("ps:suffix").getValue().getString();
+ Version tmpASVersion = new Version(major, minor, patch, new
Version.Qualifier(Version.Qualifier.Prefix.valueOf(prefix),
Version.Qualifier.Suffix.valueOf(suffix)));
+
+ tmpVersionNode = tmpNode.getNode("ps:jdkVersion");
+ major =
(int)tmpVersionNode.getProperty("ps:major").getValue().getLong();
+ minor =
(int)tmpVersionNode.getProperty("ps:minor").getValue().getLong();
+ patch =
(int)tmpVersionNode.getProperty("ps:patch").getValue().getLong();
+ prefix =
tmpVersionNode.getProperty("ps:prefix").getValue().getString();
+ suffix =
tmpVersionNode.getProperty("ps:suffix").getValue().getString();
+ Version tmpJDKVersion = new Version(major, minor, patch, new
Version.Qualifier(Version.Qualifier.Prefix.valueOf(prefix),
Version.Qualifier.Suffix.valueOf(suffix)));
+
+ tmpVersionNode = tmpNode.getNode("ps:jbpVersion");
+ major =
(int)tmpVersionNode.getProperty("ps:major").getValue().getLong();
+ minor =
(int)tmpVersionNode.getProperty("ps:minor").getValue().getLong();
+ patch =
(int)tmpVersionNode.getProperty("ps:patch").getValue().getLong();
+ prefix =
tmpVersionNode.getProperty("ps:prefix").getValue().getString();
+ suffix =
tmpVersionNode.getProperty("ps:suffix").getValue().getString();
+ Version tmpJBPVersion = new Version(major, minor, patch, new
Version.Qualifier(Version.Qualifier.Prefix.valueOf(prefix),
Version.Qualifier.Suffix.valueOf(suffix)));
+
+ Environment environment = new Environment();
+ environment.setAsVersion(tmpASVersion);
+ environment.setJbpVersion(tmpJBPVersion);
+ environment.setJdkVersion(tmpJDKVersion);
+
+
+ Compatibility comp = null;
+ if (tmpNode.isNodeType("ps:sameEnvironmentCompatibility"))
+ {
+ comp = new SameEnvironmentCompatibility(environment);
+
+ }
+ else if (tmpNode.isNodeType("ps:sameEnvironmentIncompatibility"))
+ {
+ comp = new SameEnvironmentIncompatibility(environment);
+ }
+ compatibilityList.add(comp);
+ }
+ artifact.setCompatibilityList(compatibilityList);
+ }
}
-
}
Modified:
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/NodeFactory.java
===================================================================
---
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/NodeFactory.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/NodeFactory.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -37,10 +37,14 @@
import org.jboss.portletswap.model.Artifact;
import org.jboss.portletswap.model.Author;
import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.CompatibilityList;
import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.License;
import org.jboss.portletswap.model.Module;
import org.jboss.portletswap.model.Version;
+import org.jboss.portletswap.model.compatibility.Compatibility;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentCompatibility;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentIncompatibility;
import org.jboss.portletswap.model.impl.jcr.JCRArtifactImpl;
import org.jboss.portletswap.model.impl.jcr.JCRAuthorImpl;
import org.jboss.portletswap.model.impl.jcr.JCRCategoryImpl;
@@ -92,6 +96,13 @@
createLocalizedStringNode(artifactNode, "ps:displayName",
displayName);
}
+ // Store the compatibility list
+ CompatibilityList compatibilityList = artifact.getCompatibilityList();
+ if (compatibilityList != null)
+ {
+ createCompatibilityNode(artifactNode, compatibilityList);
+ }
+
return artifactNode;
}
@@ -179,5 +190,62 @@
}
return node;
}
+
+ public static Node createCompatibilityNode(Node parent, CompatibilityList list) throws
RepositoryException
+ {
+ Node node = parent.addNode("ps:compatibilityList",
"ps:compatibilityList");
+ for(Compatibility compatibility: list.getCompatibilities())
+ {
+ if (compatibility instanceof SameEnvironmentCompatibility)
+ {
+ SameEnvironmentCompatibility compat =
(SameEnvironmentCompatibility)compatibility;
+ Node compNode = node.addNode("ps:compatibility",
"ps:sameEnvironmentCompatibility");
+ createVersionNode(compNode, "ps:asVersion",
compat.getEnvironment().getAsVersion());
+ createVersionNode(compNode, "ps:jbpVersion",
compat.getEnvironment().getJbpVersion());
+ createVersionNode(compNode, "ps:jdkVersion",
compat.getEnvironment().getJdkVersion());
+ }
+ else if (compatibility instanceof SameEnvironmentIncompatibility)
+ {
+ SameEnvironmentIncompatibility compat =
(SameEnvironmentIncompatibility)compatibility;
+ Node compNode = node.addNode("ps:compatibility",
"ps:sameEnvironmentIncompatibility");
+ createVersionNode(compNode, "ps:asVersion",
compat.getEnvironment().getAsVersion());
+ createVersionNode(compNode, "ps:jbpVersion",
compat.getEnvironment().getJbpVersion());
+ createVersionNode(compNode, "ps:jdkVersion",
compat.getEnvironment().getJdkVersion());
+ }
+ }
+ return node;
+ }
+
+ public static Node createVersionNode(Node parent, String nodeType, Version version)
throws RepositoryException
+ {
+ Node versionNode = parent.addNode(nodeType, nodeType);
+ int nb = version.getMajor();
+ if (nb != -1)
+ {
+ versionNode.setProperty("ps:major", nb);
+ }
+ nb = version.getMinor();
+ if (nb != -1)
+ {
+ versionNode.setProperty("ps:minor", nb);
+ }
+ nb = version.getPatch();
+ if (nb != -1)
+ {
+ versionNode.setProperty("ps:patch", nb);
+ }
+ Version.Qualifier qualifier = version.getQualifier();
+ if (qualifier != null)
+ {
+ versionNode.setProperty("ps:prefix", qualifier.getPrefix().name());
+ }
+ if (qualifier.getSuffix() != null)
+ {
+ versionNode.setProperty("ps:suffix", qualifier.getSuffix().name());
+
+ }
+ return versionNode;
+ }
+
}
Modified: src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
===================================================================
---
src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd 2008-02-01
13:28:54 UTC (rev 227)
@@ -33,12 +33,25 @@
[ps:artifacts] > nt:folder
+ ps:artifact multiple
+[ps:compatibilityList] > nt:base
+ + ps:compatibility multiple
+
+[ps:compatibility] > nt:base
+ + ps:asVersion
+ + ps:jbpVersion
+ + ps:jdkVersion
+
+[ps:sameEnvironmentCompatibility] > ps:compatibility
+
+[ps:sameEnvironmentIncompatibility] > ps:compatibility
+
[ps:artifact] > nt:base, mix:referenceable
- jcr:lastModified (date) mandatory ignore
- ps:module (reference) mandatory
- ps:license (reference)
- ps:type (string) mandatory
+ ps:version mandatory
+ + ps:compatibilityList
[ps:fileArtifact] > ps:artifact
- ps:inputStream (binary)
@@ -59,4 +72,10 @@
- ps:patch mandatory
- ps:prefix mandatory
- ps:suffix
+
+ [ps:asVersion] > ps:version
+
+ [ps:jdkVersion] > ps:version
+
+ [ps:jbpVersion] > ps:version
\ No newline at end of file
Modified:
src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
===================================================================
---
src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -42,11 +42,14 @@
import org.jboss.portletswap.jcr.JCRServiceImpl;
import org.jboss.portletswap.model.Artifact;
import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.CompatibilityList;
import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.License;
import org.jboss.portletswap.model.Module;
import org.jboss.portletswap.model.Type;
import org.jboss.portletswap.model.Version;
+import org.jboss.portletswap.model.compatibility.Environment;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentCompatibility;
import org.jboss.portletswap.repository.NotFoundException;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
@@ -339,16 +342,51 @@
FileArtifact getArtifact = (FileArtifact)artifacts.get(0);
assertNotNull(getArtifact);
assertNotNull(getArtifact.getInputStream());
+ }
+
+ @Test
+ public void testAddArtifactWithCompatibilityList() throws Exception
+ {
+ Module module = new Module("Test");
+ assertNull(module.getId());
+ module = repositoryService.storeModule(module);
+
+ Version version = new Version(1, 0, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
-// FileOutputStream fos = new FileOutputStream("/tmp/foobarou");
-//
-// byte[] buf = new byte[256];
-// int read = 0;
-// while ((read = getArtifact.getInputStream().read(buf)) > 0) {
-// fos.write(buf, 0, read);
-// }
-//
+ InputStream is = new FileInputStream("/tmp/test");
+ Artifact artifact = new FileArtifact(Type.JSR168PORTLET, module, new
File("/tmp/test"), is);
+ ((Artifact)artifact).setName("Bozo");
+ artifact.setVersion(version);
+ License license = new License("LGPL", "blah");
+ license = repositoryService.storeLicense(license);
+ artifact.setLicense(license);
+
+ CompatibilityList compatibilityList = new CompatibilityList();
+ Environment environment = new Environment();
+ environment.setAsVersion(new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA)));
+ environment.setJbpVersion(new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA)));
+ environment.setJdkVersion(new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA)));
+ SameEnvironmentCompatibility compatibility = new
SameEnvironmentCompatibility(environment);
+ compatibilityList.add(compatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ artifact = repositoryService.storeArtifact(artifact);
+
+ List<Artifact> artifacts = module.getArtifacts();
+ assertEquals(1, artifacts.size());
+
+ FileArtifact getArtifact = (FileArtifact)artifacts.get(0);
+ assertNotNull(getArtifact);
+ assertNotNull(getArtifact.getInputStream());
+// compatibility = (SameEnvironmentCompatibility)
getArtifact.getCompatibilityList().getCompatibilities().get(0);
+// assertNotNull(compatibility);
+// assertEquals(3, compatibility.getEnvironment().getJbpVersion().getPatch());
+ compatibilityList = getArtifact.getCompatibilityList();
+ assertNotNull(compatibilityList);
}
+
+
}
Modified:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -167,5 +167,6 @@
{
this.module = module;
}
+
}
Deleted:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -1,33 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public enum CompatibilityLevel {
-
- COMPATIBLE, INCOMPATIBLE, UNKNOWN
-}
-
Modified:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityList.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityList.java 2008-01-28
13:27:30 UTC (rev 226)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityList.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -22,12 +22,82 @@
******************************************************************************/
package org.jboss.portletswap.model;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portletswap.model.compatibility.Compatibility;
+import org.jboss.portletswap.model.compatibility.CompatibilityInconsistencyException;
+import org.jboss.portletswap.model.compatibility.CompatibilityLevel;
+import org.jboss.portletswap.model.compatibility.Environment;
+
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
public class CompatibilityList
{
+ private List<Compatibility> compatibilities = new
ArrayList<Compatibility>();
+ public CompatibilityLevel getCompatibilityLevel(Environment env) throws
CompatibilityInconsistencyException
+ {
+ int compatibilityValue = 0;
+ CompatibilityLevel result = null;
+ int counter = 0;
+
+ for (Compatibility compatibility: compatibilities)
+ {
+ CompatibilityLevel compatibilityLevel =
compatibility.getCompatibilityLevel(env);
+ if (compatibilityLevel.getCompatibilityValue() ==
CompatibilityLevel.COMPATIBLE_LEVEL_VALUE)
+ {
+ // we always go ahead to check for inconsistencies
+ if ((result == null) || (result.getCompatibilityValue() !=
CompatibilityLevel.INCOMPATIBLE_LEVEL_VALUE))
+ {
+ result = CompatibilityLevel.COMPATIBLE_LEVEL;
+ }
+ else
+ {
+ throw new CompatibilityInconsistencyException();
+ }
+ }
+ else if (compatibilityLevel.getCompatibilityValue() ==
CompatibilityLevel.INCOMPATIBLE_LEVEL_VALUE)
+ {
+ // we always go ahead to check for inconsistencies
+ if ((result == null) || (result.getCompatibilityValue() !=
CompatibilityLevel.COMPATIBLE_LEVEL_VALUE))
+ {
+ // It is compatible and we are sure
+ result = CompatibilityLevel.INCOMPATIBLE_LEVEL;
+ }
+ else
+ {
+ throw new CompatibilityInconsistencyException();
+ }
+ }
+ else
+ {
+ counter++;
+ compatibilityValue += compatibilityLevel.getCompatibilityValue() / counter;
+ }
+ }
+
+ if (result != null)
+ {
+ return result;
+ }
+ else
+ {
+ return new CompatibilityLevel(compatibilityValue);
+ }
+ }
+
+ public void add(Compatibility compatibility)
+ {
+ compatibilities.add(compatibility);
+ }
+
+ public List<Compatibility> getCompatibilities()
+ {
+ return compatibilities;
+ }
+
}
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Compatibility.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Compatibility.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Compatibility.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Compatibility
+{
+ public CompatibilityLevel getCompatibilityLevel(Environment env);
+
+
+ public enum Limit
+ {
+ MAJOR, MINOR, PATCH, QUALIFIER
+ }
+}
+
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityInconsistencyException.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityInconsistencyException.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityInconsistencyException.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CompatibilityInconsistencyException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5526741312515506855L;
+
+}
+
Copied:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityLevel.java
(from rev 224,
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java)
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityLevel.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/CompatibilityLevel.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CompatibilityLevel {
+
+ private int compatibilityValue;
+
+ public static final int COMPATIBLE_LEVEL_VALUE = 100;
+
+ public static final int UNKNOWN_LEVEL_VALUE = 0;
+
+ public static final int INCOMPATIBLE_LEVEL_VALUE = -100;
+
+ public static CompatibilityLevel COMPATIBLE_LEVEL = new
CompatibilityLevel(COMPATIBLE_LEVEL_VALUE);
+
+ public static CompatibilityLevel INCOMPATIBLE_LEVEL = new
CompatibilityLevel(INCOMPATIBLE_LEVEL_VALUE);
+
+ public static CompatibilityLevel UNKNOWN_LEVEL = new
CompatibilityLevel(UNKNOWN_LEVEL_VALUE);
+
+ public CompatibilityLevel(int compatibilityValue)
+ {
+ this.compatibilityValue = compatibilityValue;
+ }
+
+ public int getCompatibilityValue()
+ {
+ return compatibilityValue;
+ }
+}
+
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Environment.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Environment.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/Environment.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+import org.jboss.portletswap.model.Version;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Environment
+{
+
+ private Version asVersion;
+
+ private Version jbpVersion;
+
+ private Version jdkVersion;
+
+ public Version getAsVersion()
+ {
+ return asVersion;
+ }
+
+ public void setAsVersion(Version asVersion)
+ {
+ this.asVersion = asVersion;
+ }
+
+ public Version getJbpVersion()
+ {
+ return jbpVersion;
+ }
+
+ public void setJbpVersion(Version jbpVersion)
+ {
+ this.jbpVersion = jbpVersion;
+ }
+
+ public Version getJdkVersion()
+ {
+ return jdkVersion;
+ }
+
+ public void setJdkVersion(Version jdkVersion)
+ {
+ this.jdkVersion = jdkVersion;
+ }
+}
+
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentCompatibility.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentCompatibility.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentCompatibility.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+import org.jboss.portletswap.model.Version;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SameEnvironmentCompatibility implements Compatibility
+{
+ private Environment env;
+
+ private Limit asLimit;
+
+ private Limit jbpLimit;
+
+ private Limit jdkLimit;
+
+ public SameEnvironmentCompatibility(Environment env)
+ {
+ this(env, Limit.QUALIFIER, Limit.QUALIFIER, Limit.QUALIFIER);
+ }
+
+ public SameEnvironmentCompatibility(Environment env, Limit asLimit, Limit jbpLimit,
Limit jdkLimit)
+ {
+ this.env = env;
+ this.asLimit = asLimit;
+ this.jbpLimit = jbpLimit;
+ this.jdkLimit = jdkLimit;
+ }
+
+ public CompatibilityLevel getCompatibilityLevel(Environment compare)
+ {
+ if ((isCompatible(env.getAsVersion(), compare.getAsVersion(), asLimit)) &&
+ (isCompatible(env.getJbpVersion(), compare.getJbpVersion(), jbpLimit))
&&
+ (isCompatible(env.getJdkVersion(), compare.getJdkVersion(), jdkLimit)))
+ {
+ return CompatibilityLevel.COMPATIBLE_LEVEL;
+ }
+ else
+ {
+ return CompatibilityLevel.UNKNOWN_LEVEL;
+ }
+ }
+
+ public boolean isCompatible(Version from, Version to, Limit limit)
+ {
+ if (from.getMajor() == to.getMajor())
+ {
+ if (limit.equals(Limit.MAJOR))
+ {
+ return true;
+ }
+ if (from.getMinor() == to.getMinor())
+ {
+ if (limit.equals(Limit.MINOR))
+ {
+ return true;
+ }
+ if (from.getPatch() == to.getPatch())
+ {
+ if (limit.equals(Limit.PATCH))
+ {
+ return true;
+ }
+ if (from.getQualifier().equals(to.getQualifier()))
+ {
+ if (limit.equals(Limit.QUALIFIER))
+ {
+ return true;
+ }
+ }
+ }
+
+ }
+
+ }
+ return false;
+ }
+
+ public Environment getEnvironment()
+ {
+ return env;
+ }
+}
+
Added:
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentIncompatibility.java
===================================================================
---
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentIncompatibility.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/compatibility/SameEnvironmentIncompatibility.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model.compatibility;
+
+import org.jboss.portletswap.model.Version;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SameEnvironmentIncompatibility implements Compatibility
+{
+ private Environment env;
+
+ private Limit asLimit;
+
+ private Limit jbpLimit;
+
+ private Limit jdkLimit;
+
+ public SameEnvironmentIncompatibility(Environment env)
+ {
+ this(env, Limit.QUALIFIER, Limit.QUALIFIER, Limit.QUALIFIER);
+ }
+
+ public SameEnvironmentIncompatibility(Environment env, Limit asLimit, Limit jbpLimit,
Limit jdkLimit)
+ {
+ this.env = env;
+ this.asLimit = asLimit;
+ this.jbpLimit = jbpLimit;
+ this.jdkLimit = jdkLimit;
+ }
+
+ public CompatibilityLevel getCompatibilityLevel(Environment compare)
+ {
+ if ((isIncompatible(env.getAsVersion(), compare.getAsVersion(), asLimit)) ||
+ (isIncompatible(env.getJbpVersion(), compare.getJbpVersion(), jbpLimit)) ||
+ (isIncompatible(env.getJdkVersion(), compare.getJdkVersion(), jdkLimit)))
+ {
+ return CompatibilityLevel.INCOMPATIBLE_LEVEL;
+ }
+ else
+ {
+ return CompatibilityLevel.UNKNOWN_LEVEL;
+ }
+ }
+
+ public boolean isIncompatible(Version from, Version to, Limit limit)
+ {
+ if (from.getMajor() == to.getMajor())
+ {
+ if (limit.equals(Limit.MAJOR))
+ {
+ return true;
+ }
+ if (from.getMinor() == to.getMinor())
+ {
+ if (limit.equals(Limit.MINOR))
+ {
+ return true;
+ }
+ if (from.getPatch() == to.getPatch())
+ {
+ if (limit.equals(Limit.PATCH))
+ {
+ return true;
+ }
+ if (from.getQualifier().equals(to.getQualifier()))
+ {
+ if (limit.equals(Limit.QUALIFIER))
+ {
+ return true;
+ }
+ }
+ }
+
+ }
+
+ }
+ return false;
+ }
+
+ public Environment getEnvironment()
+ {
+ return env;
+ }
+
+
+}
+
Added:
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/model/CompatibilityTestCase.java
===================================================================
---
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/model/CompatibilityTestCase.java
(rev 0)
+++
src/server/trunk/server-service/server-model/src/test/java/org/jboss/portletswap/model/CompatibilityTestCase.java 2008-02-01
13:28:54 UTC (rev 227)
@@ -0,0 +1,214 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portletswap.model;
+
+import org.jboss.portletswap.model.compatibility.CompatibilityInconsistencyException;
+import org.jboss.portletswap.model.compatibility.CompatibilityLevel;
+import org.jboss.portletswap.model.compatibility.Environment;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentCompatibility;
+import org.jboss.portletswap.model.compatibility.SameEnvironmentIncompatibility;
+import org.jboss.portletswap.model.compatibility.Compatibility.Limit;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CompatibilityTestCase extends TestCase
+{
+
+ public void testSimple() throws CompatibilityInconsistencyException
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+ artifact.setCompatibilityList(compatibilityList);
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ CompatibilityLevel compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ assertEquals(CompatibilityLevel.UNKNOWN_LEVEL_VALUE,
compatibilityLevel.getCompatibilityValue());
+ }
+
+ public void testExactVersion() throws CompatibilityInconsistencyException
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ Environment compatible = env;
+ SameEnvironmentCompatibility envCompatibility = new
SameEnvironmentCompatibility(compatible);
+
+ compatibilityList.add(envCompatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ CompatibilityLevel compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ assertEquals(CompatibilityLevel.COMPATIBLE_LEVEL_VALUE,
compatibilityLevel.getCompatibilityValue());
+ }
+
+ public void testExactVersionIncompatibility() throws
CompatibilityInconsistencyException
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ Environment incompatible = env;
+ SameEnvironmentIncompatibility envIncompatibility = new
SameEnvironmentIncompatibility(incompatible);
+
+ compatibilityList.add(envIncompatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ CompatibilityLevel compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ assertEquals(CompatibilityLevel.INCOMPATIBLE_LEVEL_VALUE,
compatibilityLevel.getCompatibilityValue());
+ }
+
+
+ public void testInconsistencyVersion()
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ Environment compatible = env;
+ SameEnvironmentCompatibility envCompatibility = new
SameEnvironmentCompatibility(compatible);
+ compatibilityList.add(envCompatibility);
+
+ SameEnvironmentIncompatibility envIncompatibility = new
SameEnvironmentIncompatibility(compatible);
+ compatibilityList.add(envIncompatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ boolean exception = false;
+ CompatibilityLevel compatibilityLevel = null;
+ try
+ {
+ compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ }
+ catch (CompatibilityInconsistencyException e)
+ {
+ exception = true;
+ }
+ assertTrue(exception);
+ assertNull(compatibilityLevel);
+ }
+
+ public void testExactVersionIncompatibility2() throws
CompatibilityInconsistencyException
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ Version asVersion2 = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion2 = new Version(2, 6, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion2 = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment incompatible = new Environment();
+ incompatible.setAsVersion(asVersion2);
+ incompatible.setJbpVersion(jbpVersion2);
+ incompatible.setJdkVersion(jdkVersion2);
+
+ SameEnvironmentIncompatibility envIncompatibility = new
SameEnvironmentIncompatibility(incompatible);
+
+ compatibilityList.add(envIncompatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ CompatibilityLevel compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ assertEquals(CompatibilityLevel.UNKNOWN_LEVEL_VALUE,
compatibilityLevel.getCompatibilityValue());
+ }
+
+ public void testExactVersionIncompatibility3() throws
CompatibilityInconsistencyException
+ {
+ Artifact artifact = new FileArtifact();
+ CompatibilityList compatibilityList = new CompatibilityList();
+
+ Version asVersion = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion = new Version(2, 6, 3, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment env = new Environment();
+ env.setAsVersion(asVersion);
+ env.setJbpVersion(jbpVersion);
+ env.setJdkVersion(jdkVersion);
+
+ Version asVersion2 = new Version(4, 2, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jbpVersion2 = new Version(2, 6, 2, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+ Version jdkVersion2 = new Version(1, 5, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA));
+
+ Environment incompatible = new Environment();
+ incompatible.setAsVersion(asVersion2);
+ incompatible.setJbpVersion(jbpVersion2);
+ incompatible.setJdkVersion(jdkVersion2);
+
+ SameEnvironmentIncompatibility envIncompatibility = new
SameEnvironmentIncompatibility(incompatible, Limit.QUALIFIER, Limit.MINOR,
Limit.QUALIFIER);
+
+ compatibilityList.add(envIncompatibility);
+
+ artifact.setCompatibilityList(compatibilityList);
+
+ CompatibilityLevel compatibilityLevel =
artifact.getCompatibilityList().getCompatibilityLevel(env);
+ assertEquals(CompatibilityLevel.INCOMPATIBLE_LEVEL_VALUE,
compatibilityLevel.getCompatibilityValue());
+ }
+}
+