incubator-river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r934802 - in /incubator/river/jtsk/trunk: src/net/jini/core/event/ src/net/jini/core/lookup/ src/net/jini/io/ src/net/jini/loader/ test/src/net/jini/io/
Date Fri, 16 Apr 2010 11:54:22 GMT
Author: peter_firmstone
Date: Fri Apr 16 11:54:22 2010
New Revision: 934802

URL: http://svn.apache.org/viewvc?rev=934802&view=rev
Log:
Experimental commit, please feel free to read / participate / discuss.

Added:
    incubator/river/jtsk/trunk/src/net/jini/io/Converter.java   (with props)
    incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java   (with props)
    incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java   (with props)
Modified:
    incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java
    incubator/river/jtsk/trunk/src/net/jini/io/CDCMarshalledObject.java
    incubator/river/jtsk/trunk/src/net/jini/io/Convert.java
    incubator/river/jtsk/trunk/src/net/jini/io/FromMOInputStream.java
    incubator/river/jtsk/trunk/src/net/jini/io/MarshalledObject.java
    incubator/river/jtsk/trunk/src/net/jini/io/ToMOInputStream.java
    incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessClassLoader.java
    incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessOverridePermission.java

Modified: incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java Fri Apr 16 11:54:22
2010
@@ -18,7 +18,15 @@
 
 package net.jini.core.event;
 
