-
Bug
-
Resolution: Fixed
-
P3
-
rmi-iiop_fcs, 1.4.0
-
None
-
merlin
-
sparc
-
solaris_1, solaris_2.6
The RMI-IIOP Implementation results in a Class Cast Exception if the Tie classes generated from IONA's rmic compiler which generates the Tie Object to extend
PortableServer.Servant
The test case from CTS is attached.
---
package com.sun.cts.tests.rmiiiop.extension.javax_rmi.CORBA.Util;
import java.io.*;
import java.util.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.CORBA.*;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import javax.rmi.*;
import javasoft.sqe.javatest.*;
import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;
public class CopyObjectsTests extends ServiceEETest implements Serializable
{
private final int arraysize = 5;
private Properties orbProps = null;
/*
* @class.setup_props: org.omg.CORBA.ORBClass;
* java.naming.factory.initial;
* rmiiiop.ORBClass;
* rmiiiop.ORBSingletonClass;
*/
public void setup(String[] args, Properties p) throws Fault
{
//Initial setup
try
{
Context initialNamingContext = new InitialContext();
orbProps = new Properties();
orbProps.put("org.omg.CORBA.ORBClass",
p.getProperty("rmiiiop.ORBClass"));
orbProps.put("org.omg.CORBA.ORBSingletonClass",
p.getProperty("rmiiiop.ORBSingletonClass"));
}catch (ThreadDeath e) {
throw new Fault("setup failed");
}catch (Throwable e) {
throw new Fault("setup failed");
}
}
public void cleanup() throws Fault
{
}
/*
* Run the test and report to stdout/stderr.
*/
public static void main (String args[]) {
Status s;
CopyObjectsTests test = new CopyObjectsTests();
s = test.run(args, System.err, System.out);
s.exit();
}
/**
* CopyObjects0001: Tests copying an array of java.lang.Objects.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0001
* @assertion: Copies or connects an array of objects.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0001() throws Fault
{
boolean pass = false;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
Date da[] = new Date[arraysize];
for(int i = 0; i<da.length; i++)
da[i] = new Date();
BitSet ba[] = new BitSet[arraysize];
for(int i = 0; i<ba.length; i++) {
ba[i] = new BitSet(i+1*10);
ba[i].set(i+1); ba[i].set(i+4); ba[i].set(i+5);
}
Float fa[] = new Float[arraysize];
for(int i = 0; i<fa.length; i++)
fa[i] = new Float(i-3.0);
Integer ia[] = new Integer[arraysize];
for(int i = 0; i<ia.length; i++)
ia[i] = new Integer(i-3);
CallBackImpl cbia[] = new CallBackImpl[arraysize];
for(int i = 0; i<cbia.length; i++)
cbia[i] = new CallBackImpl();
//Copy an array of Date objects
Object da2[] = Util.copyObjects(da, orb);
//Copy an array of BitSet objects
Object ba2[] = Util.copyObjects(ba, orb);
//Copy an array of Float objects
Object fa2[] = Util.copyObjects(fa, orb);
//Copy an array of Integer objects
Object ia2[] = Util.copyObjects(ia, orb);
//Copy an array of remote objects
Object cbia2[] = Util.copyObjects(cbia, orb);
TestUtil.logMsg("BitSet1 = " + ba);
TestUtil.logMsg("BitSet2 = " + ba2);
TestUtil.logMsg("Date1 = " + da);
TestUtil.logMsg("Date2 = " + da2);
TestUtil.logMsg("Float1 = " + fa);
TestUtil.logMsg("Float2 = " + fa2);
TestUtil.logMsg("Integer1 = " + ia);
TestUtil.logMsg("Integer2 = " + ia2);
TestUtil.logMsg("Remote Object = " + cbia);
TestUtil.logMsg("Reference to Remote Object = " + cbia2);
//Verify the data read from copyObjects
if(da2.length != da.length)
TestUtil.logErr("copyObjects() the Date array lengths are not equal");
for(int i = 0; i<da2.length; i++) {
if(!(da2[i] instanceof Date))
TestUtil.logErr("copyObjects() the objects did not contain the copied Date objects array");
else if(!da2[i].equals(da[i]))
TestUtil.logErr("copyObjects() Date objects arrays are not equal");
}
if(ba2.length != ba.length)
TestUtil.logErr("copyObjects() the BitSet array lengths are not equal");
for(int i = 0; i<ba2.length; i++) {
if(!(ba2[i] instanceof BitSet))
TestUtil.logErr("copyObjects() the objects did not contain the copied BitSet objects array");
else if(!ba2[i].equals(ba[i]))
TestUtil.logErr("copyObjects() BitSet objects arrays are not equal");
}
if(ia2.length != ia.length)
TestUtil.logErr("copyObjects() the Integer array lengths are not equal");
for(int i = 0; i<ia2.length; i++) {
if(!(ia2[i] instanceof Integer))
TestUtil.logErr("copyObjects() the objects did not contain the copied Integer objects array");
else if(!ia2[i].equals(ia[i]))
TestUtil.logErr("copyObjects() Integer objects arrays are not equal");
}
if(fa2.length != fa.length)
TestUtil.logErr("copyObjects() the Float array lengths are not equal");
for(int i = 0; i<fa2.length; i++) {
if(!(fa2[i] instanceof Float))
TestUtil.logErr("copyObjects() the objects did not contain the copied Float objects array");
else if(!fa2[i].equals(fa[i]))
TestUtil.logErr("copyObjects() Float objects arrays are not equal");
}
if(cbia2.length != cbia.length)
TestUtil.logErr("copyObjects() the Remote Object array lengths are not equal");
for(int i = 0; i<cbia2.length; i++) {
try {
((CallBackInterface)cbia2[i]).ping();
TestUtil.logMsg("test passed");
pass = true;
} catch (RemoteException e) {
TestUtil.logErr("copyObject() Could not call method on Remote objects");
}
}
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: " + e);
}
if (!pass)
throw new Fault("CopyObjects0001 failed");
}
/**
* CopyObjects0002: Tests passing an array of null objects.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0002
* @assertion: Test passing an array of null objects.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0002() throws Fault
{
boolean pass = true;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
//Try copying an array of null objects
java.lang.Object o[] =
(java.lang.Object[])Util.copyObjects((java.lang.Object[])null, orb);
if(o != null) {
TestUtil.logErr("copyObjects() did not return array of null objects");
pass = false;
}
} catch (NullPointerException e) {
TestUtil.logMsg("NullPointerException received as expected");
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: "+e);
}
if (!pass)
throw new Fault("CopyObjects0002 failed");
}
/**
* CopyObjects0003: Tests passing a null orb.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0003
* @assertion: Test passing a null orb.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0003() throws Fault
{
boolean pass = true;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
//Try copying an array of Date objects to a null orb
Date da[] = new Date[arraysize];
for(int i = 0; i<da.length; i++) {
da[i] = new Date();
Date da2[] = (Date[])Util.copyObjects(da, (org.omg.CORBA.ORB)null);
TestUtil.logErr("copyObjects() did not raise expected NullPointerException");
pass = false;
}
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (NullPointerException e) {
TestUtil.logMsg("NullPointerException received as expected");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: "+e);
}
if (!pass)
throw new Fault("CopyObjects0003 failed");
}
void error (String reason ) throws Fault
{
TestUtil.logErr("An error has occured: " + reason);
throw new Fault(reason);
}
}
PortableServer.Servant
The test case from CTS is attached.
---
package com.sun.cts.tests.rmiiiop.extension.javax_rmi.CORBA.Util;
import java.io.*;
import java.util.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.CORBA.*;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import javax.rmi.*;
import javasoft.sqe.javatest.*;
import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;
public class CopyObjectsTests extends ServiceEETest implements Serializable
{
private final int arraysize = 5;
private Properties orbProps = null;
/*
* @class.setup_props: org.omg.CORBA.ORBClass;
* java.naming.factory.initial;
* rmiiiop.ORBClass;
* rmiiiop.ORBSingletonClass;
*/
public void setup(String[] args, Properties p) throws Fault
{
//Initial setup
try
{
Context initialNamingContext = new InitialContext();
orbProps = new Properties();
orbProps.put("org.omg.CORBA.ORBClass",
p.getProperty("rmiiiop.ORBClass"));
orbProps.put("org.omg.CORBA.ORBSingletonClass",
p.getProperty("rmiiiop.ORBSingletonClass"));
}catch (ThreadDeath e) {
throw new Fault("setup failed");
}catch (Throwable e) {
throw new Fault("setup failed");
}
}
public void cleanup() throws Fault
{
}
/*
* Run the test and report to stdout/stderr.
*/
public static void main (String args[]) {
Status s;
CopyObjectsTests test = new CopyObjectsTests();
s = test.run(args, System.err, System.out);
s.exit();
}
/**
* CopyObjects0001: Tests copying an array of java.lang.Objects.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0001
* @assertion: Copies or connects an array of objects.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0001() throws Fault
{
boolean pass = false;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
Date da[] = new Date[arraysize];
for(int i = 0; i<da.length; i++)
da[i] = new Date();
BitSet ba[] = new BitSet[arraysize];
for(int i = 0; i<ba.length; i++) {
ba[i] = new BitSet(i+1*10);
ba[i].set(i+1); ba[i].set(i+4); ba[i].set(i+5);
}
Float fa[] = new Float[arraysize];
for(int i = 0; i<fa.length; i++)
fa[i] = new Float(i-3.0);
Integer ia[] = new Integer[arraysize];
for(int i = 0; i<ia.length; i++)
ia[i] = new Integer(i-3);
CallBackImpl cbia[] = new CallBackImpl[arraysize];
for(int i = 0; i<cbia.length; i++)
cbia[i] = new CallBackImpl();
//Copy an array of Date objects
Object da2[] = Util.copyObjects(da, orb);
//Copy an array of BitSet objects
Object ba2[] = Util.copyObjects(ba, orb);
//Copy an array of Float objects
Object fa2[] = Util.copyObjects(fa, orb);
//Copy an array of Integer objects
Object ia2[] = Util.copyObjects(ia, orb);
//Copy an array of remote objects
Object cbia2[] = Util.copyObjects(cbia, orb);
TestUtil.logMsg("BitSet1 = " + ba);
TestUtil.logMsg("BitSet2 = " + ba2);
TestUtil.logMsg("Date1 = " + da);
TestUtil.logMsg("Date2 = " + da2);
TestUtil.logMsg("Float1 = " + fa);
TestUtil.logMsg("Float2 = " + fa2);
TestUtil.logMsg("Integer1 = " + ia);
TestUtil.logMsg("Integer2 = " + ia2);
TestUtil.logMsg("Remote Object = " + cbia);
TestUtil.logMsg("Reference to Remote Object = " + cbia2);
//Verify the data read from copyObjects
if(da2.length != da.length)
TestUtil.logErr("copyObjects() the Date array lengths are not equal");
for(int i = 0; i<da2.length; i++) {
if(!(da2[i] instanceof Date))
TestUtil.logErr("copyObjects() the objects did not contain the copied Date objects array");
else if(!da2[i].equals(da[i]))
TestUtil.logErr("copyObjects() Date objects arrays are not equal");
}
if(ba2.length != ba.length)
TestUtil.logErr("copyObjects() the BitSet array lengths are not equal");
for(int i = 0; i<ba2.length; i++) {
if(!(ba2[i] instanceof BitSet))
TestUtil.logErr("copyObjects() the objects did not contain the copied BitSet objects array");
else if(!ba2[i].equals(ba[i]))
TestUtil.logErr("copyObjects() BitSet objects arrays are not equal");
}
if(ia2.length != ia.length)
TestUtil.logErr("copyObjects() the Integer array lengths are not equal");
for(int i = 0; i<ia2.length; i++) {
if(!(ia2[i] instanceof Integer))
TestUtil.logErr("copyObjects() the objects did not contain the copied Integer objects array");
else if(!ia2[i].equals(ia[i]))
TestUtil.logErr("copyObjects() Integer objects arrays are not equal");
}
if(fa2.length != fa.length)
TestUtil.logErr("copyObjects() the Float array lengths are not equal");
for(int i = 0; i<fa2.length; i++) {
if(!(fa2[i] instanceof Float))
TestUtil.logErr("copyObjects() the objects did not contain the copied Float objects array");
else if(!fa2[i].equals(fa[i]))
TestUtil.logErr("copyObjects() Float objects arrays are not equal");
}
if(cbia2.length != cbia.length)
TestUtil.logErr("copyObjects() the Remote Object array lengths are not equal");
for(int i = 0; i<cbia2.length; i++) {
try {
((CallBackInterface)cbia2[i]).ping();
TestUtil.logMsg("test passed");
pass = true;
} catch (RemoteException e) {
TestUtil.logErr("copyObject() Could not call method on Remote objects");
}
}
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: " + e);
}
if (!pass)
throw new Fault("CopyObjects0001 failed");
}
/**
* CopyObjects0002: Tests passing an array of null objects.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0002
* @assertion: Test passing an array of null objects.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0002() throws Fault
{
boolean pass = true;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
//Try copying an array of null objects
java.lang.Object o[] =
(java.lang.Object[])Util.copyObjects((java.lang.Object[])null, orb);
if(o != null) {
TestUtil.logErr("copyObjects() did not return array of null objects");
pass = false;
}
} catch (NullPointerException e) {
TestUtil.logMsg("NullPointerException received as expected");
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: "+e);
}
if (!pass)
throw new Fault("CopyObjects0002 failed");
}
/**
* CopyObjects0003: Tests passing a null orb.
* (See Sec. 28.5.1.4 of the Java Language to IDL Mapping
* spec. ptc/99-03-09)
*/
/*
* @testName: CopyObjects0003
* @assertion: Test passing a null orb.
* @test_Strategy: No strategy defined
*/
public void CopyObjects0003() throws Fault
{
boolean pass = true;
try
{
org.omg.CORBA.ORB orb = ORB.init(new String[0], orbProps);
//Try copying an array of Date objects to a null orb
Date da[] = new Date[arraysize];
for(int i = 0; i<da.length; i++) {
da[i] = new Date();
Date da2[] = (Date[])Util.copyObjects(da, (org.omg.CORBA.ORB)null);
TestUtil.logErr("copyObjects() did not raise expected NullPointerException");
pass = false;
}
} catch (ThreadDeath e) {
//test was killed. propagate exception
throw new Fault("test was killed");
} catch (NullPointerException e) {
TestUtil.logMsg("NullPointerException received as expected");
} catch (Throwable e) {
TestUtil.printStackTrace(e);
error("copyObjects() raised unexpected exception: "+e);
}
if (!pass)
throw new Fault("CopyObjects0003 failed");
}
void error (String reason ) throws Fault
{
TestUtil.logErr("An error has occured: " + reason);
throw new Fault(reason);
}
}
- duplicates
-
JDK-4306517 PortableRemoteObject.toStub() does not work with POA stubs/ties
-
- Closed
-