|
| 1 | +/* |
| 2 | + * Copyright (c) 2016-2019 Contributors to the Eclipse Foundation |
| 3 | + * |
| 4 | + * See the NOTICE file(s) distributed with this work for additional |
| 5 | + * information regarding copyright ownership. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * You may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * |
| 19 | + */ |
| 20 | +package org.eclipse.microprofile.config.tck.broken; |
| 21 | + |
| 22 | +import javax.enterprise.inject.spi.DeploymentException; |
| 23 | + |
| 24 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 25 | +import org.jboss.arquillian.container.test.api.ShouldThrowException; |
| 26 | +import org.jboss.arquillian.testng.Arquillian; |
| 27 | +import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 28 | +import org.jboss.shrinkwrap.api.asset.EmptyAsset; |
| 29 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; |
| 30 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 31 | +import org.testng.annotations.Test; |
| 32 | + |
| 33 | +/** |
| 34 | + * A test to verify that a {@link |
| 35 | + * org.eclipse.microprofile.config.inject.ConfigProperty}-annotated |
| 36 | + * injection point in an observer method with a payload that is not an |
| 37 | + * instance of {@link java.util.Optional} that does not have a |
| 38 | + * corresponding configuration property value set will cause a {@link |
| 39 | + * DeploymentException} to be thrown. |
| 40 | + * |
| 41 | + * @author <a href="https://about.me/lairdnelson" |
| 42 | + * target="_parent">Laird Nelson</a> |
| 43 | + */ |
| 44 | +public class MissingValueOnObserverMethodInjectionTest extends Arquillian { |
| 45 | + |
| 46 | + @ShouldThrowException(DeploymentException.class) |
| 47 | + @Deployment |
| 48 | + public static WebArchive deploy() { |
| 49 | + JavaArchive testJar = ShrinkWrap |
| 50 | + .create(JavaArchive.class, "missingValueOnObserverMethodInjectionTest.jar") |
| 51 | + .addClass(ConfigObserver.class) |
| 52 | + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") |
| 53 | + .as(JavaArchive.class); |
| 54 | + |
| 55 | + WebArchive war = ShrinkWrap |
| 56 | + .create(WebArchive.class, "missingValueOnObserverMethodInjectionTest.war") |
| 57 | + .addAsLibrary(testJar); |
| 58 | + return war; |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void test() { |
| 63 | + } |
| 64 | + |
| 65 | +} |
0 commit comments