コード例 #1
0
  /** @throws Exception If failed. */
  public void testAntGarTaskToString() throws Exception {
    String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
    String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
    String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_6";
    String metaDirName = baseDirName + File.separator + "META-INF";
    String garFileName = baseDirName + ".gar";

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

    assert mkdir;

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

    assert mkdir;

    // 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.setBasedir(new File(garFileName));
    garTask.setProject(garProject);
    garTask.setDescrdir(new File(garFileName));

    garTask.toString();
  }
コード例 #2
0
  /** @throws Exception If failed. */
  @SuppressWarnings({"TypeMayBeWeakened"})
  public void testCorrectAntGarTask() throws Exception {
    String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
    String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
    String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_0";
    String metaDirName = baseDirName + File.separator + "META-INF";
    String garFileName = baseDirName + ".gar";
    String garDescDirName =
        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(garDescDirName), 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.setBasedir(new File(baseDirName));
    garTask.setProject(garProject);

    garTask.execute();

    File garFile = new File(garFileName);

    assert garFile.exists();

    boolean res = checkStructure(garFile, true);

    assert res;
  }
コード例 #3
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());
    }
  }
コード例 #4
0
  /** @throws Exception If failed. */
  @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"})
  public void testStartMultipleGridsFromSpring() throws Exception {
    File cfgFile =
        GridTestUtils.resolveIgnitePath(
            GridTestProperties.getProperty("loader.self.multipletest.config"));

    assert cfgFile != null;

    String path = cfgFile.getAbsolutePath();

    info("Loading Grid from configuration file: " + path);

    final GridTuple<IgniteState> gridState1 = F.t(null);
    final GridTuple<IgniteState> gridState2 = F.t(null);

    final Object mux = new Object();

    IgnitionListener factoryLsnr =
        new IgnitionListener() {
          @Override
          public void onStateChange(String name, IgniteState state) {
            synchronized (mux) {
              if ("grid-factory-test-1".equals(name)) gridState1.set(state);
              else if ("grid-factory-test-2".equals(name)) gridState2.set(state);
            }
          }
        };

    G.addListener(factoryLsnr);

    G.start(path);

    assert G.ignite("grid-factory-test-1") != null;
    assert G.ignite("grid-factory-test-2") != null;

    synchronized (mux) {
      assert gridState1.get() == STARTED
          : "Invalid grid state [expected=" + STARTED + ", returned=" + gridState1 + ']';
      assert gridState2.get() == STARTED
          : "Invalid grid state [expected=" + STARTED + ", returned=" + gridState2 + ']';
    }

    G.stop("grid-factory-test-1", true);
    G.stop("grid-factory-test-2", true);

    synchronized (mux) {
      assert gridState1.get() == STOPPED
          : "Invalid grid state [expected=" + STOPPED + ", returned=" + gridState1 + ']';
      assert gridState2.get() == STOPPED
          : "Invalid grid state [expected=" + STOPPED + ", returned=" + gridState2 + ']';
    }
  }