Beispiel #1
0
  @Test
  public void runTest() {
    Field field = new Field();
    ArrayList<String> args = new ArrayList<String>();

    Teleport teleportCommand = new Teleport();
    Point playerPos;

    Init initCommand = new Init();
    ArrayList<String> argsInit = new ArrayList<String>();
    argsInit.add("10");
    argsInit.add("10");
    argsInit.add("4");
    argsInit.add("4");
    initCommand.run(field, argsInit);

    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 4);
    assertEquals(playerPos.y, 4);

    args.add("0");
    args.add("0");
    teleportCommand.run(field, args);
    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 0);
    assertEquals(playerPos.y, 0);

    args.clear();
    args.add("4");
    args.add("5");
    teleportCommand.run(field, args);
    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 4);
    assertEquals(playerPos.y, 5);
  }
Beispiel #2
0
  private void configureComponents() {

    // Chargement des données.
    Init uniqueinstance = Init.getInit();
    uniqueinstance.chargementinitial();

    contactList.setContainerDataSource(Vehicule.getVehicules());
    contactList1.setContainerDataSource(Vehicule.getVehiculesPrixBas());
    contactList2.setContainerDataSource(Visiteur.getVisiteur());
    contactList3.setContainerDataSource(Affectation.getAffectation());

    // contactTable.setContainerDataSource(new BeanItemContainer<>( Vehicule.class));
    contactList.setColumnOrder("marque", "modele", "prix"); // choisir l'ordre des colonnes
    contactList.removeColumn("id");
    contactList1.setColumnOrder("marque", "modele", "prix"); // choisir l'ordre des colonnes
    contactList1.removeColumn("id"); // masquer la colonne
    // contactList.setSelectionMode(Grid.SelectionMode.SINGLE);

    contactList2.setColumnOrder("id", "prenom", "nom", "marque"); // choisir l'ordre des colonnes
    contactList3.setColumnOrder("id", "dateAffection", "nom", "marque");

    contactList.setSizeFull();
    contactList1.setSizeFull();
    contactList2.setSizeFull();
    contactList3.setSizeFull();
  }
 public void editsToNextGrid(Init myParam) {
   //// System.out.println(myParam.returnXDimension());
   //// System.out.println("break");
   for (int x = 0; x < myParam.returnXDimension(); x++) {
     for (int y = 0; y < myParam.returnYDimension(); y++) {
       getToMyNextCell(x, y);
     }
   }
 };
Beispiel #4
0
  public Epfd(Init init) {
    self = init.getSelf();
    allNodes = init.getAll();

    delay = init.getInitialDelay();
    delta = init.getDeltaDelay();
    sequenceNo = 0;
    alive = new HashSet<>(init.getAll());
    suspected = new HashSet<>();

    subscribe(startHandler, control);
    subscribe(handleCheckTimeout, timer);
    subscribe(handleHbRequests, pp2p);
    subscribe(handleHbReplies, pp2p);
  }
  public static Connection getConnection(DataNode node) throws SQLException {

    IndusConfiguration indusConfig = Init._this().getIndusConfiguration();
    if (node.isLeafNode()) {
      String hostname = node.getProperty("host");
      String dbName = node.getProperty("datasource");

      // if datasource is not set, use the leaf node name itself
      if (dbName == null || dbName == "") {
        dbName = node.getNodeName();
      }

      DbType dbType = DbType.valueOf(node.getProperty("type"));
      String temp = indusConfig.getProperty("account_" + dbName, "indus;indus");

      String[] userNamePassword = temp.split(";");
      String userName = userNamePassword[0];
      String password = userNamePassword[1];

      return getDataSourceConnection(hostname, dbName, userName, password, dbType);
    } else {
      // This a virtual DataSource, so make connection to the database associated with indus
      return getIndusConnection();
    }
  }
