static {
    System.setProperty("svnkit.log.native.calls", "true");

    final SvnKitDebugLogger logger =
        new SvnKitDebugLogger(
            Boolean.getBoolean(LOG_PARAMETER_NAME), Boolean.getBoolean(TRACE_NATIVE_CALLS), LOG);
    SVNDebugLog.setDefaultLog(logger);

    SVNJNAUtil.setJNAEnabled(true);
    SvnHttpAuthMethodsDefaultChecker.check();

    SVNAdminAreaFactory.setSelector(new SvnKitAdminAreaFactorySelector());

    DAVRepositoryFactory.setup();
    SVNRepositoryFactoryImpl.setup();
    FSRepositoryFactory.setup();

    // non-optimized writing is fast enough on Linux/MacOS, and somewhat more reliable
    if (SystemInfo.isWindows) {
      SVNAdminArea14.setOptimizedWritingEnabled(true);
    }

    if (!SVNJNAUtil.isJNAPresent()) {
      LOG.warn("JNA is not found by svnkit library");
    }

    ourExplicitlySetSslProtocols = System.getProperty(SVNKIT_HTTP_SSL_PROTOCOLS);
  }
Ejemplo n.º 2
0
  static {
    System.setProperty("svnkit.log.native.calls", "true");
    final JavaSVNDebugLogger logger =
        new JavaSVNDebugLogger(
            Boolean.getBoolean(LOG_PARAMETER_NAME), Boolean.getBoolean(TRACE_NATIVE_CALLS), LOG);
    SVNDebugLog.setDefaultLog(logger);

    SVNJNAUtil.setJNAEnabled(true);
    SvnHttpAuthMethodsDefaultChecker.check();

    SVNAdminAreaFactory.setSelector(new SvnFormatSelector());

    DAVRepositoryFactory.setup();
    SVNRepositoryFactoryImpl.setup();
    FSRepositoryFactory.setup();

    // non-optimized writing is fast enough on Linux/MacOS, and somewhat more reliable
    if (SystemInfo.isWindows) {
      SVNAdminArea14.setOptimizedWritingEnabled(true);
    }

    if (!SVNJNAUtil.isJNAPresent()) {
      LOG.warn("JNA is not found by svnkit library");
    }
    initLogFilters();

    // Alexander Kitaev says it is default value (SSLv3) - since 8254
    if (!SystemInfo.JAVA_RUNTIME_VERSION.startsWith("1.7")
        && System.getProperty(SVNKIT_HTTP_SSL_PROTOCOLS) == null) {
      System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "SSLv3");
    }
  }
Ejemplo n.º 3
0
  private <DATA_TYPE> void handleBackgroundOperationException(
      OperationAndData<DATA_TYPE> operationAndData, Throwable e) {
    do {
      if ((operationAndData != null) && RetryLoop.isRetryException(e)) {
        if (!Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)) {
          log.debug("Retry-able exception received", e);
        }
        if (client
            .getRetryPolicy()
            .allowRetry(
                operationAndData.getThenIncrementRetryCount(),
                operationAndData.getElapsedTimeMs(),
                operationAndData)) {
          if (!Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)) {
            log.debug("Retrying operation");
          }
          backgroundOperations.offer(operationAndData);
          break;
        } else {
          if (!Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)) {
            log.debug("Retry policy did not allow retry");
          }
          if (operationAndData.getErrorCallback() != null) {
            operationAndData.getErrorCallback().retriesExhausted(operationAndData);
          }
        }
      }

      logError("Background exception was not retry-able or retry gave up", e);
    } while (false);
  }
 private synchronized void checkTimeouts() throws Exception {
   long elapsed = System.currentTimeMillis() - connectionStartMs;
   if (elapsed >= Math.min(sessionTimeoutMs, connectionTimeoutMs)) {
     if (zooKeeper.hasNewConnectionString()) {
       handleNewConnectionString();
     } else if (elapsed > sessionTimeoutMs) {
       if (!Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)) {
         log.warn(
             String.format(
                 "Connection attempt unsuccessful after %d (greater than session timeout of %d). Resetting connection and trying again with a new connection.",
                 elapsed, sessionTimeoutMs));
       }
       reset();
     } else {
       KeeperException.ConnectionLossException connectionLossException =
           new KeeperException.ConnectionLossException();
       if (!Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)) {
         log.error(
             String.format(
                 "Connection timed out for connection string (%s) and timeout (%d) / elapsed (%d)",
                 zooKeeper.getConnectionString(), connectionTimeoutMs, elapsed),
             connectionLossException);
       }
       tracer.get().addCount("connections-timed-out", 1);
       throw connectionLossException;
     }
   }
 }
