Skip to content

Commit

Permalink
Add workaround for a missing 'Resource' implementation with a no-arg …
Browse files Browse the repository at this point in the history
…constructor

Signed-off-by: Steffen Nießing <[email protected]>
  • Loading branch information
zUniQueX committed Jul 20, 2023
1 parent e4236a9 commit e658ae1
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
<module>servlet-request-wrapper-binding-2</module>
<module>sonar-test</module>
<module>spring6</module>
<module>test-utils</module>
<module>tracing-support</module>
</modules>
</profile>
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/security-digest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,19 @@
<loginServices>
<loginService implementation="org.eclipse.jetty.security.HashLoginService">
<name>my-realm</name>
<config>${basedir}/src/main/resources/jetty/realm.properties</config>
<config implementation="org.glassfish.jersey.tests.integration.utils.JerseyPathResource">
<path>${basedir}/src/main/resources/jetty/realm.properties</path>
</config>
</loginService>
</loginServices>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.tests.integration</groupId>
<artifactId>test-utils</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>

</plugins>
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/test-utils/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<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/maven-v4_0_0.xsd">
<parent>
<artifactId>project</artifactId>
<groupId>org.glassfish.jersey.tests.integration</groupId>
<version>3.1.99-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>test-utils</artifactId>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.tests.integration.utils;

import org.eclipse.jetty.util.resource.Resource;

import java.io.File;
import java.net.URI;
import java.nio.file.Path;

/**
* A {@link Resource} implementation with a default constructor to support using it in Maven {@code implementation} attributes.
* This is obsolete from Jetty >12.0.0.beta3.
*
* TODO: remove this
*/
public class JerseyPathResource extends Resource {
private String path;

@Override
public Path getPath() {
return new File(path).toPath();
}

@Override
public boolean isContainedIn(Resource r) {
return false;
}

@Override
public boolean isDirectory() {
return new File(path).isDirectory();
}

@Override
public boolean isReadable() {
return new File(path).canRead();
}

@Override
public URI getURI() {
return new File(path).toURI();
}

@Override
public String getName() {
return path;
}

@Override
public String getFileName() {
return path;
}

@Override
public Resource resolve(String subUriPath) {
return null;
}
}

0 comments on commit e658ae1

Please sign in to comment.