Issue #23507 hk2-config use junit5 instead of junit4
- also moved "example" impl to own package and formatted definitions so now it
makes a bit more sense (to me at least)
diff --git a/nucleus/hk2/config-types/src/test/java/org/jvnet/hk2/config/types/test/ConfigTypesTest.java b/nucleus/hk2/config-types/src/test/java/org/jvnet/hk2/config/types/test/ConfigTypesTest.java
index 2724957..a91dc9d 100644
--- a/nucleus/hk2/config-types/src/test/java/org/jvnet/hk2/config/types/test/ConfigTypesTest.java
+++ b/nucleus/hk2/config-types/src/test/java/org/jvnet/hk2/config/types/test/ConfigTypesTest.java
@@ -31,7 +31,6 @@
* Tests for specialized config types
*
* @author jwells
- *
*/
public class ConfigTypesTest {
diff --git a/nucleus/hk2/hk2-config/pom.xml b/nucleus/hk2/hk2-config/pom.xml
index fd6388f..8ccb1a0 100644
--- a/nucleus/hk2/hk2-config/pom.xml
+++ b/nucleus/hk2/hk2-config/pom.xml
@@ -59,6 +59,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigDisposalTest.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigDisposalTest.java
index 9247950..6fdd6d1 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigDisposalTest.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigDisposalTest.java
@@ -16,11 +16,7 @@
package org.jvnet.hk2.config.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import java.beans.PropertyVetoException;
import java.net.URL;
import java.util.List;
import java.util.Random;
@@ -30,207 +26,197 @@
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.api.ServiceLocatorFactory;
import org.glassfish.hk2.utilities.BuilderHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.hk2.config.ConfigParser;
import org.jvnet.hk2.config.ConfigSupport;
import org.jvnet.hk2.config.DomDocument;
import org.jvnet.hk2.config.SingleConfigCode;
import org.jvnet.hk2.config.TransactionFailure;
+import org.jvnet.hk2.config.test.example.ConfigModule;
+import org.jvnet.hk2.config.test.example.GenericConfig;
+import org.jvnet.hk2.config.test.example.GenericContainer;
+import org.jvnet.hk2.config.test.example.SimpleConnector;
+import org.jvnet.hk2.config.test.example.SimpleDocument;
+import org.jvnet.hk2.config.test.example.WebContainerAvailability;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class ConfigDisposalTest {
private final static String TEST_NAME = "ConfigDisposal";
private final static Random RANDOM = new Random();
- private ServiceLocator habitat;
+ private ServiceLocator locator;
- @Before
+ @BeforeEach
public void before() {
String testName = TEST_NAME + RANDOM.nextInt();
- habitat = ServiceLocatorFactory.getInstance().create(testName);
- DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
+ locator = ServiceLocatorFactory.getInstance().create(testName);
+ DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
- new ConfigModule(habitat).configure(config);
+ new ConfigModule(locator).configure(config);
config.commit();
parseDomainXml();
}
- @After
+ @AfterEach
public void after() {
- ServiceLocatorFactory.getInstance().destroy(habitat);
- habitat = null;
+ ServiceLocatorFactory.getInstance().destroy(locator);
+ locator = null;
}
public void parseDomainXml() {
- ConfigParser parser = new ConfigParser(habitat);
- URL url = ConfigDisposalTest.class.getResource("/domain.xml");
- System.out.println("URL : " + url);
-
- try {
- DomDocument doc = parser.parse(url, new SimpleDocument(habitat));
- System.out.println("[parseDomainXml] ==> Successfully parsed");
- assert(doc != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- assert(false);
- }
+ final ConfigParser parser = new ConfigParser(locator);
+ final URL url = ConfigDisposalTest.class.getResource("/domain.xml");
+ assertNotNull(url);
+ final DomDocument<?> doc = parser.parse(url, new SimpleDocument(locator));
+ assertNotNull(doc);
}
- // to regenerate config injectors do the following in command line:
- // mvn config-generator:generate-test-injectors
- // cp target/generated-sources/hk2-config-generator/src/test/java/org/jvnet/hk2/config/test/* src/test/java/org/jvnet/hk2/config/test/
- @Test // Removed container causes nested elements be removed
+ @Test
public void testDisposedNestedAndNamed() throws TransactionFailure {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assertEquals("Extensions", 1, sc.getExtensions().size());
- assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size());
+ SimpleConnector sc = locator.getService(SimpleConnector.class);
+ assertEquals(1, sc.getExtensions().size(), "Extensions");
+ assertEquals(2, sc.getExtensions().get(0).getExtensions().size(), "Nested children");
- ConfigSupport.apply(new SingleConfigCode<SimpleConnector>() {
- @Override
- public Object run(SimpleConnector sc)
- throws PropertyVetoException, TransactionFailure {
- List<GenericContainer> extensions = sc.getExtensions();
- GenericContainer child = extensions.get(extensions.size() - 1);
- extensions.remove(child);
- return child;
- }
- }, sc);
+ SingleConfigCode<SimpleConnector> configCode = sc1 -> {
+ List<GenericContainer> extensions = sc1.getExtensions();
+ GenericContainer child = extensions.get(extensions.size() - 1);
+ extensions.remove(child);
+ return child;
+ };
+ ConfigSupport.apply(configCode, sc);
- assertEquals("Removed extensions", 0, sc.getExtensions().size());
- // NOTE, habitat.getService(GenericConfig.class) creates new instance
- // if not all instances of GenericConfig descriptors are removed
- assertNull("GenericContainer descriptor still has " +
- habitat.getDescriptors(BuilderHelper.createContractFilter(GenericContainer.class.getName())),
- habitat.getService(GenericContainer.class));
- assertNull("GenericConfig descriptor test still has " +
- habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())),
- habitat.getService(GenericConfig.class, "test"));
- assertNull("GenericConfig descriptor still has " +
- habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())),
- habitat.getService(GenericConfig.class));
+ assertAll(
+ () -> assertThat("Removed extensions", sc.getExtensions(), hasSize(0)),
+ // NOTE, habitat.getService(GenericConfig.class) creates new instance
+ // if not all instances of GenericConfig descriptors are removed
+ () -> assertNull(locator.getService(GenericContainer.class), "GenericContainer descriptor still has " +
+ locator.getDescriptors(BuilderHelper.createContractFilter(GenericContainer.class.getName()))),
+ () -> assertNull(locator.getService(GenericConfig.class, "test"), "GenericConfig descriptor test still has " +
+ locator.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName()))),
+ () -> assertNull(locator.getService(GenericConfig.class), "GenericConfig descriptor still has " +
+ locator.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())))
+ );
// assert with VisualVm there is no GenericContainer and GenericConfig instances with OQL query:
// select x.implementation.toString() from org.jvnet.hk2.config.test.SimpleConfigBeanWrapper x
}
@Test
public void testRemoveNamed() throws TransactionFailure {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assertEquals("Eextensions", 1, sc.getExtensions().size());
- assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size());
+ SimpleConnector sc = locator.getService(SimpleConnector.class);
+ assertAll(
+ () -> assertThat("Extensions", sc.getExtensions(), hasSize(1)),
+ () -> assertThat("Nested children", sc.getExtensions().get(0).getExtensions(), hasSize(2))
+ );
GenericContainer extension = sc.getExtensions().get(0);
- ConfigSupport.apply(new SingleConfigCode<GenericContainer>() {
- @Override
- public Object run(GenericContainer container)
- throws PropertyVetoException, TransactionFailure {
- List<GenericConfig> childExtensions = container.getExtensions();
- GenericConfig nestedChild = childExtensions.get(childExtensions.size() - 1);
- childExtensions.remove(nestedChild);
- return nestedChild;
- }
- }, extension);
+ SingleConfigCode<GenericContainer> configCode = container -> {
+ List<GenericConfig> childExtensions = container.getExtensions();
+ GenericConfig nestedChild = childExtensions.get(childExtensions.size() - 1);
+ childExtensions.remove(nestedChild);
+ return nestedChild;
+ };
+ ConfigSupport.apply(configCode, extension);
- assertEquals("Removed extensions", 1, sc.getExtensions().size());
- assertNull("Removed nested named child", habitat.getService(GenericConfig.class, "test2"));
- // make sure other elements are not removed
- assertNotNull("Nested named child", habitat.getService(GenericConfig.class, "test1"));
- assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test"));
+ assertAll(
+ () -> assertThat("Removed Extensions", sc.getExtensions(), hasSize(1)),
+ () -> assertNull(locator.getService(GenericConfig.class, "test2"), "Removed nested named child"),
+ // make sure other elements are not removed
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test1"), "Nested named child"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test"), "Nested named grand child")
+ );
}
@Test
public void testRemovedOne() throws TransactionFailure {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assertEquals("Extensions", 1, sc.getExtensions().size());
+ SimpleConnector connector = locator.getService(SimpleConnector.class);
+ assertEquals(1, connector.getExtensions().size(), "Extensions");
- ConfigSupport.apply(new SingleConfigCode<SimpleConnector>() {
- @Override
- public Object run(SimpleConnector sc)
- throws PropertyVetoException, TransactionFailure {
- List<GenericContainer> extensions = sc.getExtensions();
- GenericContainer child = sc.createChild(GenericContainer.class);
- WebContainerAvailability grandchild = child.createChild(WebContainerAvailability.class);
- child.setWebContainerAvailability(grandchild);
- extensions.add(child);
- return child;
- }
- }, sc);
+ SingleConfigCode<SimpleConnector> configCode = sc -> {
+ List<GenericContainer> extensions = sc.getExtensions();
+ GenericContainer child = sc.createChild(GenericContainer.class);
+ WebContainerAvailability grandchild = child.createChild(WebContainerAvailability.class);
+ child.setWebContainerAvailability(grandchild);
+ extensions.add(child);
+ return child;
+ };
+ ConfigSupport.apply(configCode, connector);
+ assertEquals(2, connector.getExtensions().size(), "Added extensions");
- assertEquals("Added extensions", 2, sc.getExtensions().size());
-
- ConfigSupport.apply(new SingleConfigCode<SimpleConnector>() {
- @Override
- public Object run(SimpleConnector sc)
- throws PropertyVetoException, TransactionFailure {
- List<GenericContainer> extensions = sc.getExtensions();
- GenericContainer child = extensions.get(extensions.size() - 1);
- extensions.remove(child);
- return child;
- }
- }, sc);
-
- assertEquals("Removed extensions", 1, sc.getExtensions().size());
-
- assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1"));
- assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test"));
- assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2"));
- assertNotNull("GenericContainer Service", habitat.getService(GenericContainer.class));
+ SingleConfigCode<SimpleConnector> configCode2 = (SingleConfigCode<SimpleConnector>) sc -> {
+ List<GenericContainer> extensions = sc.getExtensions();
+ GenericContainer child = extensions.get(extensions.size() - 1);
+ extensions.remove(child);
+ return child;
+ };
+ ConfigSupport.apply(configCode2, connector);
+ assertAll(
+ () -> assertThat("Removed extensions", connector.getExtensions(), hasSize(1)),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test1"), "Nested named child 1"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test"), "Nested named grand child"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test2"), "Nested named child 2"),
+ () -> assertNotNull(locator.getService(GenericContainer.class), "GenericContainer Service")
+ );
}
@Test
public void testReplaceNode() throws TransactionFailure {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assertEquals("Eextensions", 1, sc.getExtensions().size());
+ SimpleConnector sc = locator.getService(SimpleConnector.class);
+ assertEquals(1, sc.getExtensions().size(), "Eextensions");
GenericContainer extension = sc.getExtensions().get(0);
- assertEquals("Child extensions", 2, extension.getExtensions().size());
+ assertEquals(2, extension.getExtensions().size(), "Child extensions");
GenericConfig nestedChild = extension.getExtensions().get(0);
- ConfigSupport.apply(new SingleConfigCode<GenericConfig>() {
- @Override
- public Object run(GenericConfig nestedChild)
- throws PropertyVetoException, TransactionFailure {
- nestedChild.setGenericConfig(null);
- GenericConfig newChild = nestedChild.createChild(GenericConfig.class);
- newChild.setName("test3");
- nestedChild.setGenericConfig(newChild);
- return nestedChild;
- }
- }, nestedChild);
+ SingleConfigCode<GenericConfig> configCode = nestedChild1 -> {
+ nestedChild1.setGenericConfig(null);
+ GenericConfig newChild = nestedChild1.createChild(GenericConfig.class);
+ newChild.setName("test3");
+ nestedChild1.setGenericConfig(newChild);
+ return nestedChild1;
+ };
+ ConfigSupport.apply(configCode, nestedChild);
- assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1"));
- assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2"));
- assertNull("Nested named grand child replaced", habitat.getService(GenericConfig.class, "test"));
+ assertAll(
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test1"), "Nested named child 1"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test2"), "Nested named child 2"),
+ () -> assertNull(locator.getService(GenericConfig.class, "test"), "Nested named grand child replaced")
+ );
}
@Test
public void testReplaceChild() throws TransactionFailure {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assertEquals("Eextensions", 1, sc.getExtensions().size());
+ SimpleConnector sc = locator.getService(SimpleConnector.class);
+ assertEquals(1, sc.getExtensions().size(), "Eextensions");
GenericContainer extension = sc.getExtensions().get(0);
- assertEquals("Child extensions", 2, extension.getExtensions().size());
+ assertEquals(2, extension.getExtensions().size(), "Child extensions");
- ConfigSupport.apply(new SingleConfigCode<GenericContainer>() {
- @Override
- public Object run(GenericContainer extension)
- throws PropertyVetoException, TransactionFailure {
- GenericConfig newChild = extension.createChild(GenericConfig.class);
- newChild.setName("test3");
- GenericConfig nestedChild = extension.getExtensions().set(0, newChild);
- return nestedChild;
- }
- }, extension);
+ SingleConfigCode<GenericContainer> configCode = extension1 -> {
+ GenericConfig newChild = extension1.createChild(GenericConfig.class);
+ newChild.setName("test3");
+ GenericConfig nestedChild = extension1.getExtensions().set(0, newChild);
+ return nestedChild;
+ };
+ ConfigSupport.apply(configCode, extension);
- assertEquals("Extensions", 2, extension.getExtensions().size());
- assertNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1"));
- assertNull("Nested named grand child replaced", habitat.getService(GenericConfig.class, "test"));
- assertEquals("New Nested child", "test3", extension.getExtensions().get(0).getName());
- // can't verify it with getService becaue named alias is not created with createChild
- //assertNotNull("New Nested child", habitat.getService(GenericConfig.class, "test3"));
- assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2"));
+ assertAll(
+ () -> assertThat("Extensions", extension.getExtensions(), hasSize(2)),
+ () -> assertNull(locator.getService(GenericConfig.class, "test1"), "Nested named child 1"),
+ () -> assertNull(locator.getService(GenericConfig.class, "test"), "Nested named grand child replaced"),
+ () -> assertEquals("test3", extension.getExtensions().get(0).getName(), "New Nested child"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test3"), "New Nested child"),
+ () -> assertNotNull(locator.getService(GenericConfig.class, "test2"), "Nested named child 2")
+ );
}
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java
index ddbc320..8ce1107 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java
@@ -16,7 +16,13 @@
package org.jvnet.hk2.config.test;
-//import com.sun.enterprise.module.bootstrap.Populator;
+import java.beans.PropertyChangeEvent;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import org.glassfish.hk2.api.ActiveDescriptor;
import org.glassfish.hk2.api.Descriptor;
@@ -26,16 +32,17 @@
import org.glassfish.hk2.api.ServiceHandle;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.api.ServiceLocatorFactory;
-import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.jvnet.hk2.config.ConfigBean;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.jvnet.hk2.config.ConfigBeanProxy;
import org.jvnet.hk2.config.ConfigInjector;
import org.jvnet.hk2.config.ConfigListener;
import org.jvnet.hk2.config.ConfigParser;
import org.jvnet.hk2.config.ConfigSupport;
+import org.jvnet.hk2.config.ConfigView;
import org.jvnet.hk2.config.ConfigurationPopulator;
import org.jvnet.hk2.config.Dom;
import org.jvnet.hk2.config.DomDocument;
@@ -44,17 +51,35 @@
import org.jvnet.hk2.config.ObservableBean;
import org.jvnet.hk2.config.Populator;
import org.jvnet.hk2.config.SingleConfigCode;
-import org.jvnet.hk2.config.TransactionFailure;
import org.jvnet.hk2.config.Transactions;
import org.jvnet.hk2.config.UnprocessedChangeEvents;
import org.jvnet.hk2.config.provider.internal.ConfigInstanceListener;
+import org.jvnet.hk2.config.test.example.ConfigModule;
+import org.jvnet.hk2.config.test.example.DummyPopulator;
+import org.jvnet.hk2.config.test.example.EjbContainerAvailability;
+import org.jvnet.hk2.config.test.example.EjbContainerAvailabilityInjector;
+import org.jvnet.hk2.config.test.example.GenericConfigInjector;
+import org.jvnet.hk2.config.test.example.GenericContainer;
+import org.jvnet.hk2.config.test.example.GenericContainerInjector;
+import org.jvnet.hk2.config.test.example.SimpleConfigBeanWrapper;
+import org.jvnet.hk2.config.test.example.SimpleConnector;
+import org.jvnet.hk2.config.test.example.SimpleConnectorInjector;
+import org.jvnet.hk2.config.test.example.WebContainerAvailabilityInjector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
+import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses;
+import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.getOneMetadataField;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This runs a set of tests to test various habitat and Dom APIs
@@ -62,414 +87,305 @@
*
* @author Mahesh Kannan
*/
+@TestMethodOrder(OrderAnnotation.class)
public class ConfigTest {
- private final static String TEST_NAME = "";
- private final static ServiceLocator habitat = ServiceLocatorFactory.getInstance().create(TEST_NAME);
+ private static final String TEST_NAME = "";
+ private static final ServiceLocator locator = ServiceLocatorFactory.getInstance().create(TEST_NAME);
- @BeforeClass
+ @BeforeAll
public static void before() {
- DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
- DynamicConfiguration config = dcs.createDynamicConfiguration();
- new ConfigModule(habitat).configure(config);
-
+ final DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
+ final DynamicConfiguration config = dcs.createDynamicConfiguration();
+ new ConfigModule(locator).configure(config);
config.commit();
}
- // @Test
+ @Test
+ @Order(1)
public void lookupAllInjectors() {
- String[] expected = {
+ final String[] expected = {
SimpleConnectorInjector.class.getName(), EjbContainerAvailabilityInjector.class.getName(),
WebContainerAvailabilityInjector.class.getName(), GenericContainerInjector.class.getName(),
GenericConfigInjector.class.getName()
};
- List<String> expectedInjectors = Arrays.asList(expected);
-
- List<ServiceHandle<ConfigInjector>> inhabitants = habitat.getAllServiceHandles(ConfigInjector.class);
- Set<String> inhabitantNames = new HashSet<String>();
- for (ServiceHandle<?> inh : inhabitants) {
+ final List<ServiceHandle<ConfigInjector>> inhabitants = locator.getAllServiceHandles(ConfigInjector.class);
+ final Set<String> inhabitantNames = new HashSet<>();
+ for (final ServiceHandle<?> inh : inhabitants) {
inhabitantNames.add(inh.getActiveDescriptor().getImplementation());
}
- assert(inhabitants.size() == expected.length);
- assert(inhabitantNames.containsAll(expectedInjectors));
- }
-
- // @Test
- public void lookupInjectorByName() {
- ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector");
- ServiceHandle inhabitant2 = habitat.getServiceHandle(ConfigInjector.class, "ejb-container-availability");
-
- assert(inhabitant1 != null && inhabitant2 != null
- && inhabitant1.getActiveDescriptor().getImplementation().equals(SimpleConnectorInjector.class.getName())
- && inhabitant2.getActiveDescriptor().getImplementation().equals(EjbContainerAvailabilityInjector.class.getName()));
- }
-
- // @Test
- public void testLookupOfInjectorAndCheckIfActive() {
- ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector");
- ServiceHandle inhabitant2 = habitat.getServiceHandle(ConfigInjector.class, "ejb-container-availability");
- assert(inhabitant1 != null && inhabitant2 != null
- && inhabitant1.isActive() == false
- && inhabitant2.isActive() == false);
- }
-
- // @Test
- public void lookupInjectorByFilter() {
- ActiveDescriptor desc = habitat.getBestDescriptor(
- new InjectionTargetFilter(EjbContainerAvailability.class.getName()));
- assert(desc != null
- && desc.getImplementation().equals(EjbContainerAvailabilityInjector.class.getName()));
- }
-
- // @Test
- public void parseDomainXml() {
- ConfigParser parser = new ConfigParser(habitat);
- URL url = this.getClass().getResource("/domain.xml");
- System.out.println("URL : " + url);
-
- try {
- DomDocument doc = parser.parse(url);
- System.out.println("[parseDomainXml] ==> Successfully parsed");
- assert(doc != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- assert(false);
- }
- }
-
- // @Test
- public void lookupConnectorServiceAndEnsureNotActive() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- System.out.println("[lookupConnectorService] Got sc : " + sc.getClass().getName());
- ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector");
- assert(sc != null && !inhabitant1.isActive());
- }
-
-
- // @Test
- public void getConnectorServiceAndCheckIfActive() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- String port = sc.getPort();
- ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector");
- assert(port.equals("8080")); // && inhabitant1.isActive());
- }
-
- // @Test
- public void testConfig() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- System.out.println("[testConfig] : " + sc.getClass().getName());
- assert(Proxy.isProxyClass(sc.getClass()));
- }
-
- // @Test
- public void testDefaultValuesFromConfig() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- assert(
- sc.getWebContainerAvailability().getPersistenceFrequency().equals("web-method")
- && Boolean.valueOf(sc.getEjbContainerAvailability().getAvailabilityEnabled())
- && sc.getEjbContainerAvailability().getSfsbPersistenceType().equals("file")
- && sc.getEjbContainerAvailability().getSfsbHaPersistenceType().equals("replicated")
+ assertAll(
+ () -> assertThat(inhabitants, hasSize(expected.length)),
+ () -> assertThat(inhabitantNames, containsInAnyOrder(expected))
);
}
- // @Test
- public void testDom() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
-
- assert(Dom.class.isAssignableFrom(Dom.unwrap(ejb).getClass())
- && ConfigBeanProxy.class.isAssignableFrom(ejb.getClass()));
- }
-
- // @Test
- public void testHabitatFromDom() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
-
- Dom ejbDom = Dom.unwrap(ejb);
- assert(ejbDom.getHabitat() != null);
- }
-
- // @Test
- public void testDomTx() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
-
- Dom ejbDom = Dom.unwrap(ejb);
- assert(ejbDom.getHabitat() != null);
-
- String avEnabled = ejb.getAvailabilityEnabled();
- try {
- ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
- @Override
- public Object run(EjbContainerAvailability param)
- throws PropertyVetoException, TransactionFailure {
- param.setSfsbHaPersistenceType("coherence");
- param.setSfsbCheckpointEnabled("**MUST BE**");
- return null;
- }
- }, ejb);
-
- //printEjb("AFTER CHANGES", ejb);
- assert(ejb.getSfsbHaPersistenceType().equals("coherence")
- && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**")
- && ejb.getAvailabilityEnabled().equals(avEnabled));
- } catch (Exception e) {
- e.printStackTrace();
- assert(false);
- }
- }
-
- // @Test
- public void testDomTxReadOnlyAttributes() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- final EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
-
- Dom ejbDom = Dom.unwrap(ejb);
- assert(ejbDom.getHabitat() != null);
-
- String origAVEnabled = ejb.getAvailabilityEnabled();
- final String origSFSBHaPersistenceType = ejb.getSfsbHaPersistenceType();
- try {
- ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
- @Override
- public Object run(EjbContainerAvailability param)
- throws PropertyVetoException, TransactionFailure {
- param.setSfsbHaPersistenceType("99999.999");
- param.setSfsbCheckpointEnabled("**MUST BE**");
-
- assert(origSFSBHaPersistenceType.equals(ejb.getSfsbHaPersistenceType()));
- assert(! ejb.getSfsbHaPersistenceType().equals(param.getSfsbHaPersistenceType()));
- return null;
- }
- }, ejb);
-
- //printEjb("AFTER CHANGES", ejb);
- assert(ejb.getSfsbHaPersistenceType().equals("99999.999")
- && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**")
- && ejb.getAvailabilityEnabled().equals(origAVEnabled));
- } catch (Exception e) {
- e.printStackTrace();
- assert(false);
- }
- }
-
- // @Test
- public void testGetImplAndAddListener() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- final EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
- ObservableBean obean = (ObservableBean) ConfigSupport.getImpl(ejb);
- EjbObservableBean ejbBean = new EjbObservableBean();
-
- assert(ejbBean.getCount() == 0);
- obean.addListener(ejbBean);
- try {
- ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
- @Override
- public Object run(EjbContainerAvailability param)
- throws PropertyVetoException, TransactionFailure {
- param.setSfsbHaPersistenceType("DynamicData");
- param.setSfsbCheckpointEnabled("**MUST BE**");
- assert(! ejb.getSfsbHaPersistenceType().equals(param.getSfsbHaPersistenceType()));
- return null;
- }
- }, ejb);
-
- //printEjb("AFTER CHANGES", ejb);
- assert(ejb.getSfsbHaPersistenceType().equals("DynamicData")
- && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**"));
-
- assert(ejbBean.getCount() == 1);
- } catch (Exception e) {
- e.printStackTrace();
- assert(false);
- }
- try {
- ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
- @Override
- public Object run(EjbContainerAvailability param)
- throws PropertyVetoException, TransactionFailure {
- param.setSfsbHaPersistenceType("DynamicData1");
- param.setSfsbCheckpointEnabled("**MUST BE**");
- assert(! ejb.getSfsbHaPersistenceType().equals(param.getSfsbHaPersistenceType()));
- return null;
- }
- }, ejb);
-
- //printEjb("AFTER CHANGES", ejb);
- assert(ejb.getSfsbHaPersistenceType().equals("DynamicData1")
- && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**"));
-
- assert(ejbBean.getCount() == 2);
-
- System.out.println("getImpl(ejb) == > "
- + ConfigSupport.getImpl(ejb).getClass().getName());
- System.out.println("getImpl(ejb).getMasterView() == > "
- + ConfigSupport.getImpl(ejb).getMasterView().getClass().getName());
- System.out.println("getImpl(ejb).getProxyType() == > "
- + ConfigSupport.getImpl(ejb).getProxyType().getClass().getName());
- } catch (Exception e) {
- e.printStackTrace();
- assert(false);
- }
- }
-
- // @Test
- public void testGetConfigBean() {
- SimpleConnector sc = habitat.getService(SimpleConnector.class);
- final EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
- ConfigBean ejbConfigBean = (ConfigBean) ConfigBean.unwrap(ejb);
-
- assert(ejbConfigBean != null);
- }
-
- // @Test
- public void testGenericContainerInjector() {
- ServiceHandle sh = habitat.getServiceHandle(ConfigInjector.class, "generic-container");
-
- assert(sh != null);
-
- }
-
- // @Test
- public void testLongDataType() {
- GenericContainer gc = habitat.getService(GenericContainer.class);
- Object obj = gc.getStartupTime();
- assert(obj.getClass() == Long.class);
-
- }
-
- // @Test
- public void testIntDataType() {
- GenericContainer gc = habitat.getService(GenericContainer.class);
- Object obj = gc.getIntValue();
- assert(obj.getClass() == Integer.class);
-
- }
-
- // @Test
- public void testConfigurationPopulator() {
- DummyPopulator pop = (DummyPopulator) habitat.getService(Populator.class);
-
- ConfigurationPopulator confPopulator = habitat.getService(ConfigurationPopulator.class);
- confPopulator.populateConfig((ServiceLocator) habitat);
-
- assert(pop.isPopulateCalled());
- }
-
- // @Test
- public void testSingletonProxy() {
- SimpleConnector simpleConnector1 = habitat.getService(SimpleConnector.class);
- SimpleConnector simpleConnector2 = habitat.getService(SimpleConnector.class);
-
- System.out.println("[testSingleProxy] Got simpleConnector1 : " + simpleConnector1.getClass().getName());
- System.out.println("[testSingleProxy] Got simpleConnector2 : " + simpleConnector2.getClass().getName());
-
- assert(simpleConnector1 != null && simpleConnector1 == simpleConnector2);
- }
-
- /**
- * This test is an unfortunate reaction to the fact that JDK 7 does not run the
- * tests above in order, and that the fact that the ordering seems to be important
- * to the passing of the above tests
- */
@Test
- public void runTestsInOrder() {
- lookupAllInjectors();
- lookupInjectorByName();
- testLookupOfInjectorAndCheckIfActive();
- lookupInjectorByFilter();
- parseDomainXml();
- lookupConnectorServiceAndEnsureNotActive();
- getConnectorServiceAndCheckIfActive();
- testConfig();
- testDefaultValuesFromConfig();
- testDom();
- testHabitatFromDom();
- testDomTx();
- testDomTxReadOnlyAttributes();
- testGetImplAndAddListener();
- testGetConfigBean();
- testGenericContainerInjector();
- testLongDataType();
- testIntDataType();
- testConfigurationPopulator();
- testSingletonProxy();
+ @Order(2)
+ public void lookupInjectorByName() {
+ final ServiceHandle<?> inhabitant1 = locator.getServiceHandle(ConfigInjector.class, "simple-connector");
+ final ServiceHandle<?> inhabitant2 = locator.getServiceHandle(ConfigInjector.class, "ejb-container-availability");
+
+ assertAll(
+ () -> assertNotNull(inhabitant1),
+ () -> assertNotNull(inhabitant2)
+ );
+ assertAll(
+ () -> assertEquals(SimpleConnectorInjector.class.getName(),
+ inhabitant1.getActiveDescriptor().getImplementation()),
+ () -> assertEquals(EjbContainerAvailabilityInjector.class.getName(),
+ inhabitant2.getActiveDescriptor().getImplementation()),
+ () -> assertFalse(inhabitant1.isActive()),
+ () -> assertFalse(inhabitant2.isActive())
+
+ );
+ }
+
+ @Test
+ @Order(4)
+ public void lookupInjectorByFilter() {
+ final ActiveDescriptor<?> desc = locator
+ .getBestDescriptor(new InjectionTargetFilter(EjbContainerAvailability.class.getName()));
+ assertNotNull(desc);
+ assertEquals(EjbContainerAvailabilityInjector.class.getName(), desc.getImplementation());
+ }
+
+ @Test
+ @Order(5)
+ public void parseDomainXml() {
+ final ConfigParser parser = new ConfigParser(locator);
+ final URL url = this.getClass().getResource("/domain.xml");
+ assertNotNull(url, "url");
+ final DomDocument<?> doc = parser.parse(url);
+ assertNotNull(doc, "parsed document");
+ }
+
+ @Test
+ @Order(6)
+ public void lookupConnectorServiceAndEnsureNotActive() {
+ final SimpleConnector connector = locator.getService(SimpleConnector.class);
+ assertNotNull(connector, "simple connector");
+ System.out.println("[lookupConnectorService] Got connector : " + connector.getClass().getName());
+ assertNotNull(connector);
+ assertAll(
+ () -> assertEquals("8080", connector.getPort()),
+ () -> assertTrue(Proxy.isProxyClass(connector.getClass()))
+ );
+ final ServiceHandle<?> inhabitant1 = locator.getServiceHandle(ConfigInjector.class, "simple-connector");
+ assertFalse(inhabitant1.isActive());
+ }
+
+
+ @Test
+ @Order(9)
+ public void testDefaultValuesFromConfig() {
+ final SimpleConnector connector = locator.getService(SimpleConnector.class);
+ assertNotNull(connector);
+ assertAll(
+ () -> assertEquals("web-method", connector.getWebContainerAvailability().getPersistenceFrequency()),
+ () -> assertEquals("true", connector.getEjbContainerAvailability().getAvailabilityEnabled()),
+ () -> assertEquals("file", connector.getEjbContainerAvailability().getSfsbPersistenceType()),
+ () -> assertEquals("replicated", connector.getEjbContainerAvailability().getSfsbHaPersistenceType())
+ );
+ }
+
+ @Test
+ @Order(10)
+ public void testDomTx() throws Exception {
+ final SimpleConnector connector = locator.getService(SimpleConnector.class);
+ final EjbContainerAvailability ejb = connector.getEjbContainerAvailability();
+ assertAll(
+ () -> assertTrue(Dom.class.isAssignableFrom(Dom.unwrap(ejb).getClass()), "Dom.class"),
+ () -> assertTrue(ConfigBeanProxy.class.isAssignableFrom(ejb.getClass()), "ConfigBeanProxy.class")
+ );
+ final Dom ejbDom = Dom.unwrap(ejb);
+ assertNotNull(ejbDom.getHabitat(), "ejbDom.habitat");
+
+ final String avEnabled = ejb.getAvailabilityEnabled();
+ final SingleConfigCode<EjbContainerAvailability> configCode = p -> {
+ p.setSfsbHaPersistenceType("coherence");
+ p.setSfsbCheckpointEnabled("**MUST BE**");
+ return null;
+ };
+ ConfigSupport.apply(configCode, ejb);
+
+ assertAll(
+ () -> assertEquals("coherence", ejb.getSfsbHaPersistenceType()),
+ () -> assertEquals("**MUST BE**", ejb.getSfsbCheckpointEnabled()),
+ () -> assertEquals(avEnabled, ejb.getAvailabilityEnabled())
+ );
+ }
+
+ @Test
+ @Order(13)
+ public void testDomTxReadOnlyAttributes() throws Exception {
+ final SimpleConnector connector = locator.getService(SimpleConnector.class);
+ final EjbContainerAvailability ejb = connector.getEjbContainerAvailability();
+ final Dom ejbDom = Dom.unwrap(ejb);
+ assertNotNull(ejbDom.getHabitat(), "ejbDom.habitat");
+
+ final String origAVEnabled = ejb.getAvailabilityEnabled();
+ final String origSFSBHaPersistenceType = ejb.getSfsbHaPersistenceType();
+ final SingleConfigCode<EjbContainerAvailability> configCode = p -> {
+ p.setSfsbHaPersistenceType("99999.999");
+ p.setSfsbCheckpointEnabled("**MUST BE**");
+ assertAll(
+ () -> assertEquals(origSFSBHaPersistenceType, ejb.getSfsbHaPersistenceType()),
+ () -> assertNotEquals(p.getSfsbHaPersistenceType(), ejb.getSfsbHaPersistenceType())
+ );
+ return null;
+ };
+ ConfigSupport.apply(configCode, ejb);
+
+ assertAll(
+ () -> assertEquals("99999.999", ejb.getSfsbHaPersistenceType()),
+ () -> assertEquals("**MUST BE**", ejb.getSfsbCheckpointEnabled()),
+ () -> assertEquals(origAVEnabled, ejb.getAvailabilityEnabled())
+ );
+ }
+
+ @Test
+ @Order(14)
+ public void testGetImplAndAddListener() throws Exception {
+ final SimpleConnector connector = locator.getService(SimpleConnector.class);
+ final EjbContainerAvailability ejb = connector.getEjbContainerAvailability();
+ final ObservableBean obean = (ObservableBean) ConfigSupport.getImpl(ejb);
+ final EjbObservableBean ejbBean = new EjbObservableBean();
+
+ assertEquals(0, ejbBean.getCount());
+ obean.addListener(ejbBean);
+ final SingleConfigCode<EjbContainerAvailability> configCode = p -> {
+ p.setSfsbHaPersistenceType("DynamicData");
+ p.setSfsbCheckpointEnabled("**MUST BE**");
+ assertNotEquals(ejb.getSfsbHaPersistenceType(), p.getSfsbHaPersistenceType());
+ return null;
+ };
+ ConfigSupport.apply(configCode, ejb);
+
+ assertAll(
+ () -> assertEquals("DynamicData", ejb.getSfsbHaPersistenceType()),
+ () -> assertEquals("**MUST BE**", ejb.getSfsbCheckpointEnabled()),
+ () -> assertEquals(1, ejbBean.getCount())
+ );
+
+ final SingleConfigCode<EjbContainerAvailability> configCode2 = p -> {
+ p.setSfsbHaPersistenceType("DynamicData2");
+ p.setSfsbCheckpointEnabled("**MUST BE**");
+ assertNotEquals(ejb.getSfsbHaPersistenceType(), p.getSfsbHaPersistenceType());
+ return null;
+ };
+ ConfigSupport.apply(configCode2, ejb);
+
+ final ConfigView impl = ConfigSupport.getImpl(ejb);
+ assertAll(
+ () -> assertEquals("DynamicData2", ejb.getSfsbHaPersistenceType()),
+ () -> assertEquals("**MUST BE**", ejb.getSfsbCheckpointEnabled()),
+ () -> assertEquals(2, ejbBean.getCount()),
+ () -> assertEquals(SimpleConfigBeanWrapper.class, impl.getClass()),
+ () -> assertEquals(SimpleConfigBeanWrapper.class, impl.getMasterView().getClass()),
+ () -> assertEquals(Class.class, impl.getProxyType().getClass())
+ );
+ }
+
+
+ @Test
+ @Order(16)
+ public void testGenericContainerInjector() {
+ assertNotNull(locator.getServiceHandle(ConfigInjector.class, "generic-container"));
}
+ @Test
+ @Order(17)
+ public void testLongDataType() {
+ final GenericContainer gc = locator.getService(GenericContainer.class);
+ assertEquals(1234L, gc.getStartupTime());
+ }
+
+ @Test
+ @Order(18)
+ public void testIntDataType() {
+ final GenericContainer gc = locator.getService(GenericContainer.class);
+ assertEquals(1234, gc.getIntValue());
+ }
+
+ @Test
+ @Order(19)
+ public void testConfigurationPopulator() {
+ final DummyPopulator dummyPopulator = (DummyPopulator) locator.getService(Populator.class);
+ assertNotNull(dummyPopulator, "dummy populator");
+ final ConfigurationPopulator confPopulator = locator.getService(ConfigurationPopulator.class);
+ confPopulator.populateConfig(locator);
+ assertTrue(dummyPopulator.isPopulateCalled());
+ }
+
+ @Test
+ @Order(20)
+ public void testSingletonProxy() {
+ final SimpleConnector simpleConnector1 = locator.getService(SimpleConnector.class);
+ final SimpleConnector simpleConnector2 = locator.getService(SimpleConnector.class);
+
+ assertAll(
+ () -> assertNotNull(simpleConnector1),
+ () -> assertThat(simpleConnector1.getClass().getName(), containsString("$Proxy")),
+ () -> assertSame(simpleConnector1, simpleConnector2)
+ );
+ }
+
+
/**
* Ensures that even the non-standard format of metadata from the hk2-config subsystem can
* be read from the service in addClasses. addClasses will now read both forms, if the
* documented form fails, it'll try the hk2-config form
*/
@Test
+ @Order(21)
public void testAddClassOfInjector() {
- ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null);
+ final ServiceLocator myLocator = ServiceLocatorFactory.getInstance().create(null);
- List<ActiveDescriptor<?>> added = ServiceLocatorUtilities.addClasses(locator, EjbContainerAvailabilityInjector.class);
- ActiveDescriptor<?> descriptor = added.get(0);
+ final List<ActiveDescriptor<?>> added = addClasses(myLocator, EjbContainerAvailabilityInjector.class);
+ final ActiveDescriptor<?> descriptor = added.get(0);
- Assert.assertEquals("org.jvnet.hk2.config.test.EjbContainerAvailability", ServiceLocatorUtilities.getOneMetadataField(descriptor, "target"));
-
+ assertEquals(EjbContainerAvailability.class.getName(), getOneMetadataField(descriptor, "target"));
}
@Test
+ @Order(22)
public void testEnableConfigUtilities() {
- ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null);
+ final ServiceLocator myLocator = ServiceLocatorFactory.getInstance().create(null);
- Assert.assertNull(locator.getService(ConfigSupport.class));
- Assert.assertNull(locator.getService(ConfigurationPopulator.class));
- Assert.assertNull(locator.getService(Transactions.class));
- Assert.assertNull(locator.getService(ConfigInstanceListener.class));
-
- HK2DomConfigUtilities.enableHK2DomConfiguration(locator);
+ assertAll(
+ () -> assertNull(myLocator.getService(ConfigSupport.class)),
+ () -> assertNull(myLocator.getService(ConfigurationPopulator.class)),
+ () -> assertNull(myLocator.getService(Transactions.class)),
+ () -> assertNull(myLocator.getService(ConfigInstanceListener.class))
+ );
// Twice to check idempotence
- HK2DomConfigUtilities.enableHK2DomConfiguration(locator);
+ HK2DomConfigUtilities.enableHK2DomConfiguration(myLocator);
+ HK2DomConfigUtilities.enableHK2DomConfiguration(myLocator);
- Assert.assertEquals(1, locator.getAllServices(ConfigSupport.class).size());
- Assert.assertEquals(1, locator.getAllServices(ConfigurationPopulator.class).size());
- Assert.assertEquals(1, locator.getAllServices(Transactions.class).size());
- Assert.assertEquals(1, locator.getAllServices(ConfigInstanceListener.class).size());
+ assertAll(
+ () -> assertThat(myLocator.getAllServices(ConfigSupport.class), hasSize(1)),
+ () -> assertThat(myLocator.getAllServices(ConfigurationPopulator.class), hasSize(1)),
+ () -> assertThat(myLocator.getAllServices(Transactions.class), hasSize(1)),
+ () -> assertThat(myLocator.getAllServices(ConfigInstanceListener.class), hasSize(1))
+ );
}
- private static void printEjb(String message, EjbContainerAvailability ejb) {
- StringBuilder sb = new StringBuilder(ejb.getClass().getName());
- sb.append(" : " ).append(ejb.getAvailabilityEnabled())
- .append("; ").append(ejb.getSfsbCheckpointEnabled())
- .append("; ").append(ejb.getSfsbHaPersistenceType())
- .append("; ").append(ejb.getSfsbQuickCheckpointEnabled())
- .append(";").append(ejb.getSfsbStorePoolName());
- System.out.println(message + " ==> " + sb.toString());
- }
+ private static class InjectionTargetFilter implements Filter {
- private static void printWeb(String message, WebContainerAvailability web) {
- StringBuilder sb = new StringBuilder(web.getClass().getName());
- sb.append(" : " ).append(web.getAvailabilityEnabled())
- .append("; ").append(web.getDisableJreplica())
- .append("; ").append(web.getPersistenceFrequency())
- .append("; ").append(web.getPersistenceScope())
- .append(";").append(web.getPersistenceType())
- .append(";").append(web.getSsoFailoverEnabled());
+ private final String targetName;
- System.out.println(message + " ==> " + sb.toString());
- }
-
- private static class InjectionTargetFilter
- implements Filter {
-
- String targetName;
-
- InjectionTargetFilter(String targetName) {
+ InjectionTargetFilter(final String targetName) {
this.targetName = targetName;
}
@Override
- public boolean matches(Descriptor d) {
+ public boolean matches(final Descriptor d) {
if (d.getQualifiers().contains(InjectionTarget.class.getName())) {
- List<String> list = d.getMetadata().get("target");
+ final List<String> list = d.getMetadata().get("target");
if (list != null && list.get(0).equals(targetName)) {
return true;
}
@@ -479,13 +395,12 @@
}
}
- private static class EjbObservableBean
- implements ConfigListener {
+ private static class EjbObservableBean implements ConfigListener {
- private AtomicInteger count = new AtomicInteger();
+ private final AtomicInteger count = new AtomicInteger();
@Override
- public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
+ public UnprocessedChangeEvents changed(final PropertyChangeEvent[] events) {
System.out.println("** EjbContainerAvailability changed ==> " + count.incrementAndGet());
return null;
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailabilityInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailabilityInjector.java
deleted file mode 100644
index 6a16fec..0000000
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailabilityInjector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.annotations.Service;
-import org.jvnet.hk2.config.InjectionTarget;
-import org.jvnet.hk2.config.NoopConfigInjector;
-
-@Service(name = "ejb-container-availability", metadata = "target=org.jvnet.hk2.config.test.EjbContainerAvailability,@availability-enabled=optional,@availability-enabled=default:true,@availability-enabled=datatype:java.lang.String,@availability-enabled=leaf,@sfsb-ha-persistence-type=optional,@sfsb-ha-persistence-type=default:replicated,@sfsb-ha-persistence-type=datatype:java.lang.String,@sfsb-ha-persistence-type=leaf,@sfsb-persistence-type=optional,@sfsb-persistence-type=default:file,@sfsb-persistence-type=datatype:java.lang.String,@sfsb-persistence-type=leaf,@sfsb-checkpoint-enabled=optional,@sfsb-checkpoint-enabled=datatype:java.lang.String,@sfsb-checkpoint-enabled=leaf,@sfsb-quick-checkpoint-enabled=optional,@sfsb-quick-checkpoint-enabled=datatype:java.lang.String,@sfsb-quick-checkpoint-enabled=leaf,@sfsb-store-pool-name=optional,@sfsb-store-pool-name=datatype:java.lang.String,@sfsb-store-pool-name=leaf")
-@InjectionTarget(EjbContainerAvailability.class)
-public class EjbContainerAvailabilityInjector
- extends NoopConfigInjector
-{
-
-
-}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainerInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainerInjector.java
deleted file mode 100644
index c7d93f3..0000000
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainerInjector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.annotations.Service;
-import org.jvnet.hk2.config.InjectionTarget;
-import org.jvnet.hk2.config.NoopConfigInjector;
-
-@Service(name = "generic-container", metadata = "target=org.jvnet.hk2.config.test.GenericContainer,@max-pool-size=optional,@max-pool-size=default:32,@max-pool-size=datatype:java.lang.String,@max-pool-size=leaf,@startup-time=optional,@startup-time=default:1234,@startup-time=datatype:java.lang.String,@startup-time=leaf,@int-value=optional,@int-value=default:1234,@int-value=datatype:java.lang.String,@int-value=leaf,<web-container-availability>=org.jvnet.hk2.config.test.WebContainerAvailability,<web-container-availability>=@jakarta.validation.constraints.NotNull,<*>=collection:org.jvnet.hk2.config.test.GenericConfig")
-@InjectionTarget(GenericContainer.class)
-public class GenericContainerInjector
- extends NoopConfigInjector
-{
-
-
-}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnectorInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnectorInjector.java
deleted file mode 100644
index f367179..0000000
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnectorInjector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.annotations.Service;
-import org.jvnet.hk2.config.InjectionTarget;
-import org.jvnet.hk2.config.NoopConfigInjector;
-
-@Service(name = "simple-connector", metadata = "target=org.jvnet.hk2.config.test.SimpleConnector,@port=optional,@port=default:8080,@port=datatype:java.lang.String,@port=leaf,<ejb-container-availability>=org.jvnet.hk2.config.test.EjbContainerAvailability,<web-container-availability>=org.jvnet.hk2.config.test.WebContainerAvailability,<*>=collection:org.jvnet.hk2.config.test.GenericContainer")
-@InjectionTarget(SimpleConnector.class)
-public class SimpleConnectorInjector
- extends NoopConfigInjector
-{
-
-
-}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailabilityInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailabilityInjector.java
deleted file mode 100644
index 5fe0f9c..0000000
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailabilityInjector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.annotations.Service;
-import org.jvnet.hk2.config.InjectionTarget;
-import org.jvnet.hk2.config.NoopConfigInjector;
-
-@Service(name = "web-container-availability", metadata = "target=org.jvnet.hk2.config.test.WebContainerAvailability,@availability-enabled=optional,@availability-enabled=default:true,@availability-enabled=datatype:java.lang.String,@availability-enabled=leaf,@persistence-type=optional,@persistence-type=default:replicated,@persistence-type=datatype:java.lang.String,@persistence-type=leaf,@persistence-frequency=optional,@persistence-frequency=default:web-method,@persistence-frequency=datatype:java.lang.String,@persistence-frequency=leaf,@persistence-scope=optional,@persistence-scope=default:session,@persistence-scope=datatype:java.lang.String,@persistence-scope=leaf,@persistence-store-health-check-enabled=optional,@persistence-store-health-check-enabled=default:false,@persistence-store-health-check-enabled=datatype:java.lang.Boolean,@persistence-store-health-check-enabled=leaf,@sso-failover-enabled=optional,@sso-failover-enabled=default:false,@sso-failover-enabled=datatype:java.lang.Boolean,@sso-failover-enabled=leaf,@http-session-store-pool-name=optional,@http-session-store-pool-name=datatype:java.lang.String,@http-session-store-pool-name=leaf,@disable-jreplica=optional,@disable-jreplica=default:false,@disable-jreplica=datatype:java.lang.Boolean,@disable-jreplica=leaf")
-@InjectionTarget(WebContainerAvailability.class)
-public class WebContainerAvailabilityInjector
- extends NoopConfigInjector
-{
-
-
-}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigErrorService.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigErrorService.java
similarity index 81%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigErrorService.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigErrorService.java
index 990a98b..7efd19d 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigErrorService.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigErrorService.java
@@ -14,31 +14,24 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
-
-import jakarta.inject.Singleton;
+package org.jvnet.hk2.config.test.example;
import org.glassfish.hk2.api.ErrorInformation;
import org.glassfish.hk2.api.ErrorService;
import org.glassfish.hk2.api.MultiException;
+import jakarta.inject.Singleton;
+
/**
* @author jwells
- *
*/
@Singleton
public class ConfigErrorService implements ErrorService {
- /* (non-Javadoc)
- * @see org.glassfish.hk2.api.ErrorService#onFailure(org.glassfish.hk2.api.ErrorInformation)
- */
@Override
- public void onFailure(ErrorInformation errorInformation)
- throws MultiException {
+ public void onFailure(ErrorInformation errorInformation) throws MultiException {
if (errorInformation.getAssociatedException() != null) {
throw errorInformation.getAssociatedException();
}
-
}
-
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigModule.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigModule.java
similarity index 90%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigModule.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigModule.java
index c54a59c..359dc0e 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigModule.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/ConfigModule.java
@@ -14,9 +14,13 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
-import jakarta.inject.Singleton;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
import org.glassfish.hk2.api.ActiveDescriptor;
import org.glassfish.hk2.api.DynamicConfiguration;
@@ -35,8 +39,7 @@
import org.jvnet.hk2.config.Populator;
import org.jvnet.hk2.config.Transactions;
-
-import java.util.*;
+import jakarta.inject.Singleton;
/**
* TODO: This should be done via auto-depends (via Service and contract
@@ -83,11 +86,11 @@
.to(Populator.class).in(Singleton.class.getName())
.build());
configurator.addActiveDescriptor(ConfigErrorService.class);
- bindInjector(configurator, "simple-connector", SimpleConnector.class, SimpleConnectorInjector.class);
+ bindInjector(configurator, "simple-connector", SimpleConnector.class, SimpleConnectorInjector.class);
bindInjector(configurator, "ejb-container-availability", EjbContainerAvailability.class, EjbContainerAvailabilityInjector.class);
bindInjector(configurator, "web-container-availability", WebContainerAvailability.class, WebContainerAvailabilityInjector.class);
bindInjector(configurator, "generic-container", GenericContainer.class, GenericContainerInjector.class);
- bindInjector(configurator, "generic-config", GenericConfig.class, GenericConfigInjector.class);
+ bindInjector(configurator, "generic-config", GenericConfig.class, GenericConfigInjector.class);
}
@@ -99,7 +102,7 @@
named(elementName).andLoadWith(new MyHk2Loader(clz.getClassLoader()));
String metaData = ((Service) clz.getAnnotation(Service.class)).metadata();
- Map<String, List<String>> metaMap = new HashMap<String, List<String>>();
+ Map<String, List<String>> metaMap = new HashMap<>();
for (StringTokenizer st = new StringTokenizer(metaData, ","); st.hasMoreTokens(); ) {
String tok = st.nextToken();
int index = tok.indexOf('=');
@@ -108,7 +111,7 @@
String value = tok.substring(index + 1);
List<String> lst = metaMap.get(key);
if (lst == null) {
- lst = new LinkedList<String>();
+ lst = new LinkedList<>();
metaMap.put(key, lst);
}
lst.add(value);
@@ -129,7 +132,7 @@
implements HK2Loader {
- private ClassLoader loader;
+ private final ClassLoader loader;
MyHk2Loader(ClassLoader cl) {
loader = cl;
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/DummyPopulator.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/DummyPopulator.java
similarity index 81%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/DummyPopulator.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/DummyPopulator.java
index aa6d58a..3e86083 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/DummyPopulator.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/DummyPopulator.java
@@ -14,25 +14,18 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.ConfigParser;
import org.jvnet.hk2.config.Populator;
-/**
-* Created by IntelliJ IDEA.
-* User: makannan
-* Date: 5/2/12
-* Time: 11:11 AM
-* To change this template use File | Settings | File Templates.
-*/
@Service
-public class DummyPopulator
- implements Populator {
+public class DummyPopulator implements Populator {
private boolean populateCalled;
+ @Override
public void run(ConfigParser p) {
populateCalled = true;
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailability.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailability.java
similarity index 98%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailability.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailability.java
index 457f4f9..bf43f0a 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/EjbContainerAvailability.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailability.java
@@ -14,14 +14,14 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.config.Attribute;
-import org.jvnet.hk2.config.Configured;
-import org.jvnet.hk2.config.ConfigBeanProxy;
+package org.jvnet.hk2.config.test.example;
import java.beans.PropertyVetoException;
+import org.jvnet.hk2.config.Attribute;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.Configured;
+
/* @XmlType(name = "", propOrder = {
"property"
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailabilityInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailabilityInjector.java
new file mode 100644
index 0000000..b6475a2
--- /dev/null
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/EjbContainerAvailabilityInjector.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.jvnet.hk2.config.test.example;
+
+import org.jvnet.hk2.annotations.Service;
+import org.jvnet.hk2.config.InjectionTarget;
+import org.jvnet.hk2.config.NoopConfigInjector;
+
+@Service(
+ name = "ejb-container-availability",
+ metadata = "target=org.jvnet.hk2.config.test.example.EjbContainerAvailability,"
+ + "@availability-enabled=optional,"
+ + "@availability-enabled=default:true,"
+ + "@availability-enabled=datatype:java.lang.String,"
+ + "@availability-enabled=leaf,"
+ + "@sfsb-ha-persistence-type=optional,"
+ + "@sfsb-ha-persistence-type=default:replicated,"
+ + "@sfsb-ha-persistence-type=datatype:java.lang.String,"
+ + "@sfsb-ha-persistence-type=leaf,"
+ + "@sfsb-persistence-type=optional,"
+ + "@sfsb-persistence-type=default:file,"
+ + "@sfsb-persistence-type=datatype:java.lang.String,"
+ + "@sfsb-persistence-type=leaf,"
+ + "@sfsb-checkpoint-enabled=optional,"
+ + "@sfsb-checkpoint-enabled=datatype:java.lang.String,"
+ + "@sfsb-checkpoint-enabled=leaf,"
+ + "@sfsb-quick-checkpoint-enabled=optional,"
+ + "@sfsb-quick-checkpoint-enabled=datatype:java.lang.String,"
+ + "@sfsb-quick-checkpoint-enabled=leaf,"
+ + "@sfsb-store-pool-name=optional,"
+ + "@sfsb-store-pool-name=datatype:java.lang.String,"
+ + "@sfsb-store-pool-name=leaf"
+)
+@InjectionTarget(EjbContainerAvailability.class)
+public class EjbContainerAvailabilityInjector extends NoopConfigInjector {
+
+}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfig.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfig.java
similarity index 96%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfig.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfig.java
index 8c2a208..a39a987 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfig.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfig.java
@@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
import org.jvnet.hk2.config.Attribute;
import org.jvnet.hk2.config.ConfigBeanProxy;
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfigInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfigInjector.java
similarity index 64%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfigInjector.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfigInjector.java
index c64d1b3..ef6d5de 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericConfigInjector.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericConfigInjector.java
@@ -14,17 +14,23 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.InjectionTarget;
import org.jvnet.hk2.config.NoopConfigInjector;
-@Service(name = "generic-config", metadata = "target=org.jvnet.hk2.config.test.GenericConfig,@name=optional,@name=datatype:java.lang.String,@name=leaf,key=@name,keyed-as=org.jvnet.hk2.config.test.GenericConfig,<generic-config>=org.jvnet.hk2.config.test.GenericConfig")
+@Service(
+ name = "generic-config",
+ metadata = "target=org.jvnet.hk2.config.test.example.GenericConfig,"
+ + "@name=optional,"
+ + "@name=datatype:java.lang.String,"
+ + "@name=leaf,"
+ + "key=@name,"
+ + "keyed-as=org.jvnet.hk2.config.test.example.GenericConfig,"
+ + "<generic-config>=org.jvnet.hk2.config.test.example.GenericConfig"
+)
@InjectionTarget(GenericConfig.class)
-public class GenericConfigInjector
- extends NoopConfigInjector
-{
-
+public class GenericConfigInjector extends NoopConfigInjector {
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainer.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainer.java
similarity index 71%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainer.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainer.java
index 8a3a568..b8a2f8c 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/GenericContainer.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainer.java
@@ -14,25 +14,25 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.config.Attribute;
-import org.jvnet.hk2.config.Configured;
-import org.jvnet.hk2.config.Element;
-import org.jvnet.hk2.config.ConfigBeanProxy;
+package org.jvnet.hk2.config.test.example;
import java.util.List;
+import org.jvnet.hk2.config.Attribute;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.Configured;
+import org.jvnet.hk2.config.Element;
+
import jakarta.validation.constraints.NotNull;
@Configured
public interface GenericContainer extends ConfigBeanProxy {
- public static final int DEFAULT_THREAD_CORE_POOL_SIZE = 16;
- public static final int DEFAULT_THREAD_MAX_POOL_SIZE = 32;
- public static final long DEFAULT_THREAD_KEEP_ALIVE_SECONDS = 60;
- public static final int DEFAULT_THREAD_QUEUE_CAPACITY = Integer.MAX_VALUE;
- public static final boolean DEFAULT_ALLOW_CORE_THREAD_TIMEOUT = false;
- public static final boolean DEFAULT_PRESTART_ALL_CORE_THREADS = false;
+ int DEFAULT_THREAD_CORE_POOL_SIZE = 16;
+ int DEFAULT_THREAD_MAX_POOL_SIZE = 32;
+ long DEFAULT_THREAD_KEEP_ALIVE_SECONDS = 60;
+ int DEFAULT_THREAD_QUEUE_CAPACITY = Integer.MAX_VALUE;
+ boolean DEFAULT_ALLOW_CORE_THREAD_TIMEOUT = false;
+ boolean DEFAULT_PRESTART_ALL_CORE_THREADS = false;
@Attribute (defaultValue="32")
String getMaxPoolSize();
@@ -44,8 +44,7 @@
int getIntValue();
@NotNull
- @Element
- public WebContainerAvailability getWebContainerAvailability();
+ @Element WebContainerAvailability getWebContainerAvailability();
void setWebContainerAvailability(WebContainerAvailability v);
@Element("*")
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainerInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainerInjector.java
new file mode 100644
index 0000000..833c162
--- /dev/null
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/GenericContainerInjector.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.jvnet.hk2.config.test.example;
+
+import org.jvnet.hk2.annotations.Service;
+import org.jvnet.hk2.config.InjectionTarget;
+import org.jvnet.hk2.config.NoopConfigInjector;
+
+@Service(
+ name = "generic-container",
+ metadata = "target=org.jvnet.hk2.config.test.example.GenericContainer,"
+ + "@max-pool-size=optional,"
+ + "@max-pool-size=default:32,"
+ + "@max-pool-size=datatype:java.lang.String,"
+ + "@max-pool-size=leaf,"
+ + "@startup-time=optional,"
+ + "@startup-time=default:1234,"
+ + "@startup-time=datatype:java.lang.String,"
+ + "@startup-time=leaf,"
+ + "@int-value=optional,"
+ + "@int-value=default:1234,"
+ + "@int-value=datatype:java.lang.String,"
+ + "@int-value=leaf,"
+ + "<web-container-availability>=org.jvnet.hk2.config.test.example.WebContainerAvailability,"
+ + "<web-container-availability>=@jakarta.validation.constraints.NotNull,"
+ + "<*>=collection:org.jvnet.hk2.config.test.example.GenericConfig"
+)
+@InjectionTarget(GenericContainer.class)
+public class GenericContainerInjector extends NoopConfigInjector {
+
+}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanDomDecorator.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanDomDecorator.java
similarity index 89%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanDomDecorator.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanDomDecorator.java
index 0ff0331..a6e480b 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanDomDecorator.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanDomDecorator.java
@@ -14,7 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
+
+import javax.xml.stream.XMLStreamReader;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.annotations.Service;
@@ -23,14 +25,12 @@
import org.jvnet.hk2.config.DomDecorator;
import org.jvnet.hk2.config.DomDocument;
-import javax.xml.stream.XMLStreamReader;
-
@Service
public class SimpleConfigBeanDomDecorator
implements DomDecorator<SimpleConfigBeanWrapper> {
@Override
public Dom decorate(ServiceLocator habitat, DomDocument document, SimpleConfigBeanWrapper parent, ConfigModel model, XMLStreamReader in) {
- return new SimpleConfigBeanWrapper(habitat, document, (SimpleConfigBeanWrapper) parent, model, in);
+ return new SimpleConfigBeanWrapper(habitat, document, parent, model, in);
}
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanWrapper.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanWrapper.java
similarity index 88%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanWrapper.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanWrapper.java
index 496cbc3..7ffdcd7 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigBeanWrapper.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigBeanWrapper.java
@@ -14,13 +14,20 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
import java.lang.reflect.Proxy;
+
import javax.xml.stream.XMLStreamReader;
import org.glassfish.hk2.api.ServiceLocator;
-import org.jvnet.hk2.config.*;
+import org.jvnet.hk2.config.ConfigBean;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.ConfigModel;
+import org.jvnet.hk2.config.ConfigView;
+import org.jvnet.hk2.config.Dom;
+import org.jvnet.hk2.config.DomDocument;
+import org.jvnet.hk2.config.Transformer;
/**
* Translated view of a configured objects where values can be represented
@@ -40,6 +47,7 @@
public static <T extends ConfigBeanProxy> T getRawView(T s) {
Transformer rawTransformer = new Transformer() {
+ @Override
@SuppressWarnings("unchecked")
public <T extends ConfigBeanProxy> T transform(T source) {
final ConfigView handler = (ConfigView) Proxy.getInvocationHandler(source);
@@ -84,6 +92,7 @@
super.initializationCompleted();
}
+ @Override
public String toString() {
//final Set<String> attrNames = getAttributeNames();
return "GlassFishConfigBean." + getProxyType().getName();
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigViewWrapper.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigViewWrapper.java
similarity index 95%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigViewWrapper.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigViewWrapper.java
index 6827486..52411d3 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConfigViewWrapper.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConfigViewWrapper.java
@@ -14,15 +14,15 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.jvnet.hk2.config.ConfigView;
-import org.jvnet.hk2.config.ConfigBeanProxy;
-
-import java.util.regex.Pattern;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.regex.Pattern;
+
+import org.glassfish.hk2.api.ServiceLocator;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.ConfigView;
/**
@@ -100,8 +100,9 @@
int lastIdx = propName.length() - 1;
if (lastIdx > 1) {
propName = propName.substring(0,lastIdx);
- if (propName!=null)
- aliasName = propName.trim();
+ if (propName!=null) {
+ aliasName = propName.trim();
+ }
}
}
return aliasName;
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnector.java
similarity index 81%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnector.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnector.java
index e1bdd5d..b707402 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleConnector.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnector.java
@@ -14,16 +14,16 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.config.Attribute;
-import org.jvnet.hk2.config.Element;
-import org.jvnet.hk2.config.ConfigBeanProxy;
-import org.jvnet.hk2.config.Configured;
+package org.jvnet.hk2.config.test.example;
import java.beans.PropertyVetoException;
import java.util.List;
+import org.jvnet.hk2.config.Attribute;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.Configured;
+import org.jvnet.hk2.config.Element;
+
/**
* Configuration of EJB Container
@@ -36,12 +36,12 @@
@Configured
public interface SimpleConnector extends ConfigBeanProxy {
- public static final int DEFAULT_THREAD_CORE_POOL_SIZE = 16;
- public static final int DEFAULT_THREAD_MAX_POOL_SIZE = 32;
- public static final long DEFAULT_THREAD_KEEP_ALIVE_SECONDS = 60;
- public static final int DEFAULT_THREAD_QUEUE_CAPACITY = Integer.MAX_VALUE;
- public static final boolean DEFAULT_ALLOW_CORE_THREAD_TIMEOUT = false;
- public static final boolean DEFAULT_PRESTART_ALL_CORE_THREADS = false;
+ int DEFAULT_THREAD_CORE_POOL_SIZE = 16;
+ int DEFAULT_THREAD_MAX_POOL_SIZE = 32;
+ long DEFAULT_THREAD_KEEP_ALIVE_SECONDS = 60;
+ int DEFAULT_THREAD_QUEUE_CAPACITY = Integer.MAX_VALUE;
+ boolean DEFAULT_ALLOW_CORE_THREAD_TIMEOUT = false;
+ boolean DEFAULT_PRESTART_ALL_CORE_THREADS = false;
/**
* Gets the value of the steadyPoolSize property.
@@ -76,13 +76,11 @@
*/
void setPort(String value) throws PropertyVetoException;
- @Element
- public EjbContainerAvailability getEjbContainerAvailability();
+ @Element EjbContainerAvailability getEjbContainerAvailability();
void setEjbContainerAvailability(EjbContainerAvailability v);
- @Element
- public WebContainerAvailability getWebContainerAvailability();
+ @Element WebContainerAvailability getWebContainerAvailability();
void setWebContainerAvailability(WebContainerAvailability v);
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnectorInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnectorInjector.java
new file mode 100644
index 0000000..6afd01e
--- /dev/null
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleConnectorInjector.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.jvnet.hk2.config.test.example;
+
+import org.jvnet.hk2.annotations.Service;
+import org.jvnet.hk2.config.InjectionTarget;
+import org.jvnet.hk2.config.NoopConfigInjector;
+
+@Service(
+ name = "simple-connector",
+ metadata = "target=org.jvnet.hk2.config.test.example.SimpleConnector,"
+ + "@port=optional,"
+ + "@port=default:8080,"
+ + "@port=datatype:java.lang.String,"
+ + "@port=leaf,"
+ + "<ejb-container-availability>=org.jvnet.hk2.config.test.example.EjbContainerAvailability,"
+ + "<web-container-availability>=org.jvnet.hk2.config.test.example.WebContainerAvailability,"
+ + "<*>=collection:org.jvnet.hk2.config.test.example.GenericContainer"
+)
+@InjectionTarget(SimpleConnector.class)
+public class SimpleConnectorInjector extends NoopConfigInjector {
+
+}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleDocument.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleDocument.java
similarity index 96%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleDocument.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleDocument.java
index f995050..dfe6e1f 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/SimpleDocument.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/SimpleDocument.java
@@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
+package org.jvnet.hk2.config.test.example;
import javax.xml.stream.XMLStreamReader;
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailability.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailability.java
similarity index 78%
rename from nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailability.java
rename to nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailability.java
index 4e6c44b..e61aed9 100644
--- a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/WebContainerAvailability.java
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailability.java
@@ -14,16 +14,14 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-package org.jvnet.hk2.config.test;
-
-import org.jvnet.hk2.config.ConfigBeanProxy;
-
-
-import org.jvnet.hk2.config.Attribute;
-import org.jvnet.hk2.config.Configured;
+package org.jvnet.hk2.config.test.example;
import java.beans.PropertyVetoException;
+import org.jvnet.hk2.config.Attribute;
+import org.jvnet.hk2.config.ConfigBeanProxy;
+import org.jvnet.hk2.config.Configured;
+
/**
* web-container-availability SE/EE only
*/
@@ -50,8 +48,8 @@
* @return possible object is
* {@link String }
*/
- @Attribute (defaultValue="true")
- public String getAvailabilityEnabled();
+ @Attribute(defaultValue="true")
+ String getAvailabilityEnabled();
/**
* Sets the value of the availabilityEnabled property.
@@ -59,7 +57,7 @@
* @param value allowed object is
* {@link String }
*/
- public void setAvailabilityEnabled(String value) throws PropertyVetoException;
+ void setAvailabilityEnabled(String value) throws PropertyVetoException;
/**
* Gets the value of the persistenceType property.
@@ -70,8 +68,8 @@
* @return possible object is
* {@link String }
*/
- @Attribute (defaultValue="replicated")
- public String getPersistenceType();
+ @Attribute(defaultValue="replicated")
+ String getPersistenceType();
/**
* Sets the value of the persistenceType property.
@@ -79,7 +77,7 @@
* @param value allowed object is
* {@link String }
*/
- public void setPersistenceType(String value) throws PropertyVetoException;
+ void setPersistenceType(String value) throws PropertyVetoException;
/**
* Gets the value of the persistenceFrequency property.
@@ -91,8 +89,8 @@
* @return possible object is
* {@link String }
*/
- @Attribute (defaultValue="web-method")
- public String getPersistenceFrequency();
+ @Attribute(defaultValue="web-method")
+ String getPersistenceFrequency();
/**
* Sets the value of the persistenceFrequency property.
@@ -100,7 +98,7 @@
* @param value allowed object is
* {@link String }
*/
- public void setPersistenceFrequency(String value) throws PropertyVetoException;
+ void setPersistenceFrequency(String value) throws PropertyVetoException;
/**
* Gets the value of the persistenceScope property.
@@ -113,8 +111,8 @@
* @return possible object is
* {@link String }
*/
- @Attribute (defaultValue="session")
- public String getPersistenceScope();
+ @Attribute(defaultValue="session")
+ String getPersistenceScope();
/**
* Sets the value of the persistenceScope property.
@@ -122,7 +120,7 @@
* @param value allowed object is
* {@link String }
*/
- public void setPersistenceScope(String value) throws PropertyVetoException;
+ void setPersistenceScope(String value) throws PropertyVetoException;
/**
* Gets the value of the persistenceStoreHealthCheckEnabled property.
@@ -135,8 +133,8 @@
* {@link String }
*/
@Deprecated
- @Attribute (defaultValue="false",dataType=Boolean.class)
- public String getPersistenceStoreHealthCheckEnabled();
+ @Attribute(defaultValue = "false", dataType = Boolean.class)
+ String getPersistenceStoreHealthCheckEnabled();
/**
* Sets the value of the persistenceStoreHealthCheckEnabled property.
@@ -144,7 +142,7 @@
* @param value allowed object is
* {@link String }
*/
- public void setPersistenceStoreHealthCheckEnabled(String value) throws PropertyVetoException;
+ void setPersistenceStoreHealthCheckEnabled(String value) throws PropertyVetoException;
/**
* Gets the value of the ssoFailoverEnabled property.
@@ -154,8 +152,8 @@
* @return possible object is
* {@link String }
*/
- @Attribute (defaultValue="false",dataType=Boolean.class)
- public String getSsoFailoverEnabled();
+ @Attribute(defaultValue = "false", dataType = Boolean.class)
+ String getSsoFailoverEnabled();
/**
* Sets the value of the ssoFailoverEnabled property.
@@ -163,11 +161,10 @@
* @param value allowed object is
* {@link String }
*/
- public void setSsoFailoverEnabled(String value) throws PropertyVetoException;
+ void setSsoFailoverEnabled(String value) throws PropertyVetoException;
/**
* Gets the value of the httpSessionStorePoolName property.
- *
* This is the jndi-name for the JDBC Connection Pool used by the HTTP
* Session Persistence Framework. If missing, internal code will default it
* to value of store-pool-name under availability-service
@@ -178,31 +175,31 @@
*/
@Deprecated
@Attribute
- public String getHttpSessionStorePoolName();
+ String getHttpSessionStorePoolName();
/**
* Sets the value of the httpSessionStorePoolName property.
*
* @param value allowed object is
- * {@link String }
+ * {@link String }
*/
- public void setHttpSessionStorePoolName(String value) throws PropertyVetoException;
+ void setHttpSessionStorePoolName(String value) throws PropertyVetoException;
/**
* Gets thevalue of disableJreplica property.
- *
* This is the property used to disable setting the JREPLICA cookie
*
* @return returns the string representation of the boolean value
*/
- @Attribute (defaultValue="false",dataType=Boolean.class)
- public String getDisableJreplica();
+ @Attribute(defaultValue = "false", dataType = Boolean.class)
+ String getDisableJreplica();
/**
* Sets the disableJreplica property
+ *
* @param value allowed object is {@link String}
* @throws PropertyVetoException
*/
- public void setDisableJreplica(String value) throws PropertyVetoException;
+ void setDisableJreplica(String value) throws PropertyVetoException;
}
diff --git a/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailabilityInjector.java b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailabilityInjector.java
new file mode 100644
index 0000000..5f249b6
--- /dev/null
+++ b/nucleus/hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/example/WebContainerAvailabilityInjector.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.jvnet.hk2.config.test.example;
+
+import org.jvnet.hk2.annotations.Service;
+import org.jvnet.hk2.config.InjectionTarget;
+import org.jvnet.hk2.config.NoopConfigInjector;
+
+@Service(
+ name = "web-container-availability",
+ metadata = "target=org.jvnet.hk2.config.test.example.WebContainerAvailability,"
+ + "@availability-enabled=optional,"
+ + "@availability-enabled=default:true,"
+ + "@availability-enabled=datatype:java.lang.String,"
+ + "@availability-enabled=leaf,"
+ + "@persistence-type=optional,"
+ + "@persistence-type=default:replicated,"
+ + "@persistence-type=datatype:java.lang.String,"
+ + "@persistence-type=leaf,"
+ + "@persistence-frequency=optional,"
+ + "@persistence-frequency=default:web-method,"
+ + "@persistence-frequency=datatype:java.lang.String,"
+ + "@persistence-frequency=leaf,"
+ + "@persistence-scope=optional,"
+ + "@persistence-scope=default:session,"
+ + "@persistence-scope=datatype:java.lang.String,"
+ + "@persistence-scope=leaf,"
+ + "@persistence-store-health-check-enabled=optional,"
+ + "@persistence-store-health-check-enabled=default:false,"
+ + "@persistence-store-health-check-enabled=datatype:java.lang.Boolean,"
+ + "@persistence-store-health-check-enabled=leaf,"
+ + "@sso-failover-enabled=optional,"
+ + "@sso-failover-enabled=default:false,"
+ + "@sso-failover-enabled=datatype:java.lang.Boolean,"
+ + "@sso-failover-enabled=leaf,"
+ + "@http-session-store-pool-name=optional,"
+ + "@http-session-store-pool-name=datatype:java.lang.String,"
+ + "@http-session-store-pool-name=leaf,"
+ + "@disable-jreplica=optional,"
+ + "@disable-jreplica=default:false,"
+ + "@disable-jreplica=datatype:java.lang.Boolean,"
+ + "@disable-jreplica=leaf")
+@InjectionTarget(WebContainerAvailability.class)
+public class WebContainerAvailabilityInjector extends NoopConfigInjector {
+
+}