Ejemplo n.º 5
0
  public TestFaultyService(String tag) {
    super(tag);

    // read in Java system properties
    runloop_pause = Integer.getInteger("runlooppause", 5).intValue();
    shutdown_pause = Integer.getInteger("shutdownpause", 0).intValue();
    startup_pause = Integer.getInteger("startuppause", 0).intValue();
    dothrow = Boolean.getBoolean("dothrow"); // default = false
    doexit = Boolean.getBoolean("doexit"); // default = false

    logger.info(
        serviceName
            + " PARAMETERS: runlooppause="
            + runloop_pause
            + " shutdownpause="
            + shutdown_pause
            + " startuppause="
            + startup_pause
            + " dothrow="
            + dothrow
            + " doexit="
            + doexit
            + " loginterval="
            + loginterval);

    doSleep(startup_pause);

    logger.info(serviceName + " STARTING");
  }
Ejemplo n.º 6
0
    // Lazy initialized constants
    private static class CONFIG {
      // Turning on identifier quoting allows the use of reserved words for identifier (table,
      // field, etc.) names
      static final boolean ENABLE_IDENTIFIER_QUOTING =
          Boolean.getBoolean("com.webobjects.jdbcadaptor.MySQLExpression.enableIdentifierQuoting");
      // Inserts "\n\t" between statement clauses for log readability. Useful in development
      static final boolean LINE_PER_CLAUSE =
          Boolean.getBoolean("com.webobjects.jdbcadaptor.MySQLExpression.enableLinePerClause");

      // Length values for the string constant elements of the statement taking into account
      // LINE_PER_CLAUSE for development and/or MySQL log readability.
      // Note that the space is needed before FROM, WHERE etc in the LINE_PER_CLAUSE variant to
      // ensure compatibility with code that assumes a space
      // surrounding the FROM, as in
      // er.extensions.jdbc.ERXSQLHelper.rowCountForFetchSpecification(...) for example
      static final String FROM_STRING = (CONFIG.LINE_PER_CLAUSE ? "\n\t FROM " : " FROM ");
      static final String WHERE_STRING = (CONFIG.LINE_PER_CLAUSE ? "\n\t WHERE " : " WHERE ");
      static final String ORDER_BY_STRING =
          (CONFIG.LINE_PER_CLAUSE ? "\n\t ORDER BY " : " ORDER BY ");
      static final String LIMIT_STRING = (CONFIG.LINE_PER_CLAUSE ? "\n\t LIMIT " : " LIMIT ");
      static final int FROM_LENGTH = FROM_STRING.length();
      static final int WHERE_LENGTH = WHERE_STRING.length();
      static final int ORDER_BY_LENGTH = ORDER_BY_STRING.length();
      static final int LIMIT_LENGTH = LIMIT_STRING.length();

      /**
       * From the MySQL Manual: &quot;An identifier may be quoted or unquoted. If an identifier
       * contains special characters or is a reserved word, you must quote it whenever you refer to
       * it. ... The identifier quote character is the backtick.&quot;
       */
      static final String IDENTIFIER_QUOTE_CHARACTER = (ENABLE_IDENTIFIER_QUOTING ? "`" : "");
    }
Ejemplo n.º 7
0
  public static ArrayList<ArticleData> readITArticlesFromFile(String path)
      throws ParserConfigurationException, SAXException, IOException, ParseException {
    ArrayList<ArticleData> result = new ArrayList<ArticleData>();

    File file = new File(path);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(file);
    doc.getDocumentElement().normalize();
    NodeList nodeLst = doc.getElementsByTagName("art");
    for (int s = 0; s < nodeLst.getLength(); s++) {
      Node fstNode = nodeLst.item(s);

      if (fstNode.getNodeType() == Node.ELEMENT_NODE) {

        LocationData l = new LocationData();
        ArticleData article = new ArticleData();
        Element fstElmnt = (Element) fstNode;
        article.region = Integer.parseInt(fstElmnt.getAttribute("r"));
        article.type = Integer.parseInt(fstElmnt.getAttribute("type"));
        article.refId = Integer.parseInt(fstElmnt.getAttribute("id"));
        article.isBeach = Boolean.getBoolean(fstElmnt.getAttribute("beach"));
        article.pub = Boolean.getBoolean(fstElmnt.getAttribute("pub"));
        article.video = fstElmnt.getAttribute("v");
        article.title = fstElmnt.getAttribute("title");
        article.translationType = PMDataTypes.DITT_ARTICLE;

        result.add(article);
      }
    }
    return result;
  }