-import java.rmi.MarshalledObject;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import net.jini.io.Convert;
+import net.jini.io.Converter;
+import net.jini.io.FromMOInputStream;
+import net.jini.io.MarshalledInstance;
+import net.jini.io.ToMOOutputStream;
 
 /**
  * The base class or superclass for remote events.
@@ -27,7 +35,7 @@ import java.rmi.MarshalledObject;
  * to the object in which the event occurred, a long which identifies the
  * kind of event relative to the object in which the event occurred, a long
  * which indicates the sequence number of this instance of the event kind,
- * and a MarshalledObject that is to be handed back when the notification
+ * and a MarshalledInstance that is to be handed back when the notification
  * occurs.  The combination of the event identifier and the object reference
  * obtained from the RemoteEvent object should uniquely identify the event
  * type.
@@ -75,11 +83,15 @@ import java.rmi.MarshalledObject;
  * @author Sun Microsystems, Inc.
  *
  * @since 1.0
+ * @version 2.0
  */
 public class RemoteEvent extends java.util.EventObject {
-
+    /**
+     * Serialization is broken for Serializing to River Releases earlier than
+     * 2.2.0, however it will succeed 
+     * @serial
+     */
     private static final long serialVersionUID = 1777278867291906446L;
-
     /**
      * The event source.
      *
@@ -102,11 +114,14 @@ public class RemoteEvent extends java.ut
     protected long seqNum;
 
     /**
-     * The handback object.
+     * The handback object, there is a remote possibility that this object
+     * is required to be accessed by a subclass, the visibility has been 
+     * changed from protected to private, this may break binary compatibility
+     * for some.
      *
      * @serial
      */
-    protected MarshalledObject handback;
+    private net.jini.io.MarshalledObject handback;
 
     /**
      * Constructs a RemoteEvent object.
@@ -125,14 +140,45 @@ public class RemoteEvent extends java.ut
      * @param seqNum    a <tt>long</tt> containing the event sequence number
      * @param handback  a <tt>MarshalledObject</tt> that was passed in 
      *                  as part of the original event registration.
+     * @deprecated As of Release 2.2.0 this method cannot be supported on
+     * the Java CDC Personal Profile 1.12 platform.
      */
+    @Deprecated
     public RemoteEvent(Object source, long eventID, long seqNum,
-		       MarshalledObject handback) {
+		       java.rmi.MarshalledObject handback) {
 	super(source);
 	this.source = source;
 	this.eventID = eventID;
 	this.seqNum = seqNum;
-	this.handback = handback;
+        Convert convert = Convert.getInstance();
+	this.handback = convert.toJiniMarshalledObject(handback);
+    }
+    /**
+     * Constructs a RemoteEvent object.
+     * <p>
+     * The abstract state contained in a RemoteEvent object includes a 
+     * reference to the object in which the event occurred, a long which 
+     * identifies the kind of event relative to the object in which the 
+     * event occurred, a long which indicates the sequence number of this 
+     * instance of the event kind, and a MarshalledInstance that is to be 
+     * handed back when the notification occurs. The combination of the 
+     * event identifier and the object reference obtained from the 
+     * RemoteEvent object should uniquely identify the event type.
+     * 
+     * @param source    an <tt>Object</tt> representing the event source
+     * @param eventID   a <tt>long</tt> containing the event identifier
+     * @param seqNum    a <tt>long</tt> containing the event sequence number
+     * @param handback  a <tt>MarshalledInstance</tt> that was passed in 
+     *                  as part of the original event registration.
+     */
+    public RemoteEvent(Object source, long eventID, long seqNum,
+		       MarshalledInstance handback) {
+	super(source);
+        this.source = source;
+        this.eventID = eventID;
+        this.seqNum = seqNum;
+        this.handback = Converter.toJiniMarshalledObject(handback);
+           
     }
 
     /**
@@ -163,17 +209,39 @@ public class RemoteEvent extends java.ut
      * @return the MarshalledObject that was provided as a parameter to
      *         the event interest registration method, if any. 
      */
-    public MarshalledObject getRegistrationObject() {
-	return handback;
+    @Deprecated
+    public java.rmi.MarshalledObject getRegistrationObject() {
+        Convert convert = Convert.getInstance();
+	return convert.toRmiMarshalledObject(handback);
+    }
+    
+    public MarshalledInstance getRegisteredObject() {
+	return Converter.toMarshalledInstance(handback);      
     }
 
     /**
-     * Serialization support
+     * Serialization support, the serialized form of this object converts
+     * a java.rmi.MarshalledObject, later when support for marshalling to
+     * java.rmi.MarshalledObject Serialized Form is dropped, this
+     * method can still convert old events if neccessary.
      */
     private void readObject(java.io.ObjectInputStream stream)
 	throws java.io.IOException, ClassNotFoundException
     {
-	stream.defaultReadObject();
+	ObjectInputStream newStream = new FromMOInputStream(stream);
+        newStream.defaultReadObject();
 	super.source = source;
     }
+    
+    /**
+     * This method is an interim temporary measure to provide a transition
+     * period for the Serialized form in Apache River versions prior to
+     * 2.2.0
+     * @param stream
+     * @throws java.io.IOException
+     */
+    private void writeObject(java.io.ObjectOutputStream stream) throws IOException{
+        ObjectOutputStream newOutStream = new ToMOOutputStream(stream);
+        newOutStream.defaultWriteObject();
+    }
 }

Modified: incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java Fri Apr 16 11:54:22
2010
@@ -17,6 +17,8 @@
  */
 package net.jini.core.lookup;
 
+import net.jini.io.MarshalledInstance;
+
 /**
  * This class is used for remote events sent by the lookup service.  It
  * extends RemoteEvent with methods to obtain the service ID of the matched
@@ -60,6 +62,7 @@ public abstract class ServiceEvent exten
      * @param serviceID the serviceID of the item that triggered the event
      * @param transition the transition that triggered the event
      */
+    @Deprecated
     public ServiceEvent(Object source,
 			long eventID,
 			long seqNo,
@@ -72,6 +75,28 @@ public abstract class ServiceEvent exten
 	this.transition = transition;
     }
 
+    /**
+     * Simple constructor.
+     *
+     * @param source the source of this ServiceEvent
+     * @param eventID the registration eventID
+     * @param seqNo the sequence number of this event
+     * @param handback the client handback
+     * @param serviceID the serviceID of the item that triggered the event
+     * @param transition the transition that triggered the event
+     */
+    public ServiceEvent(Object source,
+			long eventID,
+			long seqNo,
+			MarshalledInstance handback,
+			ServiceID serviceID,
+			int transition)
+    {
+	super(source, eventID, seqNo, handback);
+	this.serviceID = serviceID;
+	this.transition = transition;
+    }
+    
     /** Returns the serviceID of the item that triggered the event. 
      *
      * @return a <tt>ServiceID</tt> object representing the service ID value
@@ -116,7 +141,7 @@ public abstract class ServiceEvent exten
 	sBuffer.append(", source=").append(source).append(
 	    ", eventID=").append(getID()).append(
 	    ", seqNum=").append(getSequenceNumber()).append(
-	    ", handback=").append(getRegistrationObject());
+	    ", handback=").append(getRegisteredObject());
 	return sBuffer.append("]").toString();
     }
 

Modified: incubator/river/jtsk/trunk/src/net/jini/io/CDCMarshalledObject.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/CDCMarshalledObject.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/CDCMarshalledObject.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/CDCMarshalledObject.java Fri Apr 16 11:54:22
2010
@@ -34,6 +34,11 @@ import net.jini.io.context.IntegrityEnfo
 /**
  * This is an experimental implementation and may be subject to change or
  * removal.
+ * 
+ * This will be removed shortly, a CDC version of MarshalledInstance will be
+ * compiled withouth the deprecated methods.  PackageVersion will be changed
+ * to be an package version annotation generator.
+ * 
  * A <code>CDCMarshalledObject</code> contains an object in serialized
  * form. The contained object can be deserialized on demand when
  * explicitly requested. This allows an object to be sent from one VM

Modified: incubator/river/jtsk/trunk/src/net/jini/io/Convert.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/Convert.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/Convert.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/Convert.java Fri Apr 16 11:54:22 2010
@@ -35,9 +35,19 @@ import java.util.Collections;
  * @param T - Generic Type Parameter of contained object.
  * @author Peter Firmstone
  */
-public class Convert<T> {    
+public class Convert<T> {
+    private static volatile Convert convert = new Convert();
+    protected static void setConvert(Convert converter){
+        convert = converter;
+    }
+    
+    public static Convert getInstance(){
+        return convert;
+    }
+    protected Convert(){}
+    
     @SuppressWarnings("unchecked")
-    private java.rmi.MarshalledObject<T> 
+    public java.rmi.MarshalledObject<T> 
             toRmiMarshalledObject(net.jini.io.MarshalledObject<T> privateMO){
         // To create a java.rmi.MarshalledObject with previously
 	// serialized data we first create a private
@@ -64,7 +74,17 @@ public class Convert<T> {    
 	return mo;
     }
     
-    private net.jini.io.MarshalledObject<T> toJiniMarshalledObject(
+    public net.jini.io.MarshalledInstance<T> toMarshalledInstance(
+            net.jini.io.MarshalledObject<T> mo){
+        return new MarshalledInstance<T>(mo);
+    }
+    
+    public net.jini.io.MarshalledObject<T> toJiniMarshalledObject(
+            net.jini.io.MarshalledInstance<T> instance){
+        return instance.asMarshalledObject();
+    }
+    
+    public net.jini.io.MarshalledObject<T> toJiniMarshalledObject(
             java.rmi.MarshalledObject<T> instance){
         net.jini.io.MarshalledObject<T> privateMO = null;
 	try {

Added: incubator/river/jtsk/trunk/src/net/jini/io/Converter.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/Converter.java?rev=934802&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/Converter.java (added)
+++ incubator/river/jtsk/trunk/src/net/jini/io/Converter.java Fri Apr 16 11:54:22 2010
@@ -0,0 +1,27 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.io;
+
+/**
+ * Converter Class for CDC to convert between MarshalledInstance and
+ * net.jini.io.MarshalledObject.
+ * 
+ * @see MarshalledInstance
+ * @see MarshalledObject
+ * @author Peter Firmstone
+ */
+public class Converter {
+    @SuppressWarnings("unchecked")
+    public static net.jini.io.MarshalledInstance toMarshalledInstance(
+            net.jini.io.MarshalledObject mo){
+        return new MarshalledInstance(mo);
+    }
+    
+    public static net.jini.io.MarshalledObject toJiniMarshalledObject(
+            net.jini.io.MarshalledInstance instance){
+        return instance.asMarshalledObject();
+    }
+}

Propchange: incubator/river/jtsk/trunk/src/net/jini/io/Converter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/river/jtsk/trunk/src/net/jini/io/FromMOInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/FromMOInputStream.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/FromMOInputStream.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/FromMOInputStream.java Fri Apr 16 11:54:22
2010
@@ -22,7 +22,7 @@ import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
 
-class FromMOInputStream extends ObjectInputStream {
+public class FromMOInputStream extends ObjectInputStream {
 
     public FromMOInputStream(InputStream in) throws IOException {
         super(in);

Modified: incubator/river/jtsk/trunk/src/net/jini/io/MarshalledObject.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/MarshalledObject.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/MarshalledObject.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/MarshalledObject.java Fri Apr 16 11:54:22 2010
@@ -24,7 +24,7 @@ import java.io.Serializable;
  * This is a private class used to convert <code>java.rmi.MarshalledObject</code>
  * to <code>MarshalledInstance</code> and vice versa.
  */
-final class MarshalledObject<T> implements Serializable {
+public final class MarshalledObject<T> implements Serializable {
 
     // Duplicate (private) MarshalledObject fields, and make them
     // package visable

Modified: incubator/river/jtsk/trunk/src/net/jini/io/ToMOInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/ToMOInputStream.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/ToMOInputStream.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/ToMOInputStream.java Fri Apr 16 11:54:22 2010
@@ -22,7 +22,7 @@ import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
 
-class ToMOInputStream extends ObjectInputStream {
+public class ToMOInputStream extends ObjectInputStream {
 
     public ToMOInputStream(InputStream in) throws IOException {
         super(in);

Added: incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java?rev=934802&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java (added)
+++ incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java Fri Apr 16 11:54:22 2010
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.jini.io;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * ToMOOutputStream enables writing a jini MarshalledObject into
+ * an RMI MarshalledObject Serialized form.
+ * 
+ * This is a nasty horrible hack to write the output stream as a 
+ * java.rmi.MarshalledObject, so the CDC PersonalProfile version 1.12
+ * can share this object.
+ * 
+ * Since this class accesses the private state of ObjectStreamClass, it is
+ * tied to it's internal implementation, however since this class also
+ * implements Serializable, its internal state has been publicly published
+ * so must remain compatible.
+ * 
+ * @author Peter Firmstone.
+ */
+public class ToMOOutputStream extends ObjectOutputStream{
+public ToMOOutputStream(OutputStream out) throws IOException {
+        super(out);
+        useProtocolVersion(PROTOCOL_VERSION_2);
+    }
+    @Override
+    protected void writeClassDescriptor(ObjectStreamClass desc){
+        try {
+            System.out.println(desc.getName());
+            if (desc.getName().equals("net.jini.io.MarshalledObject")) {
+                Field[] fields = ObjectStreamClass.class.getDeclaredFields();
+                int l = fields.length;
+                for (int i = 0; i < l; i++) {
+                    fields[i].setAccessible(true);
+                    if (fields[i].getName().equals("name")) {
+                        fields[i].set(desc, "java.rmi.MarshalledObject");
+                        continue;
+                    }
+                    if (fields[i].getName().equals("hasWriteObjectData")) {
+                        fields[i].setBoolean(desc, false);
+                        continue;
+                    }
+                    if (fields[i].getName().equals("readObjectMethod")) {
+                        fields[i].set(desc, null);
+                        continue;
+                    }
+                    if (fields[i].getName().equals("writeObjectMethod")) {
+                        fields[i].set(desc, null);
+                    }
+                }
+            }
+            super.writeClassDescriptor(desc);
+        } catch (IllegalArgumentException ex) {
+            ex.printStackTrace();
+            //Logger.getLogger(ToMOOutputStream.class.getName()).log(Level.SEVERE, null,
ex);
+        } catch (IllegalAccessException ex) {
+            ex.printStackTrace();
+            //Logger.getLogger(ToMOOutputStream.class.getName()).log(Level.SEVERE, null,
ex);
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            //Logger.getLogger(ToMOOutputStream.class.getName()).log(Level.SEVERE, null,
ex);
+        } catch (Exception ex){
+            ex.printStackTrace();
+            //Logger.getLogger(ToMOOutputStream.class.getName()).log(Level.SEVERE, null,
ex);
+        }
+    }   
+}

Propchange: incubator/river/jtsk/trunk/src/net/jini/io/ToMOOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessClassLoader.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessClassLoader.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessClassLoader.java Fri Apr
16 11:54:22 2010
@@ -21,9 +21,6 @@ package net.jini.loader;
 import java.io.IOException;
 import java.net.URL;
 import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import net.jini.loader.pref.PreferredClassLoader;
 
 /**
  *

Modified: incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessOverridePermission.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessOverridePermission.java?rev=934802&r1=934801&r2=934802&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessOverridePermission.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/loader/CodebaseAccessOverridePermission.java Fri
Apr 16 11:54:22 2010
@@ -24,6 +24,7 @@ import java.security.BasicPermission;
  * @author Gregg Wonderly
  */
 public class CodebaseAccessOverridePermission extends BasicPermission {
+    private static final long serialVersionUID = 1L;
 	public CodebaseAccessOverridePermission( String name, String access ) {
 		super( name, access );
 	}

Added: incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java?rev=934802&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java Fri Apr 16 11:54:22
2010
@@ -0,0 +1,83 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ToMOOutputStreamTest {
+    public ToMOOutputStreamTest(){}
+    String strObject;
+    MarshalledInstance mi;
+    Convert convert;
+    net.jini.io.MarshalledObject jinmo;
+    @org.junit.BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @org.junit.AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @org.junit.Before
+    public void setUp() throws Exception {
+        strObject = "Test String";
+        mi = new MarshalledInstance(strObject);
+        convert = Convert.getInstance();
+        jinmo = convert.toJiniMarshalledObject(mi);
+    }
+
+    @org.junit.After
+    public void tearDown() throws Exception {
+    }
+
+    /**
+     * Test of toRmiMarshalledObject method, of class Convert.
+     */
+    @org.junit.Test
+    public void toRmiMarshalledObject() {
+        try {
+            System.out.println("toRmiMarshalledObject");
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ToMOOutputStream(baos);
+            oos.writeObject(jinmo);
+            oos.flush();
+            byte[] bytes = baos.toByteArray();
+            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+            ObjectInputStream ois = new ObjectInputStream(bais);
+            java.rmi.MarshalledObject mo = (java.rmi.MarshalledObject) ois.readObject();
+            if (mo == null) {
+                fail("MarshalledObject returned was null");
+            }
+            String result = (String) mo.get();
+            System.out.println(result);
+            assertEquals(strObject, result);
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (ClassNotFoundException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (NullPointerException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        }
+    }
+}

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message