Java Code Examples for org.springframework.tests.sample.beans.ITestBean#haveBirthday()
The following examples show how to use
org.springframework.tests.sample.beans.ITestBean#haveBirthday() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TxNamespaceHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void invokeTransactional() { ITestBean testBean = getTestBean(); CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager"); // try with transactional assertEquals("Should not have any started transactions", 0, ptm.begun); testBean.getName(); assertTrue(ptm.lastDefinition.isReadOnly()); assertEquals("Should have 1 started transaction", 1, ptm.begun); assertEquals("Should have 1 committed transaction", 1, ptm.commits); // try with non-transaction testBean.haveBirthday(); assertEquals("Should not have started another transaction", 1, ptm.begun); // try with exceptional try { testBean.exceptional(new IllegalArgumentException("foo")); fail("Should NEVER get here"); } catch (Throwable throwable) { assertEquals("Should have another started transaction", 2, ptm.begun); assertEquals("Should have 1 rolled back transaction", 1, ptm.rollbacks); } }
Example 2
Source File: TxNamespaceHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void invokeTransactional() { ITestBean testBean = getTestBean(); CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager"); // try with transactional assertEquals("Should not have any started transactions", 0, ptm.begun); testBean.getName(); assertTrue(ptm.lastDefinition.isReadOnly()); assertEquals("Should have 1 started transaction", 1, ptm.begun); assertEquals("Should have 1 committed transaction", 1, ptm.commits); // try with non-transaction testBean.haveBirthday(); assertEquals("Should not have started another transaction", 1, ptm.begun); // try with exceptional try { testBean.exceptional(new IllegalArgumentException("foo")); fail("Should NEVER get here"); } catch (Throwable throwable) { assertEquals("Should have another started transaction", 2, ptm.begun); assertEquals("Should have 1 rolled back transaction", 1, ptm.rollbacks); } }
Example 3
Source File: TxNamespaceHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void invokeTransactional() throws Exception { ITestBean testBean = getTestBean(); CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager"); // try with transactional assertEquals("Should not have any started transactions", 0, ptm.begun); testBean.getName(); assertTrue(ptm.lastDefinition.isReadOnly()); assertEquals("Should have 1 started transaction", 1, ptm.begun); assertEquals("Should have 1 committed transaction", 1, ptm.commits); // try with non-transaction testBean.haveBirthday(); assertEquals("Should not have started another transaction", 1, ptm.begun); // try with exceptional try { testBean.exceptional(new IllegalArgumentException("foo")); fail("Should NEVER get here"); } catch (Throwable throwable) { assertEquals("Should have another started transaction", 2, ptm.begun); assertEquals("Should have 1 rolled back transaction", 1, ptm.rollbacks); } }
Example 4
Source File: JndiObjectFactoryBeanTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testLookupWithProxyInterfaceWithNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }
Example 5
Source File: JndiObjectFactoryBeanTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setLookupOnStartup(false); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertNull(tb.getName()); assertEquals(0, tb.getAge()); proxy.returnsThis(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }
Example 6
Source File: JndiObjectFactoryBeanTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testLookupWithProxyInterfaceWithNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }
Example 7
Source File: JndiObjectFactoryBeanTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setLookupOnStartup(false); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertNull(tb.getName()); assertEquals(0, tb.getAge()); proxy.returnsThis(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }
Example 8
Source File: JndiObjectFactoryBeanTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testLookupWithProxyInterfaceWithNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }
Example 9
Source File: JndiObjectFactoryBeanTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @Override public Object lookup(String name) { if ("foo".equals(name)) { tb.setName("tb"); tb.setAge(tb.getAge() + 1); return tb; } return null; } }); jof.setJndiName("foo"); jof.setProxyInterface(ITestBean.class); jof.setLookupOnStartup(false); jof.setCache(false); jof.afterPropertiesSet(); assertTrue(jof.getObject() instanceof ITestBean); ITestBean proxy = (ITestBean) jof.getObject(); assertNull(tb.getName()); assertEquals(0, tb.getAge()); proxy.returnsThis(); assertEquals("tb", tb.getName()); assertEquals(1, tb.getAge()); proxy.returnsThis(); assertEquals(2, tb.getAge()); proxy.haveBirthday(); assertEquals(4, tb.getAge()); }