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 2013/05/20 14:46:40 UTC
[5/5] git commit: ISIS-409: junit viewer moved up to core...
ISIS-409: junit viewer moved up to core...
... in the integtestsupport module
Have put it into a 'legacy' subpackage, since will probably be
removed in the future in preference to the other stuff in integtestsupport.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/da47b564
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/da47b564
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/da47b564
Branch: refs/heads/master
Commit: da47b564a617b52d8cc803623a3ef9371ae0f1c2
Parents: 55f931a
Author: Dan Haywood <da...@apache.org>
Authored: Mon May 20 13:46:04 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Mon May 20 13:46:04 2013 +0100
----------------------------------------------------------------------
.../apache/isis/viewer/junit/Authenticator.java | 32 -
.../org/apache/isis/viewer/junit/Authorizor.java | 32 -
.../org/apache/isis/viewer/junit/ConfigDir.java | 36 -
.../java/org/apache/isis/viewer/junit/Fixture.java | 33 -
.../org/apache/isis/viewer/junit/Fixtures.java | 33 -
.../apache/isis/viewer/junit/IsisTestRunner.java | 221 ----
.../org/apache/isis/viewer/junit/Persistor.java | 32 -
.../java/org/apache/isis/viewer/junit/Service.java | 33 -
.../org/apache/isis/viewer/junit/Services.java | 33 -
.../viewer/junit/internal/AnnotationInstaller.java | 96 --
.../internal/FixtureInstallerAnnotatedClass.java | 88 --
.../IsisSystemUsingInstallersWithinJunit.java | 77 --
.../internal/ServicesInstallerAnnotatedClass.java | 68 --
.../org/apache/isis/viewer/junit/AbstractTest.java | 132 ---
.../isis/viewer/junit/DefaultAndChoicesTest.java | 42 -
.../isis/viewer/junit/InteractionListenerTest.java | 54 -
.../isis/viewer/junit/MemberDisabledTest.java | 131 ---
.../apache/isis/viewer/junit/MemberHiddenTest.java | 357 -------
.../isis/viewer/junit/MemberInvalidTest.java | 189 ----
.../apache/isis/viewer/junit/MemberModifyTest.java | 223 -----
.../apache/isis/viewer/junit/MemberReadTest.java | 93 --
.../isis/viewer/junit/ObjectImmutableTest.java | 87 --
.../apache/isis/viewer/junit/SaveObjectsTest.java | 107 --
.../org/apache/isis/viewer/junit/TitleTest.java | 33 -
.../apache/isis/viewer/junit/ViewObjectTest.java | 91 --
.../isis/viewer/junit/sample/domain/Country.java | 154 ---
.../isis/viewer/junit/sample/domain/Customer.java | 777 ---------------
.../isis/viewer/junit/sample/domain/Order.java | 184 ----
.../isis/viewer/junit/sample/domain/Product.java | 185 ----
.../junit/sample/fixtures/CountriesFixture.java | 64 --
.../sample/fixtures/CustomerOrdersFixture.java | 106 --
.../junit/sample/fixtures/CustomersFixture.java | 88 --
.../junit/sample/fixtures/JoeBloggsFixture.java | 30 -
.../junit/sample/fixtures/ProductsFixture.java | 72 --
.../junit/sample/service/CountryRepository.java | 80 --
.../junit/sample/service/CustomerRepository.java | 116 ---
.../junit/sample/service/OrderRepository.java | 67 --
.../junit/sample/service/ProductRepository.java | 103 --
component/viewer/junit/tck/pom.xml | 12 +-
.../tck/src/test/java/junit/AbstractTest.java | 8 +-
.../junit/todo/ScalarEntityRepositoryTest.java | 4 +-
.../src/test/java/junit/todo/ScalarEntityTest.java | 4 +-
core/integtestsupport/pom.xml | 7 +
.../integtestsupport/legacy/Authenticator.java | 32 +
.../core/integtestsupport/legacy/Authorizor.java | 32 +
.../core/integtestsupport/legacy/ConfigDir.java | 36 +
.../isis/core/integtestsupport/legacy/Fixture.java | 33 +
.../core/integtestsupport/legacy/Fixtures.java | 33 +
.../integtestsupport/legacy/IsisTestRunner.java | 221 ++++
.../core/integtestsupport/legacy/Persistor.java | 32 +
.../isis/core/integtestsupport/legacy/Service.java | 33 +
.../core/integtestsupport/legacy/Services.java | 33 +
.../legacy/components/AnnotationInstaller.java | 96 ++
.../components/FixtureInstallerAnnotatedClass.java | 88 ++
.../IsisSystemUsingInstallersWithinJunit.java | 77 ++
.../ServicesInstallerAnnotatedClass.java | 68 ++
.../core/integtestsupport/legacy/AbstractTest.java | 132 +++
.../legacy/DefaultAndChoicesTest.java | 42 +
.../legacy/InteractionListenerTest.java | 54 +
.../legacy/MemberDisabledTest.java | 131 +++
.../integtestsupport/legacy/MemberHiddenTest.java | 357 +++++++
.../integtestsupport/legacy/MemberInvalidTest.java | 189 ++++
.../integtestsupport/legacy/MemberModifyTest.java | 223 +++++
.../integtestsupport/legacy/MemberReadTest.java | 93 ++
.../legacy/ObjectImmutableTest.java | 87 ++
.../integtestsupport/legacy/SaveObjectsTest.java | 107 ++
.../core/integtestsupport/legacy/TitleTest.java | 33 +
.../integtestsupport/legacy/ViewObjectTest.java | 91 ++
.../legacy/sample/domain/Country.java | 154 +++
.../legacy/sample/domain/Customer.java | 777 +++++++++++++++
.../legacy/sample/domain/Order.java | 184 ++++
.../legacy/sample/domain/Product.java | 185 ++++
.../legacy/sample/fixtures/CountriesFixture.java | 64 ++
.../sample/fixtures/CustomerOrdersFixture.java | 106 ++
.../legacy/sample/fixtures/CustomersFixture.java | 88 ++
.../legacy/sample/fixtures/JoeBloggsFixture.java | 30 +
.../legacy/sample/fixtures/ProductsFixture.java | 72 ++
.../legacy/sample/service/CountryRepository.java | 80 ++
.../legacy/sample/service/CustomerRepository.java | 116 +++
.../legacy/sample/service/OrderRepository.java | 67 ++
.../legacy/sample/service/ProductRepository.java | 103 ++
core/pom.xml | 2 +-
example/application/claims/pom.xml | 9 -
example/application/claims/viewer-dnd/pom.xml | 18 +-
.../isis/example/claims/junit/AbstractTest.java | 6 +-
.../isis/example/claims/junit/ClaimSubmitTest.java | 4 +-
.../isis/example/claims/junit/NewClaimTest.java | 4 +-
.../application/quickstart_dnd_junit_bdd/pom.xml | 9 -
.../quickstart_dnd_junit_bdd/tests-junit/pom.xml | 11 +-
.../src/test/java/junit/AbstractTest.java | 8 +-
.../java/junit/todo/ToDoItemRepositoryTest.java | 4 +-
.../src/test/java/junit/todo/ToDoItemTest.java | 4 +-
pom.xml | 1 -
93 files changed, 4437 insertions(+), 4436 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
deleted file mode 100644
index 910546b..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
+++ /dev/null
@@ -1,32 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authenticator {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
deleted file mode 100644
index ee0f5b2..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
+++ /dev/null
@@ -1,32 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authorizor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
deleted file mode 100644
index a1e70f3..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
+++ /dev/null
@@ -1,36 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The location of the <tt>config</tt> directory, relative to the base.
- */
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ConfigDir {
- String value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java
deleted file mode 100644
index 2909009..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java
+++ /dev/null
@@ -1,33 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixture {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java
deleted file mode 100644
index 3d33ec7..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java
+++ /dev/null
@@ -1,33 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixtures {
- Fixture[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java
deleted file mode 100644
index a795b0b..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.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.viewer.junit;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.jmock.Mockery;
-import org.junit.internal.runners.InitializationError;
-import org.junit.internal.runners.JUnit4ClassRunner;
-import org.junit.internal.runners.MethodRoadie;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
-import org.junit.runner.Description;
-import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunNotifier;
-
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
-import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.authentication.exploration.AuthenticationRequestExploration;
-import org.apache.isis.core.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
-import org.apache.isis.core.runtime.installers.InstallerLookupDefault;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.SystemConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.viewer.junit.internal.IsisSystemUsingInstallersWithinJunit;
-
-/**
- * Copied from JMock, and with the same support.
- *
- */
-public class IsisTestRunner extends JUnit4ClassRunner {
-
- private final Field mockeryField;
-
- /**
- * Only used during object construction.
- */
- public IsisTestRunner(final Class<?> testClass) throws InitializationError {
- super(testClass);
-
- // JMock initialization, adapted to allow for no mockery field.
- mockeryField = findFieldAndMakeAccessible(testClass, Mockery.class);
- }
-
- private static String getConfigDir(final Class<?> javaClass) {
- final ConfigDir fixturesAnnotation = javaClass.getAnnotation(ConfigDir.class);
- if (fixturesAnnotation != null) {
- return fixturesAnnotation.value();
- }
- return null;
- }
-
- @Override
- protected void invokeTestMethod(final Method method, final RunNotifier notifier) {
-
- final TestClass testClass = getTestClass();
- final String configDirIfAny = getConfigDir(testClass.getJavaClass());
-
- final Description description = methodDescription(method);
-
- final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderDefault(configDirIfAny);
- isisConfigurationBuilder.add(SystemConstants.NOSPLASH_KEY, "" + true); // switch
- // off
- // splash
-
- final InstallerLookupDefault installerLookup = new InstallerLookupDefault();
- isisConfigurationBuilder.injectInto(installerLookup);
- installerLookup.init();
-
- IsisSystemUsingInstallersWithinJunit system = null;
- AuthenticationSession session = null;
- try {
- // init the system; cf similar code in Isis and
- // IsisServletContextInitializer
- final DeploymentType deploymentType = DeploymentType.PROTOTYPE;
-
- // TODO: replace with regular IsisSystem and remove this subclass.
- system = new IsisSystemUsingInstallersWithinJunit(deploymentType, installerLookup, testClass);
-
- system.init();
-
- // specific to this bootstrap mechanism
- AuthenticationRequest request;
- final LogonFixture logonFixture = system.getFixturesInstaller().getLogonFixture();
- if (logonFixture != null) {
- request = new AuthenticationRequestLogonFixture(logonFixture);
- } else {
- request = new AuthenticationRequestExploration(logonFixture);
- }
- session = IsisContext.getAuthenticationManager().authenticate(request);
-
- IsisContext.openSession(session);
- getTransactionManager().startTransaction();
-
- final Object test = createTest();
- getServicesInjector().injectServicesInto(test);
-
- final TestMethod testMethod = wrapMethod(method);
- new MethodRoadie(test, testMethod, notifier, description).run();
-
- getTransactionManager().endTransaction();
-
- } catch (final InvocationTargetException e) {
- testAborted(notifier, description, e.getCause());
- getTransactionManager().abortTransaction();
- return;
- } catch (final Exception e) {
- testAborted(notifier, description, e);
- return;
- } finally {
- if (system != null) {
- if (session != null) {
- IsisContext.closeSession();
- }
- system.shutdown();
- }
- }
- }
-
- private void testAborted(final RunNotifier notifier, final Description description, final Throwable e) {
- notifier.fireTestStarted(description);
- notifier.fireTestFailure(new Failure(description, e));
- notifier.fireTestFinished(description);
- }
-
- /**
- * Taken from JMock's runner.
- */
- @Override
- protected TestMethod wrapMethod(final Method method) {
- return new TestMethod(method, getTestClass()) {
- @Override
- public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException {
-
- super.invoke(testFixture);
-
- if (mockeryField != null) {
- mockeryOf(testFixture).assertIsSatisfied();
- }
- }
- };
- }
-
- /**
- * JMock code.
- *
- * @param test
- * @return
- */
- protected Mockery mockeryOf(final Object test) {
- if (mockeryField == null) {
- return null;
- }
- try {
- final Mockery mockery = (Mockery) mockeryField.get(test);
- if (mockery == null) {
- throw new IllegalStateException(String.format("Mockery named '%s' is null", mockeryField.getName()));
- }
- return mockery;
- } catch (final IllegalAccessException e) {
- throw new IllegalStateException(String.format("cannot get value of field %s", mockeryField.getName()), e);
- }
- }
-
- /**
- * Adapted from JMock code.
- */
- static Field findFieldAndMakeAccessible(final Class<?> testClass, final Class<?> clazz) throws InitializationError {
- for (Class<?> c = testClass; c != Object.class; c = c.getSuperclass()) {
- for (final Field field : c.getDeclaredFields()) {
- if (clazz.isAssignableFrom(field.getType())) {
- field.setAccessible(true);
- return field;
- }
- }
- }
- return null;
- }
-
- // /////////////////////////////////////////////////////
- // Dependencies (from context)
- // /////////////////////////////////////////////////////
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- private static ServicesInjectorSpi getServicesInjector() {
- return getPersistenceSession().getServicesInjector();
- }
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
deleted file mode 100644
index c7d59e3..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
+++ /dev/null
@@ -1,32 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Persistor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java
deleted file mode 100644
index 6cc809c..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java
+++ /dev/null
@@ -1,33 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Service {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java
deleted file mode 100644
index 81b09f5..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java
+++ /dev/null
@@ -1,33 +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.viewer.junit;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Services {
- Service[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
deleted file mode 100644
index 7c78163..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
+++ /dev/null
@@ -1,96 +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.viewer.junit.internal;
-
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
-import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
-import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
-import org.apache.isis.viewer.junit.Authenticator;
-import org.apache.isis.viewer.junit.Authorizor;
-import org.apache.isis.viewer.junit.Persistor;
-
-public class AnnotationInstaller {
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- // {{ AuthenticationManagerInstaller
- public AuthenticationManagerInstaller addAuthenticatorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authenticator authenticatorAnnotation = javaClass.getAnnotation(Authenticator.class);
- if (authenticatorAnnotation != null) {
- return addAuthenticatorRepresentedBy(authenticatorAnnotation);
- } else {
- return new BypassAuthenticationManagerInstaller();
- }
-
- }
-
- private AuthenticationManagerInstaller addAuthenticatorRepresentedBy(final Authenticator authenticatorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authenticatorAnnotation.value();
- return (AuthenticationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ AuthorizationManagerInstaller
- public AuthorizationManagerInstaller addAuthorizerAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authorizor authorizorAnnotation = javaClass.getAnnotation(Authorizor.class);
- if (authorizorAnnotation != null) {
- return addAuthorizerRepresentedBy(authorizorAnnotation);
- } else {
- return new BypassAuthorizationManagerInstaller();
- }
-
- }
-
- private AuthorizationManagerInstaller addAuthorizerRepresentedBy(final Authorizor authorizorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authorizorAnnotation.value();
- return (AuthorizationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ PersistenceMechanismInstaller
- public PersistenceMechanismInstaller addPersistorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Persistor annotation = javaClass.getAnnotation(Persistor.class);
- if (annotation != null) {
- return addPersistorRepresentedBy(annotation);
- } else {
- return new InMemoryPersistenceMechanismInstaller();
- }
-
- }
-
- private PersistenceMechanismInstaller addPersistorRepresentedBy(final Persistor annotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = annotation.value();
- return (PersistenceMechanismInstaller) fixtureClass.newInstance();
- }
- // }}
-
- // new InMemoryUserProfileStoreInstaller();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java
deleted file mode 100644
index d37709e..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.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.viewer.junit.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerAbstract;
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
-
-public class FixtureInstallerAnnotatedClass extends FixturesInstallerAbstract {
-
- private final List<Object> fixtures = new ArrayList<Object>();
-
- /**
- * @see #addFixturesAnnotatedOn(Class)
- */
- public FixtureInstallerAnnotatedClass() {
- super("annotated");
- }
-
- // ///////////////////////////////////////////
- // Hook method
- // ///////////////////////////////////////////
-
- /**
- * Just copies the fixtures added using
- * {@link #addFixturesAnnotatedOn(Class)} into the delegate.
- */
- @Override
- protected void addFixturesTo(final FixturesInstallerDelegate delegate) {
- for (final Object fixture : fixtures) {
- delegate.addFixture(fixture);
- }
- }
-
- // ///////////////////////////////////////////
- // addFixturesAnnotatedOn (not API)
- // ///////////////////////////////////////////
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- public void addFixturesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Fixtures fixturesAnnotation = javaClass.getAnnotation(Fixtures.class);
- if (fixturesAnnotation != null) {
- final Fixture[] fixtureAnnotations = fixturesAnnotation.value();
- for (final Fixture fixtureAnnotation : fixtureAnnotations) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- final Fixture fixtureAnnotation = javaClass.getAnnotation(Fixture.class);
- if (fixtureAnnotation != null) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- private void addFixtureRepresentedBy(final Fixture fixtureAnnotation, final List<Object> fixtures) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = fixtureAnnotation.value();
- fixtures.add(fixtureClass.newInstance());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
deleted file mode 100644
index 0c31c48..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
+++ /dev/null
@@ -1,77 +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.viewer.junit.internal;
-
-import org.junit.internal.runners.TestClass;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.profilestore.InMemoryUserProfileStoreInstaller;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemUsingInstallers;
-
-public class IsisSystemUsingInstallersWithinJunit extends IsisSystemUsingInstallers {
-
- private final TestClass testClass;
-
- public IsisSystemUsingInstallersWithinJunit(final DeploymentType deploymentType, final InstallerLookup installerLookup, final TestClass testClass) {
- super(deploymentType, installerLookup);
- installerLookup.getConfigurationBuilder().add("isis.deploymentType", deploymentType.nameLowerCase());
-
- this.testClass = testClass;
-
- final AnnotationInstaller installer = new AnnotationInstaller();
-
- try {
- setAuthenticationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthenticatorAnnotatedOn(this.testClass.getJavaClass())));
-
- setAuthorizationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthorizerAnnotatedOn(this.testClass.getJavaClass())));
-
- setPersistenceMechanismInstaller(getInstallerLookup().injectDependenciesInto(installer.addPersistorAnnotatedOn(this.testClass.getJavaClass())));
-
- setUserProfileStoreInstaller(getInstallerLookup().injectDependenciesInto(new InMemoryUserProfileStoreInstaller()));
-
- // fixture installer
- final FixtureInstallerAnnotatedClass fixtureInstaller = new FixtureInstallerAnnotatedClass();
- fixtureInstaller.addFixturesAnnotatedOn(this.testClass.getJavaClass());
- setFixtureInstaller(fixtureInstaller);
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
-
- // services installer
- final ServicesInstallerAnnotatedClass servicesInstaller = new ServicesInstallerAnnotatedClass();
- try {
- servicesInstaller.addServicesAnnotatedOn(this.testClass.getJavaClass());
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
- setServicesInstaller(servicesInstaller);
- }
-
- public TestClass getTestClass() {
- return testClass;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java
deleted file mode 100644
index 646df12..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.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.viewer.junit.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.runtime.services.ServicesInstallerAbstract;
-import org.apache.isis.viewer.junit.Service;
-import org.apache.isis.viewer.junit.Services;
-
-public class ServicesInstallerAnnotatedClass extends ServicesInstallerAbstract {
-
- public ServicesInstallerAnnotatedClass() {
- super("annotated");
- }
-
- public void addServicesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final List<Object> services = new ArrayList<Object>();
- addServicesAnnotatedOn(javaClass, services);
- addServices(services);
- }
-
- private void addServicesAnnotatedOn(final Class<?> testClass, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Services servicesAnnotation = testClass.getAnnotation(Services.class);
- if (servicesAnnotation != null) {
- final Service[] serviceAnnotations = servicesAnnotation.value();
- for (final Service serviceAnnotation : serviceAnnotations) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- final Service serviceAnnotation = testClass.getAnnotation(Service.class);
- if (serviceAnnotation != null) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- private void addServiceRepresentedBy(final Service serviceAnnotation, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Class<?> serviceClass = serviceAnnotation.value();
- // there's no need to unravel any Collections of services,
- // because the ServiceLoader will do it for us later.
- services.add(serviceClass.newInstance());
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class); // ie List<Object.class>, of services
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java
deleted file mode 100644
index 85a0027..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.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.viewer.junit;
-
-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.wrapper.WrapperFactory;
-import org.apache.isis.core.wrapper.WrapperFactoryDefault;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-import org.apache.isis.viewer.junit.sample.domain.Customer;
-import org.apache.isis.viewer.junit.sample.domain.Product;
-import org.apache.isis.viewer.junit.sample.fixtures.CountriesFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.CustomerOrdersFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.CustomersFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.ProductsFixture;
-import org.apache.isis.viewer.junit.sample.service.CountryRepository;
-import org.apache.isis.viewer.junit.sample.service.CustomerRepository;
-import org.apache.isis.viewer.junit.sample.service.OrderRepository;
-import org.apache.isis.viewer.junit.sample.service.ProductRepository;
-
-@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) })
-public abstract class AbstractTest {
-
- protected Customer custJsDO;
- protected Customer custJsWO;
-
- protected Product product355DO;
- protected Product product355VO;
-
- protected Product product850DO;
-
- protected Country countryGbrDO;
- protected Country countryGbrVO;
-
- 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");
- product355VO = wrapperFactory.wrap(product355DO);
- product850DO = productRepository.findByCode("850-18003");
-
- countryGbrDO = countryRepository.findByCode("GBR");
- countryGbrVO = wrapperFactory.wrap(countryGbrDO);
-
- countryUsaDO = countryRepository.findByCode("USA");
- countryAusDO = countryRepository.findByCode("AUS");
-
- custJsDO = customerRepository.findByName("Pawson");
- custJsWO = wrapperFactory.wrap(custJsDO);
- }
-
- @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/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java
deleted file mode 100644
index cc90c9d..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/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.viewer.junit;
-
-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/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java
deleted file mode 100644
index 9cb9cd2..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/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.viewer.junit;
-
-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.viewer.junit.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/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
deleted file mode 100644
index 0bb145b..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
+++ /dev/null
@@ -1,131 +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.viewer.junit;
-
-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.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.DisabledException;
-import org.apache.isis.core.progmodel.facets.members.disabled.annotation.DisabledFacetAnnotation;
-import org.apache.isis.core.progmodel.facets.members.disabled.method.DisableForContextFacetViaMethod;
-import org.apache.isis.viewer.junit.sample.domain.Order;
-
-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(), equalTo("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(), equalTo("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(), equalTo("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(), equalTo("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(DisabledFacetAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("More Orders"));
- assertThat(ex.getMessage(), equalTo("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(), equalTo("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(), equalTo("cannot invoke"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
deleted file mode 100644
index d8cb0c8..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
+++ /dev/null
@@ -1,357 +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.viewer.junit;
-
-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.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.HiddenException;
-import org.apache.isis.core.progmodel.facets.members.hidden.annotation.HiddenFacetForMemberAnnotation;
-import org.apache.isis.core.progmodel.facets.members.hidden.forsession.HideForSessionFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.members.hidden.method.HideForContextFacetViaMethod;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-
-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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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(HiddenFacetForMemberAnnotation.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/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
deleted file mode 100644
index 3ef955f..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
+++ /dev/null
@@ -1,189 +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.viewer.junit;
-
-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.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.InvalidException;
-import org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacetDefault;
-import org.apache.isis.core.progmodel.facets.actions.validate.method.ActionValidationFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateAddToFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.properties.validate.maxlenannot.MaxLengthFacetAnnotationForProperty;
-import org.apache.isis.core.progmodel.facets.properties.validate.regexannot.RegExFacetAnnotationForProperty;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-
-public class MemberInvalidTest extends AbstractTest {
-
- @Test
- public void whenValueInvalidImperativelyThenThrowsException() {
- final String[] values = new String[] { "Dick", null };
- 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(), equalTo("bad first name"));
- }
- }
- }
-
- @Test
- public void whenAssociationInvalidImperativelyThenThrowsException() {
- custJsDO.validateCountryOfBirth = "bad country of birth";
- final Country[] values = new Country[] { countryUsaDO, null };
- 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(), equalTo("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(), equalTo("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(), equalTo("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(), equalTo("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(MaxLengthFacetAnnotationForProperty.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(RegExFacetAnnotationForProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Insensitive Field"));
- }
- }
-
- @Test
- public void whenCanSetValidRegExCaseInsensitive() {
- custJsWO.setRegExCaseInsensitiveField("AbCfoobar");
- }
-
-}