openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: svn commit: r501955 - /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java
Date Wed, 31 Jan 2007 20:25:27 GMT
Hi Kevin,

Sorry for commenting before reading this...

On Jan 31, 2007, at 11:39 AM, Kevin Sutter wrote:

> Sorry about the "whole changed file" thing again.  I thought I had  
> found the
> problem with a doubly defined [miscellany] section in my svn config  
> file.
> But, I changed that and I still have the problem.  Like I mentioned  
> before,
> this only seems to happen after using the SVN Eclipse plugin to do  
> a merge
> of a patch.

Do you review the diff in Eclipse before committing?

> Maybe I should just use the SVN command line to do the commit?

That works.

> Or, maybe I have to manually do the Windows->Linux line ending  
> conversion
> before committing any changes?  Seems kind of error prone,  
> especially as my
> memory continues to grow older...  :-)

This also works.
>
> I looked back in our dev mailing list and Craig had performed an  
> operation
> on two of the OpenJPA sub-projects that supposedly helps with this
> situation.  Is this operation "permanent"?

Yes. For existing files that should have the eol-style, svn  
automatically normalizes the files upon commit.

> That is, if I run this on each
> sub-project and push the changes out, will that clean up this line  
> ending
> thing?

Yes. When you first apply the property to a file, it might give you  
one of those 100% changed commits, but that will not happen on  
subsequent commits.

> The problem with this approach is that it seems to only work with
> existing files.  Any new files and we would have to remember to run  
> this
> operation again.

Yes, IIRC this is true. New files need to have the property added.  
There is a property that you can set in your environment but there's  
nothing that I can recall to set an entire directory tree permanently  
to this status.

