polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject polygene-java git commit: POLYGENE-121 : Validated that reporting is correct and the issue can be closed.
Date Thu, 19 Apr 2018 03:51:47 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 71bad2987 -> 7489e06b5


POLYGENE-121 : Validated that reporting is correct and the issue can be closed.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/7489e06b
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/7489e06b
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/7489e06b

Branch: refs/heads/develop
Commit: 7489e06b5b74a5336bab2db0c5b205e82092c26d
Parents: 71bad29
Author: niclas <niclas@hedhman.org>
Authored: Thu Apr 19 11:51:41 2018 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Thu Apr 19 11:51:41 2018 +0800

----------------------------------------------------------------------
 .../constraints/HostPortConstraintTest.java     | 31 ++++++++++++++++++++
 1 file changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7489e06b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java
b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java
index 75d525a..ea85d6f 100644
--- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java
+++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java
@@ -20,7 +20,10 @@
 package org.apache.polygene.library.constraints;
 
 import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.composite.TransientBuilder;
 import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.mixin.NoopMixin;
 import org.apache.polygene.api.property.Property;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -84,6 +87,27 @@ public class HostPortConstraintTest extends AbstractPolygeneTest
     }
 
     @Test
+    public void givenInvalidHostNameWhenConstructingExpectConstrainViolation()
+        throws Exception
+    {
+        TransientBuilder<SomeValue> builder = transientBuilderFactory.newTransientBuilder(
SomeValue.class );
+        assertThrows( ConstraintViolationException.class, () -> {
+            builder.prototype().hostPort().set( "1:2:3_i:1234" );
+            builder.newInstance();
+        } );
+    }
+
+    @Test
+    public void givenInvalidHostNameWhenCallingServiceExpectConstrainViolation()
+        throws Exception
+    {
+        SomeService someService = serviceFinder.findService( SomeService.class ).get();
+        assertThrows( ConstraintViolationException.class, () -> {
+            someService.doSomething( "1:2:3_i:1234" );
+        } );
+    }
+
+    @Test
     public void givenInvalidPortNumberWhenSettingPropertyExpectConstrainViolation()
         throws Exception
     {
@@ -114,6 +138,7 @@ public class HostPortConstraintTest extends AbstractPolygeneTest
         throws AssemblyException
     {
         module.transients( SomeValue.class );
+        module.services( SomeService.class );
     }
 
     public interface SomeValue
@@ -122,4 +147,10 @@ public class HostPortConstraintTest extends AbstractPolygeneTest
         @Optional
         Property<String> hostPort();
     }
+
+    @Mixins( NoopMixin.class )
+    public interface SomeService
+    {
+        void doSomething(@HostPort String hostPort);
+    }
 }


Mime
View raw message