Beispiel #6
0
  // <editor-fold defaultstate="collapsed" desc="import">
  @POST
  @Path("/import/zip")
  @Consumes(MediaType.MULTIPART_FORM_DATA)
  public Response importZip(
      @FormDataParam("file") FormDataContentDisposition fileDisposition,
      @FormDataParam("file") InputStream file) {
    String storeDirPath = Init.getStoredQueriesPath();
    File storeDir = storeDirPath == null ? null : new File(storeDirPath);
    if (storeDir == null) return Response.status(Response.Status.NOT_FOUND).build();

    final StringBuilder res = new StringBuilder();
    if (fileDisposition != null) {
      logInfo("import {0}", fileDisposition.getFileName());
      try {
        unzip(
            storeDir,
            file,
            new Reciver<String>() {
              @Override
              public void recive(String logtext) {
                res.append(logtext.trim());
                res.append("\n");
              }
            });
      } catch (IOException ex) {
        Logger.getLogger(SqlQueriesRest.class.getName()).log(Level.SEVERE, null, ex);
        return Response.serverError().build();
      }
    }
    return Response.ok("succ\n" + res.toString()).build();
  }
Beispiel #7
0
  @GET
  @Path("/export/zip")
  public Response exportZip() {
    String storeDirPath = Init.getStoredQueriesPath();
    File storeDir = storeDirPath == null ? null : new File(storeDirPath);
    if (storeDir != null && storeDir.exists()) {
      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();

      try {
        zip(byteStream, storeDir, false, "/");
      } catch (IOException ex) {
        Logger.getLogger(SqlQueriesRest.class.getName()).log(Level.SEVERE, null, ex);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
      }

      return Response.ok()
          .type(MediaType.APPLICATION_OCTET_STREAM_TYPE)
          .header("Content-Disposition", "attachment; filename=\"storedQueries.zip\"")
          .entity(byteStream.toByteArray())
          .build();
    } else {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    //        return Response.ok("", MediaType.TEXT_PLAIN_TYPE).build();
  }
Beispiel #8
0
  @Test(expected = IllegalArgumentException.class)
  public void runTestIllegalArgumentException() throws IllegalArgumentException {
    Field field = new Field();
    ArrayList<String> args = new ArrayList<String>();

    Teleport teleportCommand = new Teleport();

    Init initCommand = new Init();
    ArrayList<String> argsInit = new ArrayList<String>();
    argsInit.add("10");
    argsInit.add("10");
    argsInit.add("4");
    argsInit.add("4");
    initCommand.run(field, argsInit);

    teleportCommand.run(field, args);
  }
  public static Connection getIndusConnection() throws SQLException {
    IndusConfiguration indusConfig = Init._this().getIndusConfiguration();

    String dbName = indusConfig.getIndusDbName();
    DbType dbType = indusConfig.getIndusDbType();

    String userNamePassword[] = indusConfig.getProperty("account_indus", "indus;indus").split(";");
    String userName = userNamePassword[0];
    String password = userNamePassword[1];

    String hostname = indusConfig.getProperty("hostname_indus", "localhost");

    return getDataSourceConnection(hostname, dbName, userName, password, dbType);
  }
Beispiel #10
0
 private static void enqueueScriptTask(Realm realm, Init init) {
   realm.enqueueScriptTask(
       () -> {
         try {
           init.apply();
         } catch (IOException e) {
           throw new UncheckedIOException(e);
         } catch (URISyntaxException e) {
           throw new UncheckedIOException(new IOException(e));
         } catch (MalformedNameException | ResolutionException e) {
           throw e.toScriptException(realm.defaultContext());
         }
       });
 }
Beispiel #11
0
 public static void main(final String[] args) {
   Init.init();
   addPerson();
 }
 static {
   if (!Init.isLibrariesLoaded()) {
     throw new RuntimeException(
         "Libraries not loaded ! Use Init.loadLibraries() before using NativeFmodEx.");
   }
 }
 static {
   for (Quick q : Init.getAll()) {
     quicks.put(q.annotationType(), q);
   }
 }
Beispiel #14
0
 public File getStoreDir() {
   String p = Init.getStoredQueriesPath();
   if (p != null) return new File(p);
   return null;
 }