Fix for npe found in FELIX-2159 missing ()'s
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@918229 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExportTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExportTest.java
new file mode 100644
index 0000000..5748841
--- /dev/null
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExportTest.java
@@ -0,0 +1,43 @@
+package org.apache.felix.sigil.core.internal.model.osgi;
+
+import org.osgi.framework.Version;
+
+import junit.framework.TestCase;
+
+public class PackageExportTest extends TestCase
+{
+ public PackageExportTest( String name )
+ {
+ super( name );
+ }
+
+ public void testEquals() {
+ PackageExport p1 = new PackageExport();
+ p1.setPackageName("foo");
+ p1.setVersion(Version.parseVersion("1.0.0"));
+
+ PackageExport p2 = new PackageExport();
+ p2.setPackageName("foo");
+ p2.setVersion(Version.parseVersion("1.0.0"));
+
+ assertTrue( p1.equals( p2 ) );
+ assertTrue( p2.equals( p1 ) );
+
+ PackageExport p3 = new PackageExport();
+ p3.setPackageName("foo");
+
+ assertFalse( p1.equals( p3 ) );
+ assertFalse( p3.equals( p1 ) );
+
+ PackageExport p4 = new PackageExport();
+ p4.setVersion(Version.parseVersion("1.0.0"));
+
+ assertFalse( p1.equals( p4 ) );
+ assertFalse( p4.equals( p1 ) );
+
+ PackageExport p5 = new PackageExport();
+ assertFalse( p1.equals( p5 ) );
+ assertFalse( p5.equals( p1 ) );
+
+ }
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExport.java b/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExport.java
index 4520113..1a1942e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageExport.java
@@ -175,8 +175,8 @@
if ( obj == this ) return true;
try {
PackageExport e = (PackageExport) obj;
- return name == null ? e.name == null : name.equals( e.name ) &&
- version == null ? e.version == null : version.equals( e.version );
+ return (name == null ? e.name == null : name.equals( e.name )) &&
+ (version == null ? e.version == null : version.equals( e.version ));
}
catch (ClassCastException e) {
return false;