Examples of FormatInfo


Examples of ch.qos.logback.core.pattern.FormatInfo

      advanceTokenPointer();
      return new Node(Node.LITERAL, t.getValue());
    case Token.PERCENT:
      advanceTokenPointer();
      // System.out.println("% token found");
      FormatInfo fi;
      Token u = getCurentToken();
      FormattingNode c;
      expectNotNull(u, "a FORMAT_MODIFIER, SIMPLE_KEYWORD or COMPOUND_KEYWORD");
      if (u.getType() == Token.FORMAT_MODIFIER) {
        fi = FormatInfo.valueOf((String) u.getValue());
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  }

  @Test
  public void testBasic() {
    {
      FormatInfo fi = FormatInfo.valueOf("45");
      FormatInfo witness = new FormatInfo();
      witness.setMin(45);
      assertEquals(witness, fi);
    }

    {
      FormatInfo fi = FormatInfo.valueOf("4.5");
      FormatInfo witness = new FormatInfo();
      witness.setMin(4);
      witness.setMax(5);
      assertEquals(witness, fi);
    }
  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  }

  @Test
  public void testRightPad() {
    {
      FormatInfo fi = FormatInfo.valueOf("-40");
      FormatInfo witness = new FormatInfo();
      witness.setMin(40);
      witness.setLeftPad(false);
      assertEquals(witness, fi);
    }

    {
      FormatInfo fi = FormatInfo.valueOf("-12.5");
      FormatInfo witness = new FormatInfo();
      witness.setMin(12);
      witness.setMax(5);
      witness.setLeftPad(false);
      assertEquals(witness, fi);
    }

    {
      FormatInfo fi = FormatInfo.valueOf("-14.-5");
      FormatInfo witness = new FormatInfo();
      witness.setMin(14);
      witness.setMax(5);
      witness.setLeftPad(false);
      witness.setLeftTruncate(false);
      assertEquals(witness, fi);
    }
  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  }

  @Test
  public void testMinOnly() {
    {
      FormatInfo fi = FormatInfo.valueOf("49");
      FormatInfo witness = new FormatInfo();
      witness.setMin(49);
      assertEquals(witness, fi);
    }

    {
      FormatInfo fi = FormatInfo.valueOf("-587");
      FormatInfo witness = new FormatInfo();
      witness.setMin(587);
      witness.setLeftPad(false);
      assertEquals(witness, fi);
    }

  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  }

  @Test
  public void testMaxOnly() {
    {
      FormatInfo fi = FormatInfo.valueOf(".49");
      FormatInfo witness = new FormatInfo();
      witness.setMax(49);
      assertEquals(witness, fi);
    }

    {
      FormatInfo fi = FormatInfo.valueOf(".-5");
      FormatInfo witness = new FormatInfo();
      witness.setMax(5);
      witness.setLeftTruncate(false);
      assertEquals(witness, fi);
    }
  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  public void testFormattingInfo() throws Exception {
    {
      Parser p = new Parser("%45x");
      Node t = p.parse();
      FormattingNode witness = new SimpleKeywordNode("x");
      witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE));
      assertEquals(witness, t);
    }
    {
      Parser p = new Parser("%4.5x");
      Node t = p.parse();
      FormattingNode witness = new SimpleKeywordNode("x");
      witness.setFormatInfo(new FormatInfo(4, 5));
      assertEquals(witness, t);
    }

    {
      Parser p = new Parser("%-4.5x");
      Node t = p.parse();
      FormattingNode witness = new SimpleKeywordNode("x");
      witness.setFormatInfo(new FormatInfo(4, 5, false, true));
      assertEquals(witness, t);
    }
    {
      Parser p = new Parser("%-4.-5x");
      Node t = p.parse();
      FormattingNode witness = new SimpleKeywordNode("x");
      witness.setFormatInfo(new FormatInfo(4, 5, false, false));
      assertEquals(witness, t);
    }

    {
      Parser p = new Parser("%-4.5x %12y");
      Node t = p.parse();
      FormattingNode witness = new SimpleKeywordNode("x");
      witness.setFormatInfo(new FormatInfo(4, 5, false, true));
      Node n = witness.next = new Node(Node.LITERAL, " ");
      n = n.next = new SimpleKeywordNode("y");
      ((FormattingNode) n).setFormatInfo(new FormatInfo(12, Integer.MAX_VALUE));
      assertEquals(witness, t);
    }
  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  @Test
  public void testOptions0() throws Exception {
    Parser p = new Parser("%45x{'test '}");
    Node t = p.parse();
    SimpleKeywordNode witness = new SimpleKeywordNode("x");
    witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE));
    List<String> ol = new ArrayList<String>();
    ol.add("test ");
    witness.setOptions(ol);
    assertEquals(witness, t);
  }
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

  @Test
  public void testOptions1() throws Exception {
    Parser p = new Parser("%45x{a, b}");
    Node t = p.parse();
    SimpleKeywordNode witness = new SimpleKeywordNode("x");
    witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE));
    List<String> ol = new ArrayList<String>();
    ol.add("a");
    ol.add("b");
    witness.setOptions(ol);
    assertEquals(witness, t);
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

    Parser p = new Parser("hello%5(XYZ)");
    Node t = p.parse();

    Node witness = new Node(Node.LITERAL, "hello");
    CompositeNode composite = new CompositeNode(BARE);
    composite.setFormatInfo(new FormatInfo(5, Integer.MAX_VALUE));
    Node child = new Node(Node.LITERAL, "XYZ");
    composite.setChildNode(child);
    witness.next = composite;

    assertEquals(witness, t);
View Full Code Here

Examples of ch.qos.logback.core.pattern.FormatInfo

      converter.write(buf, le);
      assertEquals("INFO", buf.toString());
    }
    {
      DynamicConverter<ILoggingEvent> converter = new LevelConverter();
      converter.setFormattingInfo(new FormatInfo(1, 1, true, false));
      StringBuilder buf = new StringBuilder();
      converter.write(buf, le);
      assertEquals("I", buf.toString());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.