public static void main(String[] args) throws Exception { Context context = new ContextBase(); Map<ElementSelector, Action> ruleMap = new HashMap<ElementSelector, Action>(); // we start with the rule for the top-most (root) element ruleMap.put(new ElementSelector("*/foo"), new NOPAction()); // Add an implicit action. List<ImplicitAction> iaList = new ArrayList<ImplicitAction>(); iaList.add(new PrintMeImplicitAction()); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap, iaList); // link the configurator with its context simpleConfigurator.setContext(context); simpleConfigurator.doConfigure(args[0]); StatusPrinter.printInCaseOfErrorsOrWarnings(context); } }
public static void main(String[] args) throws Exception { Map<ElementSelector, Action> ruleMap = new HashMap<ElementSelector, Action>(); // Associate "hello-world" pattern with HelloWorldAction ruleMap.put(new ElementSelector("hello-world"), new HelloWorldAction()); // Joran needs to work within a context. Context context = new ContextBase(); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap); // link the configurator with its context simpleConfigurator.setContext(context); simpleConfigurator.doConfigure(args[0]); StatusPrinter.print(context); } }
public static void main(String[] args) { Context context = new ContextBase(); for(int i = 0; i < 3; i++) { SenderRunnable senderRunnable = new SenderRunnable(""+i); context.getScheduledExecutorService().execute(senderRunnable); } System.out.println("done"); //System.exit(0); }
RollingFileHandler(String filename, int maxHistory, DataSize maxFileSize, DataSize maxTotalSize) { setFormatter(new StaticFormatter()); fileAppender = createFileAppender(filename, maxHistory, maxFileSize, maxTotalSize, new StringEncoder(), new ContextBase()); }
public static void main(String[] args) throws Exception { Context context = new ContextBase(); Map<ElementSelector, Action> ruleMap = new HashMap<ElementSelector, Action>(); // Associate "/computation" pattern with ComputationAction1 ruleMap.put(new ElementSelector("/computation"), new ComputationAction1()); // Other associations ruleMap.put(new ElementSelector("/computation/literal"), new LiteralAction()); ruleMap.put(new ElementSelector("/computation/add"), new AddAction()); ruleMap.put(new ElementSelector("/computation/multiply"), new MultiplyAction()); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap); // link the configurator with its context simpleConfigurator.setContext(context); simpleConfigurator.doConfigure(args[0]); // Print any errors that might have occured. StatusPrinter.print(context); } }
@Test public void testBasic() { Context context = new ContextBase(); context.getStatusManager().add(new InfoStatus("test", this)); StatusPrinter.print(context); String result = outputStream.toString(); assertTrue(result.contains("|-INFO in "+this.getClass().getName())); }
@Before public void setUp() throws Exception { configuration.setContext(new ContextBase()); }
@Test public void testTail2() throws Exception { SimpleRuleStore srs = new SimpleRuleStore(new ContextBase()); srs.addRule(new ElementSelector("*/c"), new XAction()); for (String s : cc.combinations("a/b/c")) { List<Action> r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); if (!(r.get(0) instanceof XAction)) { fail("Wrong type"); } } }
@Test public void testEscapeBothParentheses() { PatternLayoutBase<Object> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern("x\\(%OTT\\)y"); plb.start(); String s = plb.doLayout(new Object()); assertEquals("x(123)y", s); }
@Test public void testEscapeClosingParentheses() { PatternLayoutBase<Object> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern("x(%OTT\\)y"); plb.start(); String s = plb.doLayout(new Object()); assertEquals("x(123)y", s); }
DelimitedRequestLog(HttpServerConfig config) { appender = Logging.createFileAppender( config.getLogPath(), config.getLogMaxHistory(), config.getLogQueueSize(), new Duration(10, SECONDS), config.getLogMaxSegmentSize(), config.getLogMaxTotalSize(), new EventEncoder(), new ContextBase()); }
@Test public void testPercentAsLiteral() { PatternLayoutBase<Object> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern("hello \\% world"); plb.start(); String s = plb.doLayout(new Object()); assertEquals("hello % world", s); }
JsonRequestLog(HttpServerConfig config) { appender = Logging.createFileAppender( config.getLogPath(), config.getLogMaxHistory(), config.getLogQueueSize(), new Duration(10, SECONDS), config.getLogMaxSegmentSize(), config.getLogMaxTotalSize(), new EventEncoder(), new ContextBase()); }
@Test public void testOK() { PatternLayoutBase<Object> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern("x%OTT"); plb.start(); String s = plb.doLayout(new Object()); //System.out.println(s); //StatusManager sm = context.getStatusManager(); //StatusPrinter.print(sm); assertEquals("x123", s); }
@Before public void setUp() throws Exception { context = new ContextBase(); ec = new InterpretationContext(context, null); propertyAction = new PropertyAction(); propertyAction.setContext(context); }
@Test public void testUnStarted() { PatternLayoutBase<E> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); String s = plb.doLayout(getEventObject()); assertEquals("", s); StatusManager sm = context.getStatusManager(); StatusPrinter.print(sm); }
@Test public void testStarted() { PatternLayoutBase<E> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); String s = plb.doLayout(getEventObject()); assertEquals("", s); StatusManager sm = context.getStatusManager(); StatusPrinter.print(sm); }
public Fruit buildFruit() { Context context = new ContextBase(); this.fruit = null; context.putProperty("fruitKey", "orange-"+count); // for next round count++; FruitConfigurator fruitConfigurator = new FruitConfigurator(this); fruitConfigurator.setContext(context); try { fruitConfigurator.doConfigure(eventList); } catch(JoranException je) { je.printStackTrace(); } return fruit; }
@Test public void testEmptyPattern() { //System.out.println("testNullPattern"); PatternLayoutBase<E> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern(""); plb.start(); String s = plb.doLayout(getEventObject()); assertEquals("", s); StatusChecker checker = new StatusChecker(context.getStatusManager()); //StatusPrinter.print(context); checker.assertContainsMatch("Empty or null pattern."); }
@Test public void testNullPattern() { //System.out.println("testNullPattern"); PatternLayoutBase<E> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); plb.setPattern(null); plb.start(); String s = plb.doLayout(getEventObject()); assertEquals("", s); StatusChecker checker = new StatusChecker(context.getStatusManager()); //StatusPrinter.print(context); checker.assertContainsMatch("Empty or null pattern."); }