juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [21/21] juneau git commit: JUNEAU-76 Improvements to Context/Builder APIs
Date Sat, 23 Dec 2017 16:51:02 GMT
JUNEAU-76 Improvements to Context/Builder APIs

Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/227719b2
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/227719b2
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/227719b2

Branch: refs/heads/master
Commit: 227719b2dc52d70577728232daf5d0b9e950fb54
Parents: 77ccbc8
Author: JamesBognar <jamesbognar@apache.org>
Authored: Sat Dec 23 11:50:26 2017 -0500
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Sat Dec 23 11:50:26 2017 -0500

----------------------------------------------------------------------
 .../apache/juneau/ini/ConfigFileContext.java    |   21 +-
 .../java/org/apache/juneau/BeanConfigTest.java  |   10 +-
 .../java/org/apache/juneau/BeanMapTest.java     |    6 +-
 .../java/org/apache/juneau/ClassMetaTest.java   |   14 +-
 .../org/apache/juneau/ContextCacheTest.java     |  194 ++
 .../org/apache/juneau/DataConversionTest.java   |    2 +-
 .../org/apache/juneau/PropertyStore2Test.java   | 1741 ++++++++++++++++++
 .../org/apache/juneau/PropertyStoreTest.java    |  819 --------
 .../org/apache/juneau/XmlValidatorParser.java   |    2 +-
 .../juneau/XmlValidatorParserBuilder.java       |    2 +-
 .../apache/juneau/a/rttests/RoundTripTest.java  |    4 +-
 .../apache/juneau/jena/CommonParserTest.java    |    6 +-
 .../java/org/apache/juneau/jena/CommonTest.java |    6 +-
 .../org/apache/juneau/jena/CommonXmlTest.java   |    6 +-
 .../org/apache/juneau/jena/RdfParserTest.java   |    2 +-
 .../java/org/apache/juneau/jena/RdfTest.java    |    6 +-
 .../apache/juneau/parser/ParserGroupTest.java   |   32 +-
 .../juneau/serializer/SerializerGroupTest.java  |   44 +-
 .../juneau/transforms/BeanFilterTest.java       |    8 +-
 .../apache/juneau/transforms/BeanMapTest.java   |    6 +-
 .../juneau/transforms/CalendarSwapTest.java     |    6 +-
 .../juneau/transforms/LocalizedDatesTest.java   |   12 +-
 .../juneau/transforms/ReaderFilterTest.java     |   91 +-
 .../urlencoding/UrlEncodingParserTest.java      |    2 +-
 .../org/apache/juneau/utils/ArrayUtilsTest.java |   60 +-
 .../java/org/apache/juneau/xml/XmlTest.java     |   58 +-
 .../java/org/apache/juneau/jena/RdfCommon.java  |   67 +-
 .../java/org/apache/juneau/jena/RdfParser.java  |  114 +-
 .../apache/juneau/jena/RdfParserBuilder.java    |  225 +--
 .../apache/juneau/jena/RdfParserContext.java    |   64 -
 .../apache/juneau/jena/RdfParserSession.java    |   29 +-
 .../org/apache/juneau/jena/RdfSerializer.java   |  166 +-
 .../juneau/jena/RdfSerializerBuilder.java       |  264 +--
 .../juneau/jena/RdfSerializerContext.java       |   82 -
 .../juneau/jena/RdfSerializerSession.java       |   57 +-
 .../java/org/apache/juneau/jena/RdfUtils.java   |   14 +-
 juneau-core/juneau-marshall/TODO.txt            |   10 +-
 .../java/org/apache/juneau/BeanContext.java     |  443 ++---
 .../org/apache/juneau/BeanContextBuilder.java   | 1279 +++++++++++++
 .../main/java/org/apache/juneau/BeanMap.java    |    2 +-
 .../main/java/org/apache/juneau/BeanMeta.java   |    3 -
 .../java/org/apache/juneau/BeanSession.java     |   36 +-
 .../main/java/org/apache/juneau/Context.java    |  291 ++-
 .../java/org/apache/juneau/ContextBuilder.java  |  152 ++
 .../java/org/apache/juneau/ContextCache.java    |  174 ++
 .../apache/juneau/ContextRuntimeException.java  |   74 +
 .../main/java/org/apache/juneau/CoreObject.java |   74 -
 .../org/apache/juneau/CoreObjectBuilder.java    | 1631 ----------------
 .../main/java/org/apache/juneau/ObjectList.java |    4 +-
 .../main/java/org/apache/juneau/ObjectMap.java  |    4 +-
 .../org/apache/juneau/PropertyConverter.java    |   78 +
 .../java/org/apache/juneau/PropertyStore.java   | 1485 ---------------
 .../java/org/apache/juneau/PropertyStore2.java  |  748 ++++++++
 .../org/apache/juneau/PropertyStoreBuilder.java |  774 ++++++++
 .../org/apache/juneau/PropertyStoreOld.java     | 1254 +++++++++++++
 .../java/org/apache/juneau/PropertyType.java    |  109 ++
 .../main/java/org/apache/juneau/Session.java    |  185 +-
 .../main/java/org/apache/juneau/UriContext.java |   30 +
 .../java/org/apache/juneau/csv/CsvParser.java   |   21 +-
 .../org/apache/juneau/csv/CsvParserBuilder.java |  168 +-
 .../org/apache/juneau/csv/CsvParserContext.java |   41 -
 .../org/apache/juneau/csv/CsvParserSession.java |    2 +-
 .../org/apache/juneau/csv/CsvSerializer.java    |   21 +-
 .../apache/juneau/csv/CsvSerializerBuilder.java |  180 +-
 .../apache/juneau/csv/CsvSerializerContext.java |   41 -
 .../apache/juneau/csv/CsvSerializerSession.java |    2 +-
 .../juneau/encoders/EncoderGroupBuilder.java    |    4 +-
 .../apache/juneau/html/HtmlDocSerializer.java   |  110 +-
 .../juneau/html/HtmlDocSerializerContext.java   |   70 -
 .../juneau/html/HtmlDocSerializerSession.java   |   30 +-
 .../java/org/apache/juneau/html/HtmlParser.java |   21 +-
 .../apache/juneau/html/HtmlParserBuilder.java   |  170 +-
 .../apache/juneau/html/HtmlParserContext.java   |   41 -
 .../apache/juneau/html/HtmlParserSession.java   |    2 +-
 .../juneau/html/HtmlSchemaDocSerializer.java    |   24 +-
 .../html/HtmlSchemaDocSerializerSession.java    |    5 +-
 .../org/apache/juneau/html/HtmlSerializer.java  |   98 +-
 .../juneau/html/HtmlSerializerBuilder.java      |  225 +--
 .../juneau/html/HtmlSerializerContext.java      |   64 -
 .../juneau/html/HtmlSerializerSession.java      |   16 +-
 .../juneau/html/HtmlStrippedDocSerializer.java  |   14 +-
 .../html/HtmlStrippedDocSerializerSession.java  |    2 +-
 .../org/apache/juneau/internal/ArrayUtils.java  |   43 +-
 .../org/apache/juneau/internal/ClassUtils.java  |  169 +-
 .../apache/juneau/internal/CollectionUtils.java |   32 +-
 .../org/apache/juneau/internal/ObjectUtils.java |   16 +-
 .../java/org/apache/juneau/jso/JsoParser.java   |   12 +-
 .../org/apache/juneau/jso/JsoParserBuilder.java |  170 +-
 .../org/apache/juneau/jso/JsoSerializer.java    |   15 +-
 .../apache/juneau/jso/JsoSerializerBuilder.java |  180 +-
 .../apache/juneau/jso/JsoSerializerSession.java |    2 +-
 .../java/org/apache/juneau/json/JsonParser.java |   39 +-
 .../apache/juneau/json/JsonParserBuilder.java   |  168 +-
 .../apache/juneau/json/JsonParserContext.java   |   41 -
 .../apache/juneau/json/JsonParserSession.java   |    2 +-
 .../juneau/json/JsonSchemaSerializer.java       |   13 +-
 .../json/JsonSchemaSerializerBuilder.java       |  180 +-
 .../json/JsonSchemaSerializerSession.java       |    2 +-
 .../org/apache/juneau/json/JsonSerializer.java  |  111 +-
 .../juneau/json/JsonSerializerBuilder.java      |  198 +-
 .../juneau/json/JsonSerializerContext.java      |   55 -
 .../juneau/json/JsonSerializerSession.java      |    9 +-
 .../apache/juneau/msgpack/MsgPackParser.java    |   21 +-
 .../juneau/msgpack/MsgPackParserBuilder.java    |  168 +-
 .../juneau/msgpack/MsgPackParserContext.java    |   41 -
 .../juneau/msgpack/MsgPackParserSession.java    |    2 +-
 .../juneau/msgpack/MsgPackSerializer.java       |   29 +-
 .../msgpack/MsgPackSerializerBuilder.java       |  180 +-
 .../msgpack/MsgPackSerializerContext.java       |   49 -
 .../msgpack/MsgPackSerializerSession.java       |    5 +-
 .../apache/juneau/parser/InputStreamParser.java |    6 +-
 .../juneau/parser/InputStreamParserSession.java |    4 +-
 .../java/org/apache/juneau/parser/Parser.java   |   82 +-
 .../org/apache/juneau/parser/ParserBuilder.java |  224 +--
 .../org/apache/juneau/parser/ParserContext.java |   59 -
 .../org/apache/juneau/parser/ParserGroup.java   |   12 +-
 .../juneau/parser/ParserGroupBuilder.java       |  212 +--
 .../org/apache/juneau/parser/ParserSession.java |   33 +-
 .../org/apache/juneau/parser/ReaderParser.java  |    6 +-
 .../juneau/parser/ReaderParserSession.java      |    8 +-
 .../juneau/plaintext/PlainTextParser.java       |   18 +-
 .../plaintext/PlainTextParserBuilder.java       |  168 +-
 .../plaintext/PlainTextParserSession.java       |    9 +-
 .../juneau/plaintext/PlainTextSerializer.java   |   21 +-
 .../plaintext/PlainTextSerializerBuilder.java   |  180 +-
 .../plaintext/PlainTextSerializerSession.java   |    2 +-
 .../serializer/OutputStreamSerializer.java      |    6 +-
 .../OutputStreamSerializerSession.java          |    4 +-
 .../apache/juneau/serializer/Serializer.java    |  183 +-
 .../juneau/serializer/SerializerBuilder.java    |  373 ++--
 .../juneau/serializer/SerializerContext.java    |  102 -
 .../juneau/serializer/SerializerGroup.java      |   23 +-
 .../serializer/SerializerGroupBuilder.java      |  266 ++-
 .../juneau/serializer/SerializerSession.java    |   57 +-
 .../juneau/serializer/WriterSerializer.java     |    6 +-
 .../serializer/WriterSerializerSession.java     |    4 +-
 .../apache/juneau/soap/SoapXmlSerializer.java   |   18 +-
 .../juneau/soap/SoapXmlSerializerBuilder.java   |  188 +-
 .../juneau/soap/SoapXmlSerializerContext.java   |   34 -
 .../juneau/soap/SoapXmlSerializerSession.java   |   10 +-
 .../transform/InterfaceBeanFilterBuilder.java   |    2 +-
 .../org/apache/juneau/transform/PojoSwap.java   |    1 +
 .../org/apache/juneau/transform/Surrogate.java  |    2 +-
 .../apache/juneau/transforms/ReaderSwap.java    |   18 +
 .../java/org/apache/juneau/uon/UonParser.java   |   45 +-
 .../org/apache/juneau/uon/UonParserBuilder.java |  178 +-
 .../org/apache/juneau/uon/UonParserContext.java |   48 -
 .../org/apache/juneau/uon/UonParserSession.java |    7 +-
 .../org/apache/juneau/uon/UonSerializer.java    |   76 +-
 .../apache/juneau/uon/UonSerializerBuilder.java |  199 +-
 .../apache/juneau/uon/UonSerializerContext.java |   66 -
 .../apache/juneau/uon/UonSerializerSession.java |    9 +-
 .../juneau/urlencoding/UrlEncodingParser.java   |   32 +-
 .../urlencoding/UrlEncodingParserBuilder.java   |  179 +-
 .../urlencoding/UrlEncodingParserContext.java   |   48 -
 .../urlencoding/UrlEncodingParserSession.java   |    5 +-
 .../urlencoding/UrlEncodingSerializer.java      |   69 +-
 .../UrlEncodingSerializerBuilder.java           |  198 +-
 .../UrlEncodingSerializerContext.java           |   48 -
 .../UrlEncodingSerializerSession.java           |    5 +-
 .../apache/juneau/utils/PojoIntrospector.java   |    2 +-
 .../java/org/apache/juneau/utils/PojoRest.java  |    2 +-
 .../java/org/apache/juneau/xml/Namespace.java   |  157 +-
 .../org/apache/juneau/xml/NamespaceFactory.java |  131 --
 .../org/apache/juneau/xml/XmlDocSerializer.java |   14 +-
 .../juneau/xml/XmlDocSerializerSession.java     |    2 +-
 .../java/org/apache/juneau/xml/XmlParser.java   |   69 +-
 .../org/apache/juneau/xml/XmlParserBuilder.java |  215 +--
 .../org/apache/juneau/xml/XmlParserContext.java |   63 -
 .../org/apache/juneau/xml/XmlParserSession.java |   13 +-
 .../juneau/xml/XmlSchemaDocSerializer.java      |    8 +-
 .../xml/XmlSchemaDocSerializerSession.java      |    2 +-
 .../apache/juneau/xml/XmlSchemaSerializer.java  |   14 +-
 .../juneau/xml/XmlSchemaSerializerBuilder.java  |  180 +-
 .../juneau/xml/XmlSchemaSerializerSession.java  |    2 +-
 .../org/apache/juneau/xml/XmlSerializer.java    |  158 +-
 .../apache/juneau/xml/XmlSerializerBuilder.java |  234 +--
 .../apache/juneau/xml/XmlSerializerContext.java |   70 -
 .../apache/juneau/xml/XmlSerializerSession.java |   47 +-
 .../java/org/apache/juneau/xml/XmlUtils.java    |   14 +-
 .../apache/juneau/yaml/proto/YamlParser.java    |   39 +-
 .../juneau/yaml/proto/YamlParserBuilder.java    |  168 +-
 .../juneau/yaml/proto/YamlParserContext.java    |   41 -
 .../juneau/yaml/proto/YamlParserSession.java    |    2 +-
 .../juneau/yaml/proto/YamlSerializer.java       |   51 +-
 .../yaml/proto/YamlSerializerBuilder.java       |  198 +-
 .../yaml/proto/YamlSerializerContext.java       |   55 -
 .../yaml/proto/YamlSerializerSession.java       |    9 +-
 juneau-doc/src/main/javadoc/overview.html       |  101 +
 .../juneau/examples/rest/PhotosResource.java    |   14 +-
 .../examples/rest/AddressBookResourceTest.java  |    8 +-
 .../SampleRemoteableServicesResourceTest.java   |    2 +-
 .../juneau/rest/test/AcceptCharsetResource.java |   12 +-
 .../rest/test/CharsetEncodingsResource.java     |    8 +-
 .../rest/test/DefaultContentTypesResource.java  |   20 +-
 .../apache/juneau/rest/test/GroupsResource.java |    8 +-
 .../juneau/rest/test/HeadersResource.java       |    8 +-
 .../juneau/rest/test/InheritanceResource.java   |   24 +-
 .../juneau/rest/test/NlsPropertyResource.java   |    6 +-
 .../juneau/rest/test/OnPostCallResource.java    |    6 +-
 .../juneau/rest/test/OnPreCallResource.java     |    8 +-
 .../juneau/rest/test/ParsersResource.java       |   16 +-
 .../juneau/rest/test/PropertiesResource.java    |   14 +-
 .../juneau/rest/test/SerializersResource.java   |   16 +-
 .../juneau/rest/test/TransformsResource.java    |    2 +-
 .../org/apache/juneau/rest/client/RestCall.java |    6 +-
 .../apache/juneau/rest/client/RestClient.java   |   16 +-
 .../juneau/rest/client/RestClientBuilder.java   |  248 ++-
 .../apache/juneau/rest/jaxrs/BaseProvider.java  |    6 +-
 .../juneau/rest/jaxrs/JuneauProvider.java       |   10 +-
 .../java/org/apache/juneau/rest/CallMethod.java |   39 +-
 .../org/apache/juneau/rest/HtmlDocBuilder.java  |    2 +-
 .../java/org/apache/juneau/rest/RestConfig.java |    6 +-
 .../org/apache/juneau/rest/RestContext.java     |   36 +-
 .../org/apache/juneau/rest/RestResponse.java    |    9 +-
 .../apache/juneau/rest/annotation/Property.java |   16 +-
 .../juneau/rest/annotation/RestResource.java    |   14 +-
 217 files changed, 12291 insertions(+), 10309 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
index 593a7e9..6684f0a 100644
--- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
+++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
@@ -22,10 +22,10 @@ public class ConfigFileContext extends Context {
 	/**
 	 * TODO
 	 *
-	 * @param propertyStore
+	 * @param ps
 	 */
-	public ConfigFileContext(PropertyStore propertyStore) {
-		super(propertyStore);
+	public ConfigFileContext(PropertyStore2 ps) {
+		super(ps);
 	}
 
 	/**
@@ -57,4 +57,19 @@ public class ConfigFileContext extends Context {
 	 * TODO
 	 */
 	public static final String CONFIGFILE_wsDepth = "ConfigFile.wsDepth";
+
+	@Override
+	public ContextBuilder builder() {
+		throw new NoSuchMethodError();
+	}
+
+	@Override
+	public Session createSession(SessionArgs args) {
+		throw new NoSuchMethodError();
+	}
+
+	@Override
+	public SessionArgs createDefaultSessionArgs() {
+		throw new NoSuchMethodError();
+	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigTest.java
b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigTest.java
index cd9709a..7932009 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigTest.java
@@ -458,7 +458,7 @@ public class BeanConfigTest {
 	//====================================================================================================
 	@Test
 	public void testProxyHandler() throws Exception {
-		BeanSession session = PropertyStore.create().getBeanContext().createSession();
+		BeanSession session = BeanContext.DEFAULT.createBeanSession();
 
 		A f1 = (A) Proxy.newProxyInstance(this.getClass()
 				.getClassLoader(), new Class[] { A.class },
@@ -760,14 +760,14 @@ public class BeanConfigTest {
 
 	private void assertSameCache(ParserBuilder p1b, ParserBuilder p2b) {
 		Parser p1 = p1b.build(), p2 = p2b.build();
-		assertTrue(p1.getBeanContext().hasSameCache(p2.getBeanContext()));
-		assertTrue(p1.getBeanContext().hashCode() == p2.getBeanContext().hashCode());
+		assertTrue(p1.hasSameCache(p2));
+		assertTrue(p1.hashCode() == p2.hashCode());
 	}
 
 	private void assertDifferentCache(ParserBuilder p1b, ParserBuilder p2b) {
 		Parser p1 = p1b.build(), p2 = p2b.build();
-		assertFalse(p1.getBeanContext().hasSameCache(p2.getBeanContext()));
-		assertFalse(p1.getBeanContext().hashCode() == p2.getBeanContext().hashCode());
+		assertFalse(p1.hasSameCache(p2));
+		assertFalse(p1.hashCode() == p2.hashCode());
 	}
 
 	//====================================================================================================

http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanMapTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanMapTest.java
b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanMapTest.java
index b882cd5..9d0dc80 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanMapTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanMapTest.java
@@ -33,10 +33,10 @@ public class BeanMapTest {
 
 	JsonSerializer serializer = JsonSerializer.DEFAULT_LAX;
 
-	BeanContext bc = PropertyStore.create()
+	BeanContext bc = BeanContext.create()
 			.setBeanDictionary(MyBeanDictionaryMap.class)
 			.setPojoSwaps(CalendarSwap.ISO8601DTZ.class)
-			.getBeanContext();
+			.build();
 	BeanSession session = bc.createSession();
 
 	public static class MyBeanDictionaryMap extends BeanDictionaryMap {
@@ -1719,7 +1719,7 @@ public class BeanMapTest {
 	@Test
 	public void testHiddenProperties() throws Exception {
 		JsonSerializer s = JsonSerializer.DEFAULT_LAX;
-		BeanMeta bm = s.getBeanContext().getBeanMeta(U.class);
+		BeanMeta bm = s.getBeanMeta(U.class);
 		assertNotNull(bm.getPropertyMeta("a"));
 		assertNotNull(bm.getPropertyMeta("b"));
 		assertNull(bm.getPropertyMeta("c"));

http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ClassMetaTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ClassMetaTest.java
b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ClassMetaTest.java
index 4559d78..336c754 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ClassMetaTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ClassMetaTest.java
@@ -116,7 +116,7 @@ public class ClassMetaTest {
 		ClassMeta<?> ooo, hi1, hc1, hi2, hc2;
 		BeanSession bs;
 
-		bc = PropertyStore.create().getBeanContext();
+		bc = BeanContext.DEFAULT;
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -139,7 +139,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), HI2.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), HC2.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HI1Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HI1Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -162,7 +162,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HC1Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HC1Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -185,7 +185,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), HI2.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HI2Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HI2Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -208,7 +208,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HC2Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HC2Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -231,7 +231,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), HI2.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HI1Swap.class,HC1Swap.class,HI2Swap.class,HC2Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HI1Swap.class,HC1Swap.class,HI2Swap.class,HC2Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);
@@ -254,7 +254,7 @@ public class ClassMetaTest {
 		assertEquals(hi2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 		assertEquals(hc2.getSerializedClassMeta(bs).getInnerClass(), Map.class);
 
-		bc = PropertyStore.create().setPojoSwaps(HC2Swap.class,HI2Swap.class,HC1Swap.class,HI1Swap.class).getBeanContext();
+		bc = BeanContext.create().setPojoSwaps(HC2Swap.class,HI2Swap.class,HC1Swap.class,HI1Swap.class).build();
 		bs = bc.createSession();
 		ooo = bc.getClassMeta(Object.class);
 		hi1 = bc.getClassMeta(HI1.class);

http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
new file mode 100644
index 0000000..4da824b
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
@@ -0,0 +1,194 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.
 The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance            *
+// * with the License.  You may obtain a copy of the License at                         
                                    * 
+// *                                                                                    
                                    *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                        
                                    *
+// *                                                                                    
                                    *
+// * Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the        *
+// * specific language governing permissions and limitations under the License.         
                                    *
+// ***************************************************************************************************************************
+package org.apache.juneau;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+/**
+ * Tests the ContextCache class.
+ */
+public class ContextCacheTest {
+	
+	//-------------------------------------------------------------------------------------------------------------------
+	// Basic tests
+	//-------------------------------------------------------------------------------------------------------------------
+	
+	@Test
+	public void testBasic() {
+		
+		PropertyStoreBuilder psb = PropertyStore2.create();
+		PropertyStore2 ps = psb.build();
+		
+		A a = ContextCache.INSTANCE.create(A.class, ps);
+		B b = ContextCache.INSTANCE.create(B.class, ps);
+		C c = ContextCache.INSTANCE.create(C.class, ps);
+		
+		assertObjectEquals("{f1:'xxx'}", a);
+		assertObjectEquals("{f1:'xxx',f2:-1}", b);
+		assertObjectEquals("{f1:'xxx',f2:-1,f3:false}", c);
+		
+		A a2 = ContextCache.INSTANCE.create(A.class, ps);
+		B b2 = ContextCache.INSTANCE.create(B.class, ps);
+		C c2 = ContextCache.INSTANCE.create(C.class, ps);
+		
+		assertTrue(a == a2);
+		assertTrue(b == b2);
+		assertTrue(c == c2);
+		
+		psb.set("A.f1", "foo");
+		ps = psb.build();
+		
+		a2 = ContextCache.INSTANCE.create(A.class, ps);
+		b2 = ContextCache.INSTANCE.create(B.class, ps);
+		c2 = ContextCache.INSTANCE.create(C.class, ps);
+
+		assertObjectEquals("{f1:'foo'}", a2);
+		assertObjectEquals("{f1:'foo',f2:-1}", b2);
+		assertObjectEquals("{f1:'foo',f2:-1,f3:false}", c2);
+		
+		assertTrue(a != a2);
+		assertTrue(b != b2);
+		assertTrue(c != c2);
+		
+		a = a2; b = b2; c = c2;
+		
+		ps = psb.set("B.f2.i", 123).build();
+		
+		a2 = ContextCache.INSTANCE.create(A.class, ps);
+		b2 = ContextCache.INSTANCE.create(B.class, ps);
+		c2 = ContextCache.INSTANCE.create(C.class, ps);
+
+		assertObjectEquals("{f1:'foo'}", a2);
+		assertObjectEquals("{f1:'foo',f2:123}", b2);
+		assertObjectEquals("{f1:'foo',f2:123,f3:false}", c2);
+		
+		assertTrue(a == a2);
+		assertTrue(b != b2);
+		assertTrue(c != c2);
+
+		a = a2; b = b2; c = c2;
+		
+		ps = psb.set("C.f3.b", true).build();
+		
+		a2 = ContextCache.INSTANCE.create(A.class, ps);
+		b2 = ContextCache.INSTANCE.create(B.class, ps);
+		c2 = ContextCache.INSTANCE.create(C.class, ps);
+
+		assertObjectEquals("{f1:'foo'}", a2);
+		assertObjectEquals("{f1:'foo',f2:123}", b2);
+		assertObjectEquals("{f1:'foo',f2:123,f3:true}", c2);
+		
+		assertTrue(a == a2);
+		assertTrue(b == b2);
+		assertTrue(c != c2);
+
+		a = a2; b = b2; c = c2;
+		
+		ps = psb.set("D.bad.o", "xxx").build();
+		
+		a2 = ContextCache.INSTANCE.create(A.class, ps);
+		b2 = ContextCache.INSTANCE.create(B.class, ps);
+		c2 = ContextCache.INSTANCE.create(C.class, ps);
+
+		assertObjectEquals("{f1:'foo'}", a2);
+		assertObjectEquals("{f1:'foo',f2:123}", b2);
+		assertObjectEquals("{f1:'foo',f2:123,f3:true}", c2);
+		
+		assertTrue(a == a2);
+		assertTrue(b == b2);
+		assertTrue(c == c2);
+		
+		assertTrue(a.getPropertyStore() == a2.getPropertyStore());
+		assertTrue(b.getPropertyStore() == b2.getPropertyStore());
+		assertTrue(c.getPropertyStore() == c2.getPropertyStore());
+		
+		a2 = ContextCache.INSTANCE.create(A.class, a.getPropertyStore().builder().set("A.f1", "foo").build());
+		assertTrue(a == a2);
+		
+		a2 = ContextCache.INSTANCE.create(A.class, a.getPropertyStore().builder().set("A.f1", "bar").build());
+		assertTrue(a != a2);
+	}
+
+	
+	public static class A extends Context {
+		public final String f1;
+
+		public A(PropertyStore2 ps) {
+			super(ps);
+			f1 = getProperty("A.f1", String.class, "xxx");
+		}
+
+		@Override
+		public Session createSession(SessionArgs args) {
+			return null;
+		}
+
+		@Override
+		public SessionArgs createDefaultSessionArgs() {
+			return null;
+		}
+	}
+	
+	public static class B extends A {
+		public int f2;
+
+		public B(PropertyStore2 ps) {
+			super(ps);
+			f2 = getProperty("B.f2.i", Integer.class, -1);
+			
+		}
+	}
+	
+	public static class C extends B {
+		public boolean f3;
+		public C(PropertyStore2 ps) {
+			super(ps);
+			f3 = getProperty("C.f3.b", boolean.class, false);
+		}
+	}
+	
+	@Test
+	public void testBadConstructor() {
+		PropertyStoreBuilder psb = PropertyStore2.create();
+		PropertyStore2 ps = psb.build();		
+	
+		try {
+			ContextCache.INSTANCE.create(D1.class, ps);
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals("Public constructor with PropertyStore argument not found on class 'org.apache.juneau.ContextCacheTest$D1'",
e.getLocalizedMessage());
+		}
+		try {
+			ContextCache.INSTANCE.create(D2.class, ps);
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals("Could not create instance of class 'org.apache.juneau.ContextCacheTest$D2'",
e.getLocalizedMessage());
+		}
+	}
+	
+	public static class D1 extends A {
+		protected D1(PropertyStore2 ps) {
+			super(ps);
+		}
+	}
+
+	public static class D2 extends A {
+		public D2(PropertyStore2 ps) {
+			super(ps);
+			throw new RuntimeException("Error!");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/227719b2/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/DataConversionTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/DataConversionTest.java
b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/DataConversionTest.java
index be7c264..899a1a7 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/DataConversionTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/DataConversionTest.java
@@ -144,7 +144,7 @@ public class DataConversionTest {
 	@Test
 	public void testObjectSwaps() throws Exception {
 		String s = "Jan 12, 2001";
-		BeanSession session = PropertyStore.create().setPojoSwaps(CalendarSwap.DateMedium.class).getBeanContext().createSession();
+		BeanSession session = BeanContext.create().setPojoSwaps(CalendarSwap.DateMedium.class).build().createSession();
 		Calendar c = session.convertToType(s, GregorianCalendar.class);
 		assertEquals(2001, c.get(Calendar.YEAR));
 		c = session.convertToType(s, Calendar.class);


Mime
View raw message