You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/05/11 10:23:40 UTC

[isis] 01/02: ISIS-2112: fixes all 'runtime*' tests

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch 2112_SpringBoot
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 5fc2af3f25077af8c0ced97a58c82d4496f61685
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat May 11 12:07:09 2019 +0200

    ISIS-2112: fixes all 'runtime*' tests
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-2112
---
 .../isis/applib/services/i18n/LocaleProvider.java      |  3 ---
 .../isis/applib/services/i18n/TranslationService.java  |  5 -----
 .../runtime/services/i18n/po/TranslationServicePo.java | 18 +++---------------
 .../core/runtime/services/i18n/po/PoReaderTest.java    | 10 +++++++---
 4 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java
index f5656cb..a5854f5 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java
@@ -20,10 +20,7 @@ package org.apache.isis.applib.services.i18n;
 
 import java.util.Locale;
 
-import org.apache.isis.applib.annotation.Programmatic;
-
 public interface LocaleProvider {
 
-    @Programmatic
     Locale getLocale();
 }
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
index f3b04b8..daa723a 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
@@ -21,8 +21,6 @@ package org.apache.isis.applib.services.i18n;
 import java.util.Objects;
 import java.util.function.Predicate;
 
-import org.apache.isis.applib.annotation.Programmatic;
-
 public interface TranslationService {
 
     /**
@@ -36,7 +34,6 @@ public interface TranslationService {
      * @param text
      * @return
      */
-    @Programmatic
     public String translate(final String context, final String text);
 
     /**
@@ -53,7 +50,6 @@ public interface TranslationService {
      * @param num - whether to return the translation of the singular (if =1) or of the plural (if != 1)
      * @return
      */
-    @Programmatic
     public String translate(final String context, final String singularText, final String pluralText, int num);
 
 
@@ -108,6 +104,5 @@ public interface TranslationService {
      *     such that all pathways are exercised..
      * </p>
      */
-    @Programmatic
     Mode getMode();
 }
diff --git a/core/runtime-services/src/main/java/org/apache/isis/core/runtime/services/i18n/po/TranslationServicePo.java b/core/runtime-services/src/main/java/org/apache/isis/core/runtime/services/i18n/po/TranslationServicePo.java
index 0e2cc19..77fc8eb 100644
--- a/core/runtime-services/src/main/java/org/apache/isis/core/runtime/services/i18n/po/TranslationServicePo.java
+++ b/core/runtime-services/src/main/java/org/apache/isis/core/runtime/services/i18n/po/TranslationServicePo.java
@@ -18,11 +18,12 @@
  */
 package org.apache.isis.core.runtime.services.i18n.po;
 
+import static org.apache.isis.config.internal._Config.getConfiguration;
+
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Singleton;
 
-import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.i18n.LocaleProvider;
 import org.apache.isis.applib.services.i18n.TranslationService;
 import org.apache.isis.applib.services.i18n.TranslationsResolver;
@@ -31,8 +32,6 @@ import org.apache.isis.commons.internal.context._Context;
 import org.apache.isis.core.commons.collections.Bin;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 
-import static org.apache.isis.config.internal._Config.getConfiguration;
-
 @Singleton
 public class TranslationServicePo implements TranslationService {
 
@@ -50,7 +49,6 @@ public class TranslationServicePo implements TranslationService {
 
     // -- init, shutdown
 
-    @Programmatic
     @PostConstruct
     public void init() {
 
@@ -87,16 +85,12 @@ public class TranslationServicePo implements TranslationService {
         return _Context.isPrototyping();
     }
 
-    @Programmatic
     @PreDestroy
     public void shutdown() {
         po.shutdown();
     }
 
-
-
     @Override
-    @Programmatic
     public String translate(final String context, final String text) {
         return po.translate(context, text);
     }
@@ -114,7 +108,6 @@ public class TranslationServicePo implements TranslationService {
     /**
      * Not API
      */
-    @Programmatic
     public String toPot() {
         if (!getMode().isWrite()) {
             return null;
@@ -128,7 +121,6 @@ public class TranslationServicePo implements TranslationService {
     /**
      * Not API
      */
-    @Programmatic
     void clearCache() {
         if (!getMode().isRead()) {
             return;
@@ -142,7 +134,6 @@ public class TranslationServicePo implements TranslationService {
     /**
      * Not API
      */
-    @Programmatic
     public void toggleMode() {
         if(getMode().isRead()) {
             previousPoReader = (PoReader) po;
@@ -164,13 +155,11 @@ public class TranslationServicePo implements TranslationService {
         }
     }
 
-    // //////////////////////////////////////
-
+    // -- DEPENDENCIES
     
     private _Lazy<Bin<TranslationsResolver>> translationsResolvers = _Lazy.threadSafe(()->
         IsisContext.getServiceRegistry().select(TranslationsResolver.class) );
 
-    @Programmatic
     Bin<TranslationsResolver> getTranslationsResolver() {
         return translationsResolvers.get();
     }
@@ -178,7 +167,6 @@ public class TranslationServicePo implements TranslationService {
     private _Lazy<Bin<LocaleProvider>> localeProviders = _Lazy.threadSafe(()->
         IsisContext.getServiceRegistry().select(LocaleProvider.class) );
 
-    @Programmatic
     Bin<LocaleProvider> getLocaleProvider() {
         return localeProviders.get();
     }
diff --git a/core/runtime-services/src/test/java/org/apache/isis/core/runtime/services/i18n/po/PoReaderTest.java b/core/runtime-services/src/test/java/org/apache/isis/core/runtime/services/i18n/po/PoReaderTest.java
index b696742..6fb1880 100644
--- a/core/runtime-services/src/test/java/org/apache/isis/core/runtime/services/i18n/po/PoReaderTest.java
+++ b/core/runtime-services/src/test/java/org/apache/isis/core/runtime/services/i18n/po/PoReaderTest.java
@@ -31,6 +31,7 @@ import org.junit.Test;
 import org.apache.isis.applib.services.i18n.LocaleProvider;
 import org.apache.isis.applib.services.i18n.TranslationsResolver;
 import org.apache.isis.commons.internal.collections._Lists;
+import org.apache.isis.core.commons.collections.Bin;
 import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -53,21 +54,24 @@ public class PoReaderTest {
         
         context.checking(new Expectations() {{
             allowing(mockTranslationServicePo).getLocaleProvider();
-            will(returnValue(mockLocaleProvider));
+            will(returnValue(Bin.ofSingleton(mockLocaleProvider)));
 
             allowing(mockTranslationServicePo).getTranslationsResolver();
-            will(returnValue(mockTranslationsResolver));
+            will(returnValue(Bin.ofSingleton(mockTranslationsResolver)));
 
             allowing(mockLocaleProvider).getLocale();
             will(returnValue(Locale.UK));
         }});
         
+    }
+    
+    @Test
+    public void properMockeryOfNonPublicMethods() {
         //[ahuber] with update of byte-buddy 1.8.0 -> 1.9.2, Apache Isis runs on JDK 11+, 
         // we explicitly test proper mockery of non-public methods here ...  
         Assert.assertNotNull(mockTranslationServicePo.getLocaleProvider());
         Assert.assertNotNull(mockTranslationServicePo.getTranslationsResolver());
         Assert.assertNotNull(mockLocaleProvider.getLocale());
-        
     }
 
     public static class Translate extends PoReaderTest {