openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1815032 - in /openwebbeans/meecrowave/trunk/meecrowave-core/src: main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java
Date Sun, 12 Nov 2017 16:42:38 GMT
Author: rmannibucau
Date: Sun Nov 12 16:42:37 2017
New Revision: 1815032

URL: http://svn.apache.org/viewvc?rev=1815032&view=rev
Log:
avoid to use port 8080 by default in tests

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java?rev=1815032&r1=1815031&r2=1815032&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializer.java
Sun Nov 12 16:42:37 2017
@@ -63,7 +63,8 @@ public class MeecrowaveSeContainerInitia
         }
 
         final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1);
-        final Optional<Method> setterOpt = Stream.of(builder.getClass().getMethods())
+        final Class<? extends Meecrowave.Builder> builderClass = builder.getClass();
+        final Optional<Method> setterOpt = Stream.of(builderClass.getMethods())
                 .filter(m -> m.getName().equals(setter) && m.getParameterCount()
== 1)
                 .findFirst();
         if (!setterOpt.isPresent()) {
@@ -73,8 +74,30 @@ public class MeecrowaveSeContainerInitia
         }
 
         try {
-            builder.getClass().getMethod(setter, o.getClass()).invoke(builder, o);
-        } catch (final IllegalAccessException | NoSuchMethodException | InvocationTargetException
ex) {
+            builderClass.getMethod(setter, o.getClass()).invoke(builder, o);
+        } catch (final NoSuchMethodException nsme) {
+            if (Integer.class.isInstance(o)) {
+                try {
+                    builderClass.getMethod(setter, int.class).invoke(builder, o);
+                } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException
ex) {
+                    throw new IllegalArgumentException(nsme);
+                }
+            } else if (Long.class.isInstance(o)) {
+                try {
+                    builderClass.getMethod(setter, long.class).invoke(builder, o);
+                } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException
ex) {
+                    throw new IllegalArgumentException(nsme);
+                }
+            } else if (Boolean.class.isInstance(o)) {
+                try {
+                    builderClass.getMethod(setter, boolean.class).invoke(builder, o);
+                } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException
ex) {
+                    throw new IllegalArgumentException(nsme);
+                }
+            } else {
+                throw new IllegalArgumentException(nsme);
+            }
+        } catch (final IllegalAccessException | InvocationTargetException ex) {
             throw new IllegalArgumentException(ex);
         }
         return this;

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java?rev=1815032&r1=1815031&r2=1815032&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/cdi/MeecrowaveSeContainerInitializerTest.java
Sun Nov 12 16:42:37 2017
@@ -39,6 +39,7 @@ public class MeecrowaveSeContainerInitia
     @Test
     public void run() {
         try (final SeContainer container = SeContainerInitializer.newInstance()
+                .addProperty("httpPort", new Meecrowave.Builder().randomHttpPort().getHttpPort())
                 .disableDiscovery()
                 .addBeanClasses(Configured.class)
                 .initialize()) {



Mime
View raw message