Package de.netseeker.ejoe.test.remoting

Source Code of de.netseeker.ejoe.test.remoting.RemotingServiceTest

/*********************************************************************
* RemotingServiceTest.java
* created on 02.12.2006 by netseeker
* $Id: RemotingServiceTest.java,v 1.1 2006/12/02 19:08:43 netseeker Exp $
* $Log: RemotingServiceTest.java,v $
* Revision 1.1  2006/12/02 19:08:43  netseeker
* *** empty log message ***
*
*
* ====================================================================
*
*  Copyright 2005-2006 netseeker aka Michael Manske
*
*  Licensed 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.
* ====================================================================
*
* This file is part of the EJOE framework.
* For more information on the author, please see
* <http://www.manskes.de/>.
*
*********************************************************************/
package de.netseeker.ejoe.test.remoting;

import java.math.BigDecimal;

import de.netseeker.ejoe.EJClient;
import de.netseeker.ejoe.RemotingService;
import de.netseeker.ejoe.handler.DefaultRemotingHandler;
import de.netseeker.ejoe.test.BaseClientTest;
import de.netseeker.ejoe.test.service.ISimpleTypes;
import de.netseeker.ejoe.test.service.SimpleTypes;

/**
* @author netseeker
* @since
*/
public class RemotingServiceTest extends BaseClientTest
{
    EJClient client;

    public RemotingServiceTest()
    {
        nonBlockingIO = true;
        handler = new DefaultRemotingHandler();
        persistent = true;
    }

    /*
     * (non-Javadoc)
     *
     * @see de.netseeker.ejoe.test.BaseTest#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        if ( client == null ) client = getNewClient();
    }

    public void testService()
    {
        ISimpleTypes service = (ISimpleTypes) RemotingService.createService( SimpleTypes.class.getName(),
                                                                             ISimpleTypes.class, client );

        Object o = service.getString( "abcd" );
        assertTrue( o instanceof String );
        assertTrue( ((String) o).length() > 0 );

        o = service.getBoolean( true );
        assertTrue( o instanceof Boolean );
        assertTrue( ((Boolean) o).booleanValue() );

        o = service.getFloat( 4321 );
        assertTrue( o instanceof Float );
        assertEquals( o, new Float( 1234.0 ) );

        o = service.getDouble( 4321 );
        assertTrue( o instanceof Double );
        assertEquals( o, new Double( 1234.0 ) );

        o = service.getDecimal( new BigDecimal( 4321 ) );
        assertTrue( o instanceof BigDecimal );
        assertEquals( o, new BigDecimal( 1234.0 ) );

        o = service.getInteger( 4321 );
        assertTrue( o instanceof Integer );
        assertEquals( o, new Integer( 1234 ) );

        o = service.getShort( (short) 4321 );
        assertTrue( o instanceof Short );
        assertEquals( o, new Short( (short) 1234 ) );

        o = service.getByte( (byte) 10 );
        assertTrue( o instanceof Byte );
        assertEquals( o, new Byte( (byte) 11 ) );

        o = service.getBase64( new byte[] { (byte) 10 } );
        assertTrue( o instanceof byte[] );
        assertEquals( ((byte[]) o)[0], (byte) 11 );

    }
}
TOP

Related Classes of de.netseeker.ejoe.test.remoting.RemotingServiceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.