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:38 UTC
[20/48] isis git commit: ISIS-1178: mothballing the tck tests.
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/JodaValuedEntityFixture.java
----------------------------------------------------------------------
diff --git a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/JodaValuedEntityFixture.java b/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/JodaValuedEntityFixture.java
deleted file mode 100644
index 42cb18b..0000000
--- a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/JodaValuedEntityFixture.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.tck.fixture.scalars;
-
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.core.tck.dom.scalars.JodaValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.JodaValuedEntityRepository;
-
-public class JodaValuedEntityFixture extends AbstractFixture {
-
- @Override
- public void install() {
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- }
-
- private JodaValuedEntity createEntity() {
- final JodaValuedEntity jve = jodaValuesEntityRepository.newEntity();
- jve.setLocalDateProperty(new LocalDate(2008,3,21));
- jve.setLocalDateTimeProperty(new LocalDateTime(2009, 4, 29, 13, 45, 22));
- jve.setDateTimeProperty(new DateTime(2010, 3, 31, 9, 50, 43, DateTimeZone.UTC));
- return jve;
- }
-
- private JodaValuedEntityRepository jodaValuesEntityRepository;
-
- public void setJdkValuesEntityRepository(final JodaValuedEntityRepository jodaValuesEntityRepository) {
- this.jodaValuesEntityRepository = jodaValuesEntityRepository;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/PrimitiveValuedEntityFixture.java
----------------------------------------------------------------------
diff --git a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/PrimitiveValuedEntityFixture.java b/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/PrimitiveValuedEntityFixture.java
deleted file mode 100644
index e9db111..0000000
--- a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/PrimitiveValuedEntityFixture.java
+++ /dev/null
@@ -1,56 +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.tck.fixture.scalars;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
-
-public class PrimitiveValuedEntityFixture extends AbstractFixture {
-
- @Override
- public void install() {
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- }
-
- private PrimitiveValuedEntity createEntity() {
- final PrimitiveValuedEntity pve = primitiveValuesEntityRepository.newEntity();
- pve.setBooleanProperty(true);
- pve.setByteProperty((byte)123);
- pve.setShortProperty((short)32123);
- pve.setCharProperty('a');
- pve.setIntProperty(987654321);
- pve.setLongProperty(2345678901234567890L);
- pve.setFloatProperty(12345678901234567890.1234567890F);
- pve.setDoubleProperty(12345678901234567890.1234567890);
- return pve;
- }
-
- private PrimitiveValuedEntityRepository primitiveValuesEntityRepository;
-
- public void setPrimitiveValuesEntityRepository(final PrimitiveValuedEntityRepository primitiveValuesEntityRepository) {
- this.primitiveValuesEntityRepository = primitiveValuesEntityRepository;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/WrapperValuedEntityFixture.java
----------------------------------------------------------------------
diff --git a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/WrapperValuedEntityFixture.java b/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/WrapperValuedEntityFixture.java
deleted file mode 100644
index 0d9d869..0000000
--- a/tck/tck-fixture/src/main/java/org/apache/isis/core/tck/fixture/scalars/WrapperValuedEntityFixture.java
+++ /dev/null
@@ -1,57 +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.tck.fixture.scalars;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.core.tck.dom.scalars.WrapperValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.WrapperValuedEntityRepository;
-
-public class WrapperValuedEntityFixture extends AbstractFixture {
-
- @Override
- public void install() {
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- createEntity();
- }
-
- private WrapperValuedEntity createEntity() {
- final WrapperValuedEntity wve = wrapperValuesEntityRepository.newEntity();
- wve.setBooleanProperty(true);
- wve.setByteProperty((byte)123);
- wve.setShortProperty((short)32123);
- wve.setCharacterProperty('a');
- wve.setIntegerProperty(987654321);
- wve.setLongProperty(2345678901234567890L);
- wve.setFloatProperty(12345678901234567890.1234567890F);
- wve.setDoubleProperty(12345678901234567890.1234567890);
-
- return wve;
- }
-
- private WrapperValuedEntityRepository wrapperValuesEntityRepository;
-
- public void setPrimitiveValuesEntityRepository(final WrapperValuedEntityRepository wrapperValuesEntityRepository) {
- this.wrapperValuesEntityRepository = wrapperValuesEntityRepository;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/lib/.gitignore
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/lib/.gitignore b/tck/tck-integtests/lib/.gitignore
deleted file mode 100644
index 4c21459..0000000
--- a/tck/tck-integtests/lib/.gitignore
+++ /dev/null
@@ -1,24 +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.
-#
-
-#
-# explicitly ignoring Microsoft JDBC4 jar
-# (cannot redistribute, licensing)
-#
-sqljdbc4.jar
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/pom.xml
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/pom.xml b/tck/tck-integtests/pom.xml
deleted file mode 100644
index dee873d..0000000
--- a/tck/tck-integtests/pom.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.isis.tck</groupId>
- <artifactId>isis-tck</artifactId>
- <version>1.9.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>isis-tck-integtests</artifactId>
- <name>Isis TCK IntegTests</name>
-
- <properties>
- <siteBaseDir>..</siteBaseDir>
- <relativeUrl>objectstore-jdo-datanucleus/</relativeUrl>
- </properties>
-
- <!-- used in Site generation for relative references. -->
- <url>http://isis.apache.org/${relativeUrl}</url>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <filtering>false</filtering>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
- <dependencies>
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-core-unittestsupport</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-core-runtime</artifactId>
- </dependency>
-
- <!-- other modules in this project -->
- <dependency>
- <groupId>org.apache.isis.tck</groupId>
- <artifactId>isis-tck-dom</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.tck</groupId>
- <artifactId>isis-tck-fixture</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-core-integtestsupport</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!--
- <dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>jdbc</artifactId>
- <version>4.0</version>
- <scope>system</scope>
- <optional>true</optional>
- <systemPath>${basedir}/lib/sqljdbc4.jar</systemPath>
- </dependency>
- -->
-
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
deleted file mode 100644
index cd449c8..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
+++ /dev/null
@@ -1,674 +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;
-
-import java.util.Arrays;
-import java.util.List;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures.Fixtures.Initialization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
-import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.system.DeploymentType;
-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.runtime.system.transaction.IsisTransaction;
-import org.apache.isis.core.runtime.system.transaction.IsisTransaction.State;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.security.authentication.AuthenticationRequestNameOnly;
-import org.apache.isis.core.tck.dom.refs.*;
-import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.JdkValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.WrapperValuedEntity;
-
-/**
- * Wraps a plain {@link IsisSystemDefault}, and provides a number of features to assist with testing.
- *
- * <p>
- * TODO: need to make inherit from the {@link IsisSystemForTest}.
- */
-public class IsisSystemWithFixtures implements org.junit.rules.TestRule {
-
-
- public interface Listener {
-
- void init(IsisConfiguration configuration) throws Exception;
-
- void preSetupSystem(boolean firstTime) throws Exception;
- void postSetupSystem(boolean firstTime) throws Exception;
-
- void preBounceSystem() throws Exception;
- void postBounceSystem() throws Exception;
-
- void preTeardownSystem() throws Exception;
- void postTeardownSystem() throws Exception;
-
- }
-
- public static abstract class ListenerAdapter implements Listener {
-
- private IsisConfiguration configuration;
-
- public void init(IsisConfiguration configuration) throws Exception {
- this.configuration = configuration;
- }
-
- protected IsisConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public void preSetupSystem(boolean firstTime) throws Exception {
- }
-
- @Override
- public void postSetupSystem(boolean firstTime) throws Exception {
- }
-
- @Override
- public void preBounceSystem() throws Exception {
- }
-
- @Override
- public void postBounceSystem() throws Exception {
- }
-
- @Override
- public void preTeardownSystem() throws Exception {
- }
-
- @Override
- public void postTeardownSystem() throws Exception {
- }
-
- }
-
-
-
- /**
- * A precanned set of fixtures for use by tests if desired.
- */
- public static class Fixtures {
-
- public enum Initialization {
- INIT,
- NO_INIT
- }
-
- public ParentEntityRepository associatedEntitiesRepository = new ParentEntityRepository();
-
- public ApplibValuedEntity ave1, ave2;
- public JdkValuedEntity jve1, jve2;
- public PrimitiveValuedEntity pve1, pve2;
- public WrapperValuedEntity wve1, wve2;
-
- public SimpleEntity smpl1, smpl2, smpl3, smpl4, smpl5, smpl6;
- public ReferencingEntity rfcg1, rfcg2, rfcg3, rfcg4, rfcg5, rfcg6;
- public ParentEntity prnt1, prnt2, prnt3, prnt4, prnt5, prnt6;
- public AggregatedEntity rfcg1_a1, rfcg1_a2, rfcg1_a3, prnt1_a1, prnt1_a2, prnt1_a3;
-
- private void init(DomainObjectContainer container) {
- ave1 = container.newTransientInstance(ApplibValuedEntity.class);
- ave2 = container.newTransientInstance(ApplibValuedEntity.class);
-
- jve1 = container.newTransientInstance(JdkValuedEntity.class);
- jve2 = container.newTransientInstance(JdkValuedEntity.class);
-
- pve1 = container.newTransientInstance(PrimitiveValuedEntity.class);
- pve2 = container.newTransientInstance(PrimitiveValuedEntity.class);
-
- wve1 = container.newTransientInstance(WrapperValuedEntity.class);
- wve2 = container.newTransientInstance(WrapperValuedEntity.class);
-
- smpl1 = container.newTransientInstance(SimpleEntity.class);smpl1.setName("1");
- smpl2 = container.newTransientInstance(SimpleEntity.class);smpl2.setName("2");
- smpl3 = container.newTransientInstance(SimpleEntity.class);smpl3.setName("3");
- smpl4 = container.newTransientInstance(SimpleEntity.class);smpl4.setName("4");
- smpl5 = container.newTransientInstance(SimpleEntity.class);smpl5.setName("5");
- smpl6 = container.newTransientInstance(SimpleEntity.class);smpl6.setName("6");
- rfcg1 = container.newTransientInstance(ReferencingEntity.class);
- rfcg2 = container.newTransientInstance(ReferencingEntity.class);
- rfcg3 = container.newTransientInstance(ReferencingEntity.class);
- rfcg4 = container.newTransientInstance(ReferencingEntity.class);
- rfcg5 = container.newTransientInstance(ReferencingEntity.class);
- rfcg6 = container.newTransientInstance(ReferencingEntity.class);
- prnt1 = container.newTransientInstance(ParentEntity.class);
- prnt2 = container.newTransientInstance(ParentEntity.class);
- prnt3 = container.newTransientInstance(ParentEntity.class);
- prnt4 = container.newTransientInstance(ParentEntity.class);
- prnt5 = container.newTransientInstance(ParentEntity.class);
- prnt6 = container.newTransientInstance(ParentEntity.class);
- rfcg1_a1 = container.newAggregatedInstance(rfcg1, AggregatedEntity.class);
- rfcg1_a2 = container.newAggregatedInstance(rfcg1, AggregatedEntity.class);
- rfcg1_a3 = container.newAggregatedInstance(rfcg1, AggregatedEntity.class);
- prnt1_a1 = container.newAggregatedInstance(prnt1, AggregatedEntity.class);
- prnt1_a2 = container.newAggregatedInstance(prnt1, AggregatedEntity.class);
- prnt1_a3 = container.newAggregatedInstance(prnt1, AggregatedEntity.class);
- }
- }
-
- private IsisSystemDefault isisSystem;
- private AuthenticationSession authenticationSession;
-
- // public visibility just to reduce noise in tests
- public DomainObjectContainer container;
- // public visibility just to reduce noise in tests
- public final Fixtures fixtures;
-
- private Initialization fixturesInitialization;
- private final IsisConfiguration configuration;
- private final PersistenceMechanismInstaller persistenceMechanismInstaller;
- private final AuthenticationRequest authenticationRequest;
- private final List<Object> services;
- private List <Listener> listeners;
- private final MetaModelValidator metaModelValidator;
- private final ProgrammingModel programmingModel;
-
-
- ////////////////////////////////////////////////////////////
- // constructor
- ////////////////////////////////////////////////////////////
-
- public static class Builder {
-
- private AuthenticationRequest authenticationRequest = new AuthenticationRequestNameOnly("tester");
-
- private Initialization fixturesInitialization = Initialization.INIT;
- private IsisConfiguration configuration;
- private PersistenceMechanismInstaller persistenceMechanismInstaller = new InMemoryPersistenceMechanismInstaller();
- private MetaModelValidator metaModelValidator;
- private ProgrammingModel programmingModel;
-
- private final List <Listener> listeners = Lists.newArrayList();
- private final List<Object> services = Lists.newArrayList();
-
- public Builder() {
- withServices(new DomainObjectContainerDefault());
- }
-
- public Builder with(IsisConfiguration configuration) {
- this.configuration = configuration;
- return this;
- }
-
- public Builder with(Initialization initialization) {
- this.fixturesInitialization = initialization;
- return this;
- }
-
- public Builder with(PersistenceMechanismInstaller persistenceMechanismInstaller) {
- this.persistenceMechanismInstaller = persistenceMechanismInstaller;
- return this;
- }
-
- public Builder with(AuthenticationRequest authenticationRequest) {
- this.authenticationRequest = authenticationRequest;
- return this;
- }
-
- public Builder withServices(Object... services) {
- this.services.addAll(0, Arrays.asList(services));
- return this;
- }
-
- public IsisSystemWithFixtures build() {
- return new IsisSystemWithFixtures(fixturesInitialization, configuration, programmingModel, metaModelValidator, persistenceMechanismInstaller, authenticationRequest, services, listeners);
- }
-
- public Builder with(Listener listener) {
- if(listener != null) {
- listeners.add(listener);
- }
- return this;
- }
-
- public Builder with(MetaModelValidator metaModelValidator) {
- this.metaModelValidator = metaModelValidator;
- return this;
- }
-
- public Builder with(ProgrammingModel programmingModel) {
- this.programmingModel = programmingModel;
- return this;
- }
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- private IsisSystemWithFixtures(Initialization fixturesInitialization, IsisConfiguration configuration, ProgrammingModel programmingModel, MetaModelValidator metaModelValidator, PersistenceMechanismInstaller persistenceMechanismInstaller, AuthenticationRequest authenticationRequest, List<Object> services, List<Listener> listeners) {
- this.fixturesInitialization = fixturesInitialization;
- this.configuration = configuration;
- this.programmingModel = programmingModel;
- this.metaModelValidator = metaModelValidator;
- this.persistenceMechanismInstaller = persistenceMechanismInstaller;
- this.authenticationRequest = authenticationRequest;
- this.fixtures = new Fixtures();
-
- // hacky
- services.add(fixtures.associatedEntitiesRepository);
- this.services = services;
-
- this.listeners = listeners;
-
- this.container = lookupContainer();
- }
-
-
- ////////////////////////////////////////////////////////////
- // setup, teardown
- ////////////////////////////////////////////////////////////
-
-
- /**
- * Intended to be called from a test's {@link Before} method.
- */
- public void setUpSystem() throws Exception {
- setUpSystem(FireListeners.FIRE);
- }
-
- private void setUpSystem(FireListeners fireListeners) throws Exception {
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
-
- boolean firstTime = isisSystem == null;
- if (fireListeners.shouldFire()) {
- fireInitAndPreSetupSystem(firstTime);
- }
-
- if (firstTime) {
- isisSystem = createIsisSystem(services);
- isisSystem.init();
- IsisContext.closeSession();
- }
-
- final AuthenticationManager authenticationManager = isisSystem.getSessionFactory().getAuthenticationManager();
- authenticationSession = authenticationManager.authenticate(authenticationRequest);
-
- IsisContext.openSession(authenticationSession);
-
- DomainObjectContainer container = lookupContainer();
- if (firstTime && fixturesInitialization == Fixtures.Initialization.INIT) {
- fixtures.init(container);
- }
- if (fireListeners.shouldFire()) {
- firePostSetupSystem(firstTime);
- }
-
- }
-
- private DomainObjectContainer lookupContainer() {
- return lookupContainerIn(services);
- }
-
- private static DomainObjectContainer lookupContainerIn(List<Object> services1) {
- for (Object service : services1) {
- if(service instanceof DomainObjectContainer) {
- return (DomainObjectContainer) service;
- }
- }
- throw new IllegalStateException("Could not locate DomainObjectContainer");
- }
-
-
- private enum FireListeners {
- FIRE,
- DONT_FIRE;
- public boolean shouldFire() {
- return this == FIRE;
- }
- }
-
-
- /**
- * Intended to be called from a test's {@link After} method.
- */
- public void tearDownSystem() throws Exception {
- tearDownSystem(FireListeners.FIRE);
- }
-
- private void tearDownSystem(final FireListeners fireListeners) throws Exception {
- if(fireListeners.shouldFire()) {
- firePreTeardownSystem();
- }
- IsisContext.closeSession();
- if(fireListeners.shouldFire()) {
- firePostTeardownSystem();
- }
- }
-
- public void bounceSystem() throws Exception {
- firePreBounceSystem();
- tearDownSystem(FireListeners.DONT_FIRE);
- setUpSystem(FireListeners.DONT_FIRE);
- firePostBounceSystem();
- }
-
-
- private IsisSystemDefault createIsisSystem(List<Object> services) {
- final IsisSystemDefault system = new IsisSystemDefault(DeploymentType.UNIT_TESTING, services) {
- @Override
- public IsisConfiguration getConfiguration() {
- if(IsisSystemWithFixtures.this.configuration != null) {
- return IsisSystemWithFixtures.this.configuration;
- } else {
- return super.getConfiguration();
- }
- }
- @Override
- protected ProgrammingModel obtainReflectorProgrammingModel() {
- if(IsisSystemWithFixtures.this.programmingModel != null) {
- return IsisSystemWithFixtures.this.programmingModel;
- } else {
- return super.obtainReflectorProgrammingModel();
- }
- }
- @Override
- protected MetaModelValidator obtainReflectorMetaModelValidator() {
- if(IsisSystemWithFixtures.this.metaModelValidator != null) {
- return IsisSystemWithFixtures.this.metaModelValidator;
- } else {
- return super.obtainReflectorMetaModelValidator();
- }
- }
- @Override
- protected PersistenceMechanismInstaller obtainPersistenceMechanismInstaller(IsisConfiguration configuration) {
- final PersistenceMechanismInstaller installer = IsisSystemWithFixtures.this.persistenceMechanismInstaller;
- configuration.injectInto(installer);
- return installer;
- }
- };
- return system;
- }
-
-
-
- ////////////////////////////////////////////////////////////
- // listeners
- ////////////////////////////////////////////////////////////
-
- private void fireInitAndPreSetupSystem(boolean firstTime) throws Exception {
- if(firstTime) {
- for(Listener listener: listeners) {
- listener.init(configuration);
- }
- }
- for(Listener listener: listeners) {
- listener.preSetupSystem(firstTime);
- }
- }
-
- private void firePostSetupSystem(boolean firstTime) throws Exception {
- for(Listener listener: listeners) {
- listener.postSetupSystem(firstTime);
- }
- }
-
- private void firePreTeardownSystem() throws Exception {
- for(Listener listener: listeners) {
- listener.preTeardownSystem();
- }
- }
-
- private void firePostTeardownSystem() throws Exception {
- for(Listener listener: listeners) {
- listener.postTeardownSystem();
- }
- }
-
- private void firePreBounceSystem() throws Exception {
- for(Listener listener: listeners) {
- listener.preBounceSystem();
- }
- }
-
- private void firePostBounceSystem() throws Exception {
- for(Listener listener: listeners) {
- listener.postBounceSystem();
- }
- }
-
-
- ////////////////////////////////////////////////////////////
- // properties
- ////////////////////////////////////////////////////////////
-
- /**
- * The {@link IsisSystemDefault} created during {@link #setUpSystem()}.
- */
- public IsisSystemDefault getIsisSystem() {
- return isisSystem;
- }
-
- /**
- * The {@link AuthenticationSession} created during {@link #setUpSystem()}.
- */
- public AuthenticationSession getAuthenticationSession() {
- return authenticationSession;
- }
-
-
-
- ////////////////////////////////////////////////////////////
- // Convenience for tests
- ////////////////////////////////////////////////////////////
-
- public ObjectSpecification loadSpecification(Class<?> cls) {
- return getIsisSystem().getSessionFactory().getSpecificationLoader().loadSpecification(cls);
- }
-
- public ObjectAdapter persist(Object domainObject) {
- ensureSessionInProgress();
- ensureObjectIsNotPersistent(domainObject);
- container.persist(domainObject);
- return adapterFor(domainObject);
- }
-
- public ObjectAdapter destroy(Object domainObject ) {
- ensureSessionInProgress();
- ensureObjectIsPersistent(domainObject);
- container.remove(domainObject);
- return adapterFor(domainObject);
- }
-
- public ObjectAdapter adapterFor(Object domainObject) {
- ensureSessionInProgress();
- return getAdapterManager().adapterFor(domainObject);
- }
-
- public ObjectAdapter reload(RootOid oid) {
- ensureSessionInProgress();
- final PersistenceSession persistenceSession = getPersistenceSession();
- return persistenceSession.loadObject(oid);
- }
-
- public ObjectAdapter recreateAdapter(RootOid oid) {
- ensureSessionInProgress();
- return getAdapterManager().adapterFor(oid);
- }
-
- public ObjectAdapter remapAsPersistent(Object pojo, RootOid persistentOid) {
- ensureSessionInProgress();
- ensureObjectIsNotPersistent(pojo);
- final ObjectAdapter adapter = adapterFor(pojo);
- getPersistenceSession().getAdapterManager().remapAsPersistent(adapter, persistentOid);
- return adapter;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends ObjectStore> T getObjectStore(Class<T> cls) {
- final PersistenceSession persistenceSession = getPersistenceSession();
- return (T) persistenceSession.getObjectStore();
- }
-
- private static void ensureSessionInProgress() {
- if(!IsisContext.inSession()) {
- throw new IllegalStateException("Session must be in progress");
- }
- }
-
- private void ensureObjectIsNotPersistent(Object domainObject) {
- if(container.isPersistent(domainObject)) {
- throw new IllegalArgumentException("domain object is already persistent");
- }
- }
-
- private void ensureObjectIsPersistent(Object domainObject) {
- if(!container.isPersistent(domainObject)) {
- throw new IllegalArgumentException("domain object is not persistent");
- }
- }
-
- ////////////////////////////////////////////////////////////
- // JUnit @Rule integration
- ////////////////////////////////////////////////////////////
-
- @Override
- public Statement apply(final Statement base, Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- setUpSystem();
- try {
- base.evaluate();
- tearDownSystem();
- } catch(Throwable ex) {
- try {
- tearDownSystem();
- } catch(Exception ex2) {
- // ignore, since already one pending
- }
- throw ex;
- }
- }
- };
- }
-
-
-
- public void beginTran() {
- final IsisTransactionManager transactionManager = getTransactionManager();
- final IsisTransaction transaction = transactionManager.getTransaction();
-
- if(transaction == null) {
- transactionManager.startTransaction();
- return;
- }
-
- final State state = transaction.getState();
- switch(state) {
- case COMMITTED:
- case ABORTED:
- transactionManager.startTransaction();
- break;
- case IN_PROGRESS:
- // nothing to do
- break;
- case MUST_ABORT:
- Assert.fail("Transaction is in state of '" + state + "'");
- break;
- default:
- Assert.fail("Unknown transaction state '" + state + "'");
- }
-
- }
-
- public void commitTran() {
- final IsisTransactionManager transactionManager = getTransactionManager();
- final IsisTransaction transaction = transactionManager.getTransaction();
- if(transaction == null) {
- Assert.fail("No transaction exists");
- return;
- }
- final State state = transaction.getState();
- switch(state) {
- case COMMITTED:
- case ABORTED:
- case MUST_ABORT:
- Assert.fail("Transaction is in state of '" + state + "'");
- break;
- case IN_PROGRESS:
- transactionManager.endTransaction();
- break;
- default:
- Assert.fail("Unknown transaction state '" + state + "'");
- }
- }
-
- public void abortTran() {
- final IsisTransactionManager transactionManager = getTransactionManager();
- final IsisTransaction transaction = transactionManager.getTransaction();
- if(transaction == null) {
- Assert.fail("No transaction exists");
- return;
- }
- final State state = transaction.getState();
- switch(state) {
- case ABORTED:
- break;
- case COMMITTED:
- Assert.fail("Transaction is in state of '" + state + "'");
- break;
- case MUST_ABORT:
- case IN_PROGRESS:
- transactionManager.abortTransaction();
- break;
- default:
- Assert.fail("Unknown transaction state '" + state + "'");
- }
- }
-
- protected IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- public PersistenceSession getPersistor() {
- return getPersistenceSession();
- }
-
- public AdapterManager getAdapterManager() {
- return getPersistor().getAdapterManager();
- }
-
- protected PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixturesTest_basicTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixturesTest_basicTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixturesTest_basicTest.java
deleted file mode 100644
index ac72288..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixturesTest_basicTest.java
+++ /dev/null
@@ -1,47 +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;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.tck.dom.scalars.JdkValuedEntity;
-
-public class IsisSystemWithFixturesTest_basicTest {
-
- @Rule
- public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
-
- @Test
- public void savePojo() throws Exception {
-
- iswf.beginTran();
- assertThat(iswf.container.allInstances(JdkValuedEntity.class).size(), is(0));
-
- iswf.container.persist(iswf.fixtures.jve1);
-
- assertThat(iswf.container.allInstances(JdkValuedEntity.class).size(), is(1));
- iswf.commitTran();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
deleted file mode 100644
index 010c130..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
+++ /dev/null
@@ -1,140 +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;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.services.eventbus.EventBusService;
-import org.apache.isis.applib.services.wrapper.WrapperFactory;
-import org.apache.isis.applib.services.wrapper.WrapperObject;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Product;
-import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CountriesFixture;
-import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CustomerOrdersFixture;
-import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CustomersFixture;
-import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.ProductsFixture;
-import org.apache.isis.core.integtestsupport.legacy.sample.service.CountryRepository;
-import org.apache.isis.core.integtestsupport.legacy.sample.service.CustomerRepository;
-import org.apache.isis.core.integtestsupport.legacy.sample.service.OrderRepository;
-import org.apache.isis.core.integtestsupport.legacy.sample.service.ProductRepository;
-import org.apache.isis.core.wrapper.WrapperFactoryDefault;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-@RunWith(IsisTestRunner.class)
-@Fixtures({ @Fixture(CountriesFixture.class), @Fixture(ProductsFixture.class), @Fixture(CustomersFixture.class), @Fixture(CustomerOrdersFixture.class) })
-@Services({ @Service(CountryRepository.class), @Service(ProductRepository.class), @Service(CustomerRepository.class), @Service(OrderRepository.class), @Service(WrapperFactoryDefault.class), @Service(EventBusService.Noop.class) })
-public abstract class AbstractTest {
-
- protected Customer custJsDO;
- protected Customer custJsWO;
-
- protected Product product355DO;
- protected Product product355WO;
-
- protected Product product850DO;
-
- protected Country countryGbrDO;
- protected Country countryGbrWO;
-
- protected Country countryUsaDO;
- protected Country countryAusDO;
-
- private ProductRepository productRepository;
- private CustomerRepository customerRepository;
- private CountryRepository countryRepository;
-
- private DomainObjectContainer domainObjectContainer;
- private WrapperFactory wrapperFactory;
-
- @Before
- public void setUp() {
-
- product355DO = productRepository.findByCode("355-40311");
- product355WO = wrapperFactory.wrap(product355DO);
- product850DO = productRepository.findByCode("850-18003");
-
- countryGbrDO = countryRepository.findByCode("GBR");
- countryGbrWO = wrapperFactory.wrap(countryGbrDO);
-
- countryUsaDO = countryRepository.findByCode("USA");
- countryAusDO = countryRepository.findByCode("AUS");
-
- custJsDO = customerRepository.findByName("Pawson");
- custJsWO = wrapperFactory.wrap(custJsDO);
-
- assertThat(product355WO instanceof WrapperObject, is(true));
- assertThat(countryGbrWO instanceof WrapperObject, is(true));
- assertThat(custJsWO instanceof WrapperObject, is(true));
- }
-
- @After
- public void tearDown() {
- }
-
- // //////////////////////////////////////////////////////
- // Injected.
- // //////////////////////////////////////////////////////
-
- protected WrapperFactory getWrapperFactory() {
- return wrapperFactory;
- }
-
- public void setWrapperFactory(final WrapperFactory headlessViewer) {
- this.wrapperFactory = headlessViewer;
- }
-
- protected DomainObjectContainer getDomainObjectContainer() {
- return domainObjectContainer;
- }
-
- public void setDomainObjectContainer(final DomainObjectContainer domainObjectContainer) {
- this.domainObjectContainer = domainObjectContainer;
- }
-
- protected ProductRepository getProductRepository() {
- return productRepository;
- }
-
- public void setProductRepository(final ProductRepository productRepository) {
- this.productRepository = productRepository;
- }
-
- protected CustomerRepository getCustomerRepository() {
- return customerRepository;
- }
-
- public void setCustomerRepository(final CustomerRepository customerRepository) {
- this.customerRepository = customerRepository;
- }
-
- protected CountryRepository getCountryRepository() {
- return countryRepository;
- }
-
- public void setCountryRepository(final CountryRepository countryRepository) {
- this.countryRepository = countryRepository;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
deleted file mode 100644
index edcc3a3..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
+++ /dev/null
@@ -1,42 +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;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class DefaultAndChoicesTest extends AbstractTest {
-
- @Test
- public void defaults() {
- final Object[] defaultPlaceOrder = custJsWO.defaultPlaceOrder();
- assertThat(defaultPlaceOrder.length, is(2));
- }
-
- @Ignore("not yet tested")
- @Test
- public void choicesDefaults() {
- // not tested.
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
deleted file mode 100644
index 8669781..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
+++ /dev/null
@@ -1,54 +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;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.events.InteractionEvent;
-import org.apache.isis.applib.events.PropertyAccessEvent;
-import org.apache.isis.applib.services.wrapper.listeners.InteractionAdapter;
-import org.apache.isis.applib.services.wrapper.listeners.InteractionListener;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
-
-public class InteractionListenerTest extends AbstractTest {
-
- @Test
- public void shouldBeAbleToAddListener() {
- final Customer proxiedCustRP = getWrapperFactory().wrap(custJsDO);
- final InteractionEvent[] events = { null };
- final InteractionListener l = new InteractionAdapter() {
- @Override
- public void propertyAccessed(final PropertyAccessEvent ev) {
- events[0] = ev;
- }
- };
- getWrapperFactory().addInteractionListener(l);
-
- proxiedCustRP.getFirstName();
- assertThat(events[0], notNullValue());
- final PropertyAccessEvent ev = (PropertyAccessEvent) events[0];
- assertThat(ev.getMemberNaturalName(), is("First Name"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
deleted file mode 100644
index b4a27e0..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
+++ /dev/null
@@ -1,132 +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;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.DisabledException;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Order;
-import org.apache.isis.core.metamodel.facets.properties.property.disabled.DisabledFacetForDisabledAnnotationOnProperty;
-import org.apache.isis.core.metamodel.facets.members.disabled.method.DisableForContextFacetViaMethod;
-
-public class MemberDisabledTest extends AbstractTest {
-
- @Test
- public void whenValueDisabledForValueThenThrowsException() {
- custJsDO.disableFirstName = "cannot alter";
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot alter"));
- }
- }
-
- @Test
- public void whenValueDisabledForNullThenThrowsException() {
- custJsDO.disableFirstName = "cannot alter";
- try {
- custJsWO.setFirstName(null);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot alter"));
- }
- }
-
- @Test
- public void whenAssociationDisabledForReferenceThenThrowsException() {
- custJsDO.disableCountryOfBirth = "cannot alter";
- try {
- custJsWO.setCountryOfBirth(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot alter"));
- }
- }
-
- @Test
- public void whenAssociationDisabledForNullThenThrowsException() {
- custJsDO.disableCountryOfBirth = "cannot alter";
- try {
- custJsWO.setCountryOfBirth(null);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot alter"));
- }
- }
-
- @Test
- public void whenCollectionDisabledThenAddToThrowsException() {
- final List<Order> orders = custJsWO.getOrders();
- final Order order = orders.get(0);
- try {
- custJsWO.addToMoreOrders(order);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForDisabledAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("More Orders"));
- assertThat(ex.getMessage(), Matchers.containsString("Always disabled"));
- }
- }
-
- @Test
- public void whenCollectionDisabledThenRemovefromThrowsException() {
- custJsDO.addToVisitedCountries(countryUsaDO);
- custJsDO.disableVisitedCountries = "cannot alter";
- try {
- custJsWO.removeFromVisitedCountries(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot alter"));
- }
- }
-
- @Test
- public void whenActionDisabledThenThrowsException() {
- custJsDO.disablePlaceOrder = "cannot invoke";
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- assertThat(ex.getMessage(), Matchers.containsString("cannot invoke"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
deleted file mode 100644
index f2bf3e4..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
+++ /dev/null
@@ -1,356 +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;
-
-import org.junit.Test;
-import org.apache.isis.applib.services.wrapper.HiddenException;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
-import org.apache.isis.core.metamodel.facets.properties.property.hidden.HiddenFacetForHiddenAnnotationOnProperty;
-import org.apache.isis.core.metamodel.facets.members.hidden.forsession.HideForSessionFacetViaMethod;
-import org.apache.isis.core.metamodel.facets.members.hidden.method.HideForContextFacetViaMethod;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-public class MemberHiddenTest extends AbstractTest {
-
- @Test
- public void whenValueHiddenImperativelyForValueThenModifyThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenValueHiddenImperativelyForNullThenModifyThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenValueHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.getFirstName();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenAssociationHiddenImperativelyForValueThenModifyThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.setCountryOfBirth(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
- @Test
- public void whenAssociationHiddenImperativelyForNullThenModifyThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.setCountryOfBirth(null);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
- @Test
- public void whenAssociationHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.getCountryOfBirth();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
- @Test
- public void whenIfCollectionHiddenImperativelyThenAddToThrowsException() {
- custJsDO.hideVisitedCountries = true;
- try {
- custJsWO.addToVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenCollectionHiddenImperativelyThenRemoveFromThrowsException() {
- custJsDO.hideVisitedCountries = true;
- custJsDO.addToVisitedCountries(countryGbrDO);
- try {
- custJsWO.removeFromVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenCollectionHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideVisitedCountries = true;
- custJsDO.addToVisitedCountries(countryGbrDO);
- try {
- custJsWO.getVisitedCountries();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenActionHiddenImperativelyThenThrowsException() {
- custJsDO.hidePlaceOrder = true;
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyForValueThenModifyThrowsException() {
- try {
- custJsWO.setAlwaysHiddenValue("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyForNullThenModifyThrowsException() {
- try {
- custJsWO.setAlwaysHiddenValue(null);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenValue();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenAssociationHiddenDeclarativelyThenModifyThrowsException() {
- final Country[] values = new Country[] { countryUsaDO, null };
- for (final Country value : values) {
- try {
- custJsWO.setAlwaysHiddenAssociation(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
- }
- }
- }
-
- @Test
- public void whenAssociationHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenAssociation();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenAddToThrowsException() {
- try {
- custJsWO.addToAlwaysHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenRemoveFromThrowsException() {
- custJsDO.removeFromAlwaysHiddenCollection(countryUsaDO);
- try {
- custJsWO.removeFromAlwaysHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenCollection();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenActionHiddenDeclarativelyThenThrowsException() {
- try {
- custJsWO.alwaysHiddenAction();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForHiddenAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Action"));
- }
- }
-
- @Test
- public void whenValueHiddenNotAuthorizedThenModifyThrowsException() {
- final String[] values = new String[] { "Dick", null };
- for (final String value : values) {
- try {
- custJsWO.setSessionHiddenValue(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
- }
- }
- }
-
- @Test
- public void whenValueHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenValue();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
- }
- }
-
- @Test
- public void whenAssociationHiddenNotAuthorizedThenModifyThrowsException() {
- final Country[] values = new Country[] { countryUsaDO, null };
- for (final Country value : values) {
- try {
- custJsWO.setSessionHiddenAssociation(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
- }
- }
- }
-
- @Test
- public void whenAssociationHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenAssociation();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenAddToThrowsException() {
- try {
- custJsWO.addToSessionHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenRemoveFromThrowsException() {
- custJsDO.addToSessionHiddenCollection(countryUsaDO);
- try {
- custJsWO.removeFromSessionHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenCollection();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenActionHiddenNotAuthorizedThenThrowsException() {
- try {
- custJsWO.sessionHiddenAction();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Action"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/93a1d5cc/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
deleted file mode 100644
index cd17d79..0000000
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
+++ /dev/null
@@ -1,255 +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;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import org.hamcrest.Matchers;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.InvalidException;
-import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
-import org.apache.isis.core.metamodel.facets.properties.property.maxlength.MaxLengthFacetForMaxLengthAnnotationOnProperty;
-import org.apache.isis.core.metamodel.facets.properties.property.regex.RegExFacetForRegExAnnotationOnProperty;
-import org.apache.isis.core.metamodel.facets.objectvalue.mandatory.MandatoryFacetDefault;
-import org.apache.isis.core.metamodel.facets.actions.validate.method.ActionValidationFacetViaMethod;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateAddToFacetViaMethod;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateRemoveFromFacetViaMethod;
-import org.apache.isis.core.metamodel.facets.properties.validating.method.PropertyValidateFacetViaMethod;
-
-public class MemberInvalidTest extends AbstractTest {
-
- @Test
- public void whenValueInvalidImperativelyThenThrowsException() {
- final String[] values = new String[] { "Dick", "Harry" };
- for (final String value : values) {
- custJsDO.validateFirstNameExpectedArg = value;
- custJsDO.validateFirstName = "bad first name";
- try {
- custJsWO.setFirstName(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), Matchers.containsString("bad first name"));
- }
- }
- }
-
- @Test
- public void whenValueNullThenDoesNotThrowException() {
- final String[] values = new String[] { null };
- for (final String value : values) {
- custJsDO.validateFirstNameExpectedArg = value;
- custJsDO.validateFirstName = "bad first name";
- // should not trigger exception
- custJsWO.setFirstName(value);
- }
- }
-
-
- @Ignore // different behaviour testing in Eclipse vs Maven (different exception type thrown); not sure why
- @Test
- public void whenValueInvalidImperativelyOnMandatoryThenThrowsException() {
- final String[] values = new String[] { null };
- for (final String value : values) {
- custJsDO.validateFirstNameMandatoryExpectedArg = value;
- custJsDO.validateFirstNameMandatory = "bad first name";
- try {
- custJsWO.setFirstNameMandatory(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- //assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class)); // in Eclipse?
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class)); // in Maven?
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name Mandatory"));
- assertThat(ex.getMessage(), Matchers.containsString("bad first name"));
- }
- }
- }
-
-
-
- @Test
- public void whenAssociationInvalidImperativelyThenThrowsException() {
- custJsDO.validateCountryOfBirth = "bad country of birth";
- final Country[] values = new Country[] { countryUsaDO };
- for (final Country value : values) {
- try {
- custJsWO.setCountryOfBirth(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), Matchers.containsString("bad country of birth"));
- }
- }
- }
-
- @Test
- public void whenAssociationNullOnOptionalThenDoesNotThrowException() {
- final Country[] values = new Country[] { null };
- for (final Country value : values) {
- custJsDO.validateCountryOfBirth = "bad country of birth";
- // should not throw exception
- custJsWO.setCountryOfBirth(value);
- }
- }
-
-
- @Ignore // different behaviour testing in Eclipse vs Maven (different exception type thrown); not sure why
- @Test
- public void whenAssociationNullOnMandatoryImperativelyThenThrowsException() {
- custJsDO.validateCountryOfBirthMandatory = "bad country of birth";
- final Country[] values = new Country[] { null };
- for (final Country value : values) {
- try {
- custJsWO.setCountryOfBirthMandatory(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- //assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class)); // in Eclipse?
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class)); // in Maven?
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth Mandatory"));
- assertThat(ex.getMessage(), Matchers.containsString("bad country of birth"));
- }
- }
- }
-
-
-
- @Test
- public void whenCollectionInvalidImperativelyThenAddToThrowsException() {
- custJsDO.validateAddToVisitedCountries = "bad country";
- try {
- custJsWO.addToVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateAddToFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), Matchers.containsString("bad country"));
- }
- }
-
- @Test
- public void whenCollectionInvalidImperativelyThenRemoveFromThrowsException() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.validateRemoveFromVisitedCountries = "bad country";
- try {
- custJsWO.removeFromVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateRemoveFromFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), Matchers.containsString("bad country"));
- }
- }
-
- @Test
- public void whenActionInvalidImperativelyThenThrowsException() {
- custJsDO.validatePlaceOrder = "can't place order";
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(ActionValidationFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- assertThat(ex.getMessage(), Matchers.containsString("can't place order"));
- }
- }
-
- @Test
- public void whenValueCanSetNullOnOptionalField() {
- custJsWO.setOptionalValue(null);
- }
-
- @Test
- public void whenAssociationCanSetNullOnOptionalField() {
- custJsWO.setOptionalAssociation(null);
- }
-
- @Test
- public void whenValueInvalidMandatoryThenThrowsException() {
- try {
- custJsWO.setMandatoryValue(null);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Value"));
- }
- }
-
- @Test
- public void whenAssociationInvalidMandatoryThenThrowsException() {
- try {
- custJsWO.setMandatoryAssociation(null);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Association"));
- }
- }
-
- @Test
- public void whenInvalidMaxLengthThenThrowsException() {
- try {
- custJsWO.setMaxLengthField("This is far too long");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MaxLengthFacetForMaxLengthAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Max Length Field"));
- }
- }
-
- @Test
- public void whenInvalidRegExCaseSensitiveThenThrowsException() {
- try {
- custJsWO.setRegExCaseSensitiveField("abCfoobar");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Sensitive Field"));
- }
- }
-
- @Test
- public void whenCanSetValidRegExCaseSensitive() {
- custJsWO.setRegExCaseInsensitiveField("abcfoobar");
-
- }
-
- @Test
- public void whenInvalidRegExCaseInsensitiveThenThrowsException() {
- try {
- custJsWO.setRegExCaseInsensitiveField("abXfoobar");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(RegExFacetForRegExAnnotationOnProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Insensitive Field"));
- }
- }
-
- @Test
- public void whenCanSetValidRegExCaseInsensitive() {
- custJsWO.setRegExCaseInsensitiveField("AbCfoobar");
- }
-
-}