/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4109103
* @summary rmid should annotate child process output
*
* @author Laird Dornin; code borrowed from Ann Wollrath
*
* @library ../../../testlibrary
* @build TestLibrary RMID MyRMI CheckAnnotations_Stub
* @run main/othervm/policy=security.policy/timeout=480 CheckAnnotations
*/
public class CheckAnnotations
{
// buffers to store rmid output.
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
try {
// Set security manager according to the
// testlibrary.
// start an rmid.
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// activation groups
p.put("java.security.policy",
p.put("java.security.manager",
/* new desc - we will reuse in order to get multiple vms.*/
new ActivationGroupDesc(p, null);
/* The test-
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
for (int i = 0; i < 3; i++) {
// object activated in annotation check via method call
if(!checkAnnotations(i-1)) {
}
/*
* Clean up object too.
*/
("Deactivate object via method call");
}
("\nsuccess: CheckAnnotations test passed ");
} catch (Exception e) {
} finally {
try {
} catch (InterruptedException e) {
}
}
}
/**
* check to make sure that the output from a spawned vm is
*/
throws IOException
{
try {
} catch(Exception e) {
}
/**
* cause the spawned vm to generate output that will
* be checked for proper annotation. printOut is
* actually being called on an activated implementation.
*/
/* we have to wait for output to filter down
* from children so we can read it before we
* kill rmid.
*/
for (int i = 0 ; i < 5 ; i ++ ) {
// have to give output from rmid time to trickle down to
// this process
try {
} catch(InterruptedException e) {
}
{
break;
}
}
// only test when we are annotating..., first run does not annotate
if (iteration >= 0) {
while (stOut.hasMoreTokens()) {
}
while (stErr.hasMoreTokens()) {
}
return false;
}
return false;
}
// just make sure that last two strings are what we expect.
iteration)) ) {
return true;
} else {
return false;
}
}
return true;
}
// implementation of MyRMI, make this object activatable.
public CheckAnnotations
throws RemoteException {
super(id,0);
}
}
}
/**
* Spawns a thread to deactivate the object.
*/
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* unexport the object forcibly.
*/
public void run() {
}
}