/*********************************************************************
* RemotingTest.java
* created on 07.06.2007 by netseeker
* $Id: RemotingTest.java,v 1.1 2007/11/17 10:59:55 netseeker Exp $
* $Log: RemotingTest.java,v $
* Revision 1.1 2007/11/17 10:59:55 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.cltest;
import java.math.BigDecimal;
import java.util.logging.Logger;
import de.netseeker.ejoe.EJClient;
import de.netseeker.ejoe.EJConstants;
import de.netseeker.ejoe.RemotingService;
import de.netseeker.ejoe.adapter.XStreamAdapter;
import de.netseeker.ejoe.test.service.ISimpleTypes;
import de.netseeker.ejoe.test.service.SimpleTypes;
import junit.framework.TestCase;
/**
* @author netseeker
*
* @since
*/
public class RemotingTest extends TestCase
{
private static final Logger log = Logger.getLogger( RemotingTest.class.getName() );
private EJClient client;
/**
* @param name
*/
public RemotingTest(String name)
{
super( name );
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
super.setUp();
client = new EJClient( "127.0.0.1", EJConstants.EJOE_PORT,
new XStreamAdapter( true ) );
client.enableRemoteClassloading();
client.enablePersistentConnection( true );
}
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 );
}
}