Example #1
0
  public JstType translate() {

    TranslationController controller = getTranslationController(m_initializer);
    JstType type = controller.targetedTranslation(m_javaCls);

    logTime("Translate");
    getCtx().getErrorReporter().reportAll();
    return type;
  }
Example #2
0
  public static void testType(
      Class srcType,
      TranslationController controller,
      boolean persistVjo,
      boolean persistJsr,
      boolean validate) {

    // Reset
    // LibManager.getInstance().clear();
    // JstCache.getInstance().clear();
    // TranslateCtx.createCtx();
    getCtx().setTranslateInfo(new HashMap<JstType, TranslateInfo>());

    // Start
    getTracer().startGroup(ID, new TraceAttr("name", srcType.getSimpleName()));
    // getLogger().log(Level.INFO, "Started testing type " +
    // srcType.getSimpleName());

    TestHelper helper = new TestHelper(srcType, controller.getInitializer());
    String vjoActual = "";

    JstType jstType = controller.targetedTranslation(srcType);

    vjoActual = helper.toVjo(jstType, CodeStyle.PRETTY);

    String jsrActual = "";
    jsrActual = helper.toJsr(jstType, CodeStyle.PRETTY);

    printErrors(controller.getErrors());
    printExceptions(controller.getExceptions());

    if (persistVjo) {
      helper.writeVjo(vjoActual);
    }

    if (persistJsr) {
      helper.writeJsr(jsrActual);
    }

    // Assert
    if (validate) {
      String jsrExpectedResult = helper.getExpectedJsr();
      String vjoExpectedResult = helper.getExpectedVjo();
      Assert.assertEquals(
          "Expected Result : \n" + vjoExpectedResult + "\nActual Result : \n" + vjoActual,
          vjoExpectedResult,
          vjoActual);

      Assert.assertEquals(
          "Expected Result : \n" + jsrExpectedResult + "\nActual Result : \n" + jsrActual,
          jsrExpectedResult,
          jsrActual);
    }
    // getLogger().log(Level.INFO, "Ended testing type " +
    // srcType.getSimpleName());
  }
Example #3
0
 public static void vjoOnDemand(Class srcType, TranslationController controller) {
   List<JstType> jstTypes = controller.onDemandTranslation(srcType);
   try {
     writeVjo(jstTypes);
   } catch (ClassNotFoundException e) {
     System.err.println("CLASS TO TRANSLATE WAS NOT FOUND");
     e.printStackTrace();
   }
 }