| CommandGenerationHelperTest.java |
/* PAT: Persistent Applications Toolkit (patsystem.sf.net)
* Copyright (C) 2004, 2005 Tomasz Nazar, nthx at irc dot pl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Full version of the license is /docs/LICENSE.txt
*/
package org.nthx.pat;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
/** Test for {@link CommandGenerationHelper} class.
*
* @version $Id: CommandGenerationHelperTest.java 3725 2005-06-09 23:57:03Z nthx $
* @author nthx@users.sourceforge.net
*/
public class CommandGenerationHelperTest
extends TestCase
{
public void testBos2Stream()
{
User user = new User();
user.setOID(new Long(17));
User target = new User();
target.setOID(new Long(102301230123L)); // -> Long(1023...)
Object[] bos = new Object[3];
bos[0] = new String("AAAA"); // -> "AAAA"
bos[1] = user; // -> Long(17L)
bos[2] = new Long(8); // -> Long(8L)
ObjectForStream[] forStream =
CommandGenerationHelper.targetAndBos2FakeOIDs(target, bos);
assertNotNull(forStream);
assertEquals(4, forStream.length);
assertNotNull(forStream[0]);
assertNotNull(forStream[1]);
assertNotNull(forStream[2]);
assertNotNull(forStream[3]);
assertEquals(true, forStream[0].isBo);
assertEquals(false, forStream[1].isBo);
assertEquals(true, forStream[2].isBo);
assertEquals(false, forStream[3].isBo);
assertEquals(new Long(102301230123L), forStream[0].objectOrOID);
assertEquals("AAAA", forStream[1].objectOrOID);
assertEquals(new Long(17), forStream[2].objectOrOID);
assertEquals(new Long(8), forStream[3].objectOrOID);
}
/** @@pat.bo */
private class User
extends IdentifiableMixin
implements BusinessObject
{
}
//--- Constructors ----------
public CommandGenerationHelperTest(String arg)
{
super(arg);
}
public static void main(String[] args)
{
junit.textui.TestRunner.run(CommandGenerationHelperTest.class);
}
private transient Logger logTest = Logger.getLogger("pat");
}