nashorn/test/script/trusted/JDK-8141209.js
author aefimov
Tue, 10 Jan 2017 22:15:54 +0300
changeset 43126 26c4004e8cc0
parent 42961 339ad1309506
permissions -rw-r--r--
8159058: SAXParseException when sending soap message Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42961
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     1
/*
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     4
 *
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     7
 * published by the Free Software Foundation.
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     8
 *
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    13
 * accompanied this code).
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    14
 *
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    18
 *
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    21
 * questions.
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    22
 */
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    23
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    24
/**
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    25
 * JDK-8141209 : $EXEC should allow streaming
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    26
 *
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    27
 * @test
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    28
 * @fork
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    29
 * @option -scripting
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    30
 * @run
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    31
 */
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    32
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    33
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    34
var System = Java.type("java.lang.System");
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    35
var File = Java.type("java.io.File");
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    36
var ByteArrayInputStream = Java.type("java.io.ByteArrayInputStream");
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    37
var ByteArrayOutputStream = Java.type("java.io.ByteArrayOutputStream");
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    38
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    39
var input = <<<EOD
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    40
There was an Old Man with a beard,
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    41
Who said, It is just as I feared!
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    42
Two Owls and a Hen,
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    43
Four Larks and a Wren,
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    44
Have all built their nests in my beard!
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    45
EOD
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    46
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    47
function tempFile() {
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    48
    return File.createTempFile("JDK-8141209", ".txt").toString();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    49
}
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    50
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    51
`ls -l / | sed > ${tempFile()} -e '/^d/ d'`
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    52
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    53
$EXEC(["ls", "-l", "|", "sed", "-e", "/^d/ d", ">", tempFile()])
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    54
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    55
var t1 = tempFile();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    56
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    57
$EXEC(<<<EOD)
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    58
ls -l >${t1}
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    59
sed <${t1} >${tempFile()} -e '/^d/ d'
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    60
EOD
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    61
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    62
$EXEC(<<<EOD, `ls -l`)
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    63
sed >${tempFile()} -e '/^d/ d'
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    64
EOD
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    65
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    66
var instream = new ByteArrayInputStream(input.getBytes());
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    67
var outstream = new ByteArrayOutputStream();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    68
var errstream = new ByteArrayOutputStream();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    69
$EXEC("sed -e '/beard/ d'", instream, outstream, errstream);
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    70
var out = outstream.toString();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    71
var err = errstream.toString();
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    72
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    73
instream = new ByteArrayInputStream(input.getBytes());
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    74
$EXEC("sed -e '/beard/ d'", instream, System.out, System.err);
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    75
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    76
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    77
$EXEC(<<<EOD)
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    78
cd .
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    79
setenv TEMP 0
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    80
unsetenv TEMP
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    81
EOD
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    82
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    83
$ENV.JJS_THROW_ON_EXIT = "1";
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    84
$ENV.JJS_TIMEOUT = "1000";
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    85
$ENV.JJS_ECHO = "1";
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    86
$ENV.JJS_INHERIT_IO = "1";
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    87
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    88
$EXEC("echo hello world", instream);
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    89
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    90
339ad1309506 8151994: test/script/basic/JDK-8141209.js fails
sdama
parents:
diff changeset
    91