package org.apache.commons.bcel6;

import junit.framework.TestCase;
import org.apache.commons.bcel6.*;
import org.apache.commons.bcel6.classfile.Signature;
import org.apache.commons.bcel6.classfile.Utility;
import org.apache.commons.bcel6.generic.Type;

public class PLSE2TestCase extends AbstractTestCase {

    public void testSignatureToStringWithGenerics() throws Exception {

    // tests for BCEL-197
        
        String expectedValue = "java.util.Map<X, java.util.List<Y>>";
        String actualValue = Utility.signatureToString("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;");
        assertEquals("generic signature", expectedValue, actualValue);
        //System.out.printf("U: %s%nS: %s%n", actualValue, Signature.translate("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;"));

        expectedValue = "java.util.Set<? extends java.nio.file.OpenOption>";
        actualValue = Utility.signatureToString("Ljava/util/Set<+Ljava/nio/file/OpenOption;>;");
        assertEquals("generic signature", expectedValue, actualValue);
        //System.out.printf("U: %s%nS: %s%n", actualValue, Signature.translate("Ljava/util/Set<+Ljava/nio/file/OpenOption;>;"));

        expectedValue = "java.nio.file.attribute.FileAttribute<?>...[]";
        actualValue = Utility.signatureToString("[Ljava/nio/file/attribute/FileAttribute<*>;");
        assertEquals("generic signature", expectedValue, actualValue);
        //System.out.printf("U: %s%nS: %s%n", actualValue, Signature.translate("[Ljava/nio/file/attribute/FileAttribute<*>;"));
        //System.out.printf("U: %s%nS: %s%n", actualValue, Signature.translate("Ljava/nio/file/attribute/FileAttribute<*>;"));

    // test for BCEL-243
        
        // expectedValue = "Ljava/util/Map<TX;Ljava/util/List<TY;>;>;";
        // The line commented out above is the correct expected value; however,
        // the constructor for ObjectType is yet another place where BCEL does
        // not understand generics so we need to substitute the modified value below.
        expectedValue = "Ljava/util/Map<X, java/util/List<Y>>;";
        actualValue = (Type.getType("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;")).getSignature();
        assertEquals("Type.getType", expectedValue, actualValue);
    }

}

@@ -12,29 +12,20 @@
 .apache.
-commons.
 bcel
-6
 ;%0A%0Aimpor
@@ -70,29 +70,20 @@
 .apache.
-commons.
 bcel
-6
 .*;%0Aimpo
@@ -92,37 +92,28 @@
  org.apache.
-commons.
 bcel
-6
 .classfile.S
@@ -140,29 +140,20 @@
 .apache.
-commons.
 bcel
-6
 .classfi
@@ -186,21 +186,12 @@
 che.
-commons.
 bcel
-6
 .gen

correct package names