001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: F_EtypeOutildateEC2.java 9709 2006-10-10 08:37:20Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import java.util.Date;
029:
030: import javax.naming.NamingException;
031: import javax.rmi.PortableRemoteObject;
032:
033: import junit.framework.Test;
034: import junit.framework.TestSuite;
035:
036: import org.objectweb.jonas.jtests.beans.etype.outildate.OutildateHome;
037:
038: /**
039: * This is a test suite about java.util.Date field of entity bean CMP version 2.
040: * Beans used: etype/outildate
041: * @author Helene Joanin
042: */
043:
044: public class F_EtypeOutildateEC2 extends A_EtypeOutildate {
045:
046: private static String BEAN_HOME = "EtypeOutildateEC2Home";
047: protected static OutildateHome home = null;
048: private static final long ONE_HOUR = 60L * 60L * 1000L;
049: private static final long ONE_DAY = 24L * ONE_HOUR;
050:
051: public F_EtypeOutildateEC2(String name) {
052: super (name);
053: }
054:
055: protected void setUp() {
056: super .setUp();
057: useBeans("outildate", false);
058: }
059:
060: public OutildateHome getHome() {
061: if (home == null) {
062: try {
063: home = (OutildateHome) PortableRemoteObject.narrow(ictx
064: .lookup(BEAN_HOME), OutildateHome.class);
065: } catch (NamingException e) {
066: fail("Cannot get bean home: " + BEAN_HOME);
067: }
068: // init here tables if CMP2
069: try {
070: home.create("pk1", new Date(ONE_DAY));
071: home.create("pk2", new Date(2 * ONE_DAY));
072: home.create("pk3", new Date(3 * ONE_DAY));
073: home.create("pk4", new Date(4 * ONE_DAY));
074: home.create("pk5", new Date(5 * ONE_DAY));
075: home.create("pk5bis", new Date(5 * ONE_DAY));
076: home.create("pktoremove", new Date(12 * ONE_DAY));
077: home.create("pknull", (Date) null);
078: home.create("pkchangenull", new Date(12 * ONE_DAY));
079: } catch (Exception i) {
080: }
081: }
082: return home;
083: }
084:
085: public static Test suite() {
086: return new TestSuite(F_EtypeOutildateEC2.class);
087: }
088:
089: public static void main(String args[]) {
090: String testtorun = null;
091: // Get args
092: for (int argn = 0; argn < args.length; argn++) {
093: String s_arg = args[argn];
094: Integer i_arg;
095: if (s_arg.equals("-n")) {
096: testtorun = args[++argn];
097: }
098: }
099: if (testtorun == null) {
100: junit.textui.TestRunner.run(suite());
101: } else {
102: junit.textui.TestRunner.run(new F_EtypeOutildateEC2(
103: testtorun));
104: }
105: }
106: }
|