Package org.apache.openejb.devtools.core

Examples of org.apache.openejb.devtools.core.JDTFacade


      status.addFatalError(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError.parse"));
      return new NullChange();
    }
   
    try {
      JDTFacade jdtFacade = new JDTFacade(project);
     
      List<Converter> converterList = new ArrayList<Converter>();
      converterList.add(new SessionBeanConverter(jdtFacade));
      converterList.add(new EntityBeanConverter(jdtFacade));
      converterList.add(new EjbReferencesConverter(jdtFacade));
     
      if (ejb3Interfaces) {
        SessionBeanInterfaceModifier converter = new SessionBeanInterfaceModifier(jdtFacade);
        converter.setUseHome(useHomeInterface);
        converterList.add(converter);
      }
     
      if (remoteAnnotations) {
        SessionBeanRemoteAnnotationAdder converter = new SessionBeanRemoteAnnotationAdder(jdtFacade);
        converter.setUseHome(useHomeInterface);
        converterList.add(converter);
      }
     
      if (convertEntityBeansToPojos) {
        converterList.add(new EntityBeanPojoConverter(jdtFacade));
      }
     
      if (generateEntityManagerCode) {
        converterList.add(new EntityBeanUsageConverter(jdtFacade));
      }
     
      Converter[] converters = converterList.toArray(new Converter[0]);
     
      OpenEjbXmlConverter converter = new OpenEjbXmlConverter(converters, new EclipseProjectClassLoader(getClass().getClassLoader(), project));
      converter.convert(ejbJarInputSource, openEjbJarInputSource);

      String[] warnings = jdtFacade.getWarnings();
      for (String warning : warnings) {
        status.addWarning(warning);
      }

      return jdtFacade.getChange();

    } catch (Exception e) {
      status.addFatalError(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError") + ":" + e.getLocalizedMessage());
      return new NullChange();
    }
View Full Code Here


  private void doTest(String startFilename, String expectedFilename, String bean) throws CoreException, IOException {
    fixture.addClassToProject("org.superbiz.ProductBean", fixture.getStreamContent(getClass().getResourceAsStream("Ejb21ProductBean.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    fixture.addClassToProject("org.superbiz.ProductHome", fixture.getStreamContent(getClass().getResourceAsStream("Ejb21ProductHome.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    fixture.addClassToProject(bean, fixture.getStreamContent(getClass().getResourceAsStream(startFilename))); //$NON-NLS-1$ //$NON-NLS-2$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addField(bean, "entityManagerFactory", "javax.persistence.EntityManagerFactory");

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("name", "TestPU");
    facade.addFieldAnnotation(bean, "entityManagerFactory", PersistenceUnit.class, properties);
   
   
    String code = "javax.persistence.EntityManager entityManager = entityManagerFactory.createEntityManager();\r\n" +
        "javax.persistence.Query query = entityManager.createQuery(\"SELECT p from Product p where p.name = ?1\");\r\n" +
        "query.getResultList();";
   
    facade.changeInvocationsTo("org.superbiz.ProductHome", "findBy", new String[] { "java.lang.String"}, code); //$NON-NLS-1$
   
    Change change = facade.getChange();
    change.perform(new NullProgressMonitor());

    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream(expectedFilename)), fixture.getClassContents(bean)); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

    super(name);
  }

  public void testShouldAddAnAnnotationToAJavaSourceFile() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean1", fixture.getStreamContent(getClass().getResourceAsStream("Test1.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addClassAnnotation("org.apache.openejb.test.TestBean1", Stateless.class, null); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);

    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult1.txt")), getClassContents("org.apache.openejb.test.TestBean1")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  }
 
  public void testShouldAddAnAnnotationToAJavaSourceFileAndNotAddAnImportIfTheImportAlreadyExists() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean2", fixture.getStreamContent(getClass().getResourceAsStream("Test2.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
   
    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addClassAnnotation("org.apache.openejb.test.TestBean2", Stateless.class, null); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult2.txt")), getClassContents("org.apache.openejb.test.TestBean2")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult2.txt")), getClassContents("org.apache.openejb.test.TestBean2")); //$NON-NLS-1$ //$NON-NLS-2$
  }

  public void testShouldAddAnAnnotationToAJavaSourceFileAndNotAddAnImportIfThePackageIsAlreadyImported() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean3", fixture.getStreamContent(getClass().getResourceAsStream("Test3.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addClassAnnotation("org.apache.openejb.test.TestBean3", Stateless.class, null); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult3.txt")), getClassContents("org.apache.openejb.test.TestBean3")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  public void testShouldAddAnnotationWithProperties() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean4", fixture.getStreamContent(getClass().getResourceAsStream("Test4.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    Map<String,Object> properties = new HashMap<String,Object>();
    properties.put("name", "Test"); //$NON-NLS-1$ //$NON-NLS-2$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addClassAnnotation("org.apache.openejb.test.TestBean4", Entity.class, properties); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult4.txt")), getClassContents("org.apache.openejb.test.TestBean4")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  public void testShouldAddAnnotationWithEnumProperty() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean5", fixture.getStreamContent(getClass().getResourceAsStream("Test5.txt"))); //$NON-NLS-1$ //$NON-NLS-2$
    Map<String,Object> properties = new HashMap<String,Object>();
    properties.put("value", TransactionManagementType.BEAN); //$NON-NLS-1$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addClassAnnotation("org.apache.openejb.test.TestBean5", TransactionManagement.class, properties); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult5.txt")), getClassContents("org.apache.openejb.test.TestBean5")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  }

  public void testShouldAddMethodAnnotationWithEnumProperty() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean6", fixture.getStreamContent(getClass().getResourceAsStream("Test6.txt"))); //$NON-NLS-1$ //$NON-NLS-2$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    facade.addMethodAnnotation("org.apache.openejb.test.TestBean6", "echoHelloWorld", new String[] {"java.lang.String"}, ManyToMany.class, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult6.txt")), getClassContents("org.apache.openejb.test.TestBean6")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  }
 
  public void testShouldAddAnnotationWithClassAttributeWithStringPassedIn() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean7", fixture.getStreamContent(getClass().getResourceAsStream("Test7.txt"))); //$NON-NLS-1$ //$NON-NLS-2$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    Map<String, Object> properties = new HashMap<String,Object>();
    properties.put("value", new String[] { "org.apache.openejb.test.Test7" }); //$NON-NLS-1$ //$NON-NLS-2$
    facade.addClassAnnotation("org.apache.openejb.test.TestBean7", Remote.class, properties); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult7.txt")), getClassContents("org.apache.openejb.test.TestBean7")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

  }

  public void testShouldAddAnnotationWithNestedAttributes() throws Exception {
    addNewClassToProject("org.apache.openejb.test.TestBean8", fixture.getStreamContent(getClass().getResourceAsStream("Test8.txt"))); //$NON-NLS-1$ //$NON-NLS-2$

    JDTFacade facade = new JDTFacade(fixture.getProject());
    Map<String, Object> properties = new HashMap<String, Object>();
   
    Map<String, Object> activationConfigProperty = new HashMap<String, Object>();
    activationConfigProperty.put("propertyName", "destinationType"); //$NON-NLS-1$ //$NON-NLS-2$
    activationConfigProperty.put("propertyValue", "javax.jms.Queue"); //$NON-NLS-1$ //$NON-NLS-2$
   
    properties.put("activationConfig", new Map[] { activationConfigProperty }); //$NON-NLS-1$
   
    facade.addClassAnnotation("org.apache.openejb.test.TestBean8", MessageDriven.class, properties); //$NON-NLS-1$
   
    Change change = facade.getChange();
    FakeProgressMonitor progressMonitor = new FakeProgressMonitor();
    change.perform(progressMonitor);
   
    assertEquals(fixture.getStreamContent(getClass().getResourceAsStream("ExpectedResult8.txt")), getClassContents("org.apache.openejb.test.TestBean8")); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

TOP

Related Classes of org.apache.openejb.devtools.core.JDTFacade

Copyright © 2018 www.massapicom. 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.