/** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, marshallerBackup); }
/** * @return Entry Processor. */ protected String getEntryProcessor(){ return GridTestProperties.getProperty(GridTestProperties.ENTRY_PROCESSOR_CLASS_NAME) != null ? GridTestProperties.getProperty(GridTestProperties.ENTRY_PROCESSOR_CLASS_NAME) : "org.apache.ignite.tests.p2p.CacheDeploymentEntryProcessor"; }
/** * @param name Property name. * @return Property value. */ public static synchronized String getProperty(String name) { return getProperties().get(name); }
/** * @param props Initial properties. * @param dir Directory path. * @return Loaded properties. */ private static Map<String, String> loadProperties(Map<String, String> props, String dir) { File cfg = getTestConfigurationFile(dir, TESTS_PROP_FILE); if (cfg != null) loadFromFile(props, cfg); return props; }
/** * @throws Exception If failed. */ @Test public void testPropertyEnabled() throws Exception { String useSimpleNameBackup = GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER); try { GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); checkProperty("TestClass"); } finally { if (useSimpleNameBackup != null) GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); } }
/** */ @BeforeClass public static void setup() { GridTestProperties.init(); }
/** * @param user User name. */ private static void configureLog4j(String user) { String cfgFile = System.getProperty("IGNITE_TEST_PROP_LOG4J_FILE"); if (cfgFile == null) cfgFile = "log4j-test.xml"; File log4jFile = getTestConfigurationFile(user, cfgFile); if (log4jFile == null) log4jFile = getTestConfigurationFile(null, cfgFile); DOMConfigurator.configure(log4jFile.getAbsolutePath()); System.out.println("Configured log4j from: " + log4jFile); }
/** * @param dir Directory path. * @return Properties. */ public static synchronized Map<String, String> getProperties(String dir) { Map<String, String> props = pathProps.get(dir); if (props == null) { props = new HashMap<>(); // Load default properties. props.putAll(dfltProps); // Load properties from specified folder // potentially overriding defaults. loadProperties(props, dir); pathProps.put(dir, props); } return props; }
/** * @param props Initial properties. * @param file Property file. * @return Loaded properties. */ private static Map<String, String> loadFromFile(Map<String, String> props, File file) { try { try (InputStream in = new FileInputStream(file)) { Properties fileProps = new Properties(); fileProps.load(in); for (Entry<Object, Object> prop : fileProps.entrySet()) props.put((String) prop.getKey(), (String) prop.getValue()); for (Entry<String, String> prop : props.entrySet()) prop.setValue(substituteProperties(prop.getValue())); } } catch (IOException e) { e.printStackTrace(); assert false : "Failed to load test configuration properties: " + file; } return props; } }
/** * @param expTypeName Type name. * @throws Exception If failed. */ private void checkProperty(String expTypeName) throws Exception { String marshBackup = GridTestProperties.getProperty(MARSH_CLASS_NAME); try { GridTestProperties.setProperty(MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); IgniteBinary binary = startGrid().binary(); BinaryObjectBuilder builder = binary.builder("org.ignite.test.TestClass"); BinaryObject bObj = builder.build(); assertEquals(expTypeName, bObj.type().typeName()); } finally { if (marshBackup != null) GridTestProperties.setProperty(MARSH_CLASS_NAME, marshBackup); } } }
/** * @param startGrid Start grid flag. */ @SuppressWarnings({"OverriddenMethodCallDuringObjectConstruction"}) protected GridAbstractTest(boolean startGrid) { assert isJunitFrameworkClass() : "GridAbstractTest class cannot be extended directly " + "(use GridCommonAbstractTest class instead)."; // Initialize properties. Logger initialized here. GridTestProperties.init(); log = new GridTestLog4jLogger(); GridAbstractTest.startGrid = startGrid; }
public static String keyStorePassword() { return GridTestProperties.getProperty("ssl.keystore.password"); }
/** */ @BeforeClass public static void init() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); } }
/** * @param name Property name. * @param val Property value. */ public static synchronized void setProperty(String name, String val) { getProperties().put(name, val); }
/** * @return Time for load test in minutes. */ private int getTestDurationInMinutes() { return Integer.valueOf(GridTestProperties.getProperty("load.test.duration")); }
/** */ @BeforeClass public static void init() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); } }
/** * @return Properties. */ public static synchronized Map<String, String> getProperties() { String user = System.getProperty("user.name"); assert user != null; return getProperties(user); }
/** * @return Number of threads for the test. */ private int getThreadCount() { return Integer.valueOf(GridTestProperties.getProperty("load.test.threadnum")); }
/** */ @BeforeClass public static void init() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); } }
/** * @param name Property name. * @param dir Directory path. * @return Property value. */ public static synchronized String getProperty(String name, String dir) { return getProperties(dir).get(name); }