View Javadoc

1   /*
2    * $Id: SingletonObjectFactoryTestCase.java 22377 2011-07-11 12:41:42Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.object;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertSame;
15  
16  public class SingletonObjectFactoryTestCase extends AbstractObjectFactoryTestCase
17  {
18  
19      @Override
20      public AbstractObjectFactory getUninitialisedObjectFactory()
21      {
22          return new SingletonObjectFactory();
23      }
24  
25      @Override
26      public void testGetObjectClass() throws Exception
27      {
28          SingletonObjectFactory factory = (SingletonObjectFactory) getUninitialisedObjectFactory();
29          factory.setObjectClass(Object.class);
30          factory.initialise();
31          
32          assertEquals(Object.class, factory.getObjectClass());
33      }
34  
35      @Override
36      public void testGet() throws Exception
37      {
38          SingletonObjectFactory factory = (SingletonObjectFactory) getUninitialisedObjectFactory();
39          factory.setObjectClass(Object.class);
40          factory.initialise();
41          
42          assertSame(factory.getInstance(muleContext), factory.getInstance(muleContext));
43      }
44  
45  }