Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Spring Boot 3.2.0 #2

Merged
merged 12 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto 8
- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '8'
java-version: '17'
architecture: x64
- name: Maven Build
run: mvn clean install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 8 (Corretto)
- name: Set up JDK (Corretto)
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build with Maven
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto 8
- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 8
java-version: 17
- name: Maven Build
run: mvn clean install
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Set up JDK Corretto 8
- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '8'
java-version: '17'
architecture: x64

- name: "Configure Git"
Expand Down
2 changes: 0 additions & 2 deletions odata2-annotation-processor/annotation-processor-ref/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
Expand All @@ -102,7 +101,6 @@
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
/*******************************************************************************
* 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.annotation.processor.ref.model;

Expand All @@ -23,74 +19,76 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

/**
*
*/
public class ResourceHelper {

public static byte[] loadAsByte(final String resource) {
return load(resource, new byte[0]);
}

public static byte[] load(final String resource, final byte[] defaultResult) {
InputStream instream = null;
try {
instream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
if (instream == null) {
return defaultResult;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int b = 0;
while ((b = instream.read()) != -1) {
stream.write(b);
}
public static byte[] loadAsByte(final String resource) {
return load(resource, new byte[0]);
}

return stream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (instream != null) {
public static byte[] load(final String resource, final byte[] defaultResult) {
InputStream instream = null;
try {
instream.close();
} catch (IOException ex) {}
}
instream = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(resource);
if (instream == null) {
return defaultResult;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int b = 0;
while ((b = instream.read()) != -1) {
stream.write(b);
}

return stream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (instream != null) {
try {
instream.close();
} catch (IOException ex) {
}
}
}
}

public enum Format {
BMP, JPEG, PNG, GIF
}
}

public enum Format {
BMP, JPEG, PNG, GIF
};
public static byte[] generateImage() {
return generateImage(Format.PNG);
}

public static byte[] generateImage() {
return generateImage(Format.PNG);
}
public static byte[] generateImage(final Format format) {
try {
int width = 320;
int height = 320;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
WritableRaster raster = image.getRaster();

public static byte[] generateImage(final Format format) {
try {
int width = 320;
int height = 320;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
WritableRaster raster = image.getRaster();
int mod = format.ordinal() + 2;
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
if (((h / 32) + (w / 32)) % mod == 0) {
raster.setSample(w, h, 0, 0);
} else {
raster.setSample(w, h, 0, 1);
}
}
}

int mod = format.ordinal() + 2;
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
if (((h / 32) + (w / 32)) % mod == 0) {
raster.setSample(w, h, 0, 0);
} else {
raster.setSample(w, h, 0, 1);
}
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ImageIO.write(image, format.name(), out);
return out.toByteArray();
} catch (IOException ex) {
return new byte[0];
}
}

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ImageIO.write(image, format.name(), out);
return out.toByteArray();
} catch (IOException ex) {
return new byte[0];
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
/*******************************************************************************
* 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.annotation.processor.ref;

import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpResponse;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.api.edm.Edm;
Expand All @@ -38,59 +32,59 @@

/**
* Abstract base class for tests employing the reference scenario reading or writing XML.
*
*
*/
@Ignore("no test methods")
public class AbstractRefXmlTest extends AbstractRefTest {
public AbstractRefXmlTest(final ServletType servletType) {
super(servletType);
}

@Before
public void setXmlNamespacePrefixes() {
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005);
prefixMap.put(Edm.PREFIX_APP, Edm.NAMESPACE_APP_2007);
prefixMap.put(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08);
prefixMap.put(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08);
prefixMap.put(Edm.PREFIX_EDM, Edm.NAMESPACE_EDM_2008_09);
prefixMap.put(Edm.PREFIX_EDMX, Edm.NAMESPACE_EDMX_2007_06);
prefixMap.put(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998);
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
}

@Override
protected void badRequest(final String uri) throws Exception {
final HttpResponse response = callUri(uri, HttpStatusCodes.BAD_REQUEST);
validateXmlError(getBody(response));
}
public AbstractRefXmlTest(final ServletType servletType) {
super(servletType);
}

@Override
protected void notFound(final String uri) throws Exception {
final HttpResponse response = callUri(uri, HttpStatusCodes.NOT_FOUND);
validateXmlError(getBody(response));
}
@Before
public void setXmlNamespacePrefixes() {
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005);
prefixMap.put(Edm.PREFIX_APP, Edm.NAMESPACE_APP_2007);
prefixMap.put(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08);
prefixMap.put(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08);
prefixMap.put(Edm.PREFIX_EDM, Edm.NAMESPACE_EDM_2008_09);
prefixMap.put(Edm.PREFIX_EDMX, Edm.NAMESPACE_EDMX_2007_06);
prefixMap.put(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998);
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
}

protected void validateXmlError(final String xml) throws XpathException, IOException, SAXException {
assertXpathExists("/m:error", xml);
assertXpathExists("/m:error/m:code", xml);
assertXpathExists("/m:error/m:message[@xml:lang=\"en\"]", xml);
}
@Override
protected void badRequest(final String uri) throws Exception {
final HttpResponse response = callUri(uri, HttpStatusCodes.BAD_REQUEST);
validateXmlError(getBody(response));
}

protected String readFile(final String filename) throws IOException {
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
if (in == null) {
throw new IOException("Requested file '" + filename + "' was not found.");
@Override
protected void notFound(final String uri) throws Exception {
final HttpResponse response = callUri(uri, HttpStatusCodes.NOT_FOUND);
validateXmlError(getBody(response));
}

byte[] tmp = new byte[8192];
int count = in.read(tmp);
StringBuffer b = new StringBuffer();
while (count >= 0) {
b.append(new String(tmp, 0, count));
count = in.read(tmp);
protected void validateXmlError(final String xml) throws XpathException, IOException, SAXException {
assertXpathExists("/m:error", xml);
assertXpathExists("/m:error/m:code", xml);
assertXpathExists("/m:error/m:message[@xml:lang=\"en\"]", xml);
}

return b.toString();
}
protected String readFile(final String filename) throws IOException {
InputStream in = AbstractRefXmlTest.class.getResourceAsStream(filename);
if (in == null) {
throw new IOException("Requested file '" + filename + "' was not found.");
}

byte[] tmp = new byte[8192];
int count = in.read(tmp);
StringBuffer b = new StringBuffer();
while (count >= 0) {
b.append(new String(tmp, 0, count));
count = in.read(tmp);
}

return b.toString();
}
}
Loading