Ejemplo n.º 8
0
  private void doExecute(ProcessorTestCase child, Description description) throws Exception {
    File destination = extractTest(child, description);
    PrintStream originalOut = System.out;

    final Verifier verifier;
    if (Boolean.getBoolean(SYS_PROP_DEBUG)) {
      if (child.processor.getToolchain() == null) {
        // when not using toolchains for a test, then the compiler is executed within the Maven JVM.
        // So make
        // sure we fork a new JVM for that, and let that new JVM use the command 'mvnDebug' instead
        // of 'mvn'
        verifier = new Verifier(destination.getCanonicalPath(), null, true, true);
        verifier.setDebugJvm(true);
      } else {
        verifier = new Verifier(destination.getCanonicalPath());
        verifier.addCliOption("-Pdebug-forked-javac");
      }
    } else {
      verifier = new Verifier(destination.getCanonicalPath());
    }

    List<String> goals = new ArrayList<String>(3);

    goals.add("clean");

    try {
      configureToolchains(child, verifier, goals, originalOut);
      configureProcessor(child, verifier);

      verifier.addCliOption(
          "-Dcompiler-source-target-version=" + child.processor.getSourceTargetVersion());

      if ("1.8".equals(child.processor.getSourceTargetVersion())
          || "1.9".equals(child.processor.getSourceTargetVersion())) {
        verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct-jdk8");
      } else {
        verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct");
      }

      if (Boolean.getBoolean(SYS_PROP_DEBUG)) {
        originalOut.print("Processor Integration Test: ");
        originalOut.println("Listening for transport dt_socket at address: 8000 (in some seconds)");
      }

      goals.add("test");

      addAdditionalCliArguments(child, verifier);

      originalOut.println("executing " + child.processor.name().toLowerCase());

      verifier.executeGoals(goals);
      verifier.verifyErrorFreeLog();
    } finally {
      verifier.resetStreams();
    }
  }
Ejemplo n.º 9
0
  static {
    try {
      TRACE = TRACE || Boolean.getBoolean("hsqldb.trace");
      TRACESYSTEMOUT = TRACESYSTEMOUT || Boolean.getBoolean("hsqldb.tracesystemout");
    } catch (Exception e) {
    }

    if (!sDescription[LAST_ERROR_HANDLE].equals("LAST")) {
      throw new RuntimeException(sDescription[Trace.GENERAL_ERROR]);
    }
  }
Ejemplo n.º 10
0
  /**
   * Method called when the task is executed It continuously check the state of SMS with a frequency
   * of {@link PERIOD}
   */
  @Override
  protected Object doInBackground(Object... params) {

    try {
      Context ctxtApp = (Context) params[0];
      Uri uriSmsInbox = Uri.parse("content://sms/inbox");

      while (true) {
        Cursor cursor = ctxtApp.getContentResolver().query(uriSmsInbox, null, null, null, null);

        /**
         * The SMS charge indicator are reset every time we check the inbox All received SMS are
         * checked, we should consider another way (e.g. consider those received this morning, day)
         * For the unread messages, consider only those received after the last read message
         */
        int newNbAllSms = 0;
        int newNbReadSms = 0;
        int newNbUnReadSms = 0;

        if (cursor.moveToFirst()) {
          do {
            String person = cursor.getString(cursor.getColumnIndex("person"));
            String address = cursor.getString(cursor.getColumnIndex("address"));
            String body = cursor.getString(cursor.getColumnIndex("body"));
            String status = cursor.getString(cursor.getColumnIndex("status"));
            String type = cursor.getString(cursor.getColumnIndex("type"));
            boolean seen = Boolean.getBoolean(cursor.getString(cursor.getColumnIndex("seen")));
            boolean read = Boolean.getBoolean(cursor.getString(cursor.getColumnIndex("read")));
            newNbAllSms += 1;
            newNbReadSms += (read == true ? 1 : 0);
            newNbUnReadSms += (read == false ? 1 : 0);
            Date date = new Date(Long.parseLong(cursor.getString(cursor.getColumnIndex("date"))));
            Log.v(
                TAG,
                date + ": " + person + ", " + address + ", " + body + ", " + status + ", " + type
                    + ", " + seen + ", " + read);
          } while (cursor.moveToNext());
          nbAllSms = nbAllSms == newNbAllSms ? nbAllSms : newNbAllSms;
          nbReadSms = nbReadSms == newNbReadSms ? nbReadSms : newNbReadSms;
          nbUnReadSms = nbUnReadSms == newNbUnReadSms ? nbUnReadSms : newNbUnReadSms;
        }
        cursor.close();
        Thread.sleep(PERIOD);
      }
    } catch (InterruptedException ie) {

      ie.printStackTrace();
    }

    return null;
  }
