Examples of Mockery


Examples of org.jmock.Mockery

   
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        source = new StaxSource(StaxUtil.createReader(new StringSource(XML)));
        context = new Mockery();
    }
View Full Code Here

Examples of org.jmock.Mockery

import java.util.List;
import java.util.ArrayList;

public class EntityBeanUsageConverterTest extends TestCase {
    public void testShouldGenerateEntityManagerCodeForUsageOfEntityBean() throws Exception {
        Mockery context = new Mockery();

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).addField("org.superbiz.StoreBean", "emf", "javax.persistence.EntityManagerFactory");

                Map<String, Object> emfProps = new HashMap<String, Object>();
                emfProps.put("name", "OpenEJBPU");
                one(facade).addFieldAnnotation("org.superbiz.StoreBean", "emf", PersistenceUnit.class, emfProps);

                List<String[]> ejbCreateSigs = new ArrayList<String[]>();
                ejbCreateSigs.add(new String[] { "java.lang.Integer" });
                one(facade).getSignatures("org.superbiz.ProductHome", "create");
                will(returnValue(ejbCreateSigs));

                one(facade).convertMethodToConstructor("org.superbiz.ProductBean", "ejbCreate", new String[] { "java.lang.Integer" });
                one(facade).changeInvocationsToConstructor("org.superbiz.ProductHome", "create", new String[] { "java.lang.Integer" }, "org.superbiz.ProductBean");

                one(facade).getMethodReturnType("org.superbiz.ProductHome", "findAll", new String[0]);
                will(returnValue("java.util.Collection"));

                one(facade).isTypeCollection("java.util.Collection");
                will(returnValue(true));

                one(facade).changeInvocationsTo("org.superbiz.ProductHome", "findAll", new String[0], "javax.persistence.EntityManager entityManager = entityManagerFactory.createEntityManager();\r\njavax.persistence.Query query = entityManager.createQuery(\"SELECT p from Product p\");\r\nquery.getResultList();\r\n");
            }
        });

        AppModule module = new TestFixture().getAppModule("simple-session-and-entity-ejb-jar.xml", null);
        new EntityBeanUsageConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

Examples of org.jmock.Mockery

import junit.framework.TestCase;

public class EjbReferencesConverterTest extends TestCase {
  public void testShouldNotThrowAnExceptionWhenProcessingAnEmptyEjbJar() throws Exception {
    Mockery context = new Mockery();
   
    IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("empty-ejb-jar.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
View Full Code Here

Examples of org.jmock.Mockery

   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
  }
 
  public void testShouldNotThrowAnExceptionWhenProcessingAnEmptyEnterpriseBeansElement() throws Exception {
    Mockery context = new Mockery();
   
    IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("nobeans-ejb-jar.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
View Full Code Here

Examples of org.jmock.Mockery

   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
  }

  public void testShouldNotThrowAnExceptionIfSessionBeanHasNoRemoteAndNoLocalClasses() throws Exception {
    Mockery context = new Mockery();
   
    IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("badsession-ejb-jar.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
View Full Code Here

Examples of org.jmock.Mockery

   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
  }
 
  public void testShouldNotThrowAnExceptionIfSessionBeanIsEmpty() throws Exception {
    Mockery context = new Mockery();
   
    IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("emptysession-ejb-jar.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
View Full Code Here

Examples of org.jmock.Mockery

   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
  }
 
  public void testShouldAddDIAnnotationForRemoteInterface() throws Exception {
    Mockery context = new Mockery();
   
    final IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("single-session-bean.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
    EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
        ejbModule.setClassLoader(classLoader);
   
    AppModule appModule = new AppModule(classLoader, "ModuleToConvert"); //$NON-NLS-1$
    appModule.getEjbModules().add(ejbModule);
   
    context.checking(new Expectations() {
      {
        one(jdtFacade).addAnnotationToFieldsOfType("org.superbiz.Store", EJB.class,  null);
      }
    });
   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
    context.assertIsSatisfied();
  }
View Full Code Here

Examples of org.jmock.Mockery

    new EjbReferencesConverter(jdtFacade).convert(appModule);
    context.assertIsSatisfied();
  }

  public void testShouldAddDIAnnotationForLocalInterface() throws Exception {
    Mockery context = new Mockery();
   
    final IJDTFacade jdtFacade = context.mock(IJDTFacade.class);
    InputStream is = getClass().getResourceAsStream("single-session-bean-local.xml");
    ClassLoader classLoader = getClass().getClassLoader();
   
    InputSource ejbJarSrc = new InputSource(is);
    EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
    EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
        ejbModule.setClassLoader(classLoader);
   
    AppModule appModule = new AppModule(classLoader, "ModuleToConvert"); //$NON-NLS-1$
    appModule.getEjbModules().add(ejbModule);
   
    context.checking(new Expectations() {
      {
        one(jdtFacade).addAnnotationToFieldsOfType("org.superbiz.Store", EJB.class,  null);
      }
    });
   
    new EjbReferencesConverter(jdtFacade).convert(appModule);
    context.assertIsSatisfied();
  }
View Full Code Here

Examples of org.jmock.Mockery

import org.jmock.Expectations;
import org.apache.openejb.config.AppModule;

public class SessionBeanInterfaceModifierTest extends TestCase {
    public void testShouldRemoveEJBObjectInterfaceAndAddRemoteInterface() throws Exception {
        Mockery context = new Mockery();

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeInterface("org.superbiz.StoreBean", "javax.ejb.SessionBean");
                one(facade).removeInterface("org.superbiz.Store", "javax.ejb.EJBObject");
                one(facade).addInterface("org.superbiz.StoreBean", "org.superbiz.Store");
            }
        });

        AppModule module = new TestFixture().getAppModule("single-session-bean.xml", null);
        new SessionBeanInterfaceModifier(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

Examples of org.jmock.Mockery

        context.assertIsSatisfied();
    }

    public void testShouldRemoveEJBLocalObjectInterfaceAndAddLocalInterface() throws Exception {
        Mockery context = new Mockery();

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeInterface("org.superbiz.StoreBean", "javax.ejb.SessionBean");
                one(facade).removeInterface("org.superbiz.Store", "javax.ejb.EJBLocalObject");
                one(facade).addInterface("org.superbiz.StoreBean", "org.superbiz.Store");
            }
        });

        AppModule module = new TestFixture().getAppModule("single-session-bean-local.xml", null);
        new SessionBeanInterfaceModifier(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.