You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2011/05/03 08:22:23 UTC
svn commit: r1098935 [15/20] - in /incubator/isis/trunk/runtimes/dflt:
bytecode/dflt/src/main/java/org/apache/isis/runtimes/dflt/bytecode/dflt/classsubstitutor/
bytecode/dflt/src/main/java/org/apache/isis/runtimes/dflt/bytecode/dflt/objectfactory/
byte...
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/exploration/ExplorationAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/exploration/ExplorationAuthenticatorTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/exploration/ExplorationAuthenticatorTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/exploration/ExplorationAuthenticatorTest.java Tue May 3 06:22:09 2011
@@ -17,20 +17,11 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.authentication.standard.exploration;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.runtime.authentication.AuthenticationRequestAbstract;
import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.AuthenticationRequestExploration;
@@ -38,85 +29,101 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.ExplorationAuthenticatorConstants;
import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
import org.apache.isis.runtimes.dflt.runtime.system.SystemConstants;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@RunWith(JMock.class)
public class ExplorationAuthenticatorTest {
-
- private Mockery mockery = new JUnit4Mockery();
- private IsisConfiguration mockConfiguration;
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private IsisConfiguration mockConfiguration;
private ExplorationAuthenticator authenticator;
- private AuthenticationRequestExploration explorationRequest;
+ private AuthenticationRequestExploration explorationRequest;
- private SomeOtherAuthenticationRequest someOtherRequest;
+ private SomeOtherAuthenticationRequest someOtherRequest;
private static class SomeOtherAuthenticationRequest extends AuthenticationRequestAbstract {
- public SomeOtherAuthenticationRequest() {
- super("other");
- }
- }
+ public SomeOtherAuthenticationRequest() {
+ super("other");
+ }
+ }
@Before
public void setUp() {
- mockConfiguration = mockery.mock(IsisConfiguration.class);
+ mockConfiguration = mockery.mock(IsisConfiguration.class);
+
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.NAKEDOBJECTS_USERS);
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.NAKEDOBJECTS_USERS);
- will(returnValue(DeploymentType.EXPLORATION.name()));
- }});
-
- explorationRequest = new AuthenticationRequestExploration();
- someOtherRequest = new SomeOtherAuthenticationRequest();
-
- authenticator = new ExplorationAuthenticator(mockConfiguration);
+ explorationRequest = new AuthenticationRequestExploration();
+ someOtherRequest = new SomeOtherAuthenticationRequest();
+
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
}
@Test
public void canAuthenticateExplorationRequest() throws Exception {
- assertThat(authenticator.canAuthenticate(explorationRequest), is(true));
+ assertThat(authenticator.canAuthenticate(explorationRequest), is(true));
}
@Test
public void canAuthenticateSomeOtherTypeOfRequest() throws Exception {
- assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
+ assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
}
@Test
public void isValidExplorationRequestWhenRunningInExplorationMode() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
- will(returnValue(DeploymentType.EXPLORATION.name()));
- }});
- assertThat(authenticator.isValid(explorationRequest), is(true));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
+ assertThat(authenticator.isValid(explorationRequest), is(true));
}
@Test
public void isNotValidExplorationRequestWhenRunningInSomethingOtherThanExplorationMode() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
- will(returnValue(DeploymentType.PROTOTYPE.name()));
- }});
- assertThat(authenticator.isValid(explorationRequest), is(false));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ will(returnValue(DeploymentType.PROTOTYPE.name()));
+ }
+ });
+ assertThat(authenticator.isValid(explorationRequest), is(false));
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void expectsThereToBeADeploymentTypeInIsisConfiguration() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
- will(returnValue(null));
- }});
- authenticator.isValid(explorationRequest);
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ will(returnValue(null));
+ }
+ });
+ authenticator.isValid(explorationRequest);
}
@Test
public void isValidSomeOtherTypeOfRequest() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
- will(returnValue(DeploymentType.EXPLORATION.name()));
- }});
- assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
+ assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/fixture/LogonFixtureAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/fixture/LogonFixtureAuthenticatorTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/fixture/LogonFixtureAuthenticatorTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/fixture/LogonFixtureAuthenticatorTest.java Tue May 3 06:22:09 2011
@@ -17,11 +17,17 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.authentication.standard.fixture;
-import java.util.List;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestAbstract;
+import org.apache.isis.runtimes.dflt.runtime.authentication.fixture.LogonFixtureAuthenticator;
+import org.apache.isis.runtimes.dflt.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
@@ -29,99 +35,98 @@ import org.jmock.integration.junit4.JUni
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequestAbstract;
-import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.MultiUserExplorationSession;
-import org.apache.isis.runtimes.dflt.runtime.authentication.fixture.LogonFixtureAuthenticator;
-import org.apache.isis.runtimes.dflt.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
-import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
-
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.CoreMatchers.*;
@RunWith(JMock.class)
public class LogonFixtureAuthenticatorTest {
-
- private Mockery mockery = new JUnit4Mockery();
- private IsisConfiguration mockConfiguration;
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private IsisConfiguration mockConfiguration;
private LogonFixtureAuthenticator authenticator;
- private AuthenticationRequestLogonFixture logonFixtureRequest;
+ private AuthenticationRequestLogonFixture logonFixtureRequest;
- private SomeOtherAuthenticationRequest someOtherRequest;
+ private SomeOtherAuthenticationRequest someOtherRequest;
private static class SomeOtherAuthenticationRequest extends AuthenticationRequestAbstract {
- public SomeOtherAuthenticationRequest() {
- super("other");
- }
- }
+ public SomeOtherAuthenticationRequest() {
+ super("other");
+ }
+ }
@Before
public void setUp() {
- mockConfiguration = mockery.mock(IsisConfiguration.class);
-
- logonFixtureRequest = new AuthenticationRequestLogonFixture(new LogonFixture("joebloggs"));
- someOtherRequest = new SomeOtherAuthenticationRequest();
- authenticator = new LogonFixtureAuthenticator(mockConfiguration);
+ mockConfiguration = mockery.mock(IsisConfiguration.class);
+
+ logonFixtureRequest = new AuthenticationRequestLogonFixture(new LogonFixture("joebloggs"));
+ someOtherRequest = new SomeOtherAuthenticationRequest();
+ authenticator = new LogonFixtureAuthenticator(mockConfiguration);
}
@Test
public void canAuthenticateExplorationRequest() throws Exception {
- assertThat(authenticator.canAuthenticate(logonFixtureRequest), is(true));
+ assertThat(authenticator.canAuthenticate(logonFixtureRequest), is(true));
}
@Test
public void canAuthenticateSomeOtherTypeOfRequest() throws Exception {
- assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
+ assertThat(authenticator.canAuthenticate(someOtherRequest), is(false));
}
@Test
public void isValidLogonFixtureRequestWhenRunningInExplorationMode() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString("isis.deploymentType");
- will(returnValue(DeploymentType.EXPLORATION.name()));
- }});
- assertThat(authenticator.isValid(logonFixtureRequest), is(true));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
+ assertThat(authenticator.isValid(logonFixtureRequest), is(true));
}
@Test
public void isValidLogonFixtureRequestWhenRunningInPrototypeMode() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString("isis.deploymentType");
- will(returnValue(DeploymentType.PROTOTYPE.name()));
- }});
- assertThat(authenticator.isValid(logonFixtureRequest), is(true));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(DeploymentType.PROTOTYPE.name()));
+ }
+ });
+ assertThat(authenticator.isValid(logonFixtureRequest), is(true));
}
@Test
- public void isNotValidExplorationRequestWhenRunningInSomethingOtherThanExplorationOrPrototypeMode() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString("isis.deploymentType");
- will(returnValue(DeploymentType.SERVER.name()));
- }});
- assertThat(authenticator.isValid(logonFixtureRequest), is(false));
+ public void isNotValidExplorationRequestWhenRunningInSomethingOtherThanExplorationOrPrototypeMode()
+ throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(DeploymentType.SERVER.name()));
+ }
+ });
+ assertThat(authenticator.isValid(logonFixtureRequest), is(false));
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void expectsThereToBeADeploymentTypeInIsisConfiguration() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString("isis.deploymentType");
- will(returnValue(null));
- }});
- authenticator.isValid(logonFixtureRequest);
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(null));
+ }
+ });
+ authenticator.isValid(logonFixtureRequest);
}
@Test
public void isValidSomeOtherTypeOfRequest() throws Exception {
- mockery.checking(new Expectations(){{
- allowing(mockConfiguration).getString("isis.deploymentType");
- will(returnValue(DeploymentType.EXPLORATION.name()));
- }});
- assertThat(authenticator.canAuthenticate(new SomeOtherAuthenticationRequest()), is(false));
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
+ assertThat(authenticator.canAuthenticate(new SomeOtherAuthenticationRequest()), is(false));
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/context/IsisContextTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/context/IsisContextTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/context/IsisContextTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/context/IsisContextTest.java Tue May 3 06:22:09 2011
@@ -17,21 +17,11 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.context;
import java.util.Collections;
import java.util.List;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.config.IsisConfigurationDefault;
@@ -52,13 +42,20 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyPersistenceSession;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyReflector;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxySession;
-
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@RunWith(JMock.class)
public class IsisContextTest {
- private Mockery mockery = new JUnit4Mockery();
-
+ private final Mockery mockery = new JUnit4Mockery();
+
private IsisConfiguration configuration;
private PersistenceSession persistenceSession;
private ObjectReflector reflector;
@@ -70,8 +67,7 @@ public class IsisContextTest {
protected AuthenticationManager mockAuthenticationManager;
protected AuthorizationManager mockAuthorizationManager;
- private List<Object> servicesList;
-
+ private List<Object> servicesList;
@Before
public void setUp() throws Exception {
@@ -84,46 +80,42 @@ public class IsisContextTest {
mockUserProfileLoader = mockery.mock(UserProfileLoader.class);
mockAuthenticationManager = mockery.mock(AuthenticationManager.class);
mockAuthorizationManager = mockery.mock(AuthorizationManager.class);
-
+
configuration = new IsisConfigurationDefault();
reflector = new TestProxyReflector();
persistenceSession = new TestProxyPersistenceSession(mockPersistenceSessionFactory);
- mockery.checking(new Expectations() {{
- one(mockPersistenceSessionFactory).createPersistenceSession();
- will(returnValue(persistenceSession));
-
- ignoring(mockPersistenceSessionFactory);
-
- one(mockUserProfileLoader).getProfile(with(any(AuthenticationSession.class)));
- will(returnValue(new UserProfile()));
-
- ignoring(mockUserProfileLoader);
-
- ignoring(mockAuthenticationManager);
-
- ignoring(mockAuthorizationManager);
-
- ignoring(mockTemplateImageLoader);
- }});
-
- reflector.setRuntimeContext(new RuntimeContextFromSession());
-
- IsisContext.setConfiguration(configuration);
-
- IsisSessionFactory sessionFactory =
- new IsisSessionFactoryDefault(
- DeploymentType.EXPLORATION,
- configuration,
- mockTemplateImageLoader,
- reflector,
- mockAuthenticationManager,
- mockAuthorizationManager,
- mockUserProfileLoader,
- mockPersistenceSessionFactory, servicesList);
+ mockery.checking(new Expectations() {
+ {
+ one(mockPersistenceSessionFactory).createPersistenceSession();
+ will(returnValue(persistenceSession));
+
+ ignoring(mockPersistenceSessionFactory);
+
+ one(mockUserProfileLoader).getProfile(with(any(AuthenticationSession.class)));
+ will(returnValue(new UserProfile()));
+
+ ignoring(mockUserProfileLoader);
+
+ ignoring(mockAuthenticationManager);
+
+ ignoring(mockAuthorizationManager);
+
+ ignoring(mockTemplateImageLoader);
+ }
+ });
+
+ reflector.setRuntimeContext(new RuntimeContextFromSession());
+
+ IsisContext.setConfiguration(configuration);
+
+ final IsisSessionFactory sessionFactory =
+ new IsisSessionFactoryDefault(DeploymentType.EXPLORATION, configuration, mockTemplateImageLoader,
+ reflector, mockAuthenticationManager, mockAuthorizationManager, mockUserProfileLoader,
+ mockPersistenceSessionFactory, servicesList);
IsisContextStatic.createRelaxedInstance(sessionFactory);
sessionFactory.init();
-
+
session = new TestProxySession();
IsisContext.openSession(session);
}
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest.java Tue May 3 06:22:09 2011
@@ -17,19 +17,15 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.memento;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.runtimes.dflt.runtime.memento.Memento;
import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit4TestCase;
-
+import org.junit.Before;
+import org.junit.Test;
public class MementoTest extends ProxyJunit4TestCase {
@@ -60,17 +56,16 @@ public class MementoTest extends ProxyJu
assertEquals(originalAdapter.getSpecification(), returnedAdapter.getSpecification());
}
-// @Ignore("TODO need to add reflective code to test system for this to work")
-// @Test
-// public void testName() throws Exception {
-// @SuppressWarnings("unused")
-// final TestPojoSimple originalPojo = (TestPojoSimple) originalAdapter.getObject();
-//
-// @SuppressWarnings("unused")
-// final TestPojoSimple returnedPojo = (TestPojoSimple) returnedAdapter.getObject();
-//
-// // assertEquals(originalPojo.getName(), returnedPojo.getName());
-// }
+ // @Ignore("TODO need to add reflective code to test system for this to work")
+ // @Test
+ // public void testName() throws Exception {
+ // @SuppressWarnings("unused")
+ // final TestPojoSimple originalPojo = (TestPojoSimple) originalAdapter.getObject();
+ //
+ // @SuppressWarnings("unused")
+ // final TestPojoSimple returnedPojo = (TestPojoSimple) returnedAdapter.getObject();
+ //
+ // // assertEquals(originalPojo.getName(), returnedPojo.getName());
+ // }
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest2_Test.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest2_Test.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest2_Test.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest2_Test.java Tue May 3 06:22:09 2011
@@ -17,22 +17,12 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.memento;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.Before;
-import org.junit.Test;
-
import org.apache.isis.core.commons.encoding.DataOutputStreamExtended;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.ResolveState;
@@ -43,19 +33,28 @@ import org.apache.isis.core.metamodel.sp
import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContextStatic;
import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSessionFactory;
-
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.Before;
+import org.junit.Test;
public class MementoTest2_Test {
- private Mockery mockery = new JUnit4Mockery(){{
- setImposteriser(ClassImposteriser.INSTANCE);
- }};
+ private final Mockery mockery = new JUnit4Mockery() {
+ {
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }
+ };
private ObjectAdapter rootAdapter;
-// private ObjectAdapter returnedAdapter;
-//
-// private TestObject rootObject;
-//
-// private TestObject recreatedObject;
+ // private ObjectAdapter returnedAdapter;
+ //
+ // private TestObject rootObject;
+ //
+ // private TestObject recreatedObject;
private Oid oid;
@@ -63,7 +62,6 @@ public class MementoTest2_Test {
private Memento memento;
-
@Before
public void setUp() throws Exception {
Logger.getRootLogger().setLevel(Level.OFF);
@@ -80,7 +78,7 @@ public class MementoTest2_Test {
will(returnValue(false));
atLeast(1).of(rootSpecification).getAssociations();
- will(returnValue(Arrays.asList( (ObjectAssociation)nameField)));
+ will(returnValue(Arrays.asList((ObjectAssociation) nameField)));
atLeast(1).of(rootSpecification).getFullIdentifier();
will(returnValue(TestObject.class.getName()));
@@ -105,170 +103,132 @@ public class MementoTest2_Test {
}
});
-
// Root object
rootAdapter = mockery.mock(ObjectAdapter.class);
- //rootObject = new TestObject("Harry");
+ // rootObject = new TestObject("Harry");
final ObjectAdapter nameAdapter = mockery.mock(ObjectAdapter.class, "name");
oid = mockery.mock(Oid.class);
// object encoding
mockery.checking(new Expectations() {
- {
- atLeast(1).of(rootAdapter).getSpecification();
- will(returnValue(rootSpecification));
-
- atLeast(1).of(rootAdapter).getOid();
- will(returnValue(oid));
-
- atLeast(1).of(rootAdapter).getResolveState();
- will(returnValue(ResolveState.RESOLVED));
-
- atLeast(1).of(nameField).get(rootAdapter);
- will(returnValue(nameAdapter));
-
-
- one(encodeableFacet).toEncodedString(nameAdapter);
- will(returnValue("_HARRY_"));
-
-
- /*
- atLeast(1).of(oid).isTransient();
- will(returnValue(false));
-
- atLeast(1).of(rootAdapter).getObject();
- will(returnValue(rootObject));
-
- one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(recreatedAdapter));.
-
- atLeast(1).of(recreatedAdapter).getOid();
- will(returnValue(oid));
-
- one(recreatedAdapter).getResolveState();
- will(returnValue(ResolveState.GHOST));
-
- one(recreatedAdapter).changeState(ResolveState.UPDATING);
-
- atLeast(1).of(recreatedAdapter).getSpecification();
- will(returnValue(rootSpecification));
+ {
+ atLeast(1).of(rootAdapter).getSpecification();
+ will(returnValue(rootSpecification));
- atLeast(1).of(recreatedAdapter).getObject();
- will(returnValue(recreatedObject));
+ atLeast(1).of(rootAdapter).getOid();
+ will(returnValue(oid));
- /*
- one(mockAdapterManager).adapterFor("Harry", originalAdapter, specification.getAssociation("name"));
- will(returnValue(nameAdapter));
+ atLeast(1).of(rootAdapter).getResolveState();
+ will(returnValue(ResolveState.RESOLVED));
- atLeast(1).of(nameAdapter).getObject();
- will(returnValue("Harry"));
- */
- }
- });
+ atLeast(1).of(nameField).get(rootAdapter);
+ will(returnValue(nameAdapter));
+ one(encodeableFacet).toEncodedString(nameAdapter);
+ will(returnValue("_HARRY_"));
+
+ /*
+ * atLeast(1).of(oid).isTransient(); will(returnValue(false));
+ *
+ * atLeast(1).of(rootAdapter).getObject(); will(returnValue(rootObject));
+ *
+ * one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(recreatedAdapter));.
+ *
+ * atLeast(1).of(recreatedAdapter).getOid(); will(returnValue(oid));
+ *
+ * one(recreatedAdapter).getResolveState(); will(returnValue(ResolveState.GHOST));
+ *
+ * one(recreatedAdapter).changeState(ResolveState.UPDATING);
+ *
+ * atLeast(1).of(recreatedAdapter).getSpecification(); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(recreatedAdapter).getObject(); will(returnValue(recreatedObject));
+ *
+ * /* one(mockAdapterManager).adapterFor("Harry", originalAdapter,
+ * specification.getAssociation("name")); will(returnValue(nameAdapter));
+ *
+ * atLeast(1).of(nameAdapter).getObject(); will(returnValue("Harry"));
+ */
+ }
+ });
// object decoding
mockery.checking(new Expectations() {
- {
- /*
- atLeast(1).of(oid).isTransient();
- will(returnValue(false));
-
- atLeast(1).of(rootAdapter).getObject();
- will(returnValue(rootObject));
-/*
- one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(recreatedAdapter));
-
- atLeast(1).of(recreatedAdapter).getOid();
- will(returnValue(oid));
-
- one(recreatedAdapter).getResolveState();
- will(returnValue(ResolveState.GHOST));
-
- one(recreatedAdapter).changeState(ResolveState.UPDATING);
-
- atLeast(1).of(recreatedAdapter).getSpecification();
- will(returnValue(rootSpecification));
-
- atLeast(1).of(recreatedAdapter).getObject();
- will(returnValue(recreatedObject));
-
- /*
- one(mockAdapterManager).adapterFor("Harry", originalAdapter, specification.getAssociation("name"));
- will(returnValue(nameAdapter));
-
- atLeast(1).of(nameAdapter).getObject();
- will(returnValue("Harry"));
- */
- }
- });
-
+ {
+ /*
+ * atLeast(1).of(oid).isTransient(); will(returnValue(false));
+ *
+ * atLeast(1).of(rootAdapter).getObject(); will(returnValue(rootObject)); /*
+ * one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(recreatedAdapter));
+ *
+ * atLeast(1).of(recreatedAdapter).getOid(); will(returnValue(oid));
+ *
+ * one(recreatedAdapter).getResolveState(); will(returnValue(ResolveState.GHOST));
+ *
+ * one(recreatedAdapter).changeState(ResolveState.UPDATING);
+ *
+ * atLeast(1).of(recreatedAdapter).getSpecification(); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(recreatedAdapter).getObject(); will(returnValue(recreatedObject));
+ *
+ * /* one(mockAdapterManager).adapterFor("Harry", originalAdapter,
+ * specification.getAssociation("name")); will(returnValue(nameAdapter));
+ *
+ * atLeast(1).of(nameAdapter).getObject(); will(returnValue("Harry"));
+ */
+ }
+ });
// Persistence Session
-// final ObjectReflector reflector = mockery.mock(ObjectReflector.class);
-// final PersistenceSession mockPersistenceSession = mockery.mock(PersistenceSession.class);
+ // final ObjectReflector reflector = mockery.mock(ObjectReflector.class);
+ // final PersistenceSession mockPersistenceSession = mockery.mock(PersistenceSession.class);
final IsisSessionFactory sessionFactory = mockery.mock(IsisSessionFactory.class);
-// final AuthenticationSession mockSession = mockery.mock(AuthenticationSession.class);
-// final IsisSession session = mockery.mock(IsisSession.class);
- // final AdapterManager mockAdapterManager = mockery.mock(AdapterManager.class);
-/**
- mockery.checking(new Expectations() {
- {
- atLeast(1).of(sessionFactory).getSpecificationLoader();
- will(returnValue(reflector));
-
- atLeast(1).of(sessionFactory).openSession(mockSession);
- will(returnValue(session));
-
- atLeast(1).of(reflector).loadSpecification(TestObject.class.getName());
- will(returnValue(rootSpecification));
-
- atLeast(1).of(session).open();
-
- atLeast(1).of(session).getPersistenceSession();
- will(returnValue(mockPersistenceSession));
-
- }});
-*/
-
-
+ // final AuthenticationSession mockSession = mockery.mock(AuthenticationSession.class);
+ // final IsisSession session = mockery.mock(IsisSession.class);
+ // final AdapterManager mockAdapterManager = mockery.mock(AdapterManager.class);
+ /**
+ * mockery.checking(new Expectations() { { atLeast(1).of(sessionFactory).getSpecificationLoader();
+ * will(returnValue(reflector));
+ *
+ * atLeast(1).of(sessionFactory).openSession(mockSession); will(returnValue(session));
+ *
+ * atLeast(1).of(reflector).loadSpecification(TestObject.class.getName()); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(session).open();
+ *
+ * atLeast(1).of(session).getPersistenceSession(); will(returnValue(mockPersistenceSession));
+ *
+ * }});
+ */
IsisContextStatic.createRelaxedInstance(sessionFactory);
- // IsisContextStatic.getInstance().openSessionInstance(mockSession);
-
- // final ObjectAdapter recreatedAdapter = mockery.mock(ObjectAdapter.class, "recreated");
-
- // recreatedObject = new TestObject();
-
-
-
- /*
- returnedAdapter = mockery.mock(ObjectAdapter.class, "recreated adapter");
- final Oid returnedOid = mockery.mock(Oid.class, "recreated oid");
-
- mockery.checking(new Expectations() {
- {
-
-
- atLeast(1).of(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(returnedAdapter));
-
- atLeast(1).of(returnedAdapter).getOid();
- will(returnValue(returnedOid));
-
- }});
-*/
+ // IsisContextStatic.getInstance().openSessionInstance(mockSession);
+ // final ObjectAdapter recreatedAdapter = mockery.mock(ObjectAdapter.class, "recreated");
+ // recreatedObject = new TestObject();
+ /*
+ * returnedAdapter = mockery.mock(ObjectAdapter.class, "recreated adapter"); final Oid returnedOid =
+ * mockery.mock(Oid.class, "recreated oid");
+ *
+ * mockery.checking(new Expectations() { {
+ *
+ *
+ * atLeast(1).of(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(returnedAdapter));
+ *
+ * atLeast(1).of(returnedAdapter).getOid(); will(returnValue(returnedOid));
+ *
+ * }});
+ */
memento = new Memento(rootAdapter);
data = memento.getData();
- }
-
-
+ }
@Test
public void testOid() throws Exception {
@@ -301,117 +261,73 @@ public class MementoTest2_Test {
mockery.checking(new Expectations() {
{
- one(mockOutputImpl).writeEncodable(with(any(ObjectData.class)));
-// one(mockOutputImpl).writeUTF(TestObject.class.getName());
-// one(mockOutputImpl).writeUTF(ResolveState.RESOLVED.name());
-// one(mockOutputImpl).writeEncodable(oid);
-// one(mockOutputImpl).writeInt(1);
-// one(mockOutputImpl).writeByte((byte)1); // indicates a string
-// one(mockOutputImpl).writeUTF("name-field");
-// one(mockOutputImpl).writeUTF("_HARRY_");
- }});
- memento.encodedData(mockOutputImpl );
- mockery.assertIsSatisfied();
- }
-
-
- /*
- @Test
- public void testDifferentAdaptersReturned() throws Exception {
- final Memento memento = new Memento(rootAdapter);
- returnedAdapter = memento.recreateObject();
-
- rootAdapter.getObject();
- returnedAdapter.getObject();
-
- assertNotSame(rootAdapter, returnedAdapter);
- mockery.assertIsSatisfied();
- }
-
- @Test
- public void testDifferentObjectsReturned() throws Exception {
- final Memento memento = new Memento(rootAdapter);
- returnedAdapter = memento.recreateObject();
- assertNotSame(rootAdapter.getObject(), returnedAdapter.getObject());
- mockery.assertIsSatisfied();
- }
-
- @Test
- public void testHaveSameOid() throws Exception {
- final Memento memento = new Memento(rootAdapter);
- returnedAdapter = memento.recreateObject();
-
- rootAdapter.getObject();
- returnedAdapter.getObject();
-
- assertEquals(rootAdapter.getOid(), returnedAdapter.getOid());
- mockery.assertIsSatisfied();
- }
-
- @Test
- public void testHaveSameSpecification() throws Exception {
- final Memento memento = new Memento(rootAdapter);
- returnedAdapter = memento.recreateObject();
-
- rootAdapter.getObject();
- returnedAdapter.getObject();
-
- assertEquals(rootAdapter.getSpecificatio assertEquals("", ((ObjectData) data).getEntry("name-field"));
-n(), returnedAdapter.getSpecification());
- mockery.assertIsSatisfied();
- }
-
-*/
-
- /*
- @Test
- public void testEncoding() throws Exception {
- final TransferableWriter writer = mockery.mock(TransferableWriter.class);
- final Transferable object = mockery.mock(Transferable.class);
- mockery.checking(new Expectations() {
- {
- one(writer).writeObject(object );
-
- ignoring(object);
+ one(mockOutputImpl).writeEncodable(with(any(ObjectData.class)));
+ // one(mockOutputImpl).writeUTF(TestObject.class.getName());
+ // one(mockOutputImpl).writeUTF(ResolveState.RESOLVED.name());
+ // one(mockOutputImpl).writeEncodable(oid);
+ // one(mockOutputImpl).writeInt(1);
+ // one(mockOutputImpl).writeByte((byte)1); // indicates a string
+ // one(mockOutputImpl).writeUTF("name-field");
+ // one(mockOutputImpl).writeUTF("_HARRY_");
}
});
-
- final Memento memento = new Memento(rootAdapter);
- memento.writeData(writer);
+ memento.encodedData(mockOutputImpl);
mockery.assertIsSatisfied();
-
- }
- */
-/*
- @Test
- public void testName() throws Exception {
- final Memento memento = new Memento(rootAdapter);
- returnedAdapter = memento.recreateObject();
- assertEquals("Harry", ((TestObject) rootAdapter.getObject()).getName());
- assertEquals("Harry", ((TestObject) returnedAdapter.getObject()).getName());
- }
-*/
-
-/*
- @Test
- public void testNull2() throws Exception {
- final Memento memento = new Memento(null);
- Data data = memento.getData();
-
- assertEquals(null, data);
- // mockery.assertIsSatisfied();
}
- @Test
- public void testNull() throws Exception {
- final Memento memento = new Memento(null);
- returnedAdapter = memento.recreateObject();
- Assert.assertNull(returnedAdapter);
- // mockery.assertIsSatisfied();
- }
+ /*
+ * @Test public void testDifferentAdaptersReturned() throws Exception { final Memento memento = new
+ * Memento(rootAdapter); returnedAdapter = memento.recreateObject();
+ *
+ * rootAdapter.getObject(); returnedAdapter.getObject();
+ *
+ * assertNotSame(rootAdapter, returnedAdapter); mockery.assertIsSatisfied(); }
+ *
+ * @Test public void testDifferentObjectsReturned() throws Exception { final Memento memento = new
+ * Memento(rootAdapter); returnedAdapter = memento.recreateObject(); assertNotSame(rootAdapter.getObject(),
+ * returnedAdapter.getObject()); mockery.assertIsSatisfied(); }
+ *
+ * @Test public void testHaveSameOid() throws Exception { final Memento memento = new Memento(rootAdapter);
+ * returnedAdapter = memento.recreateObject();
+ *
+ * rootAdapter.getObject(); returnedAdapter.getObject();
+ *
+ * assertEquals(rootAdapter.getOid(), returnedAdapter.getOid()); mockery.assertIsSatisfied(); }
+ *
+ * @Test public void testHaveSameSpecification() throws Exception { final Memento memento = new
+ * Memento(rootAdapter); returnedAdapter = memento.recreateObject();
+ *
+ * rootAdapter.getObject(); returnedAdapter.getObject();
+ *
+ * assertEquals(rootAdapter.getSpecificatio assertEquals("", ((ObjectData) data).getEntry("name-field")); n(),
+ * returnedAdapter.getSpecification()); mockery.assertIsSatisfied(); }
+ */
-*/
+ /*
+ * @Test public void testEncoding() throws Exception { final TransferableWriter writer =
+ * mockery.mock(TransferableWriter.class); final Transferable object = mockery.mock(Transferable.class);
+ * mockery.checking(new Expectations() { { one(writer).writeObject(object );
+ *
+ * ignoring(object); } });
+ *
+ * final Memento memento = new Memento(rootAdapter); memento.writeData(writer); mockery.assertIsSatisfied();
+ *
+ * }
+ */
+ /*
+ * @Test public void testName() throws Exception { final Memento memento = new Memento(rootAdapter); returnedAdapter
+ * = memento.recreateObject(); assertEquals("Harry", ((TestObject) rootAdapter.getObject()).getName());
+ * assertEquals("Harry", ((TestObject) returnedAdapter.getObject()).getName()); }
+ */
+ /*
+ * @Test public void testNull2() throws Exception { final Memento memento = new Memento(null); Data data =
+ * memento.getData();
+ *
+ * assertEquals(null, data); // mockery.assertIsSatisfied(); }
+ *
+ * @Test public void testNull() throws Exception { final Memento memento = new Memento(null); returnedAdapter =
+ * memento.recreateObject(); Assert.assertNull(returnedAdapter); // mockery.assertIsSatisfied(); }
+ */
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest3_Test.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest3_Test.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest3_Test.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/MementoTest3_Test.java Tue May 3 06:22:09 2011
@@ -17,25 +17,12 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.memento;
import static org.junit.Assert.assertEquals;
import java.util.Iterator;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
import org.apache.isis.core.commons.encoding.DataOutputStreamExtended;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.ResolveState;
@@ -43,28 +30,31 @@ import org.apache.isis.core.metamodel.ad
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.metamodel.specloader.ObjectReflector;
-import org.apache.isis.runtimes.dflt.runtime.memento.CollectionData;
-import org.apache.isis.runtimes.dflt.runtime.memento.Data;
-import org.apache.isis.runtimes.dflt.runtime.memento.Memento;
import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContextStatic;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSession;
import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSessionFactory;
-
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
public class MementoTest3_Test {
- private Mockery mockery = new JUnit4Mockery(){{
- setImposteriser(ClassImposteriser.INSTANCE);
- }};
+ private final Mockery mockery = new JUnit4Mockery() {
+ {
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }
+ };
private ObjectAdapter rootAdapter;
-// private ObjectAdapter returnedAdapter;
-//
-// private TestObject rootObject;
-//
-// private TestObject recreatedObject;
+ // private ObjectAdapter returnedAdapter;
+ //
+ // private TestObject rootObject;
+ //
+ // private TestObject recreatedObject;
private Oid oid;
@@ -74,20 +64,14 @@ public class MementoTest3_Test {
private ObjectSpecification emptySpecification;
-
private ObjectAdapter element1;
-
-
-
-
@Before
public void setUp() throws Exception {
Logger.getRootLogger().setLevel(Level.OFF);
-
// Root object specification
- emptySpecification = mockery.mock(ObjectSpecification.class, "empty specification");
+ emptySpecification = mockery.mock(ObjectSpecification.class, "empty specification");
final ObjectSpecification rootSpecification = mockery.mock(ObjectSpecification.class);
final CollectionFacet collectionFacet = mockery.mock(CollectionFacet.class);
@@ -102,243 +86,186 @@ public class MementoTest3_Test {
atLeast(1).of(rootSpecification).getFacet(CollectionFacet.class);
will(returnValue(collectionFacet));
-
-
atLeast(0).of(emptySpecification).getFullIdentifier();
will(returnValue(TestObject.class.getName()));
-
/*
-
- atLeast(1).of(nameField).isPersisted();
- will(returnValue(true));
-
- atLeast(1).of(nameField).isOneToManyAssociation();
- will(returnValue(false));
-
- atLeast(1).of(nameField).getSpecification();
- will(returnValue(elementSpecification));
-
- atLeast(1).of(nameField).getId();
- will(returnValue("name-field"));
-
- atLeast(1).of(elementSpecification).isEncodeable();
- will(returnValue(true));
-
- atLeast(1).of(elementSpecification).getFacet(EncodeableFacet.class);
- will(returnValue(encodeableFacet));
- */
+ *
+ * atLeast(1).of(nameField).isPersisted(); will(returnValue(true));
+ *
+ * atLeast(1).of(nameField).isOneToManyAssociation(); will(returnValue(false));
+ *
+ * atLeast(1).of(nameField).getSpecification(); will(returnValue(elementSpecification));
+ *
+ * atLeast(1).of(nameField).getId(); will(returnValue("name-field"));
+ *
+ * atLeast(1).of(elementSpecification).isEncodeable(); will(returnValue(true));
+ *
+ * atLeast(1).of(elementSpecification).getFacet(EncodeableFacet.class);
+ * will(returnValue(encodeableFacet));
+ */
}
});
-
// Root object
rootAdapter = mockery.mock(ObjectAdapter.class);
-// rootObject = new TestObject("Harry");
-// final ObjectAdapter nameAdapter = mockery.mock(ObjectAdapter.class, "name");
+ // rootObject = new TestObject("Harry");
+ // final ObjectAdapter nameAdapter = mockery.mock(ObjectAdapter.class, "name");
oid = mockery.mock(Oid.class);
-
final TypeOfFacet typeOfFacet = mockery.mock(TypeOfFacet.class, "element 1");
-
final Iterator<?> mockIterator = mockery.mock(Iterator.class);
// object encoding
mockery.checking(new Expectations() {
+ {
- {
-
- atLeast(1).of(collectionFacet).size(rootAdapter);
- will(returnValue(2));
-
- atLeast(1).of(collectionFacet).getTypeOfFacet();
- will(returnValue(typeOfFacet));
-
- atLeast(1).of(typeOfFacet).valueSpec();
- will(returnValue(rootSpecification));
-
- atLeast(1).of(collectionFacet).iterator(rootAdapter);
- will(returnValue(mockIterator));
-
- one(mockIterator).hasNext();
- will(returnValue(true));
-
- one(mockIterator).next();
- element1 = adapter("element", 1, false);
- will(returnValue(element1));
-
- one(mockIterator).hasNext();
- will(returnValue(true));
-
- one(mockIterator).next();
- will(returnValue(adapter("element", 2, false)));
-
- one(mockIterator).hasNext();
- will(returnValue(false));
-
-
-
-
- atLeast(1).of(rootAdapter).getSpecification();
- will(returnValue(rootSpecification));
-
- atLeast(1).of(rootAdapter).getOid();
- will(returnValue(oid));
-
- atLeast(1).of(rootAdapter).getResolveState();
- will(returnValue(ResolveState.RESOLVED));
-/*
- atLeast(1).of(nameField).get(rootAdapter);
- will(returnValue(nameAdapter));
-
- */
- // one(encodeableFacet).toEncodedString(nameAdapter);
- // will(returnValue("_HARRY_"));
+ atLeast(1).of(collectionFacet).size(rootAdapter);
+ will(returnValue(2));
+ atLeast(1).of(collectionFacet).getTypeOfFacet();
+ will(returnValue(typeOfFacet));
- /*
- atLeast(1).of(oid).isTransient();
- will(returnValue(false));
+ atLeast(1).of(typeOfFacet).valueSpec();
+ will(returnValue(rootSpecification));
- atLeast(1).of(rootAdapter).getObject();
- will(returnValue(rootObject));
+ atLeast(1).of(collectionFacet).iterator(rootAdapter);
+ will(returnValue(mockIterator));
- one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(recreatedAdapter));
+ one(mockIterator).hasNext();
+ will(returnValue(true));
- atLeast(1).of(recreatedAdapter).getOid();
- will(returnValue(oid));
+ one(mockIterator).next();
+ element1 = adapter("element", 1, false);
+ will(returnValue(element1));
- one(recreatedAdapter).getResolveState();
- will(returnValue(ResolveState.GHOST));
+ one(mockIterator).hasNext();
+ will(returnValue(true));
- one(recreatedAdapter).changeState(ResolveState.UPDATING);
+ one(mockIterator).next();
+ will(returnValue(adapter("element", 2, false)));
- atLeast(1).of(recreatedAdapter).getSpecification();
- will(returnValue(rootSpecification));
+ one(mockIterator).hasNext();
+ will(returnValue(false));
- atLeast(1).of(recreatedAdapter).getObject();
- will(returnValue(recreatedObject));
+ atLeast(1).of(rootAdapter).getSpecification();
+ will(returnValue(rootSpecification));
- /*
- one(mockAdapterManager).adapterFor("Harry", originalAdapter, specification.getAssociation("name"));
- will(returnValue(nameAdapter));
+ atLeast(1).of(rootAdapter).getOid();
+ will(returnValue(oid));
- atLeast(1).of(nameAdapter).getObject();
- will(returnValue("Harry"));
- */
- }
- });
+ atLeast(1).of(rootAdapter).getResolveState();
+ will(returnValue(ResolveState.RESOLVED));
+ /*
+ * atLeast(1).of(nameField).get(rootAdapter); will(returnValue(nameAdapter));
+ */
+ // one(encodeableFacet).toEncodedString(nameAdapter);
+ // will(returnValue("_HARRY_"));
+ /*
+ * atLeast(1).of(oid).isTransient(); will(returnValue(false));
+ *
+ * atLeast(1).of(rootAdapter).getObject(); will(returnValue(rootObject));
+ *
+ * one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(recreatedAdapter));
+ *
+ * atLeast(1).of(recreatedAdapter).getOid(); will(returnValue(oid));
+ *
+ * one(recreatedAdapter).getResolveState(); will(returnValue(ResolveState.GHOST));
+ *
+ * one(recreatedAdapter).changeState(ResolveState.UPDATING);
+ *
+ * atLeast(1).of(recreatedAdapter).getSpecification(); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(recreatedAdapter).getObject(); will(returnValue(recreatedObject));
+ *
+ * /* one(mockAdapterManager).adapterFor("Harry", originalAdapter,
+ * specification.getAssociation("name")); will(returnValue(nameAdapter));
+ *
+ * atLeast(1).of(nameAdapter).getObject(); will(returnValue("Harry"));
+ */
+ }
+ });
// object decoding
mockery.checking(new Expectations() {
- {
- /*
- atLeast(1).of(oid).isTransient();
- will(returnValue(false));
-
- atLeast(1).of(rootAdapter).getObject();
- will(returnValue(rootObject));
-/*
- one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(recreatedAdapter));
-
- atLeast(1).of(recreatedAdapter).getOid();
- will(returnValue(oid));
-
- one(recreatedAdapter).getResolveState();
- will(returnValue(ResolveState.GHOST));
-
- one(recreatedAdapter).changeState(ResolveState.UPDATING);
-
- atLeast(1).of(recreatedAdapter).getSpecification();
- will(returnValue(rootSpecification));
-
- atLeast(1).of(recreatedAdapter).getObject();
- will(returnValue(recreatedObject));
-
- /*
- one(mockAdapterManager).adapterFor("Harry", originalAdapter, specification.getAssociation("name"));
- will(returnValue(nameAdapter));
-
- atLeast(1).of(nameAdapter).getObject();
- will(returnValue("Harry"));
- */
- }
- });
-
-
-
+ {
+ /*
+ * atLeast(1).of(oid).isTransient(); will(returnValue(false));
+ *
+ * atLeast(1).of(rootAdapter).getObject(); will(returnValue(rootObject)); /*
+ * one(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(recreatedAdapter));
+ *
+ * atLeast(1).of(recreatedAdapter).getOid(); will(returnValue(oid));
+ *
+ * one(recreatedAdapter).getResolveState(); will(returnValue(ResolveState.GHOST));
+ *
+ * one(recreatedAdapter).changeState(ResolveState.UPDATING);
+ *
+ * atLeast(1).of(recreatedAdapter).getSpecification(); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(recreatedAdapter).getObject(); will(returnValue(recreatedObject));
+ *
+ * /* one(mockAdapterManager).adapterFor("Harry", originalAdapter,
+ * specification.getAssociation("name")); will(returnValue(nameAdapter));
+ *
+ * atLeast(1).of(nameAdapter).getObject(); will(returnValue("Harry"));
+ */
+ }
+ });
// Persistence Session
-// final ObjectReflector reflector = mockery.mock(ObjectReflector.class);
-// final PersistenceSession mockPersistenceSession = mockery.mock(PersistenceSession.class);
+ // final ObjectReflector reflector = mockery.mock(ObjectReflector.class);
+ // final PersistenceSession mockPersistenceSession = mockery.mock(PersistenceSession.class);
final IsisSessionFactory sessionFactory = mockery.mock(IsisSessionFactory.class);
-// final AuthenticationSession mockSession = mockery.mock(AuthenticationSession.class);
-// final IsisSession session = mockery.mock(IsisSession.class);
- // final AdapterManager mockAdapterManager = mockery.mock(AdapterManager.class);
-/**
- mockery.checking(new Expectations() {
- {
- atLeast(1).of(sessionFactory).getSpecificationLoader();
- will(returnValue(reflector));
-
- atLeast(1).of(sessionFactory).openSession(mockSession);
- will(returnValue(session));
-
- atLeast(1).of(reflector).loadSpecification(TestObject.class.getName());
- will(returnValue(rootSpecification));
-
- atLeast(1).of(session).open();
-
- atLeast(1).of(session).getPersistenceSession();
- will(returnValue(mockPersistenceSession));
-
- }});
-*/
-
-
+ // final AuthenticationSession mockSession = mockery.mock(AuthenticationSession.class);
+ // final IsisSession session = mockery.mock(IsisSession.class);
+ // final AdapterManager mockAdapterManager = mockery.mock(AdapterManager.class);
+ /**
+ * mockery.checking(new Expectations() { { atLeast(1).of(sessionFactory).getSpecificationLoader();
+ * will(returnValue(reflector));
+ *
+ * atLeast(1).of(sessionFactory).openSession(mockSession); will(returnValue(session));
+ *
+ * atLeast(1).of(reflector).loadSpecification(TestObject.class.getName()); will(returnValue(rootSpecification));
+ *
+ * atLeast(1).of(session).open();
+ *
+ * atLeast(1).of(session).getPersistenceSession(); will(returnValue(mockPersistenceSession));
+ *
+ * }});
+ */
IsisContextStatic.createRelaxedInstance(sessionFactory);
- // IsisContextStatic.getInstance().openSessionInstance(mockSession);
-
- // final ObjectAdapter recreatedAdapter = mockery.mock(ObjectAdapter.class, "recreated");
-
- // recreatedObject = new TestObject();
-
-
-
- /*
- returnedAdapter = mockery.mock(ObjectAdapter.class, "recreated adapter");
- final Oid returnedOid = mockery.mock(Oid.class, "recreated oid");
-
- mockery.checking(new Expectations() {
- {
-
-
- atLeast(1).of(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
- will(returnValue(returnedAdapter));
-
- atLeast(1).of(returnedAdapter).getOid();
- will(returnValue(returnedOid));
-
- }});
-*/
+ // IsisContextStatic.getInstance().openSessionInstance(mockSession);
+ // final ObjectAdapter recreatedAdapter = mockery.mock(ObjectAdapter.class, "recreated");
+ // recreatedObject = new TestObject();
+ /*
+ * returnedAdapter = mockery.mock(ObjectAdapter.class, "recreated adapter"); final Oid returnedOid =
+ * mockery.mock(Oid.class, "recreated oid");
+ *
+ * mockery.checking(new Expectations() { {
+ *
+ *
+ * atLeast(1).of(mockPersistenceSession).recreateAdapter(oid, rootSpecification);
+ * will(returnValue(returnedAdapter));
+ *
+ * atLeast(1).of(returnedAdapter).getOid(); will(returnValue(returnedOid));
+ *
+ * }});
+ */
memento = new Memento(rootAdapter);
data = memento.getData();
- }
-
-
-
-
+ }
public ObjectAdapter adapter(final String name, final int id, final boolean isTransient) {
final ObjectAdapter object = mockery.mock(ObjectAdapter.class, name + id);
@@ -356,16 +283,11 @@ public class MementoTest3_Test {
atLeast(0).of(oid).isTransient();
will(returnValue(isTransient));
- }});
+ }
+ });
return object;
}
-
-
-
-
-
-
@Ignore("currently failing - is no longer calling isTransient on element #1 and element #2")
@Test
public void testOid() throws Exception {
@@ -394,7 +316,6 @@ public class MementoTest3_Test {
mockery.assertIsSatisfied();
}
-
@Ignore("currently failing - is no longer calling isTransient on element #1 and element #2")
@Test
public void testDataLength() throws Exception {
@@ -402,7 +323,6 @@ public class MementoTest3_Test {
mockery.assertIsSatisfied();
}
-
@Ignore("currently failing - is no longer calling isTransient on element #1 and element #2")
@Test
public void testData() throws Exception {
@@ -429,14 +349,12 @@ public class MementoTest3_Test {
one(mockOutputImpl).writeEncodable(oid2);
/*
- one(encoder).add("S");
- one(encoder).add("name-field");
- one(encoder).add("_HARRY_");
- */
- }});
- memento.encodedData(mockOutputImpl );
+ * one(encoder).add("S"); one(encoder).add("name-field"); one(encoder).add("_HARRY_");
+ */
+ }
+ });
+ memento.encodedData(mockOutputImpl);
mockery.assertIsSatisfied();
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestObject.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestObject.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestObject.java Tue May 3 06:22:09 2011
@@ -17,13 +17,13 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.memento;
public class TestObject {
private String name;
- public TestObject() {}
+ public TestObject() {
+ }
public TestObject(final String name) {
this.name = name;
@@ -32,10 +32,8 @@ public class TestObject {
public String getName() {
return name;
}
-
- public void setName(String name) {
+
+ public void setName(final String name) {
this.name = name;
}
}
-
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestPojoSimple.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestPojoSimple.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestPojoSimple.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/memento/TestPojoSimple.java Tue May 3 06:22:09 2011
@@ -17,19 +17,18 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.memento;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestPojo;
import edu.umd.cs.findbugs.annotations.SuppressWarnings;
-
public class TestPojoSimple extends TestPojo {
private String name;
- private TestPojoSimple object;
+ private TestPojoSimple object;
- public TestPojoSimple() {}
+ public TestPojoSimple() {
+ }
public TestPojoSimple(final String name) {
this.name = name;
@@ -40,11 +39,10 @@ public class TestPojoSimple extends Test
}
@SuppressWarnings("UWF_UNWRITTEN_FIELD")
- public TestPojoSimple getObject(){
+ public TestPojoSimple getObject() {
return object;
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -55,27 +53,32 @@ public class TestPojoSimple extends Test
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
- TestPojoSimple other = (TestPojoSimple) obj;
+ }
+ final TestPojoSimple other = (TestPojoSimple) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
if (object == null) {
- if (other.object != null)
+ if (other.object != null) {
return false;
- } else if (!object.equals(other.object))
+ }
+ } else if (!object.equals(other.object)) {
return false;
+ }
return true;
}
-
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AggregatedFacetAlways.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AggregatedFacetAlways.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AggregatedFacetAlways.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AggregatedFacetAlways.java Tue May 3 06:22:09 2011
@@ -17,18 +17,16 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.runtime.persistence;
-package org.apache.isis.runtimes.dflt.runtime.persistence;
-
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.MarkerFacetAbstract;
import org.apache.isis.core.metamodel.facets.object.aggregated.AggregatedFacet;
-
-
-public class AggregatedFacetAlways extends MarkerFacetAbstract {
-
- public AggregatedFacetAlways(final FacetHolder holder) {
- super(AggregatedFacet.class, holder);
- }
-
-}
+
+public class AggregatedFacetAlways extends MarkerFacetAbstract {
+
+ public AggregatedFacetAlways(final FacetHolder holder) {
+ super(AggregatedFacet.class, holder);
+ }
+
+}
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtilTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtilTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtilTest.java Tue May 3 06:22:09 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.persistence;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -27,7 +26,6 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestPojo;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyOid;
-
public class PersistorUtilTest extends ProxyJunit3TestCase {
@Override
@@ -57,4 +55,3 @@ public class PersistorUtilTest extends P
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtil_ValueAdapterTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtil_ValueAdapterTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtil_ValueAdapterTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/PersistorUtil_ValueAdapterTest.java Tue May 3 06:22:09 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.persistence;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -27,7 +26,6 @@ import org.apache.isis.core.metamodel.fa
import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyField;
-
public class PersistorUtil_ValueAdapterTest extends ProxyJunit3TestCase {
private ObjectAdapter aggregatedAdapter;
@@ -67,4 +65,3 @@ public class PersistorUtil_ValueAdapterT
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapterTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapterTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapterTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapterTest.java Tue May 3 06:22:09 2011
@@ -17,19 +17,16 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory.pojo;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.ResolveState;
import org.apache.isis.runtimes.dflt.runtime.persistence.ConcurrencyException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory.pojo.PojoAdapter;
import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestPojo;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyOid;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion;
-
public class PojoAdapterTest extends ProxyJunit3TestCase {
private ObjectAdapter adapter;
@@ -68,6 +65,7 @@ public class PojoAdapterTest extends Pro
try {
adapter.checkLock(new TestProxyVersion(2));
fail();
- } catch (final ConcurrencyException expected) {}
+ } catch (final ConcurrencyException expected) {
+ }
}
}
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreSpy.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreSpy.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreSpy.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreSpy.java Tue May 3 06:22:09 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.persistence.objectstore;
import java.util.List;
@@ -32,8 +31,6 @@ import org.apache.isis.core.metamodel.sp
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
import org.apache.isis.runtimes.dflt.runtime.persistence.UnsupportedFindException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStore;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreTransactionManagement;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
@@ -42,7 +39,6 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-
public class ObjectStoreSpy implements ObjectStore, ObjectStoreTransactionManagement {
private final Vector<String> actions = new Vector<String>();
@@ -55,59 +51,66 @@ public class ObjectStoreSpy implements O
super();
}
-
+ @Override
public String name() {
return null;
}
-
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// Open, Close
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
- public void open() throws ObjectPersistenceException {}
+ @Override
+ public void open() throws ObjectPersistenceException {
+ }
- public void close() {}
+ @Override
+ public void close() {
+ }
+ @Override
public void reset() {
actions.removeAllElements();
}
-
-
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// Transactions
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
+ @Override
public void startTransaction() {
actions.addElement("startTransaction");
}
+ @Override
public void abortTransaction() {
actions.addElement("abortTransaction");
}
+ @Override
public void endTransaction() {
actions.addElement("endTransaction");
}
+ @Override
public boolean isFixturesInstalled() {
return true;
}
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// getObject, resolve etc
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
/**
* Not API
*/
- public void setGetObject(ObjectAdapter getObject) {
+ public void setGetObject(final ObjectAdapter getObject) {
this.getObject = getObject;
}
+ @Override
public ObjectAdapter getObject(final Oid oid, final ObjectSpecification hint) throws ObjectNotFoundException,
- ObjectPersistenceException {
+ ObjectPersistenceException {
if (getObject == null) {
Assert.fail("no object expected");
}
@@ -115,112 +118,131 @@ public class ObjectStoreSpy implements O
return getObject;
}
+ @Override
+ public void resolveImmediately(final ObjectAdapter object) {
+ }
+ @Override
+ public void resolveField(final ObjectAdapter object, final ObjectAssociation field)
+ throws ObjectPersistenceException {
+ }
- public void resolveImmediately(final ObjectAdapter object) {}
-
- public void resolveField(final ObjectAdapter object, final ObjectAssociation field) throws ObjectPersistenceException {}
-
-
+ @Override
public boolean hasInstances(final ObjectSpecification cls) {
return hasInstances;
}
+ @Override
public ObjectAdapter[] getInstances(final PersistenceQuery criteria) throws ObjectPersistenceException,
- UnsupportedFindException {
+ UnsupportedFindException {
actions.addElement("getInstances " + criteria);
return new ObjectAdapter[0];
}
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// save
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
+ @Override
public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter object) {
actions.addElement("createObject " + object);
return new CreateObjectCommand() {
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {}
+ @Override
+ public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+ }
@Override
public String toString() {
return "CreateObjectCommand " + object.toString();
}
+ @Override
public ObjectAdapter onObject() {
return object;
}
};
}
+ @Override
public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter object) {
actions.addElement("destroyObject " + object);
return new DestroyObjectCommand() {
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {}
+ @Override
+ public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+ }
@Override
public String toString() {
return "DestroyObjectCommand " + object.toString();
}
+ @Override
public ObjectAdapter onObject() {
return object;
}
};
}
+ @Override
public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter object) {
actions.addElement("saveObject " + object);
return new SaveObjectCommand() {
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {}
+ @Override
+ public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+ }
@Override
public String toString() {
return "DestroyObjectCommand " + object.toString();
}
+ @Override
public ObjectAdapter onObject() {
return object;
}
};
}
+ @Override
public void execute(final List<PersistenceCommand> commands) throws ObjectPersistenceException {
- for (PersistenceCommand command: commands) {
+ for (final PersistenceCommand command : commands) {
actions.addElement("execute " + command);
command.execute(null);
}
}
-
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// Services
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
- public void registerService(final String name, final Oid oid) {}
+ @Override
+ public void registerService(final String name, final Oid oid) {
+ }
+ @Override
public Oid getOidForService(final String name) {
return null;
}
-
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// Debugging
- ///////////////////////////////////////////////////////////////
-
+ // /////////////////////////////////////////////////////////////
- public void debugData(final DebugBuilder debug) {}
+ @Override
+ public void debugData(final DebugBuilder debug) {
+ }
+ @Override
public String debugTitle() {
return null;
}
-
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
// Non API
- ///////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////
/**
* non API
@@ -229,7 +251,6 @@ public class ObjectStoreSpy implements O
return actions;
}
-
/**
* Non API
*/
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java Tue May 3 06:22:09 2011
@@ -29,7 +29,6 @@ import org.apache.isis.core.metamodel.se
import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
import org.apache.isis.runtimes.dflt.runtime.persistence.internal.RuntimeContextFromSession;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.PersistenceSessionObjectStore;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.dummy.DummyPersistAlgorithm;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.ObjectStoreTransactionManager;
import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
@@ -74,8 +73,8 @@ public class PersistenceSessionObjectSto
objectStore = new ObjectStoreSpy();
- RuntimeContextFromSession runtimeContext = new RuntimeContextFromSession();
- DomainObjectContainerDefault container = new DomainObjectContainerDefault();
+ final RuntimeContextFromSession runtimeContext = new RuntimeContextFromSession();
+ final DomainObjectContainerDefault container = new DomainObjectContainerDefault();
runtimeContext.injectInto(container);
runtimeContext.setContainer(container);
Modified: incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java?rev=1098935&r1=1098934&r2=1098935&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java Tue May 3 06:22:09 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm;
import java.util.ArrayList;
@@ -26,12 +25,9 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.ResolveState;
import org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory.pojo.PojoAdapter;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
-
public abstract class PersistAlgorithmContractTest extends ProxyJunit3TestCase {
protected static final class PersistedObjectAdderSpy implements ToPersistObjectSet {
@@ -41,10 +37,12 @@ public abstract class PersistAlgorithmCo
return persistedObjects;
}
+ @Override
public void addPersistedObject(final ObjectAdapter object) {
persistedObjects.add(object);
}
+ @Override
public void remapAsPersistent(final ObjectAdapter object) {
object.changeState(ResolveState.RESOLVED);
}
@@ -79,4 +77,3 @@ public abstract class PersistAlgorithmCo
}
}
-