Package org.objectweb.speedo.runtime.collection

Source Code of org.objectweb.speedo.runtime.collection.TestLoadMNB

/**
* Copyright (C) 2001-2004 France Telecom R&D
*
* 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
*/
package org.objectweb.speedo.runtime.collection;

import org.objectweb.speedo.SpeedoTestHelper;
import org.objectweb.speedo.pobjects.collection.AMMB;
import org.objectweb.speedo.pobjects.collection.BMMB;
import org.objectweb.util.monolog.api.BasicLevel;

import javax.jdo.PersistenceManager;

import junit.framework.Assert;

import java.util.Collection;
import java.util.Iterator;

/**
*
* @author S.Chassande-Barrioz
*/
public class TestLoadMNB extends SpeedoTestHelper {

  public TestLoadMNB(String s) {
    super(s);
  }

  protected String getLoggerName() {
    return LOG_NAME + ".rt.collection.TestLoadMNB";
  }

    public void test1() {
        PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
        Object oid = pm.newObjectIdInstance(AMMB.class, "1230");
        Assert.assertNotNull("null oid !", oid);
        AMMB a = (AMMB) pm.getObjectById(oid, false);
        Assert.assertNotNull("null AMMB object", a);
        Collection bs = a.getBs();
        Assert.assertNotNull("null collection of BMMB", bs);
        Iterator it = bs.iterator();
        while(it.hasNext()) {
            BMMB b = (BMMB) it.next();
            Assert.assertNotNull("null element collection of BMMB", b);
            logger.log(BasicLevel.DEBUG, "idb: " + b.getIdb());
            it.remove();
            b.getAs().remove(a);
            pm.deletePersistent(b);
        }
        pm.deletePersistent(a);
        pm.currentTransaction().commit();
        pm.close();
    }
}
TOP

Related Classes of org.objectweb.speedo.runtime.collection.TestLoadMNB

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.