sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r915493 - in /sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration: NameValuePairList.java SlingIntegrationTestClient.java
Date Tue, 23 Feb 2010 19:01:23 GMT
Author: justin
Date: Tue Feb 23 19:01:23 2010
New Revision: 915493

URL: http://svn.apache.org/viewvc?rev=915493&view=rev
Log:
SLING-1407 - adding nullcheck and better default alignment with current behavior

Modified:
    sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
    sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java

Modified: sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java?rev=915493&r1=915492&r2=915493&view=diff
==============================================================================
--- sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
(original)
+++ sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/NameValuePairList.java
Tue Feb 23 19:01:23 2010
@@ -30,7 +30,7 @@
     private final List<NameValuePair> delegate;
 
     public NameValuePairList() {
-       delegate = new ArrayList<NameValuePair>();
+        delegate = new ArrayList<NameValuePair>();
     }
 
     public NameValuePairList(List<NameValuePair> init) {
@@ -43,14 +43,16 @@
 
     public NameValuePairList(Map<String, String> clientNodeProperties) {
         this();
-        for (Map.Entry<String,String> e : clientNodeProperties.entrySet()) {
-            add(e.getKey(), e.getValue());
+        if (clientNodeProperties != null) {
+            for (Map.Entry<String, String> e : clientNodeProperties.entrySet()) {
+                add(e.getKey(), e.getValue());
+            }
         }
     }
 
     public void add(String name, String value) {
         delegate.add(new NameValuePair(name, value));
-     }
+    }
 
     public void addIfNew(String name, String value) {
         boolean found = false;
@@ -87,6 +89,12 @@
         }
     }
 
+    public void addOrReplaceAll(NameValuePairList other) {
+        for (NameValuePair nvp : other) {
+            addOrReplace(nvp.getName(), nvp.getValue());
+        }
+    }
+
     public void clear() {
         delegate.clear();
     }
@@ -95,6 +103,22 @@
         return delegate.iterator();
     }
 
+    public void prependIfNew(String name, String value) {
+        boolean found = false;
+        for (ListIterator<NameValuePair> li = delegate.listIterator(); li.hasNext();)
{
+            NameValuePair current = li.next();
+            if (current.getName().equals(name)) {
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            delegate.add(0, new NameValuePair(name, value));
+        }
+
+    }
+
     public int size() {
         return delegate.size();
     }

Modified: sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java?rev=915493&r1=915492&r2=915493&view=diff
==============================================================================
--- sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
(original)
+++ sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
Tue Feb 23 19:01:23 2010
@@ -125,12 +125,14 @@
         NameValuePairList nodeProperties = new NameValuePairList(clientNodeProperties);
 
         // add sling specific properties
-        nodeProperties.addOrReplace(":redirect", "*");
-        nodeProperties.addOrReplace(":displayExtension", "");
-        nodeProperties.addOrReplace(":status", "browser");
+        nodeProperties.prependIfNew(":redirect", "*");
+        nodeProperties.prependIfNew(":displayExtension", "");
+        nodeProperties.prependIfNew(":status", "browser");
 
         // add fake property - otherwise the node is not created
-        nodeProperties.addIfNew("jcr:created", "");
+        if (clientNodeProperties == null) {
+            nodeProperties.add("jcr:created", "");
+        }
 
         // force form encoding to UTF-8, which is what we use to convert the
         // string parts into stream data



Mime
View raw message