Return-Path: X-Original-To: apmail-onami-commits-archive@minotaur.apache.org Delivered-To: apmail-onami-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A0CB10799 for ; Mon, 12 May 2014 06:43:05 +0000 (UTC) Received: (qmail 71555 invoked by uid 500); 12 May 2014 06:43:05 -0000 Delivered-To: apmail-onami-commits-archive@onami.apache.org Received: (qmail 71514 invoked by uid 500); 12 May 2014 06:43:05 -0000 Mailing-List: contact commits-help@onami.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@onami.apache.org Delivered-To: mailing list commits@onami.apache.org Received: (qmail 71507 invoked by uid 99); 12 May 2014 06:43:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2014 06:43:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2014 06:43:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 36ABB2388BBD; Mon, 12 May 2014 06:42:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1593897 [9/27] - in /onami/site/persist: ./ apidocs/assets/ apidocs/reference/ apidocs/reference/org/apache/onami/persist/ cobertura/ xref-test/ xref-test/org/apache/onami/persist/ xref-test/org/apache/onami/persist/test/ xref-test/org/apa... Date: Mon, 12 May 2014 06:42:10 -0000 To: commits@onami.apache.org From: sclassen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140512064218.36ABB2388BBD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: onami/site/persist/xref-test/allclasses-frame.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/allclasses-frame.html?rev=1593897&r1=1593896&r2=1593897&view=diff ============================================================================== --- onami/site/persist/xref-test/allclasses-frame.html (original) +++ onami/site/persist/xref-test/allclasses-frame.html Mon May 12 06:42:06 2014 @@ -1,5 +1,5 @@ - + @@ -12,67 +12,181 @@ Modified: onami/site/persist/xref-test/index.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/index.html?rev=1593897&r1=1593896&r2=1593897&view=diff ============================================================================== --- onami/site/persist/xref-test/index.html (original) +++ onami/site/persist/xref-test/index.html Mon May 12 06:42:06 2014 @@ -1,6 +1,7 @@ + Apache Onami Persistence 1.0.0-SNAPSHOT Reference Added: onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html?rev=1593897&view=auto ============================================================================== --- onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html (added) +++ onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html Mon May 12 06:42:06 2014 @@ -0,0 +1,106 @@ + + + +AggregatedExceptionTest xref + + + +
+1   package org.apache.onami.persist;
+2   
+3   /*
+4    * Licensed to the Apache Software Foundation (ASF) under one
+5    * or more contributor license agreements.  See the NOTICE file
+6    * distributed with this work for additional information
+7    * regarding copyright ownership.  The ASF licenses this file
+8    * to you under the Apache License, Version 2.0 (the
+9    * "License"); you may not use this file except in compliance
+10   * with the License.  You may obtain a copy of the License at
+11   *
+12   *   http://www.apache.org/licenses/LICENSE-2.0
+13   *
+14   * Unless required by applicable law or agreed to in writing,
+15   * software distributed under the License is distributed on an
+16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+17   * KIND, either express or implied.  See the License for the
+18   * specific language governing permissions and limitations
+19   * under the License.
+20   */
+21  
+22  import org.junit.Before;
+23  import org.junit.Test;
+24  
+25  import static org.hamcrest.CoreMatchers.is;
+26  import static org.hamcrest.CoreMatchers.sameInstance;
+27  import static org.junit.Assert.assertThat;
+28  import static org.junit.Assert.fail;
+29  
+30  /**
+31   * Test for {@link AggregatedException}.
+32   */
+33  public class AggregatedExceptionTest
+34  {
+35      private AggregatedException.Builder sut;
+36  
+37      @Before
+38      public void setUp()
+39          throws Exception
+40      {
+41          sut = new AggregatedException.Builder();
+42      }
+43  
+44      @Test
+45      public void shouldNotThrowAnythingWhenEmpty()
+46      {
+47          sut.throwRuntimeExceptionIfHasCauses( "test msg" );
+48      }
+49  
+50      @Test
+51      public void shouldThrowAggregatedExceptionWithAllCollectedExceptions()
+52      {
+53          final Exception e0 = new Exception();
+54          final Exception e1 = new Exception();
+55  
+56          try
+57          {
+58              sut.add( e0 );
+59              sut.add( e1 );
+60              sut.throwRuntimeExceptionIfHasCauses( "test msg" );
+61          }
+62  
+63          catch ( AggregatedException e )
+64          {
+65              assertThat( e.getNumCauses(), is( 2 ) );
+66              assertThat( e.getCauses()[0], sameInstance( (Throwable) e0 ) );
+67              assertThat( e.getCauses()[1], sameInstance( (Throwable) e1 ) );
+68              return;
+69          }
+70  
+71          fail( "must throw AggregatedException" );
+72      }
+73  
+74      @Test
+75      public void shouldThrowOriginalExceptionWhenOnlyOne()
+76      {
+77          Exception e0 = new RuntimeException(  );
+78  
+79          try
+80          {
+81              sut.add( e0 );
+82              sut.throwRuntimeExceptionIfHasCauses( "test msg" );
+83          }
+84  
+85          catch ( RuntimeException e )
+86          {
+87              assertThat( e, sameInstance( (Throwable) e0 ) );
+88              return;
+89          }
+90  
+91          fail( "must throw RuntimeException" );
+92      }
+93  }
+
+
+ + + \ No newline at end of file Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AggregatedExceptionTest.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html?rev=1593897&view=auto ============================================================================== --- onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html (added) +++ onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html Mon May 12 06:42:06 2014 @@ -0,0 +1,257 @@ + + + +AllPersistenceUnitsTest xref + + + +
+1   package org.apache.onami.persist;
+2   
+3   /*
+4    * Licensed to the Apache Software Foundation (ASF) under one
+5    * or more contributor license agreements.  See the NOTICE file
+6    * distributed with this work for additional information
+7    * regarding copyright ownership.  The ASF licenses this file
+8    * to you under the Apache License, Version 2.0 (the
+9    * "License"); you may not use this file except in compliance
+10   * with the License.  You may obtain a copy of the License at
+11   *
+12   *   http://www.apache.org/licenses/LICENSE-2.0
+13   *
+14   * Unless required by applicable law or agreed to in writing,
+15   * software distributed under the License is distributed on an
+16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+17   * KIND, either express or implied.  See the License for the
+18   * specific language governing permissions and limitations
+19   * under the License.
+20   */
+21  
+22  import org.junit.Before;
+23  import org.junit.Test;
+24  
+25  import static org.hamcrest.CoreMatchers.is;
+26  import static org.junit.Assert.assertThat;
+27  import static org.junit.Assert.fail;
+28  import static org.mockito.Mockito.*;
+29  
+30  /**
+31   * Test for {@link AllPersistenceUnits}.
+32   */
+33  public class AllPersistenceUnitsTest
+34  {
+35      private AllPersistenceUnits sut;
+36  
+37      private PersistenceService ps1;
+38  
+39      private PersistenceService ps2;
+40  
+41      private UnitOfWork uow1;
+42  
+43      private UnitOfWork uow2;
+44  
+45      @Before
+46      public void setUp()
+47          throws Exception
+48      {
+49          sut = new AllPersistenceUnits();
+50  
+51          ps1 = mock( PersistenceService.class );
+52          ps2 = mock( PersistenceService.class );
+53  
+54          uow1 = mock( UnitOfWork.class );
+55          uow2 = mock( UnitOfWork.class );
+56  
+57          sut.add( ps1, uow1 );
+58          sut.add( ps2, uow2 );
+59      }
+60  
+61      @Test
+62      public void shouldStartOnAllPersistenceServices()
+63          throws Exception
+64      {
+65          // when
+66          sut.startAllStoppedPersistenceServices();
+67  
+68          // then
+69          verify( ps1 ).start();
+70          verify( ps2 ).start();
+71      }
+72  
+73      @Test
+74      public void shouldStartOnRunningPersistenceServices()
+75          throws Exception
+76      {
+77          // given
+78          doReturn( true ).when( ps1 ).isRunning();
+79          doReturn( true ).when( ps2 ).isRunning();
+80  
+81          // when
+82          sut.startAllStoppedPersistenceServices();
+83  
+84          // then
+85          verify( ps1, never() ).start();
+86          verify( ps2, never() ).start();
+87      }
+88  
+89      @Test
+90      public void shouldStartOnAllPersistenceServicesEvenInCaseOfException()
+91          throws Exception
+92      {
+93          // given
+94          doThrow( new RuntimeException() ).when( ps1 ).start();
+95          doThrow( new RuntimeException() ).when( ps2 ).start();
+96  
+97          // when
+98          try
+99          {
+100             sut.startAllStoppedPersistenceServices();
+101         }
+102 
+103         // then
+104         catch ( AggregatedException e )
+105         {
+106             verify( ps1 ).start();
+107             verify( ps2 ).start();
+108             assertThat( e.getNumCauses(), is( 2 ) );
+109             return;
+110         }
+111 
+112         fail( "must throw AggregatedException" );
+113     }
+114 
+115     @Test
+116     public void shouldStopOnAllPersistenceServices()
+117         throws Exception
+118     {
+119         // when
+120         sut.stopAllPersistenceServices();
+121 
+122         // then
+123         verify( ps1 ).stop();
+124         verify( ps2 ).stop();
+125     }
+126 
+127     @Test
+128     public void shouldStopOnAllPersistenceServicesEvenInCaseOfException()
+129         throws Exception
+130     {
+131         // given
+132         doThrow( new RuntimeException() ).when( ps1 ).stop();
+133         doThrow( new RuntimeException() ).when( ps2 ).stop();
+134 
+135         // when
+136         try
+137         {
+138             sut.stopAllPersistenceServices();
+139         }
+140 
+141         // then
+142         catch ( AggregatedException e )
+143         {
+144             verify( ps1 ).stop();
+145             verify( ps2 ).stop();
+146             assertThat( e.getNumCauses(), is( 2 ) );
+147             return;
+148         }
+149 
+150         fail( "must throw AggregatedException" );
+151     }
+152 
+153     @Test
+154     public void shouldBeginOnAllUnitsOfWork()
+155         throws Exception
+156     {
+157         // when
+158         sut.beginAllInactiveUnitsOfWork();
+159 
+160         // then
+161         verify( uow1 ).begin();
+162         verify( uow2 ).begin();
+163     }
+164 
+165     @Test
+166     public void shouldNotBeginOnActiveUnitsOfWork()
+167         throws Exception
+168     {
+169         // given
+170         doReturn( true ).when( uow1 ).isActive();
+171         doReturn( true ).when( uow2 ).isActive();
+172 
+173         // when
+174         sut.beginAllInactiveUnitsOfWork();
+175 
+176         // then
+177         verify( uow1, never() ).begin();
+178         verify( uow2, never() ).begin();
+179     }
+180 
+181     @Test
+182     public void shouldBeginOnAllUnitsOfWorkEvenInCaseOfException()
+183         throws Exception
+184     {
+185         // given
+186         doThrow( new RuntimeException() ).when( uow1 ).begin();
+187         doThrow( new RuntimeException() ).when( uow2 ).begin();
+188 
+189         // when
+190         try
+191         {
+192             sut.beginAllInactiveUnitsOfWork();
+193         }
+194 
+195         // then
+196         catch ( AggregatedException e )
+197         {
+198             verify( uow1 ).begin();
+199             verify( uow2 ).begin();
+200             assertThat( e.getNumCauses(), is( 2 ) );
+201             return;
+202         }
+203 
+204         fail( "must throw AggregatedException" );
+205     }
+206 
+207     @Test
+208     public void shouldEndOnAllUnitsOfWork()
+209         throws Exception
+210     {
+211         // when
+212         sut.endAllUnitsOfWork();
+213 
+214         // then
+215         verify( uow1 ).end();
+216         verify( uow2 ).end();
+217     }
+218 
+219     @Test
+220     public void shouldEndOnAllUnitsOfWorkEvenInCaseOfException()
+221         throws Exception
+222     {
+223         // given
+224         doThrow( new RuntimeException() ).when( uow1 ).end();
+225         doThrow( new RuntimeException() ).when( uow2 ).end();
+226 
+227         // when
+228         try
+229         {
+230             sut.endAllUnitsOfWork();
+231         }
+232 
+233         // then
+234         catch ( AggregatedException e )
+235         {
+236             verify( uow1 ).end();
+237             verify( uow2 ).end();
+238             assertThat( e.getNumCauses(), is( 2 ) );
+239             return;
+240         }
+241 
+242         fail( "must throw AggregatedException" );
+243     }
+244 }
+
+
+ + + \ No newline at end of file Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: onami/site/persist/xref-test/org/apache/onami/persist/AllPersistenceUnitsTest.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html?rev=1593897&view=auto ============================================================================== --- onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html (added) +++ onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html Mon May 12 06:42:06 2014 @@ -0,0 +1,159 @@ + + + +ApplicationManagedEntityManagerFactoryProviderTest xref + + + +
+1   package org.apache.onami.persist;
+2   
+3   /*
+4    * Licensed to the Apache Software Foundation (ASF) under one
+5    * or more contributor license agreements.  See the NOTICE file
+6    * distributed with this work for additional information
+7    * regarding copyright ownership.  The ASF licenses this file
+8    * to you under the Apache License, Version 2.0 (the
+9    * "License"); you may not use this file except in compliance
+10   * with the License.  You may obtain a copy of the License at
+11   *
+12   *   http://www.apache.org/licenses/LICENSE-2.0
+13   *
+14   * Unless required by applicable law or agreed to in writing,
+15   * software distributed under the License is distributed on an
+16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+17   * KIND, either express or implied.  See the License for the
+18   * specific language governing permissions and limitations
+19   * under the License.
+20   */
+21  
+22  import org.junit.Before;
+23  import org.junit.Test;
+24  
+25  import javax.persistence.EntityManagerFactory;
+26  
+27  import static org.hamcrest.CoreMatchers.is;
+28  import static org.hamcrest.CoreMatchers.sameInstance;
+29  import static org.junit.Assert.assertThat;
+30  import static org.mockito.Mockito.*;
+31  
+32  /**
+33   * Test for {@link ApplicationManagedEntityManagerFactoryProviderTest}.
+34   */
+35  public class ApplicationManagedEntityManagerFactoryProviderTest
+36  {
+37      private ApplicationManagedEntityManagerFactoryProvider sut;
+38  
+39      private EntityManagerFactory emf;
+40  
+41      private EntityManagerFactoryFactory emfFactory;
+42  
+43      @Before
+44      public void setup()
+45      {
+46          // input
+47          emfFactory = mock( EntityManagerFactoryFactory.class );
+48  
+49          // subject under test
+50          sut = new ApplicationManagedEntityManagerFactoryProvider( emfFactory );
+51  
+52          // helpers
+53          emf = mock( EntityManagerFactory.class );
+54          doReturn( emf ).when( emfFactory ).createApplicationManagedEntityManagerFactory();
+55      }
+56  
+57      @Test
+58      public void isRunningShouldReturnFalseBeforeStarting()
+59      {
+60          assertThat( sut.isRunning(), is( false ) );
+61      }
+62  
+63      @Test
+64      public void stoppingWhenNotRunningShouldDoNothing()
+65      {
+66          sut.stop();
+67  
+68          assertThat( sut.isRunning(), is( false ) );
+69      }
+70  
+71      @Test
+72      public void isRunningShouldReturnTrueAfterStarting()
+73      {
+74          sut.start();
+75  
+76          assertThat( sut.isRunning(), is( true ) );
+77          verify( emfFactory ).createApplicationManagedEntityManagerFactory();
+78      }
+79  
+80      @Test( expected = IllegalStateException.class )
+81      public void startingAfterAlreadyStartedShouldThrowException()
+82      {
+83          sut.start();
+84          sut.start();
+85      }
+86  
+87      @Test
+88      public void isRunningShouldReturnFalseAfterStartingAndStopping()
+89      {
+90          sut.start();
+91          sut.stop();
+92  
+93          assertThat( sut.isRunning(), is( false ) );
+94          verify( emf ).close();
+95      }
+96  
+97      @Test
+98      public void restartingShouldWork()
+99      {
+100         sut.start();
+101         sut.stop();
+102         sut.start();
+103 
+104         assertThat( sut.isRunning(), is( true ) );
+105         verify( emfFactory, times( 2 ) ).createApplicationManagedEntityManagerFactory();
+106         verify( emf ).close();
+107     }
+108 
+109     @Test(expected = RuntimeException.class)
+110     public void stopShouldWorkEvenInCaseOfException()
+111     {
+112         doThrow( new RuntimeException() ).when( emf ).close();
+113 
+114         sut.start();
+115         try
+116         {
+117             sut.stop();
+118         }
+119         finally
+120         {
+121 
+122             assertThat( sut.isRunning(), is( false ) );
+123             verify( emf ).close();
+124         }
+125     }
+126 
+127     @Test( expected = IllegalStateException.class )
+128     public void getShouldThrowExceptionWhenNotStarted()
+129     {
+130         sut.get();
+131     }
+132 
+133     @Test
+134     public void getShouldReturnEmf()
+135     {
+136         sut.start();
+137 
+138         assertThat( sut.get(), sameInstance( emf ) );
+139     }
+140 
+141     @Test( expected = NullPointerException.class )
+142     public void emfFactoryIsMandatory()
+143     {
+144         new ApplicationManagedEntityManagerFactoryProvider( null );
+145     }
+146 }
+
+
+ + + \ No newline at end of file Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ApplicationManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html URL: http://svn.apache.org/viewvc/onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html?rev=1593897&view=auto ============================================================================== --- onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html (added) +++ onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html Mon May 12 06:42:06 2014 @@ -0,0 +1,141 @@ + + + +ContainerManagedEntityManagerFactoryProviderTest xref + + + +
+1   package org.apache.onami.persist;
+2   
+3   /*
+4    * Licensed to the Apache Software Foundation (ASF) under one
+5    * or more contributor license agreements.  See the NOTICE file
+6    * distributed with this work for additional information
+7    * regarding copyright ownership.  The ASF licenses this file
+8    * to you under the Apache License, Version 2.0 (the
+9    * "License"); you may not use this file except in compliance
+10   * with the License.  You may obtain a copy of the License at
+11   *
+12   *   http://www.apache.org/licenses/LICENSE-2.0
+13   *
+14   * Unless required by applicable law or agreed to in writing,
+15   * software distributed under the License is distributed on an
+16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+17   * KIND, either express or implied.  See the License for the
+18   * specific language governing permissions and limitations
+19   * under the License.
+20   */
+21  
+22  import org.junit.Before;
+23  import org.junit.Test;
+24  
+25  import javax.persistence.EntityManagerFactory;
+26  
+27  import static org.hamcrest.CoreMatchers.is;
+28  import static org.hamcrest.CoreMatchers.sameInstance;
+29  import static org.junit.Assert.assertThat;
+30  import static org.mockito.Mockito.*;
+31  
+32  /**
+33   * Test for {@link ContainerManagedEntityManagerFactoryProvider}.
+34   */
+35  public class ContainerManagedEntityManagerFactoryProviderTest
+36  {
+37      private ContainerManagedEntityManagerFactoryProvider sut;
+38  
+39      private EntityManagerFactory emf;
+40  
+41      private EntityManagerFactorySource emfSource;
+42  
+43      @Before
+44      public void setup()
+45      {
+46          // input
+47          emfSource = mock( EntityManagerFactorySource.class );
+48  
+49          // subject under test
+50          sut = new ContainerManagedEntityManagerFactoryProvider( emfSource );
+51  
+52          // helpers
+53          emf = mock( EntityManagerFactory.class );
+54          doReturn( emf ).when( emfSource ).getEntityManagerFactory();
+55      }
+56  
+57      @Test
+58      public void isRunningShouldReturnFalseBeforeStarting()
+59      {
+60          assertThat( sut.isRunning(), is( false ) );
+61      }
+62  
+63      @Test
+64      public void stoppingWhenNotRunningShouldDoNothing()
+65      {
+66          sut.stop();
+67  
+68          assertThat( sut.isRunning(), is( false ) );
+69      }
+70  
+71      @Test
+72      public void isRunningShouldReturnTrueAfterStarting()
+73      {
+74          sut.start();
+75  
+76          assertThat( sut.isRunning(), is( true ) );
+77          verify( emfSource ).getEntityManagerFactory();
+78      }
+79  
+80      @Test( expected = IllegalStateException.class )
+81      public void startingAfterAlreadyStartedShouldThrowException()
+82      {
+83          sut.start();
+84          sut.start();
+85      }
+86  
+87      @Test
+88      public void isRunningShouldReturnFalseAfterStartingAndStopping()
+89      {
+90          sut.start();
+91          sut.stop();
+92  
+93          assertThat( sut.isRunning(), is( false ) );
+94          verify( emf, never() ).close();
+95      }
+96  
+97      @Test
+98      public void restartingShouldWork()
+99      {
+100         sut.start();
+101         sut.stop();
+102         sut.start();
+103 
+104         assertThat( sut.isRunning(), is( true ) );
+105         verify( emfSource, times( 2 ) ).getEntityManagerFactory();
+106         verify( emf, never() ).close();
+107     }
+108 
+109     @Test( expected = IllegalStateException.class )
+110     public void getShouldThrowExceptionWhenNotStarted()
+111     {
+112         sut.get();
+113     }
+114 
+115     @Test
+116     public void getShouldReturnEmf()
+117     {
+118         sut.start();
+119 
+120         assertThat( sut.get(), sameInstance( emf ) );
+121     }
+122 
+123     @Test( expected = NullPointerException.class )
+124     public void emfSourceIsMandatory()
+125     {
+126         new ContainerManagedEntityManagerFactoryProvider( null );
+127     }
+128 }
+
+
+ + + \ No newline at end of file Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: onami/site/persist/xref-test/org/apache/onami/persist/ContainerManagedEntityManagerFactoryProviderTest.html ------------------------------------------------------------------------------ svn:mime-type = text/html