Exemplo n.º 1
0
 @Test
 public void shouldLocalizeEnums() throws Exception {
   when(localizer.localize(anyString(), anyVararg())).thenReturn("ರಘುನಂದನ");
   assertThat(LocalizedMessage.messageFor(Enum.X).localize(localizer), is("ರಘುನಂದನ"));
   when(localizer.localize(anyString(), anyVararg())).thenReturn("ಪವನ");
   assertThat(LocalizedMessage.messageFor(Enum.yyy).localize(localizer), is("ಪವನ"));
 }
Exemplo n.º 2
0
 @Test
 public void shouldLocalizeDurations() throws Exception {
   Duration theDuration = new Duration(1000);
   String expected = "it took a long time";
   when(localizer.localize(theDuration)).thenReturn(expected);
   assertThat(LocalizedMessage.localizeDuration(theDuration).localize(localizer), is(expected));
 }
Exemplo n.º 3
0
 @Test
 public void shouldUseTheProvidedLocalizerToLocalizeWithArgs() {
   when(localizer.localize("ME", "for-real")).thenReturn("whateva");
   assertThat(
       LocalizedMessage.string("me", Arrays.asList("for-real")).localize(localizer),
       is("whateva"));
 }
Exemplo n.º 4
0
  public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
      throws SAXException {

    IslandSchema is = dispatcher.getSchemaProvider().getSchemaByNamespace(namespaceURI);
    if (is != null) {
      // find an island that has to be validated.
      // switch to the new IslandVerifier.
      IslandVerifier iv = is.createNewVerifier(namespaceURI, is.getElementDecls());
      dispatcher.switchVerifier(iv);
      iv.startElement(namespaceURI, localName, qName, atts);
      return;
    }

    boolean atLeastOneIsValid = false;

    for (int i = 0; i < exps.length; i++)
      if (exps[i] != null) {
        if (exps[i].getNameClass().accepts(namespaceURI, localName)) atLeastOneIsValid = true;
        else exps[i] = null; // this one is no longer valid.
      }

    if (!atLeastOneIsValid)
      // none is valid. report an error.
      dispatcher
          .getErrorHandler()
          .error(
              new SAXParseException(
                  Localizer.localize(ERR_UNEXPECTED_NAMESPACE, new Object[] {namespaceURI}),
                  locator));
  }
Exemplo n.º 5
0
  /** Called when the broker is starting. */
  public XMLServiceImpl(Logger logger, FileSystem fileSystem) {
    log = logger;
    this.fileSystem = fileSystem;
    entityResolver = new CalthaEntityResolver(this, fileSystem, log);

    factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(false);
    log.info(Localizer.localize(MSG_PARSER, factory.getClass().getName()));

    xmlGrammarCache = new XMLGrammarCache(this, logger);

    // factory.setFeature("http://apache.org/xml/features/validation/dynamic",true);
    // log.info(Localizer.localize(MSG_DTDVALIDATION));
  }
Exemplo n.º 6
0
  public void start() {
    if (enabled) return;
    enabled = true;

    if (timer != null) {
      timer.cancel();
    }
    timer = new Timer();
    timer.schedule(
        new TimerTask() {
          @Override
          public void run() {
            stop();
            ScanAndDataMode.getInstance(context).start();
          }
        },
        makeBeaconPeriod());
    wifiHelper.setWifiEnabled(false);
    wifiHelper.setSoftApEnabled(true);

    // Magic
    Localizer.localize();
  }
Exemplo n.º 7
0
 @Test
 public void shouldUseCapitalizedNoSpaceKeyToFindStringLocalization() throws Exception {
   when(localizer.localize(anyString(), anyVararg())).thenReturn("helped!");
   String s = "Help me";
   assertThat(LocalizedMessage.string(s).localize(localizer), is("helped!"));
 }
Exemplo n.º 8
0
 @Test
 public void shouldUseTheProvidedLocalizerToLocalize() {
   when(localizer.localize(anyString(), anyVararg())).thenReturn("whateva");
   assertThat(LocalizedMessage.string("me").localize(localizer), is("whateva"));
 }