Ejemplo n.º 11
0
  private void addIgnoresForBrowser(Browser browser, IgnoreComparator comparator) {
    if (Boolean.getBoolean("selenium.browser.remote") || SauceDriver.shouldUseSauce()) {
      comparator.addDriver(REMOTE);
    }

    switch (browser) {
      case chrome:
        comparator.addDriver(CHROME);
        break;

      case ff:
        if (Boolean.getBoolean("webdriver.firefox.marionette")) {
          comparator.addDriver(MARIONETTE);
        } else {
          comparator.addDriver(FIREFOX);
        }
        break;

      case htmlunit:
      case htmlunit_js:
        comparator.addDriver(HTMLUNIT);
        break;

      case ie:
        comparator.addDriver(IE);
        break;

      case none:
        comparator.addDriver(ALL);
        break;

      case opera:
        break;

      case operablink:
        comparator.addDriver(CHROME);
        break;

      case phantomjs:
        comparator.addDriver(PHANTOMJS);
        break;

      case safari:
        comparator.addDriver(SAFARI);
        break;

      default:
        throw new RuntimeException("Cannot determine which ignore to add ignores rules for");
    }
  }
  private void processRegistryElements(XMLElement el) {
    if (el.getName().equalsIgnoreCase("get")) {
      String scope = el.getStringAttribute("scope");
      String key = replaceTokens(el.getStringAttribute("key"));
      String value = replaceTokens(el.getStringAttribute("value"));
      String param = replaceTokens(el.getStringAttribute("parameter"));
      String defaultValue = replaceTokens(el.getStringAttribute("default"));

      addParameter(
          param,
          WinRegistry.getRegistryValue(
              scope, key, value, defaultValue == null ? "" : defaultValue));
    } else if (el.getName().equalsIgnoreCase("set")) {
      String scope = el.getStringAttribute("scope");
      String key = replaceTokens(el.getStringAttribute("key"));
      String value = replaceTokens(el.getStringAttribute("value"));
      String arg = replaceTokens(el.getStringAttribute("arg"));

      WinRegistry.setRegistryValue(scope, key, value, arg);

    } else if (el.getName().equalsIgnoreCase("if")) {

      String scope = el.getStringAttribute("scope");
      String key = replaceTokens(el.getStringAttribute("key"));
      String value = replaceTokens(el.getStringAttribute("value"));
      String notAttr = el.getStringAttribute("not");
      String existsAttr = el.getStringAttribute("exists");
      String equalsAttr = el.getStringAttribute("equals");

      if (existsAttr != null) {
        boolean exists = Boolean.getBoolean(existsAttr);
        String v = WinRegistry.getRegistryValue(scope, key, value, "DEFAULT_VALUE");
        if (v.equals("DEFAULT_VALUE") && !exists) {
          processRegistryElements(el);
        } else if (!v.equals("DEFAULT_VALUE") && exists) {
          processRegistryElements(el);
        }
      } else if (notAttr != null) {
        boolean not = Boolean.getBoolean(notAttr == null ? "false" : notAttr);
        String v = WinRegistry.getRegistryValue(scope, key, value, "");

        if (equalsAttr.equals(v) && !not) {
          processRegistryElements(el);
        } else if (!equalsAttr.equals(v) && not) {
          processRegistryElements(el);
        }
      }
    }
  }
