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;
  }
Ejemplo n.º 2
0
  @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);
  }
Ejemplo n.º 3
0
 /**
  * 已匹配的终端数据和终端属性数据
  *
  * @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 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");
    }
  }
Ejemplo n.º 5
0
 @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;
   }
 }
Ejemplo n.º 6
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());
    }
  }
Ejemplo n.º 7
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());
    }
  }
Ejemplo n.º 8
0
    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;
    }
Ejemplo n.º 9
0
 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;
 }
 @Before
 public void setUp() throws Exception {
   try {
     Class.forName("org.hsqldb.jdbcDriver");
     connection = DriverManager.getConnection("jdbc:hsqldb:mem:unit-testing-jpa", "sa", "");
   } catch (Exception ex) {
     ex.printStackTrace();
     fail("Exception during HSQL database startup.");
   }
   try {
     emFactory = Persistence.createEntityManagerFactory("MyPersistence");
     em = emFactory.createEntityManager();
   } catch (Exception ex) {
     ex.printStackTrace();
     fail("Exception during JPA EntityManager instanciation.");
   }
 }
Ejemplo n.º 11
0
 @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();
   }
 }
Ejemplo n.º 12
0
 @Override
 public void run() {
   try {
     // Perform query
     session.execute("xquery " + QUERY);
     session.close();
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
Ejemplo n.º 13
0
 @After
 public void cleanUp() throws Exception {
   try {
     localCleanUp();
   } catch (Exception e) {
     e.printStackTrace();
     throw e;
   }
   cleanupSystem();
 }
Ejemplo n.º 14
0
  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.");
  }
Ejemplo n.º 15
0
 @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();
   }
 }
Ejemplo n.º 16
0
 @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);
 }
Ejemplo n.º 17
0
 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);
     }
   }
 }
Ejemplo n.º 18
0
 @Test
 public void testLink() {
   CatchData data = new CatchData();
   String Link = "";
   String LinkResult = "";
   try {
     LinkResult = new String(data.GetURL());
     Link = "http://www.npa.gov.tw/NPAGip/wSite/public/Attachment/f1365640740030.csv";
   } catch (Exception e) {
     e.printStackTrace();
   }
   assertTrue(Link.equals(LinkResult));
 }
  @After
  public void tearDown() throws InterruptedException {

    for (final Closeable closeable : new Closeable[] {map1, map2}) {
      try {
        closeable.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    System.gc();
  }
Ejemplo n.º 20
0
 void parseMacKeyHeaderLine(String line, KatResult kr) {
   Scanner ls = new Scanner(line);
   ls.findInLine(".*=\\s*(\\d+) .*");
   MatchResult result = null;
   try {
     result = ls.match();
   } catch (Exception e) {
     System.out.println("Mac header: " + line);
     e.printStackTrace();
     System.exit(1);
   }
   kr.macKeyLen = Integer.parseInt(result.group(1));
   kr.macKey = new byte[kr.macKeyLen];
   state = MacKey;
 }
Ejemplo n.º 21
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());
    }
  }
Ejemplo n.º 22
0
 void parseMacKeyLine(String line, KatResult kr) {
   if (line.contains("(none)")) {
     return;
   }
   Scanner ls = new Scanner(line);
   while (ls.hasNext()) {
     try {
       kr.macKey[kr.macKeyFill++] = (byte) ls.nextInt(16);
     } catch (Exception e) {
       System.out.println("Mac key data: " + line);
       e.printStackTrace();
       System.exit(1);
     }
   }
 }
Ejemplo n.º 23
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;
   }
 }
Ejemplo n.º 24
0
 @Test
 public void testTotal() {
   int total = 0;
   int result = 0;
   DocApplication test = new DocApplication();
   test.doc = new UTF8Document();
   test.NewDocument("WomenData.csv");
   try {
     total = test.doc.Read();
     result = testNum.TestSize();
   } catch (Exception e) {
     e.printStackTrace();
   }
   assertEquals(total, result);
 }
Ejemplo n.º 25
0
 public static void assumeNotHeadless() {
   boolean headless = true;
   try {
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     headless = ge.isHeadless();
   } catch (Exception e) {
     e.printStackTrace();
   } catch (Error e) {
     // Really not sure why this ever happens, maybe just jenkins issues
     e.printStackTrace();
   }
   if (headless) {
     System.out.println("You are trying to start a GUI in a headless environment. Aborting test");
   }
   org.junit.Assume.assumeTrue(!headless);
 }
 @Before
 public void setUpProductCatalogue() {
   try {
     new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);
     importCsv("/merchandisefulfilmentprocess/test/testBasics.csv", "windows-1252");
     importCsv("/merchandisefulfilmentprocess/test/testCatalog.csv", "windows-1252");
     baseSiteService.setCurrentBaseSite(baseSiteService.getBaseSiteForUID("testSite"), false);
     LOG.warn("Catalogue has been imported");
   } catch (final ImpExException e) {
     LOG.warn("Catalogue import has failed");
     e.printStackTrace();
   } catch (final Exception e) {
     LOG.warn("createEssentialData(...) has failed");
     e.printStackTrace();
   }
 }
Ejemplo n.º 27
0
  @Test
  public void testUnescapedQuotesinQuotedError() throws IOException {
    String pstring = "prop=\"The cow goes \"moo\"\"";

    String expected = "The cow goes \"moo\""; // error

    // ODDLY, this seems to work.
    Exception e = null;
    try {
      testScenario("Un-escaped quotes in Quoted String(error)", pstring, expected, false);
    } catch (Exception ex) {
      System.out.println("Caught expected parser error");
      ex.printStackTrace();
    }
    // Assert.assertNotNull("Exception on bad qutoe syntax", e);
  }
Ejemplo n.º 28
0
 @Override
 public void run() {
   try {
     // Perform some queries
     for (int i = 0; i < runs; ++i) {
       final String qu =
           read
               ? "count(db:open('test'))"
               : "db:add('test', <a/>, 'test.xml', map { 'intparse': true() })";
       session.execute("xquery " + qu);
     }
     session.close();
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
Ejemplo n.º 29
0
 /**
  * 最终终端数据
  *
  * @param filePath
  * @return
  */
 public String getTerminalSQL(String filePath) {
   StringBuffer sb = new StringBuffer();
   try {
     List<String[]> list = CvsFileParser.getCSV(filePath, 100001);
     int i = 0;
     for (String[] s : list) {
       int support = 0;
       int supprotType = 0;
       if (i % 5000 == 0) {
         sb.append("LOCK TABLES tbl_bussiness_simplify WRITE;\r\n");
         sb.append(
             "insert into tbl_bussiness_simplify (d_btype,d_bdistrict,d_phonenum,d_support,d_support_type) values \r\n");
       }
       String phoneNum = s[0];
       String bd = s[1];
       String gprs = s[2];
       String wap = s[3];
       String smartPhone = s[4];
       String os = s[5];
       String wifi = s[6];
       if (smartPhone.equals("1") || os.equals("1")) {
         support = 1;
         supprotType = 2;
       } else {
         if (wap.equals("1") && gprs.equals("1")) {
           support = 1;
           supprotType = 1;
         }
       }
       sb.append("(0,\'" + bd + "\',\'" + phoneNum + "\'," + support + "," + supprotType + ")");
       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();
 }
Ejemplo n.º 30
0
    @Override
    public void run() {
      try {
        // Perform some queries
        for (int i = 0; i < runs; ++i) {
          Performance.sleep((long) (50 * RND.nextDouble()));

          // Return nth text of the database
          final int n = RND.nextInt() % MAX + 1;
          final String qu = Util.info(QUERY, n);
          session.execute("xquery " + qu);
        }
        session.close();
      } catch (final Exception ex) {
        ex.printStackTrace();
      }
    }