Bad day for attachments. This is correct second test case, ignore TestRegistryDirectPart2.
Regards, *================================* | Scott T Weaver | | <[EMAIL PROTECTED]> | | Apache Jetspeed Portal Project | | Apache Pluto Portlet Container | *================================* > -----Original Message----- > From: Weaver, Scott [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 04, 2004 10:55 AM > To: 'OJB Users List' > Subject: RE: [OTM] bi-directional 1:n not working (still not working) > > Rest of the test stuff, had to append ".txt" to everything because the > list > server filters are so anal ;) Hopefully they get through. > > Regrads, > *================================* > | Scott T Weaver | > | <[EMAIL PROTECTED]> | > | Apache Jetspeed Portal Project | > | Apache Pluto Portlet Container | > *================================* > > > -----Original Message----- > > From: Weaver, Scott [mailto:[EMAIL PROTECTED] > > Sent: Thursday, March 04, 2004 10:52 AM > > To: 'OJB Users List' > > Subject: RE: [OTM] bi-directional 1:n not working (still not working) > > > > I am now using tandem test cases to simulate the shutdown of the system > > and > > a restart, i.e. no cached items. > > > > I run the identical fetching tests in the second test case as I do in > the > > first (only the first case creates the test data). Everything works in > > the > > first case but after restart the second test fails AND errors. The > > failure > > is caused by the WebApp not being materialized into its parent, the > error > > is > > caused in the teardown() were I try and clean up the test data (see > > sys.out.txt for more details). > > > > I wrote the test cases using straight OTM, using OTMExamples as a guide; > > triple check that it wasn't something my abstraction layer was doing > > incorrectly. > > > > Regards, > > *================================* > > | Scott T Weaver | > > | <[EMAIL PROTECTED]> | > > | Apache Jetspeed Portal Project | > > | Apache Pluto Portlet Container | > > *================================* > > > > > -----Original Message----- > > > From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, March 03, 2004 6:02 PM > > > To: OJB Users List > > > Subject: RE: [OTM] bi-directional 1:n not working > > > > > > Any chance you could post a summary of what you learnt? > > > > > > Thanks, > > > > > > Rob :) > > > > > > > -----Original Message----- > > > > From: Weaver, Scott [mailto:[EMAIL PROTECTED] > > > > Sent: Thursday, 4 March 2004 11:48 a.m. > > > > To: 'OJB Users List' > > > > Subject: RE: [OTM] bi-directional 1:n not working > > > > > > > > Hi Oleg, > > > > > > > > I had a long IM conversation with Matt Baird today and he set > > > > me straight on how to use OTM and otm-dependent. However, I > > > > am still getting the NullPointerExceptions when invalidating > > > > or using the empty cache impl (see my other posts). > > > > > > > > > > > > Regards, > > > > *================================* > > > > | Scott T Weaver | > > > > | <[EMAIL PROTECTED]> | > > > > | Apache Jetspeed Portal Project | > > > > | Apache Pluto Portlet Container | > > > > *================================* > > > > > > > > > -----Original Message----- > > > > > From: Oleg Nitz [mailto:[EMAIL PROTECTED] > > > > > Sent: Wednesday, March 03, 2004 6:58 PM > > > > > To: OJB Users List > > > > > Subject: Re: [OTM] bi-directional 1:n not working > > > > > > > > > > On Wednesday 03 March 2004 16:50, Weaver, Scott wrote: > > > > > > Removing these appears to have fixed this: > > > > > > > > > > > > auto-delete="true" > > > > > > auto-update="true" > > > > > > auto-retrieve="true" > > > > > > > > > > > > I thought OTM could co-exists with these settings? I > > > > guess I was wrong. > > > > > > > > > > auto-retrieve="true" is okay > > > > > AFAIK auto-update="true" and auto-delete="true" are okay, > > > > unless you > > > > > set otm-dependent="true". When you add otm-dependent="true" > > > > > don't > > > > > forget to remove auto-update="true" and auto-delete="true". > > > > > Anyway I don't understand how auto-update="true" can affect > setting > > > > > object references to parents. > > > > > > > > > > Regards, > > > > > Oleg > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------- > - > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -------------------------------------------------------------------- > - > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] >
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache Jetspeed" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * "Apache Jetspeed", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.jetspeed.components.portletregistry; import java.util.Collection; import java.util.Iterator; import java.util.Locale; import javax.portlet.PortletMode; import junit.framework.Test; import org.apache.jetspeed.components.AbstractComponentAwareTestCase; import org.apache.jetspeed.components.ComponentAwareTestSuite; import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent; import org.apache.jetspeed.om.common.portlet.ContentTypeComposite; import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; import org.apache.jetspeed.om.common.preference.PreferenceComposite; import org.apache.jetspeed.om.portlet.impl.ContentTypeImpl; import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl; import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl; import org.apache.jetspeed.om.preference.impl.DefaultPreferenceImpl; import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl; import org.apache.jetspeed.util.JetspeedLocale; import org.apache.ojb.broker.PBKey; import org.apache.ojb.broker.query.Criteria; import org.apache.ojb.broker.query.QueryFactory; import org.apache.ojb.otm.OTMConnection; import org.apache.ojb.otm.core.Transaction; import org.apache.ojb.otm.kit.SimpleKit; import org.picocontainer.MutablePicoContainer; /** * * TestRegistry runs a suite tests creating, updating, retreiving and deleting * portlet information from the registry. * * @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver </a> * @version $Id: TestRegistry.java,v 1.5 2004/03/01 02:04:05 taylor Exp $ * */ public class TestRegistryDirectOTMPart2 extends AbstractComponentAwareTestCase { private MutablePicoContainer container; private static final String PORTLET_0_CLASS = "com.portlet.MyClass0"; private static final String PORTLET_0_NAME = "Portlet 0"; private static final String PORTLET_1_CLASS = "com.portlet.MyClass"; private static final String PORTLET_1_NAME = "Portlet 1"; private static final String PORTLET_1_UID = "com.portlet.MyClass.Portlet 1"; private static final String PORTLET_0_UID = "com.portlet.MyClass0.Portlet 0"; private static final String MODE_HELP = "HELP"; private static final String MODE_VIEW = "VIEW"; private static final String MODE_EDIT = "EDIT"; private static int testPasses = 0; public static final String APP_1_NAME = "RegistryTestPortlet"; private static PortletRegistryComponent registry; public void testContainer() { assertNotNull(container); } /* * (non-Javadoc) * * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); container = (MutablePicoContainer) getContainer(); registry = (PortletRegistryComponent) container.getComponentInstance(PortletRegistryComponent.class); testPasses++; } /* * (non-Javadoc) * * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { //Thread.sleep(10000); SimpleKit kit = SimpleKit.getInstance(); OTMConnection conn = kit.acquireConnection(new PBKey("jetspeed")); Transaction tx = kit.getTransaction(conn); tx.begin(); PortletApplicationDefinitionImpl app = null; Criteria filter = new Criteria(); filter.addEqualTo("name", "App_1"); app = (PortletApplicationDefinitionImpl) conn.getCollectionByQuery(QueryFactory.newQuery( PortletApplicationDefinitionImpl.class, filter)).iterator().next(); conn.deletePersistent(app); tx.commit(); super.tearDown(); } public static Test suite() { ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestRegistryDirectOTMPart2.class); suite.setScript("org/apache/jetspeed/containers/registry.container.groovy"); return suite; } /** * @param testName */ public TestRegistryDirectOTMPart2(String testName) { super(testName, "./src/test/Log4j.properties"); } public void test001() throws Exception { SimpleKit kit = SimpleKit.getInstance(); OTMConnection conn = kit.acquireConnection(new PBKey("jetspeed")); Transaction tx = null; tx = kit.getTransaction(conn); //invalidate(new Object[] {app}); // now makes sure everthing got persisted tx.begin(); PortletApplicationDefinitionImpl app = null; Criteria filter = new Criteria(); filter.addEqualTo("name", "App_1"); app = (PortletApplicationDefinitionImpl) conn.getCollectionByQuery(QueryFactory.newQuery( PortletApplicationDefinitionImpl.class, filter)).iterator().next(); tx.commit(); WebApplicationDefinitionImpl webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition(); PortletDefinitionImpl portlet = (PortletDefinitionImpl) app.getPortletDefinitionByName("Portlet 1"); assertNotNull("Failed to reteive portlet application", app); assertNotNull("Failed to reteive portlet application via registry", registry.getPortletApplication("App_1")); assertNotNull("Web app was not saved along with the portlet app.", webApp); assertNotNull("Portlet was not saved along with the portlet app.", app.getPortletDefinitionByName("Portlet 1")); assertNotNull("Portlet could not be retreived by unique name.", registry .getPortletDefinitionByUniqueName("App_1::Portlet 1")); assertNotNull("Portlet Application was not set in the portlet defintion.", portlet .getPortletApplicationDefinition()); assertNotNull("French description was not materialized for the web app.", webApp.getDescription(Locale.FRENCH)); assertNotNull("French display name was not materialized for the web app.", webApp.getDisplayName(Locale.FRENCH)); assertNotNull("description was not materialized for the portlet.", portlet.getDescription(Locale.getDefault())); assertNotNull("display name was not materialized for the portlet.", portlet.getDisplayName(Locale.getDefault())); assertNotNull("\"testparam\" portlet parameter was not saved", portlet.getInitParameterSet().get("testparam")); assertNotNull("\"preference 1\" was not found.", portlet.getPreferenceSet().get("preference 1")); assertNotNull("Language information not found for Portlet 1", portlet.getLanguageSet().get(Locale.getDefault())); assertNotNull("Content Type html not found.", portlet.getContentTypeSet().get("html/text")); assertNotNull("Content Type wml not found.", portlet.getContentTypeSet().get("wml")); Iterator itr = portlet.getPreferenceSet().get("preference 1").getValues(); int valueCount = 0; ; while (itr.hasNext()) { itr.next(); valueCount++; } assertEquals("\"preference 1\" did not have to values.", 2, valueCount); // pull out our Web app and add a Description to it tx = kit.getTransaction(conn); tx.begin(); webApp = null; filter = new Criteria(); filter.addEqualTo("name", "App_1"); app = (PortletApplicationDefinitionImpl) conn.getCollectionByQuery(QueryFactory.newQuery( PortletApplicationDefinitionImpl.class, filter)).iterator().next(); conn.lockForWrite(app); webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition(); conn.lockForWrite(webApp); assertNotNull("Web app was not located by query.", webApp); webApp.addDescription(Locale.getDefault(), "Web app description"); tx.commit(); // invalidate(new Object[] {webApp}); tx = kit.getTransaction(conn); tx.begin(); webApp = null; filter = new Criteria(); filter.addEqualTo("name", "App_1"); app = (PortletApplicationDefinitionImpl) conn.getCollectionByQuery(QueryFactory.newQuery( PortletApplicationDefinitionImpl.class, filter)).iterator().next(); webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition(); tx.commit(); assertNotNull("Web app was not located by query.", webApp); assertNotNull("Web app did NOT persist its description", webApp.getDescription(Locale.getDefault())); conn.close(); } protected void invalidate(Object[] objs) throws Exception { SimpleKit kit = SimpleKit.getInstance(); OTMConnection conn = kit.acquireConnection(new PBKey("jetspeed")); Transaction tx = kit.getTransaction(conn); tx.begin(); for (int i = 0; i < objs.length; i++) { conn.invalidate(conn.getIdentity(objs[i])); } tx.commit(); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
