Index: lucene/CHANGES.txt
===================================================================
--- lucene/CHANGES.txt	(revision 1188625)
+++ lucene/CHANGES.txt	(working copy)
@@ -724,6 +724,10 @@
   for implementing subclasses in different packages, where assertions are not
   enabled. (Uwe Schindler)
 
+* LUCENE-3506: tests relying on assertions being enabled were no-op because
+  they ignored AssertionError. With this fix now entire test framework 
+  (all tests) fail if assertions are disabled. (Doron Cohen)
+  
 ======================= Lucene 3.4.0 =======================
 
 Bug fixes
Index: lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java	(revision 1188625)
+++ lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java	(working copy)
@@ -146,12 +146,14 @@
     
     // Assert that SM fails if .del exists
     SegmentMerger sm = new SegmentMerger(dir, 1, "a", null, null, null, newIOContext(random));
+    boolean doFail = false;
     try {
       sm.createCompoundFile("b1", w.segmentInfos.info(0), newIOContext(random));
-      fail("should not have been able to create a .cfs with .del and .s* files");
+      doFail = true; // should never get here
     } catch (AssertionError e) {
       // expected
     }
+    assertFalse("should not have been able to create a .cfs with .del and .s* files", doFail);
     
     // Create an index w/ .s*
     w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
@@ -164,12 +166,15 @@
     r.close();
     
     // Assert that SM fails if .s* exists
+    SegmentInfos sis = new SegmentInfos();
+    sis.read(dir);
     try {
-      sm.createCompoundFile("b2", w.segmentInfos.info(0), newIOContext(random));
-      fail("should not have been able to create a .cfs with .del and .s* files");
+      sm.createCompoundFile("b2", sis.info(0), newIOContext(random));
+      doFail = true; // should never get here
     } catch (AssertionError e) {
       // expected
     }
+    assertFalse("should not have been able to create a .cfs with .del and .s* files", doFail);
 
     dir.close();
   }
Index: lucene/src/test/org/apache/lucene/TestAssertions.java
===================================================================
--- lucene/src/test/org/apache/lucene/TestAssertions.java	(revision 1188625)
+++ lucene/src/test/org/apache/lucene/TestAssertions.java	(working copy)
@@ -17,55 +17,14 @@
  * limitations under the License.
  */
 
-import java.io.Reader;
-
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 
+/**
+ * validate that assertions are enabled during tests
+ */
 public class TestAssertions extends LuceneTestCase {
 
-  public void testBasics() {
-    try {
-      assert Boolean.FALSE.booleanValue();
-      fail("assertions are not enabled!");
-    } catch (AssertionError e) {
-      assert Boolean.TRUE.booleanValue();
-    }
-  }
-  
-  static class TestAnalyzer1 extends Analyzer {
-
-    @Override
-    protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
-      return null;
-    }
-  }
-
-  static final class TestAnalyzer2 extends Analyzer {
-
-    @Override
-    protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
-      return null;
-    }
-  }
-
-  static class TestAnalyzer3 extends Analyzer {
-
-    @Override
-    protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
-      return null;
-    }
-  }
-
-  static class TestAnalyzer4 extends Analyzer {
-
-    @Override
-    protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
-      return null;
-    }
-  }
-
   static class TestTokenStream1 extends TokenStream {
     @Override
     public final boolean incrementToken() { return false; }
@@ -82,31 +41,15 @@
   }
 
   public void testTokenStreams() {
-    new TestAnalyzer1();
-    
-    new TestAnalyzer2();
-    
-    try {
-      new TestAnalyzer3();
-      fail("TestAnalyzer3 should fail assertion");
-    } catch (AssertionError e) {
-    }
-    
-    try {
-      new TestAnalyzer4();
-      fail("TestAnalyzer4 should fail assertion");
-    } catch (AssertionError e) {
-    }
-    
     new TestTokenStream1();
-    
     new TestTokenStream2();
-    
+    boolean doFail = false;
     try {
       new TestTokenStream3();
-      fail("TestTokenStream3 should fail assertion");
+      doFail = true;
     } catch (AssertionError e) {
+      // expected
     }
+    assertFalse("TestTokenStream3 should fail assertion", doFail);
   }
-
 }
Index: lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java	(revision 1188625)
+++ lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java	(working copy)
@@ -400,6 +400,9 @@
     TimeZone.setDefault(timeZone);
     similarityProvider = new RandomSimilarityProvider(random);
     testsFailed = false;
+    
+    // verify assertions are enabled (do last, for smooth cleanup)
+    assertTrue("assertions are not enabled!", assertionsEnabled());
   }
 
   @AfterClass
@@ -1442,4 +1445,15 @@
 
   @Ignore("just a hack")
   public final void alwaysIgnoredTestMethod() {}
+  
+  /** check if assertions are enabled */
+  private static boolean assertionsEnabled() {
+    try {
+      assert Boolean.FALSE.booleanValue();
+      return false; // should never get here
+    } catch (AssertionError e) {
+      return true;
+    }
+  }
+  
 }
