Browse Source

Release preparations.

pull/8/merge
Kalle Stenflo 13 years ago
parent
commit
c0aec497a6
  1. 12
      README
  2. 5
      json-path-assert/pom.xml
  3. 2
      json-path-assert/src/main/java/com/jayway/jsonassert/JsonAssert.java
  4. 2
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java
  5. 16
      json-path/src/main/java/com/jayway/jsonpath/JsonModel.java
  6. 10
      json-path/src/main/java/com/jayway/jsonpath/JsonPath.java
  7. 14
      json-path/src/main/java/com/jayway/jsonpath/spi/JsonProviderFactory.java
  8. 36
      json-path/src/main/java/com/jayway/jsonpath/spi/MappingProviderFactory.java
  9. 2
      pom.xml

12
README

@ -1,5 +1,17 @@
Java DSL for reading and testing JSON documents. Java DSL for reading and testing JSON documents.
------------------------------------------
0.8.0 2012-03-08
------------------------------------------
- Fixed issue http://code.google.com/p/json-path/issues/detail?id=8
- Fixed issue http://code.google.com/p/json-path/issues/detail?id=9
- Improved compliance
- Fixed bug with '=' sign when evaluating expressions
- OSGi support added
- Support for custom array filters in JsonPath
- Lots of new features in JsonModel
------------------------------------------ ------------------------------------------
0.5.6 2012-02-09 0.5.6 2012-02-09
------------------------------------------ ------------------------------------------

5
json-path-assert/pom.xml

@ -42,6 +42,11 @@
<artifactId>hamcrest-library</artifactId> <artifactId>hamcrest-library</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

2
json-path-assert/src/main/java/com/jayway/jsonassert/JsonAssert.java

@ -19,7 +19,7 @@ import java.util.Map;
*/ */
public class JsonAssert { public class JsonAssert {
private static JsonProvider jsonProvider = JsonProviderFactory.getInstance(); private static JsonProvider jsonProvider = JsonProviderFactory.createProvider();
public static void setJsonProvider(JsonProvider jsonProvider) { public static void setJsonProvider(JsonProvider jsonProvider) {
JsonAssert.jsonProvider = jsonProvider; JsonAssert.jsonProvider = jsonProvider;

2
json-path/src/main/java/com/jayway/jsonpath/Criteria.java

@ -87,8 +87,6 @@ public class Criteria {
return criteriaChain.get(0).singleObjectApply(map); return criteriaChain.get(0).singleObjectApply(map);
} else { } else {
for (Criteria c : this.criteriaChain) { for (Criteria c : this.criteriaChain) {
System.out.println("");
if (!c.singleObjectApply(map)) { if (!c.singleObjectApply(map)) {
return false; return false;
} }

16
json-path/src/main/java/com/jayway/jsonpath/JsonModel.java

@ -222,25 +222,25 @@ public class JsonModel {
public static JsonModel create(String json) { public static JsonModel create(String json) {
notEmpty(json, "json can not be null or empty"); notEmpty(json, "json can not be null or empty");
return new JsonModel(json, JsonProviderFactory.getInstance()); return new JsonModel(json, JsonProviderFactory.createProvider());
} }
public static JsonModel create(Object jsonObject) { public static JsonModel create(Object jsonObject) {
notNull(jsonObject, "jsonObject can not be null"); notNull(jsonObject, "jsonObject can not be null");
return new JsonModel(jsonObject, JsonProviderFactory.getInstance()); return new JsonModel(jsonObject, JsonProviderFactory.createProvider());
} }
public static JsonModel create(URL url) throws IOException { public static JsonModel create(URL url) throws IOException {
notNull(url, "url can not be null"); notNull(url, "url can not be null");
return new JsonModel(url, JsonProviderFactory.getInstance()); return new JsonModel(url, JsonProviderFactory.createProvider());
} }
public static JsonModel create(InputStream jsonInputStream) throws IOException { public static JsonModel create(InputStream jsonInputStream) throws IOException {
notNull(jsonInputStream, "jsonInputStream can not be null"); notNull(jsonInputStream, "jsonInputStream can not be null");
return new JsonModel(jsonInputStream, JsonProviderFactory.getInstance()); return new JsonModel(jsonInputStream, JsonProviderFactory.createProvider());
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -256,7 +256,7 @@ public class JsonModel {
throw new IndefinitePathException(jsonPath.getPath()); throw new IndefinitePathException(jsonPath.getPath());
} }
JsonProvider jsonProvider = JsonProviderFactory.getInstance(); JsonProvider jsonProvider = JsonProviderFactory.createProvider();
Object modelRef = jsonObject; Object modelRef = jsonObject;
@ -442,7 +442,7 @@ public class JsonModel {
if (!(model instanceof List)) { if (!(model instanceof List)) {
model = asList(model); model = asList(model);
} }
return MappingProviderFactory.getInstance().convertValue(model, List.class, targetClass); return MappingProviderFactory.createProvider().convertValue(model, List.class, targetClass);
} }
@Override @Override
@ -452,12 +452,12 @@ public class JsonModel {
setModel.add(model); setModel.add(model);
model = setModel; model = setModel;
} }
return MappingProviderFactory.getInstance().convertValue(model, Set.class, targetClass); return MappingProviderFactory.createProvider().convertValue(model, Set.class, targetClass);
} }
@Override @Override
public <T> T to(Class<T> targetClass) { public <T> T to(Class<T> targetClass) {
return MappingProviderFactory.getInstance().convertValue(model, targetClass); return MappingProviderFactory.createProvider().convertValue(model, targetClass);
} }
} }
} }

10
json-path/src/main/java/com/jayway/jsonpath/JsonPath.java

@ -171,7 +171,7 @@ public class JsonPath {
throw new IllegalArgumentException("Invalid container object"); throw new IllegalArgumentException("Invalid container object");
} }
LinkedList<Filter> contextFilters = new LinkedList<Filter>(filters); LinkedList<Filter> contextFilters = new LinkedList<Filter>(filters);
JsonProvider jsonProvider = JsonProviderFactory.getInstance(); JsonProvider jsonProvider = JsonProviderFactory.createProvider();
Object result = jsonObject; Object result = jsonObject;
@ -199,7 +199,7 @@ public class JsonPath {
public <T> T read(String json) { public <T> T read(String json) {
notEmpty(json, "json can not be null or empty"); notEmpty(json, "json can not be null or empty");
return (T) read(JsonProviderFactory.getInstance().parse(json)); return (T) read(JsonProviderFactory.createProvider().parse(json));
} }
/** /**
@ -217,7 +217,7 @@ public class JsonPath {
BufferedReader in = null; BufferedReader in = null;
try { try {
in = new BufferedReader(new InputStreamReader(jsonURL.openStream())); in = new BufferedReader(new InputStreamReader(jsonURL.openStream()));
return (T) read(JsonProviderFactory.getInstance().parse(in)); return (T) read(JsonProviderFactory.createProvider().parse(in));
} finally { } finally {
IOUtils.closeQuietly(in); IOUtils.closeQuietly(in);
} }
@ -239,7 +239,7 @@ public class JsonPath {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
fis = new FileInputStream(jsonFile); fis = new FileInputStream(jsonFile);
return (T) read(JsonProviderFactory.getInstance().parse(fis)); return (T) read(JsonProviderFactory.createProvider().parse(fis));
} finally { } finally {
IOUtils.closeQuietly(fis); IOUtils.closeQuietly(fis);
} }
@ -258,7 +258,7 @@ public class JsonPath {
notNull(jsonInputStream, "json input stream can not be null"); notNull(jsonInputStream, "json input stream can not be null");
try { try {
return (T) read(JsonProviderFactory.getInstance().parse(jsonInputStream)); return (T) read(JsonProviderFactory.createProvider().parse(jsonInputStream));
} finally { } finally {
IOUtils.closeQuietly(jsonInputStream); IOUtils.closeQuietly(jsonInputStream);
} }

14
json-path/src/main/java/com/jayway/jsonpath/spi/JsonProviderFactory.java

@ -21,8 +21,18 @@ import com.jayway.jsonpath.spi.impl.JsonSmartJsonProvider;
*/ */
public abstract class JsonProviderFactory { public abstract class JsonProviderFactory {
public static JsonProvider getInstance() { public static JsonProviderFactory factory = new JsonProviderFactory() {
return new JsonSmartJsonProvider(); @Override
protected JsonProvider create() {
return new JsonSmartJsonProvider();
}
};
public static JsonProvider createProvider() {
return factory.create();
} }
protected abstract JsonProvider create();
} }

36
json-path/src/main/java/com/jayway/jsonpath/spi/MappingProviderFactory.java

@ -19,24 +19,36 @@ import com.jayway.jsonpath.spi.impl.JacksonProvider;
/** /**
* @author Kalle Stenflo * @author Kalle Stenflo
*/ */
public class MappingProviderFactory { public abstract class MappingProviderFactory {
private static MappingProvider mappingProvider;
static { public static MappingProviderFactory factory = new MappingProviderFactory() {
try {
Class.forName("org.codehaus.jackson.map.ObjectMapper");
mappingProvider = new JacksonProvider(); private MappingProvider provider = null;
} catch (ClassNotFoundException e) {
throw new RuntimeException("org.codehaus.jackson.map.ObjectMapper not found on classpath. This is an optional dependency needed for POJO conversions.", e);
}
}
@Override
protected MappingProvider create() {
if (this.provider == null) {
synchronized (MappingProviderFactory.class) {
try {
Class.forName("org.codehaus.jackson.map.ObjectMapper");
provider = new JacksonProvider();
return provider;
} catch (ClassNotFoundException e) {
throw new RuntimeException("org.codehaus.jackson.map.ObjectMapper not found on classpath. This is an optional dependency needed for POJO conversions.", e);
}
}
} else {
return provider;
}
}
};
protected abstract MappingProvider create();
public static MappingProvider getInstance() { public static MappingProvider createProvider() {
return mappingProvider; return factory.create();
} }
} }

2
pom.xml

@ -78,6 +78,7 @@
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<!--
<plugin> <plugin>
<groupId>org.eclipse.m2e</groupId> <groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId> <artifactId>lifecycle-mapping</artifactId>
@ -103,6 +104,7 @@
</lifecycleMappingMetadata> </lifecycleMappingMetadata>
</configuration> </configuration>
</plugin> </plugin>
-->
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>

Loading…
Cancel
Save