jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alvin Antony" <Alvin.Ant...@consol.de>
Subject Problem with ObjectInputStream and WebRequest.setUserData & .getUserData()
Date Fri, 06 May 2005 09:04:46 GMT
Dear Friends,
 
I am new to the mailing list and so to Cactus!! Please pardon me if it
is a silly Q.
 
I am writing a test suit for an Applet& Servlet client server
Application. 
The Applet sends the information to the Servlet through an Object
stream, but my test case for this throws an EOFException.
 
 
public void beginService ( WebRequest webRequest ) throws
ClassNotFoundException, IOException 
    {          
        ProdFinderIntegratonTestRepository prodFinderIntegrationTestRep
= new ProdFinderIntegratonTestRepository ();
        Map input;
        try {
            input =
prodFinderIntegrationTestRep.getRequestToCreateMainCategory();
                    assertNotNull( input );
                    
                    ByteArrayOutputStream bos = new
ByteArrayOutputStream();        
                    ObjectOutputStream oos = new ObjectOutputStream( bos
);
                    oos.writeObject( input );
                    oos.flush();     
                    bos.close();
                    ByteArrayInputStream byteArrayInputStream  =  new
ByteArrayInputStream( bos.toByteArray() );        
                    objectInputStream = new ObjectInputStream(
byteArrayInputStream );        
                    webRequest.setContentType("application/binary");
                    webRequest.setUserData( objectInputStream ) ;       
        } catch (ObjectNotFoundException e) {            
            e.printStackTrace();
        } catch (PFInternalError e) {           
            e.printStackTrace();
        
        } 
    }
 
    /**
     * 
     * Class under test for void service(HttpServletRequest,
HttpServletResponse)
     */
    public void testService() throws ServletException, IOException {

        InputStream is =  request.getInputStream();        
        ObjectInputStream oInput = new ObjectInputStream(is);        
        MessageReceiver messageReceiver = new MessageReceiver();
        messageReceiver.init( config );
        messageReceiver.service(request, response );
        assertNotNull( response);        
    }
 
   [cactus] Testcase:
testService(com.siemens.productfinder.communication.TestMe
ssageReceiver): Caused an ERROR
   [cactus] null
   [cactus] java.io.EOFException
   [cactus]     at
java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInp
utStream.java:2165)
   [cactus]     at
java.io.ObjectInputStream$BlockDataInputStream.readShort(Obje
ctInputStream.java:2631)
   [cactus]     at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.
java:734)
   [cactus]     at
java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
   [cactus]     at
com.siemens.productfinder.communication.TestMessageReceiver.t
estService(Unknown Source)...
 
 
Any help would be great
 
Thanks in advance,
 
 
Alvin
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message