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 2015/07/25 11:29:36 UTC
[18/48] isis git commit: ISIS-1178: mothballing the tck tests.
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
deleted file mode 100644
index 7bb2795..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.sample.service;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
-
-@Named("Customers")
-public class CustomerRepository extends AbstractFactoryAndRepository {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = LoggerFactory.getLogger(CustomerRepository.class);
-
- // }}
-
- /**
- * Lists all customers in the repository.
- */
- public List<Customer> showAll() {
- return allInstances(Customer.class);
- }
-
- // {{ findAllByName, findByName
- /**
- * Returns a list of Customers with given last name.
- */
- public List<Customer> findAllByName(@Named("Last name") final String lastName) {
- return allMatches(Customer.class, new FilterLastName(lastName));
- }
-
- /**
- * Returns the first Customer with given last name.
- */
- public Customer findByName(@Named("Last name") final String lastName) {
- final Customer firstMatch = firstMatch(Customer.class, new FilterLastName(lastName));
- return firstMatch;
- }
-
- private final class FilterLastName implements Filter<Customer> {
- private final String name;
-
- private FilterLastName(final String name) {
- this.name = name;
- }
-
- @Override
- public boolean accept(final Customer customer) {
- return customer.getLastName().toLowerCase().contains(name.toLowerCase());
- }
- }
-
- // }}
-
- /**
- * Creates a new (still-transient) customer.
- *
- * @return
- */
- public Customer newCustomer() {
- final Customer customer = newTransientInstance(Customer.class);
- return customer;
- }
-
- /**
- * Creates a new (already persisted) customer.
- *
- * <p>
- * For use by fixtures only.
- *
- * @return
- */
- @Hidden
- public Customer newCustomer(final String firstName, final String lastName, final int customerNumber, final Country countryOfBirth) {
-
- final Customer customer = newCustomer();
- customer.setFirstName(firstName);
- customer.setLastName(lastName);
- customer.setCustomerNumber(customerNumber);
- customer.modifyCountryOfBirth(countryOfBirth);
-
- persist(customer);
- return customer;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
deleted file mode 100644
index e70c442..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.sample.service;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Order;
-
-@Named("Orders")
-public class OrderRepository extends AbstractFactoryAndRepository {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- @SuppressWarnings("unused")
- private final static Logger LOGGER = LoggerFactory.getLogger(OrderRepository.class);
-
- // {{ findRecentOrders
- public List<Order> findRecentOrders(final Customer customer, @Named("Number of Orders") final Integer numberOfOrders) {
- final List<Order> orders = customer.getOrders();
- Collections.sort(orders, new Comparator<Order>() {
- @Override
- public int compare(final Order o1, final Order o2) {
- final long time1 = o1.getOrderDate().getTime();
- final long time2 = o2.getOrderDate().getTime();
- return (int) (time2 - time1);
- }
- });
- if (orders.size() < numberOfOrders) {
- return orders;
- } else {
- return orders.subList(0, numberOfOrders);
- }
- }
-
- public Integer default1FindRecentOrders() {
- return 3;
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
deleted file mode 100644
index 4049b99..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.sample.service;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Product;
-
-@Named("Products")
-public class ProductRepository extends AbstractFactoryAndRepository {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = LoggerFactory.getLogger(ProductRepository.class);
-
- // }}
-
- /**
- * Lists all products in the repository.
- */
- public List<Product> showAll() {
- return allInstances(Product.class);
- }
-
- // {{ findByCode
- /**
- * Returns the Product with given code
- */
- public Product findByCode(@Named("Code") final String code) {
- return firstMatch(Product.class, new Filter<Product>() {
- @Override
- public boolean accept(final Product product) {
- return code.equals(product.getCode());
- }
- });
- }
-
- // }}
-
- /**
- * Creates a new product.
- *
- * <p>
- * For use by fixtures only.
- *
- * @return
- */
- @Hidden
- public Product newProduct(final String code, final String description, final int priceInPence) {
- final Product product = newTransientInstance(Product.class);
- product.setCode(code);
- product.setDescription(description);
- product.setPrice(new Double(priceInPence / 100));
- persist(product);
- return product;
- }
-
- /**
- * Creates a new still transient product.
- *
- * <p>
- * For use by tests only. Using this rather than {@link Customer} since
- * {@link Product} has a {@link Product#validate()} method.
- *
- * @return
- */
- @Hidden
- public Product newProduct() {
- return newTransientInstance(Product.class);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
deleted file mode 100644
index acd9793..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.integtestsupport.persistence;
-
-import org.jmock.Expectations;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures.Fixtures.Initialization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.core.tck.dom.refs.ParentEntityRepository;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class PersistorSessionHydratorTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private RootOid epvTransientOid = RootOidDefault.deString("!SMPL:-999", new OidMarshaller());
-
- private IdentifierGenerator mockIdentifierGenerator = context.mock(IdentifierGenerator.class);
- {
- context.checking(new Expectations() {
- {
- final ObjectSpecId docdSpecId = ObjectSpecId.of(DomainObjectContainerDefault.class.getName());
- allowing(mockIdentifierGenerator).createTransientIdentifierFor(with(equalTo(docdSpecId)), with(an(DomainObjectContainerDefault.class)));
- will(returnValue("1"));
- allowing(mockIdentifierGenerator).createPersistentIdentifierFor(with(equalTo(docdSpecId)), with(an(DomainObjectContainerDefault.class)), with(any(RootOid.class)));
- will(returnValue("1"));
-
- final ObjectSpecId peSpecId = ObjectSpecId.of("ParentEntities");
- allowing(mockIdentifierGenerator).createTransientIdentifierFor(with(equalTo(peSpecId)), with(an(ParentEntityRepository.class)));
- will(returnValue("1"));
- allowing(mockIdentifierGenerator).createPersistentIdentifierFor(with(equalTo(peSpecId)), with(an(ParentEntityRepository.class)), with(any(RootOid.class)));
- will(returnValue("1"));
-
- final ObjectSpecId smplSpecId = ObjectSpecId.of("SMPL");
- allowing(mockIdentifierGenerator).createTransientIdentifierFor(with(equalTo(smplSpecId)), with(an(SimpleEntity.class)));
- will(returnValue("-999"));
-
- allowing(mockIdentifierGenerator).createPersistentIdentifierFor(with(equalTo(smplSpecId)), with(an(SimpleEntity.class)), with(any(RootOid.class)));
- will(returnValue("1"));
- }
- });
- }
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(Initialization.NO_INIT)
- .with(new InMemoryPersistenceMechanismInstaller())
- .build();
-
-
- @Test
- public void adaptorFor_whenTransient() {
- // given
- iswf.fixtures.smpl1 = iswf.container.newTransientInstance(SimpleEntity.class);
-
- // when
- final ObjectAdapter adapter = iswf.adapterFor(iswf.fixtures.smpl1);
-
- // then
- assertEquals(epvTransientOid, adapter.getOid());
- assertEquals(iswf.fixtures.smpl1, adapter.getObject());
- assertEquals(ResolveState.TRANSIENT, adapter.getResolveState());
- assertEquals(null, adapter.getVersion());
- }
-
- @Test
- public void recreateAdapter_whenPersistent() throws Exception {
-
- // given persisted object
- iswf.fixtures.smpl1 = iswf.container.newTransientInstance(SimpleEntity.class);
- iswf.fixtures.smpl1.setName("Fred");
- iswf.persist(iswf.fixtures.smpl1);
- iswf.tearDownSystem();
- iswf.setUpSystem();
-
- // when
- final RootOidDefault oid = RootOidDefault.deString("SMPL:1", new OidMarshaller());
- final ObjectAdapter adapter = iswf.recreateAdapter(oid);
-
- // then
- assertEquals(oid, adapter.getOid());
- assertEquals(ResolveState.GHOST, adapter.getResolveState());
-
- final SimpleEntity epv = (SimpleEntity)adapter.getObject();
- assertEquals("Fred", epv.getName());
- assertNotNull(adapter.getVersion());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/RuntimeTestPojo.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/RuntimeTestPojo.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/RuntimeTestPojo.java
deleted file mode 100644
index 9b570a0..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/RuntimeTestPojo.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.core.integtestsupport.persistence;
-
-public class RuntimeTestPojo {
-
- private static int nextId;
- private final int id = nextId++;
- private final String state = "pojo" + id;
-
- @Override
- public String toString() {
- return "Pojo#" + id;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (other == this) {
- return true;
- }
- if (other.getClass() == getClass()) {
- final RuntimeTestPojo otherTestPojo = (RuntimeTestPojo) other;
- return otherTestPojo.state.equals(state);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return state.hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/tck/ObjectStoreContractTest_persist.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/tck/ObjectStoreContractTest_persist.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/tck/ObjectStoreContractTest_persist.java
deleted file mode 100644
index 933b6d6..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/tck/ObjectStoreContractTest_persist.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.integtestsupport.tck;
-
-import java.util.Date;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryFindByTitle;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-import static org.junit.Assert.*;
-
-public abstract class ObjectStoreContractTest_persist {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(createPersistenceMechanismInstaller())
- .with(iswfListener()).build();
-
-
- /**
- * Mandatory hook.
- */
- protected abstract PersistenceMechanismInstaller createPersistenceMechanismInstaller();
-
- protected IsisSystemWithFixtures.Listener iswfListener() {
- return null;
- }
-
- /**
- * hook method
- */
- protected void resetPersistenceStore() {
- }
-
- protected ObjectAdapter epv2Adapter;
- protected ObjectSpecification epvSpecification;
-
- protected ObjectStore getStore() {
- PersistenceSession psos = IsisContext.getPersistenceSession();
- return psos.getObjectStore();
- }
-
-
- @Before
- public void setUpFixtures() throws Exception {
- epv2Adapter = iswf.adapterFor(iswf.fixtures.smpl2);
- epvSpecification = iswf.loadSpecification(SimpleEntity.class);
- }
-
-
- @Test
- public void getInstances_usingFindByTitle() throws Exception {
-
- // given nothing in DB
- resetPersistenceStore();
-
- // when search for any object
- boolean hasInstances = getStore().hasInstances(epvSpecification);
-
- // then find none
- assertFalse(hasInstances);
-
- // given now persisted
- final SimpleEntity epv2 = iswf.fixtures.smpl2;
- epv2.setName("foo");
- epv2.setDate(new Date());
- epv2.setNullable(1234567890L);
- epv2.setSize(123);
-
- iswf.persist(epv2);
-
- iswf.bounceSystem();
-
- // when search for object
- List<ObjectAdapter> retrievedInstance = getStore().loadInstancesAndAdapt(new PersistenceQueryFindByTitle(epvSpecification, epv2Adapter.titleString()));
-
- // then find
- assertEquals(1, retrievedInstance.size());
- final ObjectAdapter retrievedAdapter = retrievedInstance.get(0);
-
- assertNotSame(epv2Adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)epv2Adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
-
- // and when search for some other title
- retrievedInstance = getStore().loadInstancesAndAdapt(new PersistenceQueryFindByTitle(epvSpecification, "some other title"));
-
- // then don't find
- assertEquals(0, retrievedInstance.size());
- }
-
-
- @Test
- public void updateInstance() throws Exception {
-
- // given persisted
- resetPersistenceStore();
- ObjectAdapter adapter = iswf.persist(iswf.fixtures.smpl2);
- final RootOid oid = (RootOid) adapter.getOid();
- iswf.bounceSystem();
-
- // when change
- adapter = iswf.reload(oid);
-
- SimpleEntity epv = (SimpleEntity) adapter.getObject();
- epv.setName("changed");
-
- iswf.bounceSystem();
-
- // then found
- List<ObjectAdapter> retrievedInstance = getStore().loadInstancesAndAdapt(new PersistenceQueryFindByTitle(epvSpecification, adapter.titleString()));
- assertEquals(1, retrievedInstance.size());
-
- final ObjectAdapter retrievedAdapter = retrievedInstance.get(0);
- assertNotSame(adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(adapter.getOid(), retrievedAdapter.getOid());
- }
-
- @Test
- public void removeInstance() throws Exception {
-
- // given persisted
- iswf.beginTran();
- resetPersistenceStore();
- ObjectAdapter adapter = iswf.persist(iswf.fixtures.smpl2);
- final RootOid oid = (RootOid) adapter.getOid();
- iswf.commitTran();
-
- iswf.bounceSystem();
-
- // when destroy
- iswf.beginTran();
- adapter = iswf.reload(oid);
-
- SimpleEntity epv = (SimpleEntity) adapter.getObject();
- iswf.destroy(epv);
- iswf.commitTran();
-
- iswf.bounceSystem();
-
- // then not found
- iswf.beginTran();
- assertEquals(false, getStore().hasInstances(epvSpecification));
- iswf.commitTran();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_debug.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_debug.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_debug.java
deleted file mode 100644
index 0ca1be6..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_debug.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.matchers.IsisMatchers;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class InMemoryObjectStoreTest_debug {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- private static InMemoryObjectStore getStore() {
- return (InMemoryObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
- @Test
- public void debugTitle() throws Exception {
-
- // when
- final String debugTitle = getStore().debugTitle();
-
- // then
- assertThat(debugTitle, is("In-Memory Object Store"));
- }
-
-
- @Test
- public void debugXxx_whenHasObject() throws Exception {
-
- // given
- iswf.persist(iswf.fixtures.smpl1);
-
- // when
- final DebugString debug = new DebugString();
- getStore().debugData(debug);
-
-
- // then
- assertThat(debug.toString(), IsisMatchers.containsStripNewLines("SMPL:3"));
- }
-
-
- @Test
- public void testEmpty() throws Exception {
-
- // when
- final DebugString debug = new DebugString();
- getStore().debugData(debug);
-
- // then
- assertThat(debug.toString(), is("\nDomain Objects\n--------------\n\n"));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_init.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_init.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_init.java
deleted file mode 100644
index d5ebf6a..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_init.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import static org.junit.Assert.assertFalse;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-
-public class InMemoryObjectStoreTest_init {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- private static InMemoryObjectStore getStore() {
- return (InMemoryObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
- @Test
- public void testStartsUpInUnitializedSate() throws Exception {
- assertFalse(getStore().isFixturesInstalled());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_name.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_name.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_name.java
deleted file mode 100644
index 6bf7c36..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_name.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class InMemoryObjectStoreTest_name {
-
- private InMemoryObjectStore store;
-
- @Before
- public void setUp() throws Exception {
- store = new InMemoryObjectStore();
- }
-
- @Test
- public void testName() throws Exception {
- assertEquals("In-Memory Object Store", store.name());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_openAndClose.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_openAndClose.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_openAndClose.java
deleted file mode 100644
index 241a5ae..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_openAndClose.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import org.jmock.Expectations;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Tested in style of <i>Working Effectively with Legacy Code</i> (Feathers) and
- * <i>Growing Object-Oriented Software</i> (Freeman & Pryce).
- */
-public class InMemoryObjectStoreTest_openAndClose {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private InMemoryPersistenceSessionFactory mockInMemoryPersistenceSessionFactory;
- @Mock
- private PersistenceSession mockPersistenceSession;
- @Mock
- private ObjectStorePersistedObjects mockObjectStorePersistedObjects;
-
- private boolean recreatedAdapters = false;
-
- private InMemoryObjectStore objectStore;
-
- @Before
- public void setUp() throws Exception {
- objectStore = new InMemoryObjectStore() {
- @Override
- protected InMemoryPersistenceSessionFactory getInMemoryPersistenceSessionFactory() {
- return mockInMemoryPersistenceSessionFactory;
- }
-
- @Override
- protected PersistenceSession getPersistenceSession() {
- return mockPersistenceSession;
- }
-
- @Override
- protected void recreateAdapters() {
- recreatedAdapters = true;
- }
- };
- }
-
- @Test
- public void whenOpenForFirstTimeThenCreatesPersistedObjects() throws Exception {
- context.never(mockPersistenceSession);
- context.checking(new Expectations() {
- {
- one(mockInMemoryPersistenceSessionFactory).getPersistedObjects();
- will(returnValue(null));
-
- one(mockInMemoryPersistenceSessionFactory).createPersistedObjects();
- will(returnValue(mockObjectStorePersistedObjects));
- }
- });
- objectStore.open();
- }
-
- @Test
- public void whenOpenSubsequentlyThenObtainsPersistedObjectsFromObjectStoreFactoryAndRecreatesAdapters() throws Exception {
- context.never(mockPersistenceSession);
- context.checking(new Expectations() {
- {
- one(mockInMemoryPersistenceSessionFactory).getPersistedObjects();
- will(returnValue(mockObjectStorePersistedObjects));
- }
- });
-
- assertThat(recreatedAdapters, is(false));
- objectStore.open();
- assertThat(recreatedAdapters, is(true));
- }
-
- @Test
- public void whenCloseThenGivesObjectsBackToObjectStoreFactory() throws Exception {
- context.never(mockPersistenceSession);
- whenOpenSubsequentlyThenObtainsPersistedObjectsFromObjectStoreFactoryAndRecreatesAdapters();
-
- context.checking(new Expectations() {
- {
- one(mockInMemoryPersistenceSessionFactory).attach(with(mockPersistenceSession), with(mockObjectStorePersistedObjects));
- never(mockPersistenceSession);
- }
- });
- objectStore.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persist.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persist.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persist.java
deleted file mode 100644
index e88b477..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persist.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures.Listener;
-import org.apache.isis.core.integtestsupport.tck.ObjectStoreContractTest_persist;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-
-public class InMemoryObjectStoreTest_persist extends ObjectStoreContractTest_persist {
-
- @Override
- protected PersistenceMechanismInstaller createPersistenceMechanismInstaller() {
- return new InMemoryPersistenceMechanismInstaller();
- }
-
- @Override
- protected Listener iswfListener() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persistAggregated.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persistAggregated.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persistAggregated.java
deleted file mode 100644
index b07bbf3..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_persistAggregated.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.tck.dom.refs.ReferencingEntity;
-
-public class InMemoryObjectStoreTest_persistAggregated {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(createPersistenceMechanismInstaller())
- .build();
-
- protected PersistenceMechanismInstaller createPersistenceMechanismInstaller() {
- return new InMemoryPersistenceMechanismInstaller();
- }
-
- @Test
- public void persistAggregatedEntityWithinCollection() throws Exception {
- final ReferencingEntity referencingEntity = iswf.fixtures.rfcg2;
- referencingEntity.addAggregatedEntityToCollection().setName("Aggregated Entity #1");
- iswf.persist(referencingEntity);
- }
-
-
- @Test
- public void persistAggregatedEntityWithinProperty() throws Exception {
- final ReferencingEntity referencingEntity = iswf.fixtures.rfcg2;
- referencingEntity.addAggregatedReference().setName("Aggregated Entity #1");
- iswf.persist(referencingEntity);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_reset.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_reset.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_reset.java
deleted file mode 100644
index 357a512..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_reset.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-/**
- * This is really just a test of the test infrastructure, not a real test per se.
- */
-public class InMemoryObjectStoreTest_reset {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- protected ObjectAdapter epv2Adapter;
- protected ObjectSpecification epvSpecification;
-
- protected InMemoryObjectStore getStore() {
- return (InMemoryObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
- @Before
- public void setUpFixtures() throws Exception {
- epv2Adapter = iswf.adapterFor(iswf.fixtures.smpl2);
- epvSpecification = iswf.loadSpecification(SimpleEntity.class);
- }
-
- @Test
- public void reset_clearsAdapterFromLoader() throws Exception {
-
- iswf.persist(iswf.fixtures.smpl2);
- iswf.bounceSystem();
-
- assertNotNull(getAdapterManager().getAdapterFor(epv2Adapter.getObject()));
-
- IsisContext.getPersistenceSession().testReset();
-
- assertNull(getAdapterManager().getAdapterFor(epv2Adapter.getObject()));
- }
-
-
- private PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- private AdapterManager getAdapterManager() {
- return getPersistenceSession().getAdapterManager();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_retrieve.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_retrieve.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_retrieve.java
deleted file mode 100644
index 2725e81..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_retrieve.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryFindAllInstances;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryFindByTitle;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-import static org.junit.Assert.*;
-
-public class InMemoryObjectStoreTest_retrieve {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- protected ObjectAdapter epv2Adapter;
- protected ObjectAdapter epv3Adapter;
- protected ObjectAdapter epv4Adapter;
- protected ObjectSpecification epvSpecification;
-
- protected InMemoryObjectStore getStore() {
- return (InMemoryObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
- @Before
- public void setUpFixtures() throws Exception {
- epv2Adapter = iswf.adapterFor(iswf.fixtures.smpl2);
- epv3Adapter = iswf.adapterFor(iswf.fixtures.smpl3);
- epv4Adapter = iswf.adapterFor(iswf.fixtures.smpl4);
- epvSpecification = iswf.loadSpecification(SimpleEntity.class);
- }
-
- @Test
- public void getObject_whenDoesNotExist() {
- final TypedOid oid = RootOidDefault.deString("SMPL:10", new OidMarshaller());
- try {
- getStore().loadInstanceAndAdapt(oid);
- fail();
- } catch (final ObjectNotFoundException expected) {
- }
- }
-
- @Test
- public void getObject_whenExists_returnsAdapter() throws Exception {
-
- // given
- iswf.persist(iswf.fixtures.smpl2);
- iswf.bounceSystem();
-
- final ObjectAdapter retrievedAdapter = getStore().loadInstanceAndAdapt((TypedOid) epv2Adapter.getOid());
-
- assertNotSame(epv2Adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)epv2Adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
- }
-
- @Test
- public void getInstances_whenDoesNotExist() throws Exception {
- final List<ObjectAdapter> retrievedAdapters = getStore().loadInstancesAndAdapt(new PersistenceQueryFindByTitle(epvSpecification, epv2Adapter.titleString()));
- assertEquals(0, retrievedAdapters.size());
- }
-
- @Test
- public void getInstances_findByTitle() throws Exception {
- // given
- iswf.persist(iswf.fixtures.smpl2);
- iswf.bounceSystem();
-
- // when
- final List<ObjectAdapter> retrievedAdapters = getStore().loadInstancesAndAdapt(new PersistenceQueryFindByTitle(epvSpecification, epv2Adapter.titleString()));
-
- // then
- assertEquals(1, retrievedAdapters.size());
- final ObjectAdapter retrievedAdapter = retrievedAdapters.get(0);
-
- assertNotSame(epv2Adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)epv2Adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
- }
-
- @Test
- public void getInstances_findAll() throws Exception {
- // given
- iswf.persist(iswf.fixtures.smpl2);
- iswf.bounceSystem();
-
- // when
- final List<ObjectAdapter> retrievedAdapters = getStore().loadInstancesAndAdapt(new PersistenceQueryFindAllInstances(epvSpecification));
-
- // then
- assertEquals(1, retrievedAdapters.size());
- final ObjectAdapter retrievedAdapter = retrievedAdapters.get(0);
-
- assertNotSame(epv2Adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)epv2Adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
- }
-
- @Ignore // gonna retire soon anyway...
- @Test
- public void getInstances_findRange() throws Exception {
- // given
- iswf.persist(iswf.fixtures.smpl1); // 0
- iswf.persist(iswf.fixtures.smpl2); // 1
- iswf.persist(iswf.fixtures.smpl3); // 2 <- this one
- iswf.persist(iswf.fixtures.smpl4); // 3 <- this one
- iswf.bounceSystem();
-
- // when
- final List<ObjectAdapter> retrievedAdapters = getStore().loadInstancesAndAdapt(new PersistenceQueryFindAllInstances(epvSpecification, 2, 2));
-
- // then
- assertEquals(2, retrievedAdapters.size());
- final ObjectAdapter retrievedAdapter = retrievedAdapters.get(0);
-
- assertNotSame(epv4Adapter, retrievedAdapter);
- assertEquals(((SimpleEntity)epv4Adapter.getObject()).getName(), ((SimpleEntity)retrievedAdapter.getObject()).getName());
- assertEquals(epv4Adapter.getOid(), retrievedAdapter.getOid());
- }
-
-
- @Test
- public void hasInstances_whenEmpty() throws Exception {
- assertEquals(false, getStore().hasInstances(epvSpecification));
- }
-
- @Test
- public void hasInstances_whenHasSome() throws Exception {
- iswf.persist(iswf.fixtures.smpl2);
- iswf.bounceSystem();
-
- assertEquals(true, getStore().hasInstances(epvSpecification));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_serviceRegistry.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_serviceRegistry.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_serviceRegistry.java
deleted file mode 100644
index f9b3f2e..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/objectstore/InMemoryObjectStoreTest_serviceRegistry.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.objectstore;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.tck.dom.refs.ParentEntityRepository;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-import static org.junit.Assert.assertEquals;
-
-public class InMemoryObjectStoreTest_serviceRegistry {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- protected ObjectAdapter epv2Adapter;
- protected ObjectSpecification epvSpecification;
-
- protected InMemoryObjectStore getStore() {
- return (InMemoryObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
- @Before
- public void setUpFixtures() throws Exception {
- epv2Adapter = iswf.adapterFor(iswf.fixtures.smpl2);
- epvSpecification = iswf.loadSpecification(SimpleEntity.class);
- }
-
- @Test
- public void getOidForServices() throws Exception {
- final Oid oidForService = getStore().getOidForService(iswf.loadSpecification(ParentEntityRepository.class));
- assertEquals(RootOidDefault.create(ObjectSpecId.of("ParentEntities"), "2"), oidForService);
- }
-
-
-// @Test
-// public void registerService_canBeRetrieved() throws Exception {
-// registerService14();
-//
-// final Oid oidForService = store.getOidForService(serviceSpecification);
-// assertEquals(oid14, oidForService);
-// }
-//
-// @Test
-// public void testCantRegisterServiceMoreThanOnce() throws Exception {
-// registerService14();
-// try {
-// registerService14();
-// fail();
-// } catch (final IsisException expected) {
-// }
-// }
-//
-// @Test
-// public void testCanRegisterMoreThanOneService() throws Exception {
-// registerService14();
-// registerService15();
-// }
-//
-//
-// private void resetIdentityMap() {
-// IsisContext.getPersistenceSession().testReset();
-// }
-//
-// protected void addObjectToStore(final ObjectAdapter object) {
-// final PersistenceCommand command = store.createCreateObjectCommand(object);
-// assertEquals(object, command.onObject());
-// store.execute(Collections.<PersistenceCommand> singletonList(command));
-// }
-//
-// private RootOidDefault registerService14() {
-// return oid14 = registerService(""+14);
-// }
-//
-// private RootOidDefault registerService15() {
-// return registerService(""+15);
-// }
-//
-// private RootOidDefault registerService(final String id) {
-// final RootOidDefault oid = RootOidDefault.createPersistent("SVC", id);
-// store.registerService(oid);
-// resetIdentityMap();
-// return oid;
-// }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java
deleted file mode 100644
index 5ec351c..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureFilePersistorTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.fixturedomainservice;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assume.assumeThat;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-import java.util.TimeZone;
-
-import junit.framework.Assert;
-
-import com.google.common.collect.Sets;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-import org.apache.isis.core.commons.matchers.IsisMatchers;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.tck.dom.refs.ParentEntity;
-import org.apache.isis.core.tck.dom.refs.ReferencingEntity;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-public class ObjectFixtureFilePersistorTest {
-
- private static final String DATEFORMAT_PATTERN = "dd-MMM-yyyy HH:mm z";
-
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat(DATEFORMAT_PATTERN, Locale.US);
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
- .with(configuration()).build();
-
- private static IsisConfiguration configuration() {
- final IsisConfigurationDefault config = new IsisConfigurationDefault();
- config.add("isis.value.format.datetime", DATEFORMAT_PATTERN);
- return config;
- }
-
- private ObjectFixtureFilePersistor persistor;
-
- @Before
- public void setup() throws Exception {
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
-
- Locale.setDefault(Locale.UK);
-
- persistor = new ObjectFixtureFilePersistor();
-
- iswf.fixtures.smpl1.setName("Fred Smith");
- iswf.fixtures.smpl1.setDate(dateFormat.parse("08-Mar-2010 01:00 UTC"));
-
- iswf.fixtures.smpl2.setName("Joe Bloggs");
- iswf.fixtures.smpl2.setDate(dateFormat.parse("09-Apr-2011 02:10 UTC"));
-
- assumeThat(TimeZone.getDefault().getDisplayName(), is("Greenwich Mean Time"));
- }
-
-
- @Test
- public void loadInstance() throws Exception {
-
- final StringReader reader = new StringReader(SimpleEntity.class.getName() + "#1\n name: Fred Smith\n date: 08-Mar-2010 01:00 UTC");
- final Set<Object> objects = persistor.loadData(reader);
-
- assertEquals(1, objects.size());
- final Object object = objects.toArray()[0];
- assertThat(object instanceof SimpleEntity, is(true));
- final SimpleEntity epv = (SimpleEntity) object;
- assertEquals("Fred Smith", epv.getName());
-
- assertEquals(dateFormat.parse("08-Mar-2010 01:00 GMT"), epv.getDate());
- }
-
- @Test
- public void invalidFieldLine() throws Exception {
- try {
- final StringReader reader = new StringReader(SimpleEntity.class.getName() + "#1\n name Fred Smith");
- persistor.loadData(reader);
- Assert.fail();
- } catch (final FixtureException e) {
- Assert.assertEquals("failed to load data at line 2", e.getMessage());
- Assert.assertEquals("no colon (:) in: name Fred Smith", e.getCause().getMessage());
- }
- }
-
- @Test
- public void oldFieldNameSkipped() throws Exception {
- final StringReader reader = new StringReader(SimpleEntity.class.getName() + "#1\n xname: Fred Smith");
- final Set<Object> objects = persistor.loadData(reader);
- final Object object = objects.toArray()[0];
- Assert.assertNull(((SimpleEntity) object).getName());
-
- }
-
- @Test
- public void saveNoObjects() throws Exception {
- // Person person = new Person();
- final Set<Object> objects = new HashSet<Object>();
- final StringWriter out = new StringWriter();
- persistor.save(objects, out);
- Assert.assertEquals("", out.toString());
- }
-
- @Test
- public void saveOneObject() throws Exception {
- final Set<Object> objects = Sets.newLinkedHashSet();
- objects.add(iswf.fixtures.smpl1);
-
- final StringWriter out = new StringWriter();
- persistor.save(objects, out);
- final String actual = canonicalize(out);
-
- final String expected = SimpleEntity.class.getName() + "#2\n date: 08-Mar-2010 01:00 UTC\n name: Fred Smith\n";
-
- assertThat(actual, IsisMatchers.startsWith(expected));
- }
-
- @Test
- public void saveTwoObjects() throws Exception {
- final Set<Object> objects = Sets.newLinkedHashSet();
- objects.add(iswf.fixtures.smpl1);
- objects.add(iswf.fixtures.smpl3);
-
- final StringWriter out = new StringWriter();
- persistor.save(objects, out);
- final String actual = canonicalize(out);
-
- final String expected1 = SimpleEntity.class.getName() + "#2\n date: 08-Mar-2010 01:00 UTC\n name: Fred Smith\n";
- final String expected2 = SimpleEntity.class.getName() + "#3\n date: \n name: 3\n";
- assertThat(actual, IsisMatchers.contains(expected1));
- assertThat(actual, IsisMatchers.contains(expected2));
- }
-
-
- private String canonicalize(final String out) {
- return out.replaceAll("\r\n", "\n");
- }
-
- private String canonicalize(final StringWriter out) {
- return canonicalize(out.toString());
- }
-
- @Test
- public void saveReferencedObject() throws Exception {
-
- final Set<Object> objects = Sets.newLinkedHashSet();
-
- iswf.fixtures.rfcg1.setReference(iswf.fixtures.smpl1);
- objects.add(iswf.fixtures.rfcg1);
- objects.add(iswf.fixtures.smpl1);
-
- final StringWriter out = new StringWriter();
- persistor.save(objects, out);
- final String actual = canonicalize(out);
-
- final String expected1 = ReferencingEntity.class.getName() + "#2\n aggregatedEntities: \n aggregatedReference: \n reference: " + SimpleEntity.class.getName() + "#3";
- final String expected2 = SimpleEntity.class.getName() + "#3\n date: 08-Mar-2010 01:00 UTC\n name: Fred Smith\n";
- assertThat(actual, IsisMatchers.contains(expected1));
- assertThat(actual, IsisMatchers.contains(expected2));
- }
-
-
- @Test
- public void saveObjectAndAssociatedCollection() throws Exception {
-
- final Set<Object> objects = Sets.newLinkedHashSet();
-
- iswf.fixtures.prnt1.getHomogeneousCollection().add(iswf.fixtures.smpl1);
- iswf.fixtures.prnt1.getHomogeneousCollection().add(iswf.fixtures.smpl2);
- objects.add(iswf.fixtures.prnt1);
-
- objects.add(iswf.fixtures.smpl1);
- objects.add(iswf.fixtures.smpl2);
-
- final StringWriter out = new StringWriter();
- persistor.save(objects, out);
- final String actual = canonicalize(out);
-
- final String expected1a = ParentEntity.class.getName() + "#2\n";
- final String expected1b = "heterogeneousCollection: \n homogeneousCollection: " + SimpleEntity.class.getName() + "#3 " + SimpleEntity.class.getName() + "#4 " + "\n";
- final String expected2 = SimpleEntity.class.getName() + "#3\n date: 08-Mar-2010 01:00 UTC\n name: Fred Smith\n";
- final String expected3 = SimpleEntity.class.getName() + "#4\n date: 09-Apr-2011 02:10 UTC\n name: Joe Bloggs\n";
- assertThat(actual.replaceAll("\n", "###"), IsisMatchers.contains(expected1a.replaceAll("\n", "###")));
- assertThat(actual.replaceAll("\n", "###"), IsisMatchers.contains(expected1b.replaceAll("\n", "###")));
- assertThat(actual, IsisMatchers.contains(expected2));
- assertThat(actual, IsisMatchers.contains(expected3));
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java
deleted file mode 100644
index b0fe6db..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.fixturedomainservice;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Date;
-import java.util.Locale;
-import java.util.Set;
-
-import junit.framework.Assert;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-public class ObjectFixtureServiceTest_loadFile {
-
- private static IsisConfiguration configuration() {
- IsisConfigurationDefault configuration = new IsisConfigurationDefault();
- configuration.add(ConfigurationConstants.ROOT + "exploration-objects.file", "test.data");
- return configuration;
- }
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().with(configuration()).build();
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private ObjectFixtureService service;
-
-
- @Before
- public void setup() {
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
- Locale.setDefault(Locale.UK);
-
- service = new ObjectFixtureService();
- }
-
-
- @Test
- public void loadFile() throws Exception {
-
- // when
- service.loadFile();
-
- // then
- final Set<Object> objects = service.allSavedObjects();
- Assert.assertEquals(1, objects.size());
- final Object object = objects.toArray()[0];
- assertThat(object instanceof SimpleEntity, is(true));
- Assert.assertEquals("Fred Smith", ((SimpleEntity) object).getName());
- Assert.assertEquals(new Date(110, 2, 8, 13, 32), ((SimpleEntity) object).getDate());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java
deleted file mode 100644
index 1087b67..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_loadFile_nothingExists.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.fixturedomainservice;
-
-import java.io.File;
-import java.util.Locale;
-import java.util.Set;
-
-import junit.framework.Assert;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-public class ObjectFixtureServiceTest_loadFile_nothingExists {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private ObjectFixtureService service;
-
-
- @Before
- public void setup() {
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
- Locale.setDefault(Locale.UK);
-
- service = new ObjectFixtureService();
- deleteFixtureData();
- }
-
-
- private static void deleteFixtureData() {
- new File("fixture-data").delete();
- }
-
- @Test
- public void loadNothingIfNoFileExists() throws Exception {
- service.loadFile();
-
- final Set<Object> objects = service.allSavedObjects();
- Assert.assertEquals(0, objects.size());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java
deleted file mode 100644
index fbb3b69..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/fixturedomainservice/ObjectFixtureServiceTest_save.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.fixturedomainservice;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Set;
-
-import junit.framework.Assert;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.tck.dom.refs.ParentEntity;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-public class ObjectFixtureServiceTest_save {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- private ObjectFixtureService service;
-
-
- @Before
- public void setup() {
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
- Locale.setDefault(Locale.UK);
-
- service = new ObjectFixtureService();
- deleteFixtureData();
- }
-
-
- private static void deleteFixtureData() {
- new File("fixture-data").delete();
- }
-
-
- @Test
- public void saveObjectAddedToList() throws Exception {
-
- final SimpleEntity epv = iswf.fixtures.smpl1;
- epv.setName("Fred Smith");
- epv.setDate(new Date(110, 2, 8, 13, 32));
-
- final ParentEntity epc = iswf.fixtures.prnt1;
- epc.getHomogeneousCollection().add(iswf.fixtures.smpl1);
- epc.getHomogeneousCollection().add(iswf.fixtures.smpl2);
- service.save(epc);
-
- final Set<Object> savedObjects = service.allSavedObjects();
- Assert.assertEquals(3, savedObjects.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/memento/MementoTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/memento/MementoTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/memento/MementoTest.java
deleted file mode 100644
index 6787e43..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/runtime/memento/MementoTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.core.runtime.memento;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.encoding.DataInputStreamExtended;
-import org.apache.isis.core.commons.encoding.DataOutputStreamExtended;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.tck.dom.refs.BaseEntity;
-import org.apache.isis.core.tck.dom.refs.ParentEntity;
-import org.apache.isis.core.tck.dom.refs.ReferencingEntity;
-import org.apache.isis.core.tck.dom.refs.SimpleEntity;
-
-public class MementoTest {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- private ObjectAdapter originalAdapterForEpv1;
- private ObjectAdapter originalAdapterForEpr1;
- private ObjectAdapter originalAdapterForEpc1;
-
- private ObjectAdapter recreatedAdapter;
-
- private Memento mementoForEpv1;
- private Memento mementoForEpr1;
- private Memento mementoForEpc1;
-
- private byte[] bytesForEpv1;
- private byte[] bytesForEpr1;
- private byte[] bytesForEpc1;
-
- private ByteArrayInputStream bais;
-
-
- @Before
- public void setUpSystem() throws Exception {
-
-// final Logger logger = LoggerFactory.getLogger(FieldType.class);
-// logger.setLevel(Level.DEBUG);
-// logger.addAppender(new ConsoleAppender());
-// BasicConfigurator.configure();
-
- iswf.fixtures.smpl1.setName("Fred");
- iswf.fixtures.smpl2.setName("Harry");
-
- iswf.fixtures.rfcg1_a1.setName("Tom");
-
- iswf.fixtures.rfcg1.setReference(iswf.fixtures.smpl1);
- iswf.fixtures.rfcg1.setAggregatedReference(iswf.fixtures.rfcg1_a1);
-
- iswf.fixtures.prnt1.getHomogeneousCollection().add(iswf.fixtures.smpl1);
- iswf.fixtures.prnt1.getHomogeneousCollection().add(iswf.fixtures.smpl2);
-
- iswf.fixtures.prnt1.getHeterogeneousCollection().add(iswf.fixtures.smpl1);
- iswf.fixtures.prnt1.getHeterogeneousCollection().add(iswf.fixtures.rfcg1);
-
- originalAdapterForEpv1 = iswf.adapterFor(iswf.fixtures.smpl1);
- originalAdapterForEpr1 = iswf.adapterFor(iswf.fixtures.rfcg1);
- originalAdapterForEpc1 = iswf.adapterFor(iswf.fixtures.prnt1);
-
- mementoForEpv1 = new Memento(originalAdapterForEpv1);
- mementoForEpr1 = new Memento(originalAdapterForEpr1);
- mementoForEpc1 = new Memento(originalAdapterForEpc1);
-
- bytesForEpv1 = toBytes(mementoForEpv1);
- bytesForEpr1 = toBytes(mementoForEpr1);
- bytesForEpc1 = toBytes(mementoForEpc1);
-
- iswf.tearDownSystem();
-
-// logger.debug("*************************************");
-
- iswf.setUpSystem();
-
- mementoForEpv1 = fromBytes(bytesForEpv1);
- mementoForEpr1 = fromBytes(bytesForEpr1);
- mementoForEpc1 = fromBytes(bytesForEpc1);
-
- IsisContext.getTransactionManager().startTransaction();
- }
-
-
- @After
- public void tearDown() throws Exception {
- IsisContext.getTransactionManager().endTransaction();
- }
-
- private Memento fromBytes(final byte[] bytes) throws IOException {
- bais = new ByteArrayInputStream(bytes);
- DataInputStreamExtended input = new DataInputStreamExtended(bais);
- final Memento recreate = Memento.recreateFrom(input);
- return recreate;
- }
-
-
- private static byte[] toBytes(final Memento memento) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStreamExtended output = new DataOutputStreamExtended(baos);
- memento.encodedData(output);
- return baos.toByteArray();
- }
-
-
- @Test
- public void recreateObject_adaptersAreNotSame() throws Exception {
-
- recreatedAdapter = mementoForEpv1.recreateObject();
-
- assertNotSame(originalAdapterForEpv1, recreatedAdapter);
- }
-
- @Test
- public void recreateObject_getOid_areEquals() throws Exception {
- recreatedAdapter = mementoForEpv1.recreateObject();
-
- assertEquals(originalAdapterForEpv1.getOid(), recreatedAdapter.getOid());
- }
-
- @Test
- public void recreateObject_getSpecification_isSame() throws Exception {
- recreatedAdapter = mementoForEpv1.recreateObject();
-
- final ObjectSpecification specification = originalAdapterForEpv1.getSpecification();
- final ObjectSpecification recreatedSpecification = recreatedAdapter.getSpecification();
- assertSame(specification, recreatedSpecification);
- }
-
- @Test
- public void recreateObject_valuePreserved() throws Exception {
- recreatedAdapter = mementoForEpv1.recreateObject();
- final SimpleEntity recreatedObject = (SimpleEntity)recreatedAdapter.getObject();
- assertEquals("Fred", recreatedObject.getName());
- }
-
- @Test
- public void recreateObject_referencePreserved() throws Exception {
- recreatedAdapter = mementoForEpr1.recreateObject();
- final ReferencingEntity recreatedObject = (ReferencingEntity)recreatedAdapter.getObject();
- final SimpleEntity reference1 = recreatedObject.getReference();
- assertNotNull(reference1);
-
- assertThat("Fred", equalTo(reference1.getName()));
- }
-
- @Test
- public void recreateObject_homogeneousCollectionPreserved() throws Exception {
- recreatedAdapter = mementoForEpc1.recreateObject();
- final ParentEntity recreatedObject = (ParentEntity)recreatedAdapter.getObject();
- final List<SimpleEntity> homogenousCollection = recreatedObject.getHomogeneousCollection();
- assertNotNull(homogenousCollection);
-
- assertThat(homogenousCollection.size(), is(2));
- assertThat(homogenousCollection.get(0).getName(), is("Fred"));
- assertThat(homogenousCollection.get(1).getName(), is("Harry"));
- }
-
- @Test
- public void recreateObject_heterogeneousCollectionPreserved() throws Exception {
- recreatedAdapter = mementoForEpc1.recreateObject();
- final ParentEntity recreatedObject = (ParentEntity)recreatedAdapter.getObject();
- final List<BaseEntity> hetrogenousCollection = recreatedObject.getHeterogeneousCollection();
- assertNotNull(hetrogenousCollection);
-
- assertThat(hetrogenousCollection.size(), is(2));
- final SimpleEntity firstObj = (SimpleEntity)hetrogenousCollection.get(0);
- assertThat(firstObj.getName(), is("Fred"));
-
- final ReferencingEntity secondObj = (ReferencingEntity)hetrogenousCollection.get(1);
- final SimpleEntity reference1 = secondObj.getReference();
- assertThat(reference1.getName(), is("Fred"));
-
- assertSame(firstObj, reference1);
- }
-
- @Test
- public void recreateObject_whenNull() throws Exception {
- final Memento memento = new Memento(null);
- ObjectAdapter returnedAdapter = memento.recreateObject();
- assertNull(returnedAdapter);
- }
-
-
-}