This is an automated email from the ASF dual-hosted git repository. mibo pushed a commit to branch OLINGO-1636-jdk_upgrade in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git
commit c028f769c1aa4ae33fc0f5b0f0dd04694d2ce0ef Author: Iliyan Velichkov <[email protected]> AuthorDate: Wed Dec 13 16:32:52 2023 +0200 more test adaptations Signed-off-by: Iliyan Velichkov <[email protected]> --- odata2-lib/odata-fit/pom.xml | 60 ++-- .../apache/olingo/odata2/ref/model/Employee.java | 336 ++++++++++----------- pom.xml | 21 +- 3 files changed, 228 insertions(+), 189 deletions(-) diff --git a/odata2-lib/odata-fit/pom.xml b/odata2-lib/odata-fit/pom.xml index 9fa33537..51eda2f1 100644 --- a/odata2-lib/odata-fit/pom.xml +++ b/odata2-lib/odata-fit/pom.xml @@ -17,7 +17,8 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -85,7 +86,8 @@ <groupId>org.apache.olingo</groupId> <artifactId>olingo-odata2-api</artifactId> <version>${project.version}</version> - <outputDirectory>${project.build.directory}/api_dependency</outputDirectory> + <outputDirectory> + ${project.build.directory}/api_dependency</outputDirectory> <overWrite>true</overWrite> </artifactItem> </artifactItems> @@ -103,7 +105,8 @@ <groupId>org.apache.olingo</groupId> <artifactId>olingo-odata2-core</artifactId> <version>${project.version}</version> - <outputDirectory>${project.build.directory}/core_dependency</outputDirectory> + <outputDirectory> + ${project.build.directory}/core_dependency</outputDirectory> <overWrite>true</overWrite> </artifactItem> </artifactItems> @@ -121,7 +124,8 @@ <groupId>org.apache.olingo</groupId> <artifactId>olingo-odata2-ref</artifactId> <version>${project.version}</version> - <outputDirectory>${project.build.directory}/ref_dependency</outputDirectory> + <outputDirectory> + ${project.build.directory}/ref_dependency</outputDirectory> <overWrite>true</overWrite> </artifactItem> </artifactItems> @@ -142,7 +146,8 @@ </goals> <configuration> <instrumentationPaths> - <param>${project.build.directory}/api_dependency</param> + <param> + ${project.build.directory}/api_dependency</param> </instrumentationPaths> </configuration> </execution> @@ -154,7 +159,8 @@ </goals> <configuration> <instrumentationPaths> - <param>${project.build.directory}/core_dependency</param> + <param> + ${project.build.directory}/core_dependency</param> </instrumentationPaths> </configuration> </execution> @@ -166,7 +172,8 @@ </goals> <configuration> <instrumentationPaths> - <param>${project.build.directory}/ref_dependency</param> + <param> + ${project.build.directory}/ref_dependency</param> </instrumentationPaths> </configuration> </execution> @@ -177,7 +184,8 @@ <artifactId>maven-surefire-plugin</artifactId> <configuration> <!-- use the instrumented classes for test execution --> - <classesDirectory>${project.build.directory}/generated-classes/emma/classes</classesDirectory> + <classesDirectory> + ${project.build.directory}/generated-classes/emma/classes</classesDirectory> </configuration> </plugin> </plugins> @@ -207,16 +215,32 @@ <artifactId>gson</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>xmlunit</groupId> - <artifactId>xmlunit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>test</scope> - </dependency> + <dependency> + <groupId>xmlunit</groupId> + <artifactId>xmlunit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-io</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-http</artifactId> + </dependency> </dependencies> </project> diff --git a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/model/Employee.java b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/model/Employee.java index 45c14d03..f02dbfe9 100644 --- a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/model/Employee.java +++ b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/model/Employee.java @@ -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.ref.model; @@ -25,159 +21,163 @@ import java.text.DateFormat; import java.util.Calendar; /** - * + * */ public class Employee { - private int employeeId; - private String employeeName; - private Integer age; - private Manager manager; - private Team team; - private Room room; - private String imageType; - private byte[] image; - private String imageUrl; - private Calendar entryDate; - private Location location; - - public Employee(final int employeeId, final String name) { - this.employeeId = employeeId; - setEmployeeName(name); - } - - public String getId() { - return Integer.toString(employeeId); - } - - public void setEmployeeName(final String employeeName) { - this.employeeName = employeeName; - } - - public String getEmployeeName() { - return employeeName; - } - - public void setAge(final int age) { - this.age = age; - } - - public int getAge() { - return age; - } - - public void setManager(final Manager manager) { - this.manager = manager; - } - - public Manager getManager() { - return manager; - } - - public void setTeam(final Team team) { - this.team = team; - } - - public Team getTeam() { - return team; - } - - public void setRoom(final Room room) { - this.room = room; - } - - public Room getRoom() { - return room; - } - - public void setImageUri(final String imageUri) { - imageUrl = imageUri; - } - - public String getImageUri() { - return imageUrl; - } - - public void setLocation(final Location location) { - this.location = location; - } - - public Location getLocation() { - return location; - } - - public void setEntryDate(final Calendar date) { - entryDate = date; - } - - public Calendar getEntryDate() { - return entryDate; - } - - public void setImageType(final String imageType) { - this.imageType = imageType; - } - - public String getImageType() { - return imageType; - } - - public void setImage(final byte[] image) { - this.image = image; - } - - public void setImage(final String imageUrl) { - image = loadImage(imageUrl); - } - - private static byte[] loadImage(final String imageUrl) { - try { - InputStream in = Employee.class.getResourceAsStream(imageUrl); - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - int b = 0; - while ((b = in.read()) != -1) { - stream.write(b); - } - - return stream.toByteArray(); - } catch (IOException e) { - throw new ModelException(e); - } - } - - public byte[] getImage() { - if (image == null) { - return null; - } - return image.clone(); - } - - @Override - public int hashCode() { - return employeeId; - } - - @Override - public boolean equals(final Object obj) { - return this == obj - || obj != null && getClass() == obj.getClass() && employeeId == ((Employee) obj).employeeId; - } - - @Override - public String toString() { - return "{\"EmployeeId\":\"" + employeeId + "\"," - + "\"EmployeeName\":\"" + employeeName + "\"," - + "\"ManagerId\":" + (manager == null ? "null" : "\"" + manager.getId() + "\"") + "," - + "\"RoomId\":" + (room == null ? "null" : "\"" + room.getId() + "\"") + "," - + "\"TeamId\":" + (team == null ? "null" : "\"" + team.getId() + "\"") + "," - + "\"Location\":" - + (location == null ? "null" : - "{\"City\":" + (location.getCity() == null ? "null" : - "{\"PostalCode\":\"" + location.getCity().getPostalCode() + "\"," - + "\"CityName\":\"" + location.getCity().getCityName() + "\"}") + "," - + "\"Country\":\"" + location.getCountry() + "\"}") + "," - + "\"Age\":" + age + "," - + "\"EntryDate\":" - + (entryDate == null ? "null" : "\"" + DateFormat.getInstance().format(entryDate.getTime()) + "\"") + "," - + "\"ImageUrl\":\"" + imageUrl + "\"}"; - } + private final int employeeId; + private String employeeName; + private Integer age; + private Manager manager; + private Team team; + private Room room; + private String imageType; + private byte[] image; + private String imageUrl; + private Calendar entryDate; + private Location location; + + public Employee(final int employeeId, final String name) { + this.employeeId = employeeId; + setEmployeeName(name); + } + + public String getId() { + return Integer.toString(employeeId); + } + + public void setEmployeeName(final String employeeName) { + this.employeeName = employeeName; + } + + public String getEmployeeName() { + return employeeName; + } + + public void setAge(final int age) { + this.age = age; + } + + public int getAge() { + return age; + } + + public void setManager(final Manager manager) { + this.manager = manager; + } + + public Manager getManager() { + return manager; + } + + public void setTeam(final Team team) { + this.team = team; + } + + public Team getTeam() { + return team; + } + + public void setRoom(final Room room) { + this.room = room; + } + + public Room getRoom() { + return room; + } + + public void setImageUri(final String imageUri) { + imageUrl = imageUri; + } + + public String getImageUri() { + return imageUrl; + } + + public void setLocation(final Location location) { + this.location = location; + } + + public Location getLocation() { + return location; + } + + public void setEntryDate(final Calendar date) { + entryDate = date; + } + + public Calendar getEntryDate() { + return entryDate; + } + + public void setImageType(final String imageType) { + this.imageType = imageType; + } + + public String getImageType() { + return imageType; + } + + public void setImage(final byte[] image) { + this.image = image; + } + + public void setImage(final String imageUrl) { + image = loadImage(imageUrl); + } + + private static byte[] loadImage(final String imageUrl) { + try { + InputStream in = Employee.class.getResourceAsStream(imageUrl); + if (null == imageUrl) { + throw new IllegalStateException("Cannot load resource " + imageUrl); + } + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + int b = 0; + while ((b = in.read()) != -1) { + stream.write(b); + } + + return stream.toByteArray(); + } catch (IOException e) { + throw new ModelException(e); + } + } + + public byte[] getImage() { + if (image == null) { + return null; + } + return image.clone(); + } + + @Override + public int hashCode() { + return employeeId; + } + + @Override + public boolean equals(final Object obj) { + return this == obj || obj != null && getClass() == obj.getClass() && employeeId == ((Employee) obj).employeeId; + } + + @Override + public String toString() { + return "{\"EmployeeId\":\"" + employeeId + "\"," + "\"EmployeeName\":\"" + employeeName + "\"," + "\"ManagerId\":" + + (manager == null ? "null" : "\"" + manager.getId() + "\"") + "," + "\"RoomId\":" + + (room == null ? "null" : "\"" + room.getId() + "\"") + "," + "\"TeamId\":" + + (team == null ? "null" : "\"" + team.getId() + "\"") + "," + "\"Location\":" + + (location == null ? "null" + : "{\"City\":" + (location.getCity() == null ? "null" + : "{\"PostalCode\":\"" + location.getCity() + .getPostalCode() + + "\"," + "\"CityName\":\"" + location.getCity() + .getCityName() + + "\"}") + + "," + "\"Country\":\"" + location.getCountry() + "\"}") + + "," + "\"Age\":" + age + "," + "\"EntryDate\":" + (entryDate == null ? "null" + : "\"" + DateFormat.getInstance() + .format(entryDate.getTime()) + + "\"") + + "," + "\"ImageUrl\":\"" + imageUrl + "\"}"; + } } diff --git a/pom.xml b/pom.xml index e7e7382b..6aa68f1d 100644 --- a/pom.xml +++ b/pom.xml @@ -468,7 +468,7 @@ governing permissions and limitations under <url>https://oss.sonatype.org/content/groups/staging</url> </repository> </repositories> - + <dependencyManagement> <dependencies> <dependency> @@ -493,10 +493,25 @@ governing permissions and limitations under <artifactId>jetty-server</artifactId> <version>${jetty.version}</version> </dependency> - <dependency> + <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-security</artifactId> - <version>12.0.4</version> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-io</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-http</artifactId> + <version>${jetty.version}</version> </dependency> </dependencies> </dependencyManagement>
