Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Convert Plexus Javadoc components to JSR330
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Dec 10, 2023
1 parent d32f8b2 commit 3800792
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 200 deletions.
28 changes: 25 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,26 @@
</properties>

<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<artifactId>plexus-testing</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand All @@ -69,6 +77,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>0.9.0.M2</version>
<executions>
<execution>
<id>generate-index</id>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
15 changes: 7 additions & 8 deletions src/main/java/org/codehaus/plexus/digest/ChecksumFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -27,19 +29,16 @@
* ChecksumFile
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
* @plexus.component role="org.codehaus.plexus.digest.ChecksumFile"
*/
@Named
public class ChecksumFile
{
/**
* @plexus.requirement role-hint="sha1"
*/
@Inject
@Named ( "sha1" )
private Digester digestSha1;

/**
* @plexus.requirement role-hint="md5";
*/
@Inject
@Named ( "md5" )
private Digester digestMd5;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/codehaus/plexus/digest/Md5Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
* limitations under the License.
*/

import javax.inject.Named;

/**
* Digester that does MD5 Message Digesting Only.
*
* @plexus.component role="org.codehaus.plexus.digest.Digester" role-hint="md5"
*/
@Named( "md5" )
public class Md5Digester
extends AbstractDigester
{
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/codehaus/plexus/digest/Sha1Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
* limitations under the License.
*/

import javax.inject.Named;

/**
* Digester that does SHA1 Message Digesting Only.
*
* @plexus.component role="org.codehaus.plexus.digest.Digester" role-hint="sha1"
*/
@Named( "sha1" )
public class Sha1Digester
extends AbstractDigester
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
* limitations under the License.
*/

import javax.inject.Named;

/**
* An MD5 implementation of the streaming digester.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @plexus.component role="org.codehaus.plexus.digest.StreamingDigester" role-hint="md5"
*/
@Named( "md5" )
public class StreamingMd5Digester
extends AbstractStreamingDigester
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
* limitations under the License.
*/

import javax.inject.Named;

/**
* An SHA-1 implementation of the streaming digester.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @plexus.component role="org.codehaus.plexus.digest.StreamingDigester" role-hint="sha1"
*/
@Named( "sha1" )
public class StreamingSha1Digester
extends AbstractStreamingDigester
{
Expand Down
29 changes: 15 additions & 14 deletions src/test/java/org/codehaus/plexus/digest/ChecksumFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
* limitations under the License.
*/

import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;

import javax.inject.Inject;
import java.io.File;

import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* ChecksumFileTest
* ChecksumFileTest
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*/
public class ChecksumFileTest extends PlexusTestCase
@PlexusTest
class ChecksumFileTest
{
@Inject
private ChecksumFile checksum;

protected void setUp()
throws Exception
{
super.setUp();

checksum = (ChecksumFile) lookup( ChecksumFile.class.getName() );
}

public void testIsValidChecksum()
@Test
void isValidChecksum()
throws Exception
{
File exampleDir = new File( getBasedir(), "src/test/examples" );
Expand All @@ -59,7 +59,8 @@ public void testIsValidChecksum()
assertTrue( checksum.isValidChecksum( new File( exampleDir, "openssl.jar.sha1" ) ) );
}

public void testCreateChecksum()
@Test
void createChecksum()
throws Exception
{
File dataFile = File.createTempFile( "plexus-digest-test", null );
Expand Down
22 changes: 13 additions & 9 deletions src/test/java/org/codehaus/plexus/digest/DigestUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,42 @@
* limitations under the License.
*/

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

public class DigestUtilsTest
extends TestCase
import static org.junit.jupiter.api.Assertions.assertEquals;

class DigestUtilsTest
{
/** SHA1 checksum from www.ibiblio.org/maven2, incuding file path */
private static final String SERVLETAPI_SHA1 = "bcc82975c0f9c681fcb01cc38504c992553e93ba";

public void testCleanChecksum()
@Test
void cleanChecksum()
throws DigesterException
{
String expected = SERVLETAPI_SHA1
+ " /home/projects/maven/repository-staging/to-ibiblio/maven2/servletapi/servletapi/2.4/servletapi-2.4.pom";

String s = DigestUtils.cleanChecksum( expected, "SHA1", "servletapi/servletapi/2.4/servletapi-2.4.pom" );
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
assertEquals( SERVLETAPI_SHA1, s, "Checksum doesn't match" );

}

public void testCleanChecksumAltDash1()
@Test
void cleanChecksumAltDash1()
throws DigesterException
{
String expected = SERVLETAPI_SHA1 + " -";
String s = DigestUtils.cleanChecksum( expected, "SHA1", "servletapi/servletapi/2.4/servletapi-2.4.pom" );
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
assertEquals( SERVLETAPI_SHA1, s, "Checksum doesn't match" );
}

public void testCleanChecksumAltDash2()
@Test
void cleanChecksumAltDash2()
throws DigesterException
{
String expected = "SHA1(-)=" + SERVLETAPI_SHA1;
String s = DigestUtils.cleanChecksum( expected, "SHA1", "servletapi/servletapi/2.4/servletapi-2.4.pom" );
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
assertEquals( SERVLETAPI_SHA1, s, "Checksum doesn't match" );
}
}
Loading

0 comments on commit 3800792

Please sign in to comment.