示例#1
0
  @Test
  public void testSmallFasta2() {

    try {
      InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");

      FastaReader<ProteinSequence, AminoAcidCompound> fastaReader =
          new FastaReader<ProteinSequence, AminoAcidCompound>(
              inStream,
              new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
              new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));

      int nrSeq = 0;

      LinkedHashMap<String, ProteinSequence> b = fastaReader.process();

      assertNotNull(b);

      // #282 make sure that process() still works

      assertTrue(b.keySet().size() == 10);

    } catch (Exception ex) {
      ex.printStackTrace();
      java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);

      fail(ex.getMessage());
    }
  }
  /** Test of SavePersonData method, of class MetadataRDFConverter. */
  @Test
  public void testSavePersonData() {
    System.out.println("* MetadataRDFConverterTest: SavePersonData");
    try {
      foaf_Person oPersonNull = null;
      OntModel oModel = MetadataGlobal.LoadOWL(MetadataConstants.sLocationLoadAlert);
      MetadataRDFConverter.SavePersonData(oPersonNull, oModel);
      MetadataGlobal.SaveOWL(oModel, MetadataConstants.sLocationSaveAlert);

      foaf_Person oPerson = new foaf_Person();
      oPerson.m_sFirstName = "Ivan";
      oPerson.m_sLastName = "Obradovic";
      // oPerson.m_sGender = ""; //???
      oPerson.m_sID = "*****@*****.**";
      oPerson.m_sEmail = "*****@*****.**"; // ???
      MetadataRDFConverter.SavePersonData(oPerson, oModel);
      MetadataGlobal.SaveOWL(oModel, MetadataConstants.sLocationSaveAlert);
      assertNotNull(oPerson);
      assertEquals(oPerson.m_sObjectURI.isEmpty(), false);

      //// TO-DO review the generated test code and remove the default call to fail.
      // fail("The test case is a prototype.");
    } catch (Exception ex) {
      System.out.println("Error: " + ex.getMessage());
    }
  }
示例#3
0
  @Test
  public void testSmallFasta() {

    try {
      InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");

      FastaReader<ProteinSequence, AminoAcidCompound> fastaReader =
          new FastaReader<ProteinSequence, AminoAcidCompound>(
              inStream,
              new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
              new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));

      LinkedHashMap<String, ProteinSequence> b;

      int nrSeq = 0;

      while ((b = fastaReader.process(10)) != null) {
        for (String key : b.keySet()) {
          nrSeq++;

          // #282 would result in an endless loop
          // this makes sure it has been fixed.
          assertTrue(
              "Looks like there is a problem with termination of processing of the FASTA file!",
              nrSeq < 15);
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);

      fail(ex.getMessage());
    }
  }
示例#4
0
 com.u2d.generated.FormatEnum castJmatterObject(Object object) {
   try {
     com.u2d.generated.FormatEnum output = (com.u2d.generated.FormatEnum) object;
     return output;
   } catch (Exception e) {
     Assert.fail(e.getMessage());
     return null;
   }
 }
示例#5
0
 org.jts.jsidl.binding.FormatEnum castJaxbObject(Object object) {
   try {
     org.jts.jsidl.binding.FormatEnum output = (org.jts.jsidl.binding.FormatEnum) object;
     return output;
   } catch (Exception e) {
     Assert.fail(e.getMessage());
     return null;
   }
 }
示例#6
0
 public EvalResult(String result, String stdout, String stderr, Exception e) {
   this.result = result;
   this.stdout = stdout;
   this.stderr = stderr;
   if (e == null) {
     this.exception = null;
   } else {
     this.exception = e.getClass().getName() + e.getMessage();
   }
 }
