/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
/** * If a key is found in propertiesMap then return it. Otherwise, delegate to * the context. */ public String getProperty(String key) { String v = propertiesMap.get(key); if (v != null) { return v; } else { return context.getProperty(key); } }
private String[] readStyxClassesFromProperty() { String[] targetClasses = TARGET_CLASSES_DEFAULT; Context ctx = getContext(); String property = ctx.getProperty(TARGET_CLASSES_PROPERTY_NAME); if (!Strings.isNullOrEmpty(property)) { targetClasses = Iterables.toArray(Splitter.on(",").trimResults().split(property), String.class); } else { addError(MessageFormat.format("The '{0}' property should be present on logback configuration. Using default classname prefixes.", TARGET_CLASSES_PROPERTY_NAME)); } return targetClasses; }
/** * Gets the absolute path to the filename, starting from the app's * "files" directory, if it is not already an absolute path * * @param filename filename to evaluate * @return absolute path to the filename */ private String getAbsoluteFilePath(String filename) { // In Android, relative paths created with File() are relative // to root, so fix it by prefixing the path to the app's "files" // directory. // This transformation is rather expensive, since it involves loading the // Android manifest from the APK (which is a ZIP file), and parsing it to // retrieve the application package name. This should be avoided if // possible as it may perceptibly delay the app launch time. if (EnvUtil.isAndroidOS() && !new File(filename).isAbsolute()) { String dataDir = context.getProperty(CoreConstants.DATA_DIR_KEY); filename = FileUtil.prefixRelativePath(dataDir, filename); } return filename; } }
@Test public void noClass() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + NOCLASS_XML); String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); checker.assertContainsMatch(Status.ERROR, "Missing class name for property definer. Near \\[define\\] line 1"); }
@Test public void testBadClass() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + BADCLASS_XML); // get from context String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); // check context errors checker.assertContainsMatch(Status.ERROR, "Could not create an PropertyDefiner of type"); }
@Test public void noName() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + NONAME_XML); // get from context String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); // check context errors checker.assertContainsMatch(Status.ERROR, "Missing property name for property definer. Near \\[define\\] line 1"); }
void doTest(String filename, Integer expectedInt, Class<?> exceptionClass) throws Exception { rulesMap.put(new ElementSelector("test"), new NOPAction()); rulesMap.put(new ElementSelector("test/badBegin"), new BadBeginAction()); rulesMap.put(new ElementSelector("test/badBegin/touch"), new TouchAction()); rulesMap.put(new ElementSelector("test/badEnd"), new BadEndAction()); rulesMap.put(new ElementSelector("test/badEnd/touch"), new TouchAction()); rulesMap.put(new ElementSelector("test/hello"), new HelloAction()); rulesMap.put(new ElementSelector("test/isolate"), new NOPAction()); rulesMap.put(new ElementSelector("test/isolate/badEnd"), new BadEndAction()); rulesMap.put(new ElementSelector("test/isolate/badEnd/touch"), new TouchAction()); rulesMap.put(new ElementSelector("test/isolate/touch"), new TouchAction()); rulesMap.put(new ElementSelector("test/hello"), new HelloAction()); TrivialConfigurator tc = new TrivialConfigurator(rulesMap); tc.setContext(context); tc.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/skip/" + filename); String str = context.getProperty(HelloAction.PROPERTY_KEY); assertEquals("Hello John Doe.", str); Integer i = (Integer) context.getObject(TouchAction.KEY); if (expectedInt == null) { assertNull(i); } else { assertEquals(expectedInt, i); } // check the existence of an ERROR status List<Status> statusList = sm.getCopyOfStatusList(); Status s0 = statusList.get(0); assertEquals(Status.ERROR, s0.getLevel()); assertTrue(s0.getThrowable().getClass() == exceptionClass); }