1#!/bin/sh
2#
3# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5#
6# This code is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License version 2 only, as
8# published by the Free Software Foundation.
9#
10# This code is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13# version 2 for more details (a copy is included in the LICENSE file that
14# accompanied this code).
15#
16# You should have received a copy of the GNU General Public License version
17# 2 along with this work; if not, write to the Free Software Foundation,
18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19#
20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21# or visit www.oracle.com if you need additional information or have any
22# questions.
23#
24
25# @test  
26# @bug 5036554 6357706
27# @summary unmarshal error on CORBA alias type in CORBA any
28# @run shell TestCorbaBug.sh
29
30if [ "${TESTSRC}" = "" ]
31then TESTSRC=.
32fi
33
34if [ "${TESTJAVA}" = "" ]
35then
36  PARENT=`dirname \`which java\``
37  TESTJAVA=`dirname ${PARENT}`
38  echo "TESTJAVA not set, selecting " ${TESTJAVA}
39  echo "If this is incorrect, try setting the variable manually."
40fi
41
42if [ "${TESTCLASSES}" = "" ]
43then
44  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
45  exit 1
46fi
47
48# set platform-dependent variables
49OS=`uname -s`
50case "$OS" in
51  SunOS | Linux | Darwin | AIX )
52    PS=":"
53    FS="/"
54    ;;
55  CYGWIN* )
56    PS=";"
57    FS="/"
58    ;;
59  Windows* )
60    PS=";"
61    FS="\\"
62    ;;
63  * )
64    echo "Unrecognized system!"
65    exit 1;
66    ;;
67esac
68
69CLASSPATH=.${PS}${TESTCLASSES}; export CLASSPATH
70
71THIS_DIR=`pwd`
72
73${TESTJAVA}${FS}bin${FS}java -version
74
75mkdir bug
76
77cp ${TESTSRC}${FS}bug.idl .
78${COMPILEJAVA}${FS}bin${FS}idlj bug.idl
79
80cp ${TESTSRC}${FS}JavaBug.java bug
81
82chmod -fR 777 bug
83
84${COMPILEJAVA}${FS}bin${FS}javac --add-modules java.corba -d . bug${FS}*.java
85
86${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} --add-modules java.corba -cp . bug/JavaBug > test.out 2>&1 
87
88grep "NullPointerException" test.out
89
90ERROR=$?
91
92cat test.out
93
94if [ $ERROR = 0 ]
95then
96    echo "Test Failed"
97    exit 1
98fi
99
100grep "Any: hello" test.out
101
102STATUS=$?
103
104if [ $STATUS = 0 ]
105then
106    echo "Test Passed"
107    exit 0
108else
109    echo "Invalid output"
110    cat test.out
111    exit 2
112fi
113