Craig
>
> Any other ideas?  I would like to get this cleaned up so that my  
> commits
> look consistent with everybody else's.   When I do my diffs before
> committing, only the changed lines show up.  It's the commit  
> processing that
> picks up the whole file.
>
> Thank you and, again, my apologies!
> Kevin
>
> On 1/31/07, kwsutter@apache.org <kwsutter@apache.org> wrote:
>>
>> Author: kwsutter
>> Date: Wed Jan 31 11:27:11 2007
>> New Revision: 501955
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=501955
>> Log:
>> Simple test for OPENJPA-116.  Just modified the simple  
>> TestPersistence
>> testcase with a new variation for testing the exception on  
>> getDelegate()
>> when the EM is closed.
>>
>> Modified:
>>
>>     incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/ 
>> org/apache/openjpa/persistence/simple/TestPersistence.java
>>
>> Modified:
>> incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/ 
>> apache/openjpa/persistence/simple/TestPersistence.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa- 
>> persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ 
>> simple/TestPersistence.java?view=diff&rev=501955&r1=501954&r2=501955
>>
>> ===================================================================== 
>> =========
>> ---
>> incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/ 
>> apache/openjpa/persistence/simple/TestPersistence.java
>> (original)
>> +++
>> incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/ 
>> apache/openjpa/persistence/simple/TestPersistence.java
>> Wed Jan 31 11:27:11 2007
>> @@ -1,114 +1,134 @@
>> -/*
>> - * Copyright 2006 The Apache Software Foundation.
>> - *
>> - * 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.
>> - */
>> -package org.apache.openjpa.persistence.simple;
>> -
>> -import java.util.HashMap;
>> -import java.util.Map;
>> -import javax.persistence.EntityManager;
>> -import javax.persistence.EntityManagerFactory;
>> -import javax.persistence.EntityTransaction;
>> -import javax.persistence.Persistence;
>> -
>> -import junit.framework.TestCase;
>> -import junit.textui.TestRunner;
>> -import org.apache.openjpa.persistence.OpenJPAEntityManager;
>> -
>> -/**
>> - * Simple test case to get an EntityManager and perform some basic
>> operations.
>> - *
>> - * @author Marc Prud'hommeaux
>> - */
>> -public class TestPersistence
>> -    extends TestCase {
>> -
>> -    private EntityManagerFactory emf;
>> -
>> -    public void setUp() {
>> -        Map props = new HashMap(System.getProperties());
>> -        props.put("openjpa.MetaDataFactory",
>> -            "jpa(Types=" + AllFieldTypes.class.getName() + ")");
>> -        emf = Persistence.createEntityManagerFactory("test", props);
>> -    }
>> -
>> -    public void tearDown() {
>> -        if (emf == null)
>> -            return;
>> -        try {
>> -            EntityManager em = emf.createEntityManager();
>> -            em.getTransaction().begin();
>> -            em.createQuery("delete from  
>> AllFieldTypes").executeUpdate();
>> -            em.getTransaction().commit();
>> -            em.close();
>> -            emf.close();
>> -        } catch (Exception e) {
>> -        }
>> -    }
>> -
>> -    public void testCreateEntityManager() {
>> -        EntityManager em = emf.createEntityManager();
>> -
>> -        EntityTransaction t = em.getTransaction();
>> -        assertNotNull(t);
>> -        t.begin();
>> -        t.setRollbackOnly();
>> -        t.rollback();
>> -
>> -        // openjpa-facade test
>> -        assertTrue(em instanceof OpenJPAEntityManager);
>> -        OpenJPAEntityManager ojem = (OpenJPAEntityManager) em;
>> -        ojem.getFetchPlan().setMaxFetchDepth(1);
>> -        assertEquals(1, ojem.getFetchPlan().getMaxFetchDepth());
>> -        em.close();
>> -    }
>> -
>> -    public void testPersist() {
>> -        EntityManager em = emf.createEntityManager();
>> -        em.getTransaction().begin();
>> -        em.persist(new AllFieldTypes());
>> -        em.getTransaction().commit();
>> -        em.close();
>> -    }
>> -
>> -    public void testQuery() {
>> -        EntityManager em = emf.createEntityManager();
>> -        em.getTransaction().begin();
>> -        AllFieldTypes aft = new AllFieldTypes();
>> -        aft.setStringField("foo");
>> -        aft.setIntField(10);
>> -        em.persist(aft);
>> -        em.getTransaction().commit();
>> -        em.close();
>> -
>> -        em = emf.createEntityManager();
>> -        em.getTransaction().begin();
>> -        assertEquals(1, em.createQuery
>> -            ("select x from AllFieldTypes x where x.stringField =
>> 'foo'").
>> -            getResultList().size());
>> -        assertEquals(0, em.createQuery
>> -            ("select x from AllFieldTypes x where x.stringField =
>> 'bar'").
>> -            getResultList().size());
>> -        assertEquals(1, em.createQuery
>> -            ("select x from AllFieldTypes x where x.intField >=  
>> 10").
>> -            getResultList().size());
>> -        em.getTransaction().rollback();
>> -        em.close();
>> -    }
>> -
>> -    public static void main(String[] args) {
>> -        TestRunner.run(TestPersistence.class);
>> -    }
>> -}
>> -
>> +/*
>> + * Copyright 2006 The Apache Software Foundation.
>> + *
>> + * 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.
>> + */
>> +package org.apache.openjpa.persistence.simple;
>> +
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +import javax.persistence.EntityManager;
>> +import javax.persistence.EntityManagerFactory;
>> +import javax.persistence.EntityTransaction;
>> +import javax.persistence.Persistence;
>> +
>> +import junit.framework.TestCase;
>> +import junit.textui.TestRunner;
>> +import org.apache.openjpa.persistence.OpenJPAEntityManager;
>> +
>> +/**
>> + * Simple test case to get an EntityManager and perform some basic
>> operations.
>> + *
>> + * @author Marc Prud'hommeaux
>> + */
>> +public class TestPersistence
>> +    extends TestCase {
>> +
>> +    private EntityManagerFactory emf;
>> +
>> +    public void setUp() {
>> +        Map props = new HashMap(System.getProperties());
>> +        props.put("openjpa.MetaDataFactory",
>> +            "jpa(Types=" + AllFieldTypes.class.getName() + ")");
>> +        emf = Persistence.createEntityManagerFactory("test", props);
>> +    }
>> +
>> +    public void tearDown() {
>> +        if (emf == null)
>> +            return;
>> +        try {
>> +            EntityManager em = emf.createEntityManager();
>> +            em.getTransaction().begin();
>> +            em.createQuery("delete from  
>> AllFieldTypes").executeUpdate();
>> +            em.getTransaction().commit();
>> +            em.close();
>> +            emf.close();
>> +        } catch (Exception e) {
>> +        }
>> +    }
>> +
>> +    public void testCreateEntityManager() {
>> +        EntityManager em = emf.createEntityManager();
>> +
>> +        EntityTransaction t = em.getTransaction();
>> +        assertNotNull(t);
>> +        t.begin();
>> +        t.setRollbackOnly();
>> +        t.rollback();
>> +
>> +        // openjpa-facade test
>> +        assertTrue(em instanceof OpenJPAEntityManager);
>> +        OpenJPAEntityManager ojem = (OpenJPAEntityManager) em;
>> +        ojem.getFetchPlan().setMaxFetchDepth(1);
>> +        assertEquals(1, ojem.getFetchPlan().getMaxFetchDepth());
>> +        em.close();
>> +    }
>> +
>> +    public void testPersist() {
>> +        EntityManager em = emf.createEntityManager();
>> +        em.getTransaction().begin();
>> +        em.persist(new AllFieldTypes());
>> +        em.getTransaction().commit();
>> +        em.close();
>> +    }
>> +
>> +    public void testQuery() {
>> +        EntityManager em = emf.createEntityManager();
>> +        em.getTransaction().begin();
>> +        AllFieldTypes aft = new AllFieldTypes();
>> +        aft.setStringField("foo");
>> +        aft.setIntField(10);
>> +        em.persist(aft);
>> +        em.getTransaction().commit();
>> +        em.close();
>> +
>> +        em = emf.createEntityManager();
>> +        em.getTransaction().begin();
>> +        assertEquals(1, em.createQuery
>> +            ("select x from AllFieldTypes x where x.stringField =
>> 'foo'").
>> +            getResultList().size());
>> +        assertEquals(0, em.createQuery
>> +            ("select x from AllFieldTypes x where x.stringField =
>> 'bar'").
>> +            getResultList().size());
>> +        assertEquals(1, em.createQuery
>> +            ("select x from AllFieldTypes x where x.intField >=  
>> 10").
>> +            getResultList().size());
>> +        em.getTransaction().rollback();
>> +        em.close();
>> +    }
>> +
>> +    /**
>> +     * Ensures that an IllegalStateException is thrown if  
>> getDelegate is
>> called
>> +     * after closing the EntityManager.
>> +     */
>> +    public void testGetDelegateAfterClose() {
>> +        EntityManager em = emf.createEntityManager();
>> +
>> +        em.close();
>> +
>> +        try {
>> +            Object o = em.getDelegate();
>> +            fail();
>> +        }
>> +        catch(IllegalStateException ise) {
>> +            /*
>> +             * An IllegalStateException is expected. Nothing to  
>> do here.
>> +             */
>> +        }
>> +    }
>> +
>> +    public static void main(String[] args) {
>> +        TestRunner.run(TestPersistence.class);
>> +    }
>> +}
>> +
>>
>>
>>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message