You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:19:20 UTC

[sling-org-apache-sling-testing-osgi-mock] 09/17: SLING-4771 Osgi Mock: Allow to set mock bundle symbolic name

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-1.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit f4513f87e006f1208a2d7959f417b72b25033d3c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jun 2 21:25:07 2015 +0000

    SLING-4771 Osgi Mock: Allow to set mock bundle symbolic name
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1683189 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/testing/mock/osgi/MockBundle.java | 18 +++++++++++++-----
 .../apache/sling/testing/mock/osgi/MockBundleTest.java |  8 ++++++--
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
index be17da0..9159f6a 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
@@ -44,6 +44,7 @@ public final class MockBundle implements Bundle {
     private final long bundleId;
     private final BundleContext bundleContext;
     private Map<String, String> headers = ImmutableMap.<String, String>of();
+    private String symbolicName = "mock-bundle";
 
     /**
      * Constructor
@@ -93,6 +94,18 @@ public final class MockBundle implements Bundle {
         this.headers = value;
     }
 
+    @Override
+    public String getSymbolicName() {
+        return this.symbolicName;
+    }
+
+    /**
+     * Set symbolic name for mock bundle
+     * @param value Symbolic name
+     */
+    public void setSymbolicName(String value) {
+        this.symbolicName = value;
+    }
     
     // --- unsupported operations ---
     @Override
@@ -136,11 +149,6 @@ public final class MockBundle implements Bundle {
     }
 
     @Override
-    public String getSymbolicName() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public boolean hasPermission(final Object permission) {
         throw new UnsupportedOperationException();
     }
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
index 3ab4ebe..ccce6ad 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
@@ -61,11 +61,15 @@ public class MockBundleTest {
 
     @Test
     public void testGetHeaders() {
-        assertTrue(bundle.getHeaders().isEmpty());
-        
         ((MockBundle)bundle).setHeaders(ImmutableMap.of("prop1", "value1"));
         assertEquals("value1", bundle.getHeaders().get("prop1"));
         assertEquals("value1", bundle.getHeaders("en").get("prop1"));
     }
 
+    @Test
+    public void testGetSymbolicName() throws Exception {
+        ((MockBundle)bundle).setSymbolicName("name-1");
+        assertEquals("name-1", bundle.getSymbolicName());
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.