@Test public void can_read_bindings_from_xml_config() throws NaiveContainerException, ParserConfigurationException, SAXException, IOException, InvocationTargetException { InputStream is = new ByteArrayInputStream(xml.getBytes()); Injector injector = new SimpleInjector(new XmlConfiguration(is)); Dependent dep = injector.getInstance(Dependent.class); assertEquals("string1", dep.getS1()); assertEquals("string2", dep.getS2()); assertEquals(123, dep.getInteger()); }
@Test public void testBidirectionalAssociation() throws Exception { assertTrue(SchemaUtil.isColumnPresent("Dependent", "emp_empId", metadata())); assertTrue(!SchemaUtil.isColumnPresent("Dependent", "empPK", metadata())); Employee e = new Employee(); e.empId = 1; e.empName = "Emmanuel"; Session s = openSession(); s.getTransaction().begin(); s.persist(e); Dependent d = new Dependent(); d.emp = e; s.persist(d); s.flush(); s.clear(); d = getDerivedClassById(e, s, Dependent.class); assertEquals(e.empId, d.emp.empId); s.getTransaction().rollback(); s.close(); }