Author: mhermanto
Date: Tue Apr  5 03:21:08 2011
New Revision: 1088874

URL: http://svn.apache.org/viewvc?rev=1088874&view=rev
Log:
Fix separator commenting between two neighboring/same feature bundles.

Modified:
    
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessor.java
    
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessorTest.java

Modified: 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessor.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessor.java?rev=1088874&r1=1088873&r2=1088874&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessor.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessor.java
 Tue Apr  5 03:21:08 2011
@@ -35,7 +35,7 @@ public class SeparatorCommentingProcesso
         jsBuilder.add(newComment(feature, true));
 
       // Entering a new feature, from another feature.
-      } else if (lastFeature != null && feature != null) {
+      } else if (lastFeature != null && feature != null && lastFeature != 
feature) {
         jsBuilder.add(newComment(lastFeature, false));
         jsBuilder.add(newComment(feature, true));
 

Modified: 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessorTest.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessorTest.java?rev=1088874&r1=1088873&r2=1088874&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessorTest.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/SeparatorCommentingProcessorTest.java
 Tue Apr  5 03:21:08 2011
@@ -34,7 +34,7 @@ import java.util.List;
 
 public class SeparatorCommentingProcessorTest {
   private static final List<String> ERRORS = ImmutableList.<String>of();
-  
+
   private IMocksControl control;
   private SeparatorCommentingProcessor processor;
   private JsResponse response;
@@ -44,11 +44,11 @@ public class SeparatorCommentingProcesso
     control = createControl();
     processor = new SeparatorCommentingProcessor();
   }
-  
+
   @Test
   public void testNoFeature() throws Exception {
     JsResponseBuilder builder = newBuilder();
-    
+
     control.replay();
     boolean actualReturn = processor.process(null, builder);
     JsResponse actualResponse = builder.build();
@@ -57,12 +57,12 @@ public class SeparatorCommentingProcesso
     assertTrue(actualReturn);
     assertEquals("", actualResponse.toJsString());
   }
-  
+
   @Test
   public void testOneFeature() throws Exception {
     JsContent js = JsContent.fromFeature("content", null, 
mockBundle("bundle"), null);
     JsResponseBuilder builder = newBuilder(js);
-    
+
     control.replay();
     boolean actualReturn = processor.process(null, builder);
     JsResponse actualResponse = builder.build();
@@ -75,12 +75,12 @@ public class SeparatorCommentingProcesso
         "\n/* [end] feature=bundle */\n",
         actualResponse.toJsString());
   }
-  
+
   @Test
   public void testOneText() throws Exception {
     JsContent text1 = JsContent.fromText("text1", null);
     JsResponseBuilder builder = newBuilder(text1);
-    
+
     control.replay();
     boolean actualReturn = processor.process(null, builder);
     JsResponse actualResponse = builder.build();
@@ -95,7 +95,7 @@ public class SeparatorCommentingProcesso
     JsContent js1 = JsContent.fromFeature("content1", null, 
mockBundle("bundle1"), null);
     JsContent js2 = JsContent.fromFeature("content2", null, 
mockBundle("bundle2"), null);
     JsResponseBuilder builder = newBuilder(js1, js2);
-    
+
     control.replay();
     boolean actualReturn = processor.process(null, builder);
     JsResponse actualResponse = builder.build();
@@ -111,7 +111,28 @@ public class SeparatorCommentingProcesso
         "\n/* [end] feature=bundle2 */\n",
         actualResponse.toJsString());
   }
-  
+
+  @Test
+  public void testNeighboringSameFeatures() throws Exception {
+    FeatureBundle bundle = mockBundle("bundle");
+    JsContent js1 = JsContent.fromFeature("content1", null, bundle, null);
+    JsContent js2 = JsContent.fromFeature("content2", null, bundle, null);
+    JsResponseBuilder builder = newBuilder(js1, js2);
+
+    control.replay();
+    boolean actualReturn = processor.process(null, builder);
+    JsResponse actualResponse = builder.build();
+
+    control.verify();
+    assertTrue(actualReturn);
+    assertEquals(
+        "\n/* [start] feature=bundle */\n" +
+        "content1" +
+        "content2" +
+        "\n/* [end] feature=bundle */\n",
+        actualResponse.toJsString());
+  }
+
   @Test
   public void testMultipleFeaturesWithInBetweenTexts() throws Exception {
     JsContent text1 = JsContent.fromText("text1", null);
@@ -120,7 +141,7 @@ public class SeparatorCommentingProcesso
     JsContent js1 = JsContent.fromFeature("content1", null, 
mockBundle("bundle1"), null);
     JsContent js2 = JsContent.fromFeature("content2", null, 
mockBundle("bundle2"), null);
     JsResponseBuilder builder = newBuilder(text1, js1, text2, js2, text3);
-    
+
     control.replay();
     boolean actualReturn = processor.process(null, builder);
     JsResponse actualResponse = builder.build();
@@ -139,13 +160,13 @@ public class SeparatorCommentingProcesso
         "text3",
         actualResponse.toJsString());
   }
-  
+
   private JsResponseBuilder newBuilder(JsContent... contents) {
     response = new JsResponse(Lists.newArrayList(contents),
         -1, -1, false, ERRORS, null);
     return new JsResponseBuilder(response);
   }
-  
+
   private FeatureBundle mockBundle(String name) {
     FeatureBundle result = control.createMock(FeatureBundle.class);
     expect(result.getName()).andReturn(name).anyTimes();


Reply via email to