/** 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()); } }
@Test(timeout = 2000) public void testFirehoseFailsAsExpected() { AtomicInteger c = new AtomicInteger(); TestSubscriber<Integer> ts = new TestSubscriber<>(); firehose(c) .observeOn(Schedulers.computation()) .map( v -> { try { Thread.sleep(10); } catch (Exception e) { e.printStackTrace(); } return v; }) .subscribe(ts); ts.awaitTerminalEvent(); System.out.println( "testFirehoseFailsAsExpected => Received: " + ts.valueCount() + " Emitted: " + c.get()); // FIXME it is possible slow is not slow enough or the main gets delayed and thus more than one // source value is emitted. int vc = ts.valueCount(); assertTrue("10 < " + vc, vc <= 10); ts.assertError(MissingBackpressureException.class); }
/** * 已匹配的终端数据和终端属性数据 * * @param filePath * @return */ public String getKnownTerminalSQL(String filePath) { StringBuffer sb = new StringBuffer(); try { List<String[]> list = CvsFileParser.getCSV(filePath, 100001); int i = 0; for (String[] s : list) { if (i % 5000 == 0) { sb.append("LOCK TABLES tbl_tmp_08 WRITE;\r\n"); sb.append("insert into tbl_tmp_08 (d_phonenum,d_tac,d_bistrict) values \r\n"); } String phoneNum = s[0]; String imei = s[2]; String bd = s[1]; sb.append("(\'" + phoneNum + "\',\'" + imei + "\',\'" + bd + "\')"); i++; if (i % 5000 == 0) { sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } else { if (i < list.size()) { sb.append(",").append("\r\n"); } } } sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
@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()); } }
public String execRecognizer() { try { String inputFile = new File(tmpdir, "input").getAbsolutePath(); String[] args = new String[] {"java", "-classpath", tmpdir + pathSep + CLASSPATH, "Test", inputFile}; // String cmdLine = "java -classpath "+CLASSPATH+pathSep+tmpdir+" Test " + new File(tmpdir, // "input").getAbsolutePath(); // System.out.println("execParser: "+cmdLine); Process process = Runtime.getRuntime().exec(args, null, new File(tmpdir)); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); stdoutVacuum.start(); stderrVacuum.start(); process.waitFor(); stdoutVacuum.join(); stderrVacuum.join(); String output = null; output = stdoutVacuum.toString(); if (stderrVacuum.toString().length() > 0) { this.stderrDuringParse = stderrVacuum.toString(); System.err.println("exec stderrVacuum: " + stderrVacuum); } return output; } catch (Exception e) { System.err.println("can't exec recognizer"); e.printStackTrace(System.err); } return null; }
@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()); } }
void parseHeaderLine(String line, KatResult kr) { Scanner lineScanner = new Scanner(line); lineScanner.findInLine(":Skein-(\\d+):\\s*(\\d+)-.*=\\s*(\\d+) bits(.*)"); MatchResult result = null; try { result = lineScanner.match(); } catch (Exception e) { System.out.println("Header line: " + line); e.printStackTrace(); System.exit(1); } kr.stateSize = Integer.parseInt(result.group(1)); kr.hashBitLength = Integer.parseInt(result.group(2)); kr.msgLength = Integer.parseInt(result.group(3)); kr.restOfLine = result.group(4); if ((kr.msgLength == 0) || (kr.msgLength % 8) != 0) kr.msg = new byte[(kr.msgLength >> 3) + 1]; else kr.msg = new byte[kr.msgLength >> 3]; if ((kr.hashBitLength % 8) != 0) kr.result = new byte[(kr.hashBitLength >> 3) + 1]; else kr.result = new byte[kr.hashBitLength >> 3]; kr.msgFill = 0; kr.resultFill = 0; kr.macKeyFill = 0; }
private Domain generateModel() { Domain domain = null; try { DatabaseMeta database = new DatabaseMeta(); database.setDatabaseType("Hypersonic"); // $NON-NLS-1$ database.setAccessType(DatabaseMeta.TYPE_ACCESS_JNDI); database.setDBName("SampleData"); // $NON-NLS-1$ database.setName("SampleData"); // $NON-NLS-1$ System.out.println(database.testConnection()); TableModelerSource source = new TableModelerSource(database, "ORDERS", null); // $NON-NLS-1$ domain = source.generateDomain(); List<OlapDimension> olapDimensions = new ArrayList<OlapDimension>(); OlapDimension dimension = new OlapDimension(); dimension.setName("test"); // $NON-NLS-1$ dimension.setTimeDimension(false); olapDimensions.add(dimension); domain .getLogicalModels() .get(1) .setProperty("olap_dimensions", olapDimensions); // $NON-NLS-1$ } catch (Exception e) { e.printStackTrace(); } return domain; }
@Test public void testPersistence() { try { em.getTransaction().begin(); Student u = new Student(); u.setScore(12); u.setName("eskatos"); em.persist(u); assertTrue(em.contains(u)); em.remove(u); assertFalse(em.contains(u)); em.getTransaction().commit(); } catch (Exception ex) { em.getTransaction().rollback(); ex.printStackTrace(); fail("Exception during testPersistence"); } }
@Test public void testSimpleText() throws Exception { try { lcd.backlightOff(); Thread.sleep(500); lcd.backlightOn(); Thread.sleep(500); lcd.backlightPercent(30); Thread.sleep(500); lcd.backlightPercent(70); Thread.sleep(500); for (int i = 0; i < 32; i++) { lcd.clearDisplay(); lcd.moveCursorTo(i); lcd.sendByte(("" + i).charAt(0)); Thread.sleep(300); } lcd.clearDisplay(); lcd.send2LineMessage("boo!", "yah!"); Thread.sleep(500); lcd.clearDisplay(); lcd.sendWrappedMessage("A wrapped message...Yeah that's it!"); } catch (Exception e) { e.printStackTrace(); throw e; } }
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; } }
@Test(expected = MongoException.class) public void createConnectionException2Test() { try { when(mongo.getDB(anyString())).thenThrow(MongoException.class); } catch (Exception ex) { fail(ex.getLocalizedMessage()); } MongoDAOFactory.createConnection(); }
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; } }
@Test public void testHandlerDispatching_ThrowingException() throws Throwable { try { testSubject.handle(GenericCommandMessage.asCommandMessage(new HashSet()), mockUnitOfWork); fail("Expected exception"); } catch (Exception ex) { assertEquals(Exception.class, ex.getClass()); } }
@Test public void testFuzzySearch() throws Exception { CertTypeService c = CertTypeService.getService(); try { Assert.assertNotNull(c.fuzzySearch("id", "1")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public void run() { try { // Perform query session.execute("xquery " + QUERY); session.close(); } catch (final Exception ex) { ex.printStackTrace(); } }
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(); } }
@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")); } }
@After public void cleanUp() throws Exception { try { localCleanUp(); } catch (Exception e) { e.printStackTrace(); throw e; } cleanupSystem(); }
@Test public void today() { try { Calendar today = Calendar.getInstance(); beginOfDay(today); assertTrue(sufficientlyEqual(DynamicDate.getInstance("today"), today.getTime())); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void getResourceDAOTest() { mongoResourceDAO = mock(MongoResourceDAO.class); try { PowerMockito.whenNew(MongoResourceDAO.class).withNoArguments().thenReturn(mongoResourceDAO); } catch (Exception ex) { fail(ex.getLocalizedMessage()); } toTest = new MongoDAOFactory(); toTest.getResourceDAO(); }
public static void main(String args[]) { try { SkeinTest skt = new SkeinTest(); skt.setUp(); skt.vectorTest(); } catch (Exception e) { e.printStackTrace(); } System.out.println("Skein test done."); }
@Test public void testNullInputStream() { try { new CompactMagicEnvelopeDeserializer().deserialize(null); Assert.fail("Should have received an IllegalArgumentException"); } catch (IllegalArgumentException iae) { Assert.assertEquals("Cannot deserialize from null input stream.", iae.getMessage()); } catch (Exception e) { Assert.fail("Expecting an IllegalArgumentException not a " + e.getClass().getName()); } }
@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()); } }
@Test public void vectorTest() { try { assertTrue(checkKATVectors()); } catch (Exception e) { e.printStackTrace(); } if (notProcessed != 0) System.out.println( "Processed vectors: " + processed + ", some vectors skipped (Tree): " + notProcessed); else System.out.println("Processed vectors: " + processed); }
void parseResultLine(String line, KatResult kr) { Scanner ls = new Scanner(line); while (ls.hasNext()) { try { kr.result[kr.resultFill++] = (byte) ls.nextInt(16); } catch (Exception e) { System.out.println("Result data: " + line); e.printStackTrace(); System.exit(1); } } }
@Test public void test_parse_formatter_output() { try { FileInputStream in = new FileInputStream(new File(TEST_GPX_INPUT)); List<GpsTrack> tracks = new GpxParser().parse(in); assertEquals(tracks.size(), 1); GpsTrack track = tracks.get(0); assertEquals(1758, track.size()); } catch (Exception e) { fail(e.toString()); } }
@Test public void testUsers() { try { int expected = getDataSet().getTable("User").getRowCount(); int actual = getSecurityDAO().listAllUsers().size(); for (User u : getSecurityDAO().listAllUsers()) { System.out.println(u.toString()); } } catch (Exception e) { e.printStackTrace(); } }
@After public void tearDown() throws InterruptedException { for (final Closeable closeable : new Closeable[] {map1, map2}) { try { closeable.close(); } catch (Exception e) { e.printStackTrace(); } } System.gc(); }
@Test public void test_thinned_track() { try { GpxParser parser = new GpxParser(); FileInputStream gpxIn = new FileInputStream(new File(TEST_GPX_INPUT)); List<GpsTrack> gpxTracks = parser.parse(gpxIn); GpsTrack gpxTrack = gpxTracks.get(0); GpsTrack thinned = gpxTrack.getThinnedTrack(); } catch (Exception e) { fail(e.toString()); } }