示例#7
0
 @Test
 public void today() {
   try {
     Calendar today = Calendar.getInstance();
     beginOfDay(today);
     assertTrue(sufficientlyEqual(DynamicDate.getInstance("today"), today.getTime()));
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }
示例#8
0
 @Test(expected = NullPointerException.class)
 public void testDebugger() {
   assertNull("Failure: object was not null..", _nullObject);
   try {
     _nullObject.toString();
   } catch (Exception ex) {
     String message = ex.getMessage();
     assertTrue("Failure: it's not a nullpointer exception", message.contains("null"));
   }
 }
示例#9
0
  @Before
  /** Setup the database and unmarshaller before we run the unit tests */
  public void setup() {
    seedDatabase();

    try {
      jc = JAXBContext.newInstance("org.jts.jsidl.binding");
      unmarshaller = jc.createUnmarshaller();
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
 /** prueba excepción un número negativo */
 @Test
 public void excepcionNegativos() {
   try {
     Calculadora.add("-6,4,-2");
     fail("No se lanzo una excepción cuando se intento sumar un número negativo: //*\n1*-2");
   } catch (Exception ex) {
     assertEquals("Negatives not allowed: -6, -2", ex.getMessage());
   }
   try {
     Calculadora.add("//*\n4*-3");
     fail("No se lanzo una excepción cuando se intento sumar un número negativo: //*\n1*-2");
   } catch (Exception ex) {
     assertEquals("Negatives not allowed: -3", ex.getMessage());
   }
   try {
     Calculadora.add("//*\n2*-4*6*8*-10*12*-14");
     fail(
         "No se lanzo una excepción cuando se intento sumar un número negativo: //*\n1*-2*2*3*-5*8*-1");
   } catch (Exception ex) {
     assertEquals("Negatives not allowed: -4, -10, -14", ex.getMessage());
   }
 }
示例#11
0
 @Before
 public void setUp() throws Exception {
   initializeSystem();
   try {
     localReset();
   } catch (Exception e) {
     System.out.println("Warning: Preclean failed: " + e.getMessage());
   }
   try {
     localSetUp();
   } catch (Exception e) {
     e.printStackTrace();
     throw e;
   }
 }
示例#12
0
  @Before
  public void clearGrammarCache() {
    LOG.info("Clearing grammar cache");
    ResourceSet results = null;
    try {
      results = executeQuery("validation:clear-grammar-cache()");
      String r = (String) results.getResource(0).getContent();
      System.out.println(r);

    } catch (Exception e) {
      LOG.error(e);
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
 @Test
 public void test006() throws Exception {
   J2V8Handler h =
       new J2V8Handler(
           readFile("../../src/main/resources/js/j2v8test04.js", Charset.defaultCharset()), 1);
   h.init();
   assertEquals(30, h.getCommitInterval());
   assertEquals(false, h.getTerminateOnBadData());
   try {
     h.process(
         readFile("../../src/main/resources/js/j2v8test04_data.js", Charset.defaultCharset()));
     assertEquals(true, true);
   } catch (Exception e) {
     System.err.println(e.getMessage());
     assertEquals(true, false);
   }
 }
 @Test
 public void test007() throws Exception {
   J2V8Handler h =
       new J2V8Handler(
           readFile("../../src/main/resources/js/j2v8test07.js", Charset.defaultCharset()), 1);
   h.init();
   try {
     String data =
         readFile("../../src/main/resources/js/j2v8test07_data.js", Charset.defaultCharset());
     long start = System.currentTimeMillis();
     for (int i = 0; i < 1000000; i++) h.process(data);
     long elapsedTime = System.currentTimeMillis() - start;
     System.err.println(elapsedTime);
     assertEquals(true, true);
   } catch (Exception e) {
     System.err.println(e.getMessage());
     assertEquals(true, false);
   }
 }
示例#15
0
  private void executeAndEvaluate(String query, String expectedValue) {

    LOG.info("Query=" + query);
    LOG.info("ExpectedValue=" + query);

    try {
      ResourceSet results = executeQuery(query);
      assertEquals(1, results.getSize());

      String r = (String) results.getResource(0).getContent();
      LOG.info(r);

      assertXpathEvaluatesTo(expectedValue, "//status/text()", r);

    } catch (Exception ex) {
      LOG.error(ex);
      fail(ex.getMessage());
    }
  }
  @Before
  public void setup() {
    logger.info("setup");

    this.mockMvc =
        MockMvcBuilders.webAppContextSetup(context).addFilters(springSecurityFilterChain).build();

    User user = null;
    try {
      user = userService.findByLogin("johndoe");
    } catch (ServiceException e) {
      logger.error(e.getLocalizedMessage());
    }

    Authentication authentication =
        new UsernamePasswordAuthenticationToken(user.getLogin(), user.getPassword());
    Authentication result = authenticationManager.authenticate(authentication);
    SecurityContext securityContext = SecurityContextHolder.getContext();
    securityContext.setAuthentication(result);
    session = new MockHttpSession();
    session.setAttribute(
        HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, securityContext);

    try {
      logger.info("Create Tomcat server");
      String jsonString =
          "{\"applicationName\":\"" + applicationName + "\", \"serverName\":\"" + release + "\"}";
      ResultActions resultats =
          mockMvc.perform(
              post("/application")
                  .session(session)
                  .contentType(MediaType.APPLICATION_JSON)
                  .content(jsonString));
      resultats.andExpect(status().isOk());

    } catch (Exception e) {
      logger.error(e.getMessage());
    }
  }
  @Test
  public void test010_DeploySimpleApplicationTest() throws Exception {
    logger.info("Deploy an SpringBoot application");
    String binary = "spring-boot.jar";

    try {
      logger.info("Create " + binary + " application.");
      String jsonString =
          "{\"applicationName\":\"" + applicationName + "\", \"serverName\":\"" + release + "\"}";
      ResultActions resultats =
          mockMvc.perform(
              post("/application")
                  .session(session)
                  .contentType(MediaType.APPLICATION_JSON)
                  .content(jsonString));
      resultats.andExpect(status().isOk());

      // OPEN THE PORT
      jsonString =
          "{\"applicationName\":\""
              + applicationName
              + "\",\"portToOpen\":\"8080\",\"portNature\":\"web\"}";
      resultats =
          this.mockMvc.perform(
              post("/application/ports")
                  .session(session)
                  .contentType(MediaType.APPLICATION_JSON)
                  .content(jsonString));
      resultats.andExpect(status().isOk()).andDo(print());
    } catch (Exception e) {
      logger.error(e.getMessage());
    }

    ResultActions resultats =
        mockMvc
            .perform(
                MockMvcRequestBuilders.fileUpload("/application/" + applicationName + "/deploy")
                    .file(
                        downloadAndPrepareFileToDeploy(
                            binary,
                            "https://github.com/Treeptik/CloudUnit/releases/download/1.0/"
                                + binary))
                    .session(session)
                    .contentType(MediaType.MULTIPART_FORM_DATA))
            .andDo(print());
    resultats.andExpect(status().is2xxSuccessful());

    String urlToCall =
        "http://" + applicationName.toLowerCase() + "-johndoe-forward-8080.cloudunit.dev";
    logger.debug(urlToCall);
    int i = 0;
    String content = null;
    while (i++ < TestUtils.NB_ITERATION_MAX) {
      content = getUrlContentPage(urlToCall);
      logger.debug(content);
      Thread.sleep(1000);
      if (content == null || !content.contains("502")) {
        break;
      }
    }
    logger.debug(content);
    if (content != null) {
      Assert.assertTrue(content.contains("Greetings from Spring Boot!"));
    }
  }