コード例 #1
0
  public void testAddText() throws BuildException {
    IntrospectionHelper ih = IntrospectionHelper.getHelper(java.lang.String.class);
    try {
      ih.addText("", "test");
      fail("String doesn\'t support addText");
    } catch (BuildException be) {
    }

    ih = IntrospectionHelper.getHelper(getClass());
    ih.addText(this, "test");
    try {
      ih.addText(this, "test2");
      fail("test2 shouldn\'t be equal to test");
    } catch (BuildException be) {
      assertTrue(be.getException() instanceof AssertionFailedError);
    }
  }
コード例 #2
0
  /** @throws Exception If failed. */
  public void testAntGarTaskWithDoubleP2PDescriptor() throws Exception {
    String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
    String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
    String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_2";
    String metaDirName = baseDirName + File.separator + "META-INF";
    String garFileName = baseDirName + ".gar";
    String garDescrDirName =
        U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir"))
                .getAbsolutePath()
            + File.separator
            + "ignite.xml";

    // Make base and META-INF dir.
    boolean mkdir = new File(baseDirName).mkdirs();

    assert mkdir;

    mkdir = new File(metaDirName).mkdirs();

    assert mkdir;

    // Make Gar file
    U.copy(new File(garDescrDirName), new File(metaDirName + File.separator + "ignite.xml"), true);

    // Copy files to basedir
    U.copy(new File(srcDirName), new File(baseDirName), true);

    IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask();

    Project garProject = new Project();

    garProject.setName("Gar test project");

    garTask.setDestFile(new File(garFileName));
    garTask.setDescrdir(new File(garDescrDirName));
    garTask.setBasedir(new File(baseDirName));
    garTask.setProject(garProject);

    try {
      garTask.execute();

      assert false;
    } catch (BuildException e) {
      if (log().isInfoEnabled()) log().info(e.getMessage());
    }
  }
コード例 #3
0
 public void testAttributeSetters() throws BuildException {
   Project p = new Project();
   p.setBasedir("/tmp");
   IntrospectionHelper ih = IntrospectionHelper.getHelper(getClass());
   try {
     ih.setAttribute(p, this, "one", "test");
     fail("setOne doesn't exist");
   } catch (BuildException be) {
   }
   try {
     ih.setAttribute(p, this, "two", "test");
     fail("setTwo returns non void");
   } catch (BuildException be) {
   }
   try {
     ih.setAttribute(p, this, "three", "test");
     fail("setThree takes no args");
   } catch (BuildException be) {
   }
   try {
     ih.setAttribute(p, this, "four", "test");
     fail("setFour takes two args");
   } catch (BuildException be) {
   }
   try {
     ih.setAttribute(p, this, "five", "test");
     fail("setFive takes array arg");
   } catch (BuildException be) {
   }
   try {
     ih.setAttribute(p, this, "six", "test");
     fail("Project doesn't have a String constructor");
   } catch (BuildException be) {
   }
   ih.setAttribute(p, this, "seven", "2");
   try {
     ih.setAttribute(p, this, "seven", "3");
     fail("2 shouldn't be equals to three");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "eight", "2");
   try {
     ih.setAttribute(p, this, "eight", "3");
     fail("2 shouldn't be equals to three - as int");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "nine", "2");
   try {
     ih.setAttribute(p, this, "nine", "3");
     fail("2 shouldn't be equals to three - as Integer");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "ten", "2");
   try {
     ih.setAttribute(p, this, "ten", "3");
     fail("/tmp/2 shouldn't be equals to /tmp/3");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "eleven", "2");
   try {
     ih.setAttribute(p, this, "eleven", "on");
     fail("on shouldn't be false");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "twelve", "2");
   try {
     ih.setAttribute(p, this, "twelve", "on");
     fail("on shouldn't be false");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project");
   try {
     ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper");
     fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   try {
     ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2");
     fail("org.apache.tools.ant.Project2 doesn't exist");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof ClassNotFoundException);
   }
   ih.setAttribute(p, this, "fourteen", "2");
   try {
     ih.setAttribute(p, this, "fourteen", "on");
     fail("2 shouldn't be equals to three - as StringBuffer");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "fifteen", "abcd");
   try {
     ih.setAttribute(p, this, "fifteen", "on");
     fail("o shouldn't be equal to a");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
   ih.setAttribute(p, this, "sixteen", "abcd");
   try {
     ih.setAttribute(p, this, "sixteen", "on");
     fail("o shouldn't be equal to a");
   } catch (BuildException be) {
     assertTrue(be.getException() instanceof AssertionFailedError);
   }
 }
コード例 #4
0
  public void testElementCreators() throws BuildException {
    IntrospectionHelper ih = IntrospectionHelper.getHelper(getClass());
    try {
      ih.getElementType("one");
      fail("don't have element type one");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("two");
      fail("createTwo takes arguments");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("three");
      fail("createThree returns void");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("four");
      fail("createFour returns array");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("five");
      fail("createFive returns primitive type");
    } catch (BuildException be) {
    }
    assertEquals(java.lang.String.class, ih.getElementType("six"));
    assertEquals("test", ih.createElement(this, "six"));

    try {
      ih.getElementType("seven");
      fail("addSeven takes two arguments");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("eight");
      fail("addEight takes no arguments");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("nine");
      fail("nine return non void");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("ten");
      fail("addTen takes array argument");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("eleven");
      fail("addTen takes primitive argument");
    } catch (BuildException be) {
    }
    try {
      ih.getElementType("twelve");
      fail("no primitive constructor for java.lang.Class");
    } catch (BuildException be) {
    }
    assertEquals(java.lang.StringBuffer.class, ih.getElementType("thirteen"));
    assertEquals("test", ih.createElement(this, "thirteen").toString());

    try {
      ih.createElement(this, "fourteen");
      fail("fourteen throws NullPointerException");
    } catch (BuildException be) {
      assertTrue(be.getException() instanceof NullPointerException);
    }

    try {
      ih.createElement(this, "fourteen");
      fail("fifteen throws NullPointerException");
    } catch (BuildException be) {
      assertTrue(be.getException() instanceof NullPointerException);
    }
  }