forked from apache/olingo-odata2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>
- Loading branch information
1 parent
cac7590
commit 7d55fd1
Showing
21 changed files
with
4,064 additions
and
3,886 deletions.
There are no files selected for viewing
412 changes: 209 additions & 203 deletions
412
...a/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java
Large diffs are not rendered by default.
Oops, something went wrong.
1,141 changes: 616 additions & 525 deletions
1,141
...c/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPADefaultProcessorTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
1,397 changes: 726 additions & 671 deletions
1,397
...rc/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAResponseBuilderTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
584 changes: 261 additions & 323 deletions
584
...ache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserForStaticMethodTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
1,267 changes: 651 additions & 616 deletions
1,267
...est/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
69 changes: 29 additions & 40 deletions
69
...src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/OnJPAWriteContentMock.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 |
---|---|---|
@@ -1,58 +1,47 @@ | ||
/******************************************************************************* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* 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.olingo.odata2.jpa.processor.core.mock; | ||
|
||
import java.sql.Blob; | ||
import java.sql.Clob; | ||
import java.sql.SQLException; | ||
|
||
import jakarta.sql.rowset.serial.SerialBlob; | ||
import jakarta.sql.rowset.serial.SerialClob; | ||
import jakarta.sql.rowset.serial.SerialException; | ||
|
||
import javax.sql.rowset.serial.SerialBlob; | ||
import javax.sql.rowset.serial.SerialClob; | ||
import org.apache.olingo.odata2.jpa.processor.api.OnJPAWriteContent; | ||
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; | ||
|
||
public class OnJPAWriteContentMock implements OnJPAWriteContent { | ||
|
||
@Override | ||
public Blob getJPABlob(final byte[] binaryData) throws ODataJPARuntimeException { | ||
try { | ||
return new SerialBlob(binaryData); | ||
} catch (SerialException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
} catch (SQLException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
@Override | ||
public Blob getJPABlob(final byte[] binaryData) throws ODataJPARuntimeException { | ||
try { | ||
return new SerialBlob(binaryData); | ||
} catch (SQLException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
} | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public Clob getJPAClob(final char[] characterData) throws ODataJPARuntimeException { | ||
try { | ||
return new SerialClob(characterData); | ||
} catch (SerialException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
} catch (SQLException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
@Override | ||
public Clob getJPAClob(final char[] characterData) throws ODataJPARuntimeException { | ||
try { | ||
return new SerialClob(characterData); | ||
} catch (SQLException e) { | ||
ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); | ||
} | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
} |
92 changes: 42 additions & 50 deletions
92
...core/src/test/java/org/apache/olingo/odata2/client/core/ep/JSON_XMLErrorConsumerTest.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 |
---|---|---|
@@ -1,70 +1,62 @@ | ||
/******************************************************************************* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* 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.olingo.odata2.client.core.ep; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Locale; | ||
|
||
import org.apache.olingo.odata2.api.ep.EntityProviderException; | ||
import org.apache.olingo.odata2.api.processor.ODataErrorContext; | ||
import org.apache.olingo.odata2.client.api.ODataClient; | ||
import org.apache.olingo.odata2.client.core.ep.deserializer.AbstractDeserializerTest; | ||
import org.apache.olingo.odata2.testutil.helper.LocaleAsserter; | ||
import org.apache.olingo.odata2.testutil.helper.StringHelper; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* | ||
*/ | ||
public class JSON_XMLErrorConsumerTest extends AbstractDeserializerTest { | ||
|
||
private static final String JSON = "application/json"; | ||
private static final String XML = "application/xml"; | ||
@Test | ||
public void readErrorDocumentJson() throws EntityProviderException { | ||
ODataClient providerFacade = ODataClient.newInstance(); | ||
String errorDoc = "{\"error\":{\"code\":\"ErrorCode\",\"message\":{\"lang\":\"en-US\",\"value\":\"Message\"}}}"; | ||
ODataErrorContext errorContext = providerFacade.createDeserializer(JSON). | ||
readErrorDocument(StringHelper.encapsulate(errorDoc)); | ||
// | ||
assertEquals("Wrong content type", "application/json", errorContext.getContentType()); | ||
assertEquals("Wrong message", "Message", errorContext.getMessage()); | ||
assertEquals("Wrong error code", "ErrorCode", errorContext.getErrorCode()); | ||
assertEquals("Wrong locale for lang", Locale.US, errorContext.getLocale()); | ||
} | ||
private static final String JSON = "application/json"; | ||
private static final String XML = "application/xml"; | ||
|
||
@Test | ||
public void readErrorDocumentJson() throws EntityProviderException { | ||
ODataClient providerFacade = ODataClient.newInstance(); | ||
String errorDoc = "{\"error\":{\"code\":\"ErrorCode\",\"message\":{\"lang\":\"en-US\",\"value\":\"Message\"}}}"; | ||
ODataErrorContext errorContext = providerFacade.createDeserializer(JSON) | ||
.readErrorDocument(StringHelper.encapsulate(errorDoc)); | ||
// | ||
assertEquals("Wrong content type", "application/json", errorContext.getContentType()); | ||
assertEquals("Wrong message", "Message", errorContext.getMessage()); | ||
assertEquals("Wrong error code", "ErrorCode", errorContext.getErrorCode()); | ||
LocaleAsserter.assertLocale("Wrong locale for lang", errorContext.getLocale(), Locale.US); | ||
} | ||
|
||
@Test | ||
public void readErrorDocumentXml() throws EntityProviderException { | ||
ODataClient providerFacade = ODataClient.newInstance(); | ||
String errorDoc = | ||
"<?xml version='1.0' encoding='UTF-8'?>\n" + | ||
"<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\n" + | ||
"\t<code>ErrorCode</code>\n" + | ||
"\t<message xml:lang=\"en-US\">Message</message>\n" + | ||
"</error>"; | ||
ODataErrorContext errorContext = providerFacade.createDeserializer(XML). | ||
readErrorDocument(StringHelper.encapsulate(errorDoc)); | ||
// | ||
assertEquals("Wrong content type", "application/xml", errorContext.getContentType()); | ||
assertEquals("Wrong message", "Message", errorContext.getMessage()); | ||
assertEquals("Wrong error code", "ErrorCode", errorContext.getErrorCode()); | ||
assertEquals("Wrong locale for lang", Locale.US, errorContext.getLocale()); | ||
} | ||
@Test | ||
public void readErrorDocumentXml() throws EntityProviderException { | ||
ODataClient providerFacade = ODataClient.newInstance(); | ||
String errorDoc = "<?xml version='1.0' encoding='UTF-8'?>\n" | ||
+ "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\n" + "\t<code>ErrorCode</code>\n" | ||
+ "\t<message xml:lang=\"en-US\">Message</message>\n" + "</error>"; | ||
ODataErrorContext errorContext = providerFacade.createDeserializer(XML) | ||
.readErrorDocument(StringHelper.encapsulate(errorDoc)); | ||
// | ||
assertEquals("Wrong content type", "application/xml", errorContext.getContentType()); | ||
assertEquals("Wrong message", "Message", errorContext.getMessage()); | ||
assertEquals("Wrong error code", "ErrorCode", errorContext.getErrorCode()); | ||
LocaleAsserter.assertLocale("Wrong locale for lang", errorContext.getLocale(), Locale.US); | ||
} | ||
} |
Oops, something went wrong.