コード例 #1
0
ファイル: APITest.java プロジェクト: fanlong/spoon
  @Test
  public void testOverrideOutputWriter() throws Exception {
    // this test that we can correctly set the Java output processor
    final List<Object> l = new ArrayList<Object>();
    Launcher spoon =
        new Launcher() {
          @Override
          public JavaOutputProcessor createOutputWriter(
              File sourceOutputDir, Environment environment) {
            return new JavaOutputProcessor() {
              @Override
              public void process(CtType<?> e) {
                l.add(e);
              }

              @Override
              public void init() {
                // we do nothing
              }
            };
          }
        };
    spoon.run(
        new String[] {
          "-i", "src/test/resources/spoon/test/api/",
          "-o", "target/spooned/apitest"
        });
    Assert.assertEquals(2, l.size());
  }
コード例 #2
0
ファイル: APITest.java プロジェクト: fanlong/spoon
  @Test
  public void testDestinationOfSpoon() throws Exception {
    final File binaryOutput = new File("./target/spoon/test/binary/");
    final Launcher launcher = new Launcher();
    launcher.getEnvironment().setShouldCompile(true);
    launcher.addInputResource("./src/test/java/spoon/test/api/testclasses");
    launcher.setSourceOutputDirectory("./target/spooned");
    launcher.setBinaryOutputDirectory(binaryOutput);
    launcher.run();

    assertTrue(binaryOutput.exists());
  }
コード例 #3
0
ファイル: AccessTest.java プロジェクト: tdurieux/spoon
  @Test
  public void testFieldWriteDeclaredInTheSuperclass() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.run(
        new String[] {
          "-i",
          "./src/test/resources/spoon/test/variable/Tacos.java",
          "-o",
          "target/spooned/variable",
          "--noclasspath",
          "--compliance",
          "8",
          "--level",
          "OFF"
        });

    MainTest.checkAssignmentContracts(launcher.getFactory().Package().getRootPackage());
  }
コード例 #4
0
ファイル: AccessTest.java プロジェクト: tdurieux/spoon
  @Test
  public void testVariableAccessInNoClasspath() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource("./src/test/resources/variable");
    launcher.setSourceOutputDirectory("./target/variable/");
    launcher.run();

    final CtClass<Object> aClass =
        launcher.getFactory().Class().get("org.argouml.uml.ui.behavior.use_cases.PropPanelUseCase");
    final List<CtFieldRead> elements = aClass.getElements(new TypeFilter<>(CtFieldRead.class));

    for (CtFieldRead element : elements) {
      assertNotNull(element.getVariable());
    }

    assertEquals(
        "java.lang.Class mclass = ((java.lang.Class) (org.argouml.model.ModelFacade.USE_CASE))",
        elements.get(0).getParent().toString());
    assertEquals(
        "new org.argouml.uml.ui.PropPanelButton(org.argouml.uml.ui.behavior.use_cases.PropPanelUseCase.this, buttonPanel, _navUpIcon, org.argouml.i18n.Translator.localize(\"UMLMenu\", \"button.go-up\"), \"navigateNamespace\", null)",
        elements.get(2).getParent().toString());
  }