示例#1
0
文件: TC3.java 项目: asilipo/softfood
  @SuppressWarnings("deprecation")
  @Test
  public void testUpdateIngrediente() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CAMERIERE, "1234");
    } catch (RemoteException e) {
      user_test = null;
    }

    Ingrediente ingrediente_test = ingrediente;
    ingrediente_test.setNome("INGREDIENTE TEST");
    ingrediente_test.setScadenza(new Date(109, 4, 31));
    ingrediente_test.setVariante(true);
    boolean test_return = false;
    try {
      test_return = articoloFacade.updateIngrediente(user_test, ingrediente_test);
    } catch (AccessControlException e) {
      test_return = false;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    try {
      userFacade.logout(user_test);
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    assertFalse(test_return);
  }
示例#2
0
文件: TC3.java 项目: asilipo/softfood
  @SuppressWarnings("deprecation")
  @Before
  public void setUp() throws Exception {
    System.setProperty("java.security.policy", "polis.policy");
    if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
    }
    try {
      Registry registry = LocateRegistry.getRegistry("localhost");
      articoloFacade = (IArticoloMenuFacade) registry.lookup("ArticoloFacade");
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

    user = userFacade.login(Ruolo.TEST, "test");

    ingrediente = new Ingrediente();
    ingrediente.setNome("INGREDIENTE TEST");
    ingrediente.setScadenza(new Date(109, 4, 31));
    ingrediente.setVariante(true);

    ingrediente = articoloFacade.inserisciIngrediente(user, ingrediente);
  }
示例#3
0
文件: TC2.java 项目: asilipo/softfood
  @Test
  public void testRimozioneIngrediente() {
    User user1 = null;
    try {
      user1 = userFacade.login(Ruolo.AMMINISTRATORE, "123456");
    } catch (RemoteException e1) {
      fail("RemoteException");
    }

    boolean ingredienteAttuale = false;
    try {
      ingredienteAttuale = articoloFacade.rimuoviIngrediente(user1, ingrediente.getId());
    } catch (AccessControlException e) {
      ingredienteAttuale = false;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    if (user1 != null) {
      try {
        userFacade.logout(user1);
      } catch (RemoteException e) {
        fail("RemoteException");
      }
    }

    Assert.assertFalse(ingredienteAttuale);
  }
示例#4
0
文件: TC2.java 项目: asilipo/softfood
  @SuppressWarnings("deprecation")
  @Before
  public void setUp() throws Exception {
    System.setProperty("java.security.policy", "polis.policy");
    if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
    }
    try {
      Registry registry = LocateRegistry.getRegistry("localhost");
      articoloFacade = (IArticoloMenuFacade) registry.lookup("ArticoloFacade"); // CONTROLLARE
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

    user = userFacade.login(Ruolo.TEST, "test");

    ingrediente = new Ingrediente();
    ingrediente.setDescrizione("Ingrediente di test");
    ingrediente.setId((long) 1000000L);
    ingrediente.setNome("Ingrediente di Test");
    ingrediente.setTipoIngrediente("IngredienteLungaConservazione");
    ingrediente.setScadenza(new Date(109, 1, 21));
    ingrediente.setUnitaMisura("g");
    ingrediente.setVariante(true);

    ingrediente = articoloFacade.inserisciIngrediente(user, ingrediente);
  }
  public Ingrediente inserisciIngredienteLungaConservazione(Ingrediente ingrediente) {
    try {
      Long id = this.getNewId();
      ingrediente.setId(id);
      session.persist(ingrediente);
      ingrediente = (Ingrediente) session.get(Ingrediente.class, ingrediente);

      return ingrediente;
    } catch (Exception e) {
      System.err.println(
          "IngredienteLungaConservazioneSession#inserisciIngredienteLungaConservazione");
      return null;
    }
  }
示例#6
0
文件: TC3.java 项目: asilipo/softfood
 @After
 public void tearDown() throws Exception {
   articoloFacade.rimuoviIngrediente(user, ingrediente.getId());
   userFacade.logout(user);
 }