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