felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1736040 - in /felix/trunk/gogo/runtime/src: main/java/org/apache/felix/gogo/runtime/Expander.java test/java/org/apache/felix/gogo/runtime/TestTokenizer.java
Date Mon, 21 Mar 2016 16:57:59 GMT
Author: gnodet
Date: Mon Mar 21 16:57:58 2016
New Revision: 1736040

URL: http://svn.apache.org/viewvc?rev=1736040&view=rev
Log:
Support for raw variables

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java?rev=1736040&r1=1736039&r2=1736040&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java Mon
Mar 21 16:57:58 2016
@@ -76,6 +76,7 @@ public class Expander extends BaseTokeni
     private boolean semanticJoin;
     private boolean unquote;
     private boolean asPattern;
+    private boolean rawVariable;
 
     public Expander(CharSequence text, Evaluate evaluate,
                     boolean inQuote,
@@ -113,6 +114,9 @@ public class Expander extends BaseTokeni
     private Object expand() throws Exception
     {
         Object expanded = doExpand();
+        if (rawVariable) {
+            return expanded;
+        }
         Stream<Object> stream = expanded instanceof Collection
                 ? asCollection(expanded).stream()
                 : Stream.of(expanded);
@@ -849,6 +853,7 @@ public class Expander extends BaseTokeni
                 {
                     String name = text.subSequence(start, index - 1).toString();
                     val = evaluate.get(name);
+                    rawVariable = true;
                 }
             }
         }

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java?rev=1736040&r1=1736039&r2=1736040&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java
(original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java
Mon Mar 21 16:57:58 2016
@@ -38,7 +38,9 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
@@ -181,6 +183,16 @@ public class TestTokenizer
     }
 
     @Test
+    public void testRawVariable() throws Exception
+    {
+        vars.put("a1", Arrays.asList("a", 1));
+
+        assertSame(vars.get("a1"), expand("$a1"));
+        assertNotSame(vars.get("a1"), expand("${a1}"));
+        assertEquals(vars.get("a1"), expand("${a1}"));
+    }
+
+    @Test
     public void testSubscripts() throws Exception
     {
         Map<String, String> map = new LinkedHashMap<>();



Mime
View raw message