incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r731914 - in /incubator/sling/trunk/extensions/jcrinstall/service/src: main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/
Date Tue, 06 Jan 2009 11:21:02 GMT
Author: bdelacretaz
Date: Tue Jan  6 03:20:58 2009
New Revision: 731914

URL: http://svn.apache.org/viewvc?rev=731914&view=rev
Log:
SLING-810 - _jcr_config_path property added to Configurations created by jcrinstall

Added:
    incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
  (contents, props changed)
      - copied, changed from r731907, incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
    incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
  (with props)
Modified:
    incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/MockInstallableData.java

Copied: incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
(from r731907, incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java?p2=incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java&p1=incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java&r1=731907&r2=731914&rev=731914&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
Tue Jan  6 03:20:58 2009
@@ -39,6 +39,7 @@
 public class ConfigResourceProcessor implements OsgiResourceProcessor {
 
     private static final String ALIAS_KEY = "_alias_factory_pid";
+    public static final String CONFIG_PATH_KEY = "_jcr_config_path";
     public static final String CONFIG_EXTENSION = ".cfg";
     private final ConfigurationAdmin configurationAdmin;
     private final Logger log = LoggerFactory.getLogger(this.getClass());
@@ -80,6 +81,9 @@
     	if(dict == null) {
     		throw new JcrInstallException("Null Dictionary for uri=" + uri);
     	}
+    	
+    	// Add pseudo-properties
+    	dict.put(CONFIG_PATH_KEY, uri);
         
         // Get pids from node name
         final ConfigurationPid pid = new ConfigurationPid(uri);

Propchange: incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Propchange: incubator/sling/trunk/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java?rev=731914&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
(added)
+++ incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
Tue Jan  6 03:20:58 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.sling.jcr.jcrinstall.osgi.impl;
+
+import java.util.Dictionary;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+public class ConfigResourceProcessorTest {
+    
+    private Mockery mockery;
+    
+    @org.junit.Before public void setup() {
+        mockery = new Mockery();
+    }
+    
+    @org.junit.Test public void testConfigPathProperty() throws Exception {
+        final String path = "/foo/bar/config/somenode";
+        final String data = "foo = bar";
+        final MockInstallableData id = new MockInstallableData(path, data);
+        final ConfigurationAdmin ca = mockery.mock(ConfigurationAdmin.class);
+        final ConfigResourceProcessor p = new ConfigResourceProcessor(ca);
+        final Configuration c = mockery.mock(Configuration.class);
+        final String pid = "dummyConfigPid";
+        
+        final Matcher<Dictionary<?,?>> matcher = new BaseMatcher<Dictionary<?,?>>
() {
+
+            public boolean matches(Object item) {
+                final Dictionary<?, ?> d = (Dictionary<?, ?>)item;
+                boolean result = "bar".equals(d.get("foo"));
+                result &= path.equals(d.get("_jcr_config_path"));
+                return result;
+            }
+
+            public void describeTo(Description description) {
+                description.appendText("Config Dictionary contains foo and _jcr_config_path
properties");
+            }
+        };
+        
+        mockery.checking(new Expectations() {{
+            allowing(ca).getConfiguration(with(any(String.class)), with(any(String.class)));
+            will(returnValue(c));
+            allowing(c).getPid();
+            will(returnValue(pid));
+            allowing(c).getBundleLocation();
+            will(returnValue(null));
+            allowing(c).update(with(matcher));
+        }});
+        
+        p.installOrUpdate(path, null, id);
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/MockInstallableData.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/MockInstallableData.java?rev=731914&r1=731913&r2=731914&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/MockInstallableData.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/MockInstallableData.java
Tue Jan  6 03:20:58 2009
@@ -12,8 +12,12 @@
 	private String digest;
 	private static int counter;
 	
-	public MockInstallableData(String uri) {
-        inputStream = new ByteArrayInputStream(uri.getBytes());
+    public MockInstallableData(String uri) {
+        this(uri, uri);
+    }
+    
+	public MockInstallableData(String uri, String data) {
+        inputStream = new ByteArrayInputStream(data.getBytes());
         lastModified = System.currentTimeMillis() + counter;
         counter++;
         digest = String.valueOf(lastModified);



Mime
View raw message