Ejemplo n.º 13
0
/**
 * A facility for timing a step in the runtime initialization sequence. This is independent from all
 * other JVMCI code so as to not perturb the initialization sequence. It is enabled by setting the
 * {@code "jvmci.inittimer"} system property to {@code "true"}.
 */
public final class InitTimer implements AutoCloseable {
  final String name;
  final long start;

  private InitTimer(String name) {
    int n = nesting.getAndIncrement();
    if (n == 0) {
      initializingThread = Thread.currentThread();
      System.out.println("INITIALIZING THREAD: " + initializingThread);
    } else {
      assert Thread.currentThread() == initializingThread
          : Thread.currentThread() + " != " + initializingThread;
    }
    this.name = name;
    this.start = System.currentTimeMillis();
    System.out.println("START: " + SPACES.substring(0, n * 2) + name);
  }

  @SuppressFBWarnings(
      value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
      justification = "only the initializing thread accesses this field")
  public void close() {
    final long end = System.currentTimeMillis();
    int n = nesting.decrementAndGet();
    System.out.println(
        " DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]");
    if (n == 0) {
      initializingThread = null;
    }
  }

  public static InitTimer timer(String name) {
    return ENABLED ? new InitTimer(name) : null;
  }

  public static InitTimer timer(String name, Object suffix) {
    return ENABLED ? new InitTimer(name + suffix) : null;
  }

  /** Specifies if initialization timing is enabled. */
  private static final boolean ENABLED =
      Boolean.getBoolean("jvmci.inittimer") || Boolean.getBoolean("jvmci.runtime.TimeInit");

  public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null;
  public static final String SPACES = "                                            ";

  /** Used to assert the invariant that all related initialization happens on the same thread. */
  public static Thread initializingThread;
}
Ejemplo n.º 14
0
  private boolean ensureNoLocalModifications()
      throws ComponentLookupException, ScmException, MojoExecutionException {

    if (!Boolean.getBoolean("sesat.mojo.localModifications.ignore")) {

      final ScmManager scmManager = (ScmManager) container.lookup(ScmManager.ROLE);

      loadPomProject();

      final StatusScmResult result =
          scmManager.status(
              scmManager.makeScmRepository(project.getScm().getDeveloperConnection()),
              new ScmFileSet(pomProject.getBasedir()));

      if (!result.isSuccess()) {

        getLog().error(result.getCommandOutput());
        throw new MojoExecutionException("Failed to ensure checkout has no modifications");
      }

      if (0 < result.getChangedFiles().size()) {

        throw new MojoExecutionException(
            "Your checkout has local modifications. "
                + "Server deploy can *only* be done with a clean workbench.");
      }

      return result.isSuccess() && 0 == result.getChangedFiles().size();
    }
    return true; // sesat.mojo.localModifications.ignore
  }
Ejemplo n.º 15
0
 /** Constructs ... */
 public Dialback() {
   super();
   if (System.getProperty("s2s-ejabberd-bug-workaround-active") == null) {
     System.setProperty("s2s-ejabberd-bug-workaround-active", "true");
   }
   ejabberd_bug_workaround_active = Boolean.getBoolean("s2s-ejabberd-bug-workaround-active");
 }
  @BeforeClass
  public static void startUp() throws InterruptedException, IOException {
    if (applicationContext == null) {
      if (System.getProperty(SHUTDOWN_AFTER_RUN) != null) {
        shutdownAfterRun = Boolean.getBoolean(SHUTDOWN_AFTER_RUN);
      }

      SpringApplication application =
          new SpringApplicationBuilder(
                  AdminApplication.class, AdminConfiguration.class, TestConfig.class)
              .build();
      applicationContext =
          application.run(
              String.format("--server.port=%s", adminPort),
              "--security.basic.enabled=false",
              "--spring.main.show_banner=false",
              "--spring.cloud.config.enabled=false");
    }
    JLineShellComponent shell =
        new Bootstrap(new String[] {"--port", String.valueOf(adminPort)}).getJLineShellComponent();
    if (!shell.isRunning()) {
      shell.start();
    }
    dataFlowShell = new DataFlowShell(shell);
  }
