forked from googleapis/google-http-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: allow no input with Void.class parsed type
- Loading branch information
Yaniv Inbar
committed
Apr 19, 2013
1 parent
e3f9690
commit e8c4cab
Showing
10 changed files
with
402 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
google-http-client/src/main/java/com/google/api/client/testing/json/MockJsonFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2013 Google Inc. | ||
* | ||
* Licensed 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 com.google.api.client.testing.json; | ||
|
||
import com.google.api.client.json.JsonFactory; | ||
import com.google.api.client.json.JsonGenerator; | ||
import com.google.api.client.json.JsonParser; | ||
import com.google.api.client.util.Beta; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.io.Reader; | ||
import java.io.Writer; | ||
import java.nio.charset.Charset; | ||
|
||
/** | ||
* {@link Beta} <br/> | ||
* Mock for {@link JsonFactory}. | ||
* | ||
* <p> | ||
* Implementation is thread-safe. | ||
* </p> | ||
* | ||
* @author rmistry@google.com (Ravi Mistry) | ||
* @since 1.15 (since 1.11 as com.google.api.client.testing.http.json.MockJsonFactory) | ||
*/ | ||
@Beta | ||
public class MockJsonFactory extends JsonFactory { | ||
|
||
@Override | ||
public JsonParser createJsonParser(InputStream in) throws IOException { | ||
return new MockJsonParser(this); | ||
} | ||
|
||
@Override | ||
public JsonParser createJsonParser(InputStream in, Charset charset) throws IOException { | ||
return new MockJsonParser(this); | ||
} | ||
|
||
@Override | ||
public JsonParser createJsonParser(String value) throws IOException { | ||
return new MockJsonParser(this); | ||
} | ||
|
||
@Override | ||
public JsonParser createJsonParser(Reader reader) throws IOException { | ||
return new MockJsonParser(this); | ||
} | ||
|
||
@Override | ||
public JsonGenerator createJsonGenerator(OutputStream out, Charset enc) throws IOException { | ||
return new MockJsonGenerator(this); | ||
} | ||
|
||
@Override | ||
public JsonGenerator createJsonGenerator(Writer writer) throws IOException { | ||
return new MockJsonGenerator(this); | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
google-http-client/src/main/java/com/google/api/client/testing/json/MockJsonGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2013 Google Inc. | ||
* | ||
* Licensed 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 com.google.api.client.testing.json; | ||
|
||
import com.google.api.client.json.JsonFactory; | ||
import com.google.api.client.json.JsonGenerator; | ||
import com.google.api.client.util.Beta; | ||
|
||
import java.io.IOException; | ||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
/** | ||
* {@link Beta} <br/> | ||
* Mock for {@link JsonGenerator}. | ||
* | ||
* <p> | ||
* Implementation is thread-safe. | ||
* </p> | ||
* | ||
* @author rmistry@google.com (Ravi Mistry) | ||
* @since 1.15 (since 1.11 as com.google.api.client.testing.http.json.MockJsonGenerator) | ||
*/ | ||
@Beta | ||
public class MockJsonGenerator extends JsonGenerator { | ||
|
||
private final JsonFactory factory; | ||
|
||
MockJsonGenerator(JsonFactory factory) { | ||
this.factory = factory; | ||
} | ||
|
||
@Override | ||
public JsonFactory getFactory() { | ||
return factory; | ||
} | ||
|
||
@Override | ||
public void flush() throws IOException { | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeStartArray() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeEndArray() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeStartObject() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeEndObject() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeFieldName(String name) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNull() throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeString(String value) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeBoolean(boolean state) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(int v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(long v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(BigInteger v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(float v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(double v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(BigDecimal v) throws IOException { | ||
} | ||
|
||
@Override | ||
public void writeNumber(String encodedValue) throws IOException { | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
google-http-client/src/main/java/com/google/api/client/testing/json/MockJsonParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* Copyright (c) 2013 Google Inc. | ||
* | ||
* Licensed 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 com.google.api.client.testing.json; | ||
|
||
import com.google.api.client.json.JsonFactory; | ||
import com.google.api.client.json.JsonParser; | ||
import com.google.api.client.json.JsonToken; | ||
import com.google.api.client.util.Beta; | ||
|
||
import java.io.IOException; | ||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
/** | ||
* {@link Beta} <br/> | ||
* Mock for {@link JsonParser}. | ||
* | ||
* <p> | ||
* Implementation is thread-safe. | ||
* </p> | ||
* | ||
* @author rmistry@google.com (Ravi Mistry) | ||
* @since 1.15 (since 1.11 as com.google.api.client.testing.http.json.MockJsonParser) | ||
*/ | ||
@Beta | ||
public class MockJsonParser extends JsonParser { | ||
|
||
private boolean isClosed; | ||
|
||
private final JsonFactory factory; | ||
|
||
MockJsonParser(JsonFactory factory) { | ||
this.factory = factory; | ||
} | ||
|
||
@Override | ||
public JsonFactory getFactory() { | ||
return factory; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
isClosed = true; | ||
} | ||
|
||
@Override | ||
public JsonToken nextToken() throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public JsonToken getCurrentToken() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getCurrentName() throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public JsonParser skipChildren() throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getText() throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public byte getByteValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public short getShortValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getIntValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public float getFloatValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long getLongValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public double getDoubleValue() throws IOException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public BigInteger getBigIntegerValue() throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public BigDecimal getDecimalValue() throws IOException { | ||
return null; | ||
} | ||
|
||
/** | ||
* Returns whether {@link #close()} was called. | ||
* | ||
* @since 1.15 | ||
*/ | ||
public boolean isClosed() { | ||
return isClosed; | ||
} | ||
} |
Oops, something went wrong.