Package test.aop

Examples of test.aop.Lockable


    NotLockable notLockable1 = (NotLockable) createProxy(notLockableTarget,
        getFixture().getAdvisors(
            new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")),
        NotLockable.class);
    assertTrue(notLockable1 instanceof Lockable);
    Lockable lockable = (Lockable) notLockable1;
    assertFalse(lockable.locked());
    lockable.lock();
    assertTrue(lockable.locked());

    NotLockable notLockable2Target = new NotLockable();
    NotLockable notLockable2 = (NotLockable) createProxy(notLockable2Target,
        getFixture().getAdvisors(
            new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")),
        NotLockable.class);
    assertTrue(notLockable2 instanceof Lockable);
    Lockable lockable2 = (Lockable) notLockable2;
    assertFalse(lockable2.locked());
    notLockable2.setIntValue(1);
    lockable2.lock();
    try {
      notLockable2.setIntValue(32);
      fail();
    }
    catch (IllegalStateException ex) {
    }
    assertTrue(lockable2.locked());
  }
View Full Code Here


  }

  @Test
  public void testIntroductionOnTargetImplementingInterface() {
    CannotBeUnlocked target = new CannotBeUnlocked();
    Lockable proxy = (Lockable) createProxy(target,
        // Ensure that we exclude
        AopUtils.findAdvisorsThatCanApply(
            getFixture().getAdvisors(
                new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(), "someBean")),
            CannotBeUnlocked.class
        ),
        CannotBeUnlocked.class);
    assertThat(proxy, instanceOf(Lockable.class));
    Lockable lockable = proxy;
    assertTrue("Already locked", lockable.locked());
    lockable.lock();
    assertTrue("Real target ignores locking", lockable.locked());
    try {
      lockable.unlock();
      fail();
    }
    catch (UnsupportedOperationException ex) {
      // Ok
    }
View Full Code Here

    Modifiable modifiable = (Modifiable) createProxy(target,
        advisors,
        ITestBean.class);
    assertThat(modifiable, instanceOf(Modifiable.class));
    Lockable lockable = (Lockable) modifiable;
    assertFalse(lockable.locked());

    ITestBean itb = (ITestBean) modifiable;
    assertFalse(modifiable.isModified());
    int oldAge = itb.getAge();
    itb.setAge(oldAge + 1);
    assertTrue(modifiable.isModified());
    modifiable.acceptChanges();
    assertFalse(modifiable.isModified());
    itb.setAge(itb.getAge());
    assertFalse("Setting same value does not modify", modifiable.isModified());
    itb.setName("And now for something completely different");
    assertTrue(modifiable.isModified());

    lockable.lock();
    assertTrue(lockable.locked());
    try {
      itb.setName("Else");
      fail("Should be locked");
    }
    catch (IllegalStateException ex) {
      // Ok
    }
    lockable.unlock();
    itb.setName("Tony");
  }
View Full Code Here

TOP

Related Classes of test.aop.Lockable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.