test.mixin.LockedException Java Examples
The following examples show how to use
test.mixin.LockedException.
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: AbstractAopProxyTests.java From spring-analysis-note with MIT License | 6 votes |
private void testTestBeanIntroduction(ProxyFactory pc) { int newAge = 65; ITestBean itb = (ITestBean) createProxy(pc); itb.setAge(newAge); assertEquals(newAge, itb.getAge()); Lockable lockable = (Lockable) itb; assertFalse(lockable.locked()); lockable.lock(); assertEquals(newAge, itb.getAge()); try { itb.setAge(1); fail("Setters should fail when locked"); } catch (LockedException ex) { // ok } assertEquals(newAge, itb.getAge()); // Unlock assertTrue(lockable.locked()); lockable.unlock(); itb.setAge(1); assertEquals(1, itb.getAge()); }
Example #2
Source File: AbstractAopProxyTests.java From java-technology-stack with MIT License | 6 votes |
private void testTestBeanIntroduction(ProxyFactory pc) { int newAge = 65; ITestBean itb = (ITestBean) createProxy(pc); itb.setAge(newAge); assertEquals(newAge, itb.getAge()); Lockable lockable = (Lockable) itb; assertFalse(lockable.locked()); lockable.lock(); assertEquals(newAge, itb.getAge()); try { itb.setAge(1); fail("Setters should fail when locked"); } catch (LockedException ex) { // ok } assertEquals(newAge, itb.getAge()); // Unlock assertTrue(lockable.locked()); lockable.unlock(); itb.setAge(1); assertEquals(1, itb.getAge()); }
Example #3
Source File: AbstractAopProxyTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void testTestBeanIntroduction(ProxyFactory pc) { int newAge = 65; ITestBean itb = (ITestBean) createProxy(pc); itb.setAge(newAge); assertEquals(newAge, itb.getAge()); Lockable lockable = (Lockable) itb; assertFalse(lockable.locked()); lockable.lock(); assertEquals(newAge, itb.getAge()); try { itb.setAge(1); fail("Setters should fail when locked"); } catch (LockedException ex) { // ok } assertEquals(newAge, itb.getAge()); // Unlock assertTrue(lockable.locked()); lockable.unlock(); itb.setAge(1); assertEquals(1, itb.getAge()); }
Example #4
Source File: BeanNameAutoProxyCreatorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testJdkIntroduction() { ITestBean tb = (ITestBean) beanFactory.getBean("introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals(0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); assertEquals("introductionUsingJdk", tb.getName()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }
Example #5
Source File: BeanNameAutoProxyCreatorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testJdkIntroductionAppliesToCreatedObjectsNotFactoryBean() { ITestBean tb = (ITestBean) beanFactory.getBean("factory-introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals("NOP should not have done any work yet", 0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }
Example #6
Source File: BeanNameAutoProxyCreatorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testJdkIntroduction() { ITestBean tb = (ITestBean) beanFactory.getBean("introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals(0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); assertEquals("introductionUsingJdk", tb.getName()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }
Example #7
Source File: BeanNameAutoProxyCreatorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testJdkIntroductionAppliesToCreatedObjectsNotFactoryBean() { ITestBean tb = (ITestBean) beanFactory.getBean("factory-introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals("NOP should not have done any work yet", 0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }
Example #8
Source File: BeanNameAutoProxyCreatorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testJdkIntroduction() { ITestBean tb = (ITestBean) beanFactory.getBean("introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals(0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); assertEquals("introductionUsingJdk", tb.getName()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }
Example #9
Source File: BeanNameAutoProxyCreatorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testJdkIntroductionAppliesToCreatedObjectsNotFactoryBean() { ITestBean tb = (ITestBean) beanFactory.getBean("factory-introductionUsingJdk"); NopInterceptor nop = (NopInterceptor) beanFactory.getBean("introductionNopInterceptor"); assertEquals("NOP should not have done any work yet", 0, nop.getCount()); assertTrue(AopUtils.isJdkDynamicProxy(tb)); int age = 5; tb.setAge(age); assertEquals(age, tb.getAge()); assertTrue("Introduction was made", tb instanceof TimeStamped); assertEquals(0, ((TimeStamped) tb).getTimeStamp()); assertEquals(3, nop.getCount()); ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk"); // Check two per-instance mixins were distinct Lockable lockable1 = (Lockable) tb; Lockable lockable2 = (Lockable) tb2; assertFalse(lockable1.locked()); assertFalse(lockable2.locked()); tb.setAge(65); assertEquals(65, tb.getAge()); lockable1.lock(); assertTrue(lockable1.locked()); // Shouldn't affect second assertFalse(lockable2.locked()); // Can still mod second object tb2.setAge(12); // But can't mod first try { tb.setAge(6); fail("Mixin should have locked this object"); } catch (LockedException ex) { // Ok } }