// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.DefaultLogger;
import com.intellij.openapi.util.Disposer;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.xml.util.XmlUtil;
import junit.framework.TestCase;

public class XmlUtilTest extends TestCase {

  public void testDecodeEntityRef() {
    Disposable myRoot = Disposer.newDisposable();
    DefaultLogger.disableStderrDumping(myRoot);
    assertEquals('&', XmlUtil.getCharFromEntityRef("&amp;"));
    try {
      UsefulTestCase.assertThrows(AssertionError.class, () -> XmlUtil.getCharFromEntityRef("&unknown;"));
    }
    finally {
      Disposer.dispose(myRoot);
    }
  }
}

@@ -310,58 +310,8 @@
 er;%0A
-import com.intellij.testFramework.UsefulTestCase;%0A
 impo
@@ -461,16 +461,78 @@
 Ref() %7B%0A
+    assertEquals('&', XmlUtil.getCharFromEntityRef(%22&amp;%22));%0A
     Disp
@@ -625,33 +625,27 @@
 t);%0A    
-assertEquals('&',
+try %7B%0A     
  XmlUtil
@@ -672,131 +672,74 @@
 f(%22&
-amp
+unknown
 ;%22)
-)
 ;%0A    
-try %7B%0A      UsefulTestCase.assertThrows(AssertionError.class, () -%3E XmlUtil.getCharFromEntityRef(%22&unknown;%22))
+%7D%0A    catch (AssertionError ignore) %7B%0A      return
 ;%0A  
@@ -794,14 +794,54 @@
 ;%0A    %7D%0A
+    fail(%22Exception should be thrown%22);%0A
   %7D%0A%7D%0A

remove spam from console