Ejemplo n.º 17
0
  protected List<FrameworkMethod> doComputation() {
    // Next, get all the test methods as understood by JUnit
    final List<FrameworkMethod> methods = super.computeTestMethods();

    // Now process that full list of test methods and build our custom result
    final List<FrameworkMethod> result = new ArrayList<FrameworkMethod>();
    final boolean doValidation = Boolean.getBoolean(Helper.VALIDATE_FAILURE_EXPECTED);
    int testCount = 0;

    Ignore virtualIgnore;

    for (FrameworkMethod frameworkMethod : methods) {
      // potentially ignore based on expected failure
      final FailureExpected failureExpected =
          Helper.locateAnnotation(FailureExpected.class, frameworkMethod, getTestClass());
      if (failureExpected != null && !doValidation) {
        virtualIgnore =
            new IgnoreImpl(Helper.extractIgnoreMessage(failureExpected, frameworkMethod));
      } else {
        virtualIgnore = convertSkipToIgnore(frameworkMethod);
      }

      testCount++;
      log.trace("adding test " + Helper.extractTestName(frameworkMethod) + " [#" + testCount + "]");
      result.add(new ExtendedFrameworkMethod(frameworkMethod, virtualIgnore, failureExpected));
    }
    return result;
  }
Ejemplo n.º 18
0
  private void startDebuggerService() {
    setHandler(new DebuggerHandler());
    final CountDownLatch suspendLatch = new CountDownLatch(1);
    boolean suspend = Boolean.getBoolean(MULE_DEBUG_SUSPEND);
    logger.info("Suspend property is " + suspend);
    if (suspend) {
      getHandler()
          .addListener(
              new IDebuggerServiceListener() {
                public void onStart() {
                  suspendLatch.countDown();
                }

                public void onStop() {}
              });
    }
    setServer(new RemoteDebuggerService(Integer.getInteger(MULE_DEBUG_PORT, 6666), getHandler()));
    getServer().startService();

    if (suspend) {
      try {
        System.out.println("Waiting for client to connect");
        suspendLatch.await();
      } catch (InterruptedException e) {

      }
      logger.info("Debugger started");
    }
    // We need to invoke this listener for every app that is deployed
    // registerForApplicationNotifications(null);
  }
Ejemplo n.º 19
0
 /**
  * Create a circuit to evaluate (x1 or not(x1)) and then verify that its result is true for all
  * values of x1.
  */
 public void testAlwaysTrue() {
   if (Boolean.getBoolean("no.failures")) return;
   Circuit c = new Circuit();
   c.parse("x1 or NOT x1");
   assertTrue(c.evaluate(new boolean[] {Boolean.FALSE}));
   assertTrue(c.evaluate(new boolean[] {Boolean.TRUE}));
 }
Ejemplo n.º 20
0
  public static void main(String[] args) throws IOException, MaryConfigurationException {

    if (args.length < 2) {
      System.out.println("Usage:");
      System.out.println(
          "java marytts.modules.phonemiser.TrainedLTS allophones.xml lts-model.lts [removeTrailingOneFromPhones]");
      System.exit(0);
    }
    String allophoneFile = args[0];
    String ltsFile = args[1];
    boolean myRemoveTrailingOneFromPhones = true;
    if (args.length > 2) {
      myRemoveTrailingOneFromPhones = Boolean.getBoolean(args[2]);
    }

    TrainedLTS lts =
        new TrainedLTS(
            AllophoneSet.getAllophoneSet(allophoneFile),
            new FileInputStream(ltsFile),
            myRemoveTrailingOneFromPhones,
            new Syllabifier(
                AllophoneSet.getAllophoneSet(allophoneFile), myRemoveTrailingOneFromPhones));

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line;
    while ((line = br.readLine()) != null) {
      line = line.trim();
      String pron = lts.predictPronunciation(line);
      String syl = lts.syllabify(pron);
      String sylStripped = syl.replaceAll("[-' ]+", "");
      System.out.println(sylStripped);
    }
  }
Ejemplo n.º 21
0
  /** initialize routeResolver */
  public void init(PeerGroup group, ID assignedID, Advertisement impl, EndpointRouter router)
      throws PeerGroupException {

    // extract Router service configuration properties
    PlatformConfig confAdv = (PlatformConfig) group.getConfigAdvertisement();
    Element paramBlock = null;

    if (confAdv != null) {
      paramBlock = confAdv.getServiceParam(assignedID);
    }

    if (paramBlock != null) {
      // get our tunable router parameter
      Enumeration param;

      param = paramBlock.getChildren("useRouteResolver");
      if (param.hasMoreElements()) {
        useRouteResolver = Boolean.getBoolean(((TextElement) param.nextElement()).getTextValue());
      }
    }

    this.group = group;
    this.router = router;

    localPeerId = group.getPeerID();
    localPeerAddr =
        new EndpointAddress("jxta", localPeerId.getUniqueValue().toString(), null, null);
  }
Ejemplo n.º 22
0
 @Override
 public void drain() {
   if (Boolean.getBoolean("YDEBUG")) {
     System.out.println("YDataLine.drain()");
   }
   //
 }
Ejemplo n.º 23
0
 public @Override boolean enabled() {
   if (Boolean.getBoolean("netbeans.keyring.no.native")) {
     LOG.fine("native keyring integration disabled");
     return false;
   }
   boolean envVarSet = false;
   for (String key : System.getenv().keySet()) {
     if (key.startsWith("GNOME_KEYRING_")) { // NOI18N
       envVarSet = true;
       break;
     }
   }
   if (!envVarSet) {
     LOG.fine("no GNOME_KEYRING_* environment variable set");
     return false;
   }
   String appName = "JOSM";
   try {
     // Need to do this somewhere, or we get warnings on console.
     // Also used by confirmation dialogs to give the app access to the login keyring.
     LIBRARY.g_set_application_name(appName);
     if (!LIBRARY.gnome_keyring_is_available()) {
       return false;
     }
     // #178571: try to read some key just to make sure gnome_keyring_find_password_sync is bound:
     read("NoNeXiStEnT"); // NOI18N
     return true;
   } catch (Throwable t) {
     LOG.log(Level.FINE, null, t);
     return false;
   }
 }
Ejemplo n.º 24
0
  @Test
  public void shouldNotifyUserWhenEmailAddressesAreDifferent() {
    driver.get(URL);
    String title = driver.getTitle();
    assertEquals("Rule Financial Registration Form", title);

    int randomIntNUmberForRegistration = this.generator.nextInt(100000);

    driver.findElement(By.name("firstName")).clear();
    driver.findElement(By.name("firstName")).sendKeys("Marcin");
    driver.findElement(By.name("lastName")).clear();
    driver.findElement(By.name("lastName")).sendKeys("Kowalczyk");

    String email = new String("marcinkowalczyk" + randomIntNUmberForRegistration + "@gmail.com");

    driver.findElement(By.name("email")).clear();
    driver.findElement(By.name("email")).sendKeys(email);
    driver.findElement(By.name("repeatEmail")).clear();
    driver.findElement(By.name("repeatEmail")).sendKeys("wrong" + email);

    WebElement divErrorEmailAdress =
        driver.findElement(By.xpath("html/body/div[2]/div[2]/div/div/div/div[5]/div/div"));
    boolean ariaHidden = Boolean.getBoolean(divErrorEmailAdress.getAttribute("aria-hidden"));
    assertEquals(ariaHidden, false);
  }
Ejemplo n.º 25
0
 static {
   String library = "opendds-jms-native";
   if (Boolean.getBoolean("opendds.native.debug")) {
     library = library.concat("d");
   }
   System.loadLibrary(library);
 }
Ejemplo n.º 26
0
/** @deprecated */
@Deprecated
public class DBPointer extends DBRefBase {

  static final boolean D = Boolean.getBoolean("DEBUG.DBPOINTER");

  /**
   * CTOR used for testing BSON encoding. Otherwise non-functional due to a DBRef needing a parent
   * db object, a fieldName and a db
   *
   * @param ns namespace to point to
   * @param id value of _id
   */
  public DBPointer(String ns, ObjectId id) {
    this(null, null, null, ns, id);
  }

  DBPointer(Entity parent, String fieldName, DB db, String ns, ObjectId id) {
    super(db, ns, (Object) id);

    _parent = parent;
    _fieldName = fieldName;
  }

  public String toString() {
    return "{ \"$ref\" : \"" + _ns + "\", \"$id\" : ObjectId(\"" + _id + "\") }";
  }

  public ObjectId getId() {
    return (ObjectId) _id;
  }

  final Entity _parent;
  final String _fieldName;
}
Ejemplo n.º 27
0
  @SuppressWarnings({"UnnecessaryBoxing", "UnnecessaryUnboxing"})
  protected void assertAllDataRemoved() {
    if (!createSchema()) {
      return; // no tables were created...
    }
    if (!Boolean.getBoolean(VALIDATE_DATA_CLEANUP)) {
      return;
    }

    Session tmpSession = sessionFactory.openSession();
    try {
      List list = tmpSession.createQuery("select o from java.lang.Object o").list();

      Map<String, Integer> items = new HashMap<String, Integer>();
      if (!list.isEmpty()) {
        for (Object element : list) {
          Integer l = items.get(tmpSession.getEntityName(element));
          if (l == null) {
            l = 0;
          }
          l = l + 1;
          items.put(tmpSession.getEntityName(element), l);
          System.out.println("Data left: " + element);
        }
        fail("Data is left in the database: " + items.toString());
      }
    } finally {
      try {
        tmpSession.close();
      } catch (Throwable t) {
        // intentionally empty
      }
    }
  }
Ejemplo n.º 28
0
    static
    {
	// The default allowUserAction in java.net.URLConnection is
	// false.
	try
	{
	    if (Boolean.getBoolean("HTTPClient.HttpURLConnection.AllowUI"))
		setDefaultAllowUserInteraction(true);
	}
	catch (SecurityException se)
	    { }

	// get the RedirectionModule class
	try
	    { redir_mod = Class.forName("HTTPClient.RedirectionModule"); }
	catch (ClassNotFoundException cnfe)
	    { throw new NoClassDefFoundError(cnfe.getMessage()); }

	// Set the User-Agent if the http.agent property is set
	try
	{
	    String agent = System.getProperty("http.agent");
	    if (agent != null)
		setDefaultRequestProperty("User-Agent", agent);
	}
	catch (SecurityException se)
	    { }
    }
Ejemplo n.º 29
0
  /** End-to-end installation test. */
  private void doTestAutoInstallation(String id, String fullversion) throws Exception {
    Assume.assumeTrue(
        "this is a really time consuming test, so only run it when we really want",
        Boolean.getBoolean("jenkins.testJDKInstaller"));

    retrieveUpdateCenterData();

    JDKInstaller installer = new JDKInstaller(id, true);

    JDK jdk =
        new JDK(
            "test",
            tmp.getRoot().getAbsolutePath(),
            Arrays.asList(new InstallSourceProperty(Arrays.<ToolInstaller>asList(installer))));

    j.jenkins.getJDKs().add(jdk);

    FreeStyleProject p = j.createFreeStyleProject();
    p.setJDK(jdk);
    p.getBuildersList().add(new Shell("java -fullversion\necho $JAVA_HOME"));
    FreeStyleBuild b = j.buildAndAssertSuccess(p);
    @SuppressWarnings("deprecation")
    String log = b.getLog();
    System.out.println(log);
    // make sure it runs with the JDK that just got installed
    assertTrue(log.contains(fullversion));
    assertTrue(log.contains(tmp.getRoot().getAbsolutePath()));
  }
Ejemplo n.º 30
0
  protected Server startServer(int port) throws Exception {
    Server server = new Server();
    Connector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);

    String contextPath = "";
    ServletContextHandler context = new ServletContextHandler(server, contextPath);

    // CometD servlet
    ServletHolder cometdServletHolder = new ServletHolder(CometdServlet.class);
    cometdServletHolder.setInitParameter("timeout", "10000");
    cometdServletHolder.setInitParameter("transports", WebSocketTransport.class.getName());
    if (Boolean.getBoolean("debugTests")) cometdServletHolder.setInitParameter("logLevel", "3");
    cometdServletHolder.setInitOrder(1);

    String cometdServletPath = "/cometd";
    context.addServlet(cometdServletHolder, cometdServletPath + "/*");

    server.start();
    String url = "http://localhost:" + connector.getLocalPort() + contextPath + cometdServletPath;
    server.setAttribute(OortConfigServlet.OORT_URL_PARAM, url);
    BayeuxServer bayeux =
        (BayeuxServer) context.getServletContext().getAttribute(BayeuxServer.ATTRIBUTE);
    server.setAttribute(BayeuxServer.ATTRIBUTE, bayeux);

    servers.add(server);

    return server;
  }