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.
------------------------------------------
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
------------------------------------------

5
json-path-assert/pom.xml

@ -42,6 +42,11 @@
<artifactId>hamcrest-library</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<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 {
private static JsonProvider jsonProvider = JsonProviderFactory.getInstance();
private static JsonProvider jsonProvider = JsonProviderFactory.createProvider();
public static void setJsonProvider(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);
} else {
for (Criteria c : this.criteriaChain) {
System.out.println("");
if (!c.singleObjectApply(map)) {
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) {
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) {
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 {
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 {
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());
}
JsonProvider jsonProvider = JsonProviderFactory.getInstance();
JsonProvider jsonProvider = JsonProviderFactory.createProvider();
Object modelRef = jsonObject;
@ -442,7 +442,7 @@ public class JsonModel {
if (!(model instanceof List)) {
model = asList(model);
}
return MappingProviderFactory.getInstance().convertValue(model, List.class, targetClass);
return MappingProviderFactory.createProvider().convertValue(model, List.class, targetClass);
}
@Override
@ -452,12 +452,12 @@ public class JsonModel {
setModel.add(model);
model = setModel;
}
return MappingProviderFactory.getInstance().convertValue(model, Set.class, targetClass);
return MappingProviderFactory.createProvider().convertValue(model, Set.class, targetClass);
}
@Override
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");
}
LinkedList<Filter> contextFilters = new LinkedList<Filter>(filters);
JsonProvider jsonProvider = JsonProviderFactory.getInstance();
JsonProvider jsonProvider = JsonProviderFactory.createProvider();
Object result = jsonObject;
@ -199,7 +199,7 @@ public class JsonPath {
public <T> T read(String json) {
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;
try {
in = new BufferedReader(new InputStreamReader(jsonURL.openStream()));
return (T) read(JsonProviderFactory.getInstance().parse(in));
return (T) read(JsonProviderFactory.createProvider().parse(in));
} finally {
IOUtils.closeQuietly(in);
}
@ -239,7 +239,7 @@ public class JsonPath {
FileInputStream fis = null;
try {
fis = new FileInputStream(jsonFile);
return (T) read(JsonProviderFactory.getInstance().parse(fis));
return (T) read(JsonProviderFactory.createProvider().parse(fis));
} finally {
IOUtils.closeQuietly(fis);
}
@ -258,7 +258,7 @@ public class JsonPath {
notNull(jsonInputStream, "json input stream can not be null");
try {
return (T) read(JsonProviderFactory.getInstance().parse(jsonInputStream));
return (T) read(JsonProviderFactory.createProvider().parse(jsonInputStream));
} finally {
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 static JsonProvider getInstance() {
return new JsonSmartJsonProvider();
public static JsonProviderFactory factory = new JsonProviderFactory() {
@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
*/
public class MappingProviderFactory {
public abstract class MappingProviderFactory {
private static MappingProvider mappingProvider;
static {
try {
Class.forName("org.codehaus.jackson.map.ObjectMapper");
public static MappingProviderFactory factory = new MappingProviderFactory() {
mappingProvider = new JacksonProvider();
} 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);
}
}
private MappingProvider provider = null;
@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() {
return mappingProvider;
public static MappingProvider createProvider() {
return factory.create();
}
}

2
pom.xml

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

Loading…
Cancel
Save