test/jdk/com/sun/jdi/sde/SourceDebugExtensionTest.java
author amenkov
Fri, 12 Oct 2018 10:08:11 -0700
changeset 52110 65efb9c57fef
parent 47216 71c04702a3d5
permissions -rw-r--r--
8195703: BasicJDWPConnectionTest.java: 'App exited unexpectedly with 2' Reviewed-by: sspitsyn, jcbeyler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/**
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     2
 * @test
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     3
 * @bug 4390869
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     4
 * @bug 4460328
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     5
 * @summary Test the new SourceDebugExtension facility
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     6
 * @author Robert Field
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
     8
 * @library ..
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    10
 * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    11
 * @run compile SourceDebugExtensionTest.java
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    12
 * @run compile -g SourceDebugExtensionTarg.java
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    13
 * @run driver SourceDebugExtensionTest
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
public class SourceDebugExtensionTest extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
    SourceDebugExtensionTest (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
    public static void main(String[] args)      throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
        testSetUp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
        new SourceDebugExtensionTest(args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    /********** test set-up **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    static void testSetUp() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        InstallSDE.install(new File(System.getProperty("test.classes", "."),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
                                    "SourceDebugExtensionTarg.class"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
                           new File(System.getProperty("test.src", "."),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
                                    "testString"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    protected void runTests() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
         * Get to the top of main()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
         * to determine targetClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        BreakpointEvent bpe = startToMain("SourceDebugExtensionTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        if (!vm().canGetSourceDebugExtension()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            failure("FAIL: canGetSourceDebugExtension() is false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            println("canGetSourceDebugExtension() is true");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        String expected = "An expected attribute string";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        String sde = targetClass.sourceDebugExtension();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        if (!sde.equals(expected)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            failure("FAIL: got '" + sde +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                    "' expected: '" + expected + "'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
         * resume the target listening for events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        listenUntilVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
         * deal with results of test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
         * if anything has called failure("foo") testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            println("SourceDebugExtensionTest: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            throw new Exception("SourceDebugExtensionTest: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
}