PmaServerSessionFactory extends PmaSessionFactory { public void init() throws AnnotationAnalysisException { File directory = new File(m_deviceFileBaseDirPath); if (!directory.exists()) { directory.mkdirs(); } else if (!directory.isDirectory()) { throw new RuntimeException(m_deviceFileBaseDirPath + " is not a directory"); } EntityRegistryBuilder.updateEntityRegistry(PmaRegistryImpl.COMPONENT_ID, Arrays.asList(DeviceXmlStore.class), m_entityRegistry, m_schemaRegistry, null, m_modelNodeDsmRegistry); } PmaServerSessionFactory(String deviceFileBaseDirPath, DeviceManager deviceManager, NetConfServerImpl netconfServer,
                                   NetconfDeviceAlignmentService das, EntityRegistry entityRegistry, SchemaRegistry schemaRegistry,
                                   ModelNodeDSMRegistry modelNodeDsmRegistry, AdapterManager adapterManager); void init(); void destroy(); @Override PmaSession create(String key); @Override boolean validateObject(String key, PooledObject<PmaSession> session); @Override PooledObject<PmaSession> wrap(PmaSession value); @Override void deviceDeleted(String deviceName);  }
@Test public void testRegistryThrowsExceptionIfPathIsNatADirectory() throws IOException { m_tempFile = File.createTempFile("tempfile", ".txt"); String deviceFileBaseDir = m_tempFile.getAbsolutePath(); try { new PmaServerSessionFactory(deviceFileBaseDir, m_dm, m_netconfServer, m_das, m_entityRegistry, m_schemaRegistry, m_modelNodeDsmRegistry, m_adapterManager).init(); fail("Expected an exception to be thrown here"); } catch (Exception e) { assertTrue(e instanceof RuntimeException); assertEquals(m_tempFile.getAbsolutePath() + " is not a directory", e.getMessage()); } }