Skip to content

Commit 0a68787

Browse files
authored
Merge pull request #798 from hazendaz/master
Attempting to solve mockito issues
2 parents 531bd26 + c9122a4 commit 0a68787

File tree

9 files changed

+35
-98
lines changed

9 files changed

+35
-98
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
os: [ubuntu-latest, macOS-latest, windows-latest]
29-
java: [17, 19, 20-ea]
29+
java: [17, 20, 21-ea]
3030
distribution: ['zulu']
3131
fail-fast: false
3232
max-parallel: 5

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2010-2022 the original author or authors.
4+
Copyright 2010-2023 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.

.mvn/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2010-2022 the original author or authors.
4+
Copyright 2010-2023 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 20 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -23,85 +23,50 @@
2323
import java.net.PasswordAuthentication;
2424
import java.net.URL;
2525
import java.nio.file.Files;
26-
import java.nio.file.LinkOption;
2726
import java.nio.file.Path;
2827
import java.nio.file.Paths;
2928
import java.nio.file.StandardCopyOption;
30-
import java.nio.file.StandardOpenOption;
31-
import java.util.Properties;
3229

3330
public final class MavenWrapperDownloader
3431
{
35-
private static final String WRAPPER_VERSION = "3.1.1";
32+
private static final String WRAPPER_VERSION = "3.2.0";
3633

3734
private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
3835

39-
/**
40-
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
41-
*/
42-
private static final String DEFAULT_DOWNLOAD_URL =
43-
"https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION
44-
+ "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
45-
46-
/**
47-
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the
48-
* default one.
49-
*/
50-
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
51-
52-
/**
53-
* Path where the maven-wrapper.jar will be saved to.
54-
*/
55-
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
56-
57-
/**
58-
* Name of the property which should be used to override the default download url for the wrapper.
59-
*/
60-
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
61-
6236
public static void main( String[] args )
6337
{
64-
if ( args.length == 0 )
65-
{
66-
System.err.println( " - ERROR projectBasedir parameter missing" );
67-
System.exit( 1 );
68-
}
38+
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
6939

70-
log( " - Downloader started" );
71-
final String dir = args[0].replace( "..", "" ); // Sanitize path
72-
final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize();
73-
if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) )
40+
if ( args.length != 2 )
7441
{
75-
System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir );
42+
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
7643
System.exit( 1 );
7744
}
7845

79-
log( " - Using base directory: " + projectBasedir );
80-
81-
// If the maven-wrapper.properties exists, read it and check if it contains a custom
82-
// wrapperUrl parameter.
83-
Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH );
84-
String url = readWrapperUrl( mavenWrapperPropertyFile );
85-
8646
try
8747
{
88-
Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH );
89-
createDirectories( outputFile.getParent() );
90-
downloadFileFromURL( url, outputFile );
48+
log( " - Downloader started" );
49+
final URL wrapperUrl = new URL( args[0] );
50+
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
51+
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
52+
downloadFileFromURL( wrapperUrl, wrapperJarPath );
9153
log( "Done" );
92-
System.exit( 0 );
9354
}
9455
catch ( IOException e )
9556
{
96-
System.err.println( "- Error downloading" );
97-
e.printStackTrace();
57+
System.err.println( "- Error downloading: " + e.getMessage() );
58+
if ( VERBOSE )
59+
{
60+
e.printStackTrace();
61+
}
9862
System.exit( 1 );
9963
}
10064
}
10165

102-
private static void downloadFileFromURL( String urlString, Path destination ) throws IOException
66+
private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
67+
throws IOException
10368
{
104-
log( " - Downloading to: " + destination );
69+
log( " - Downloading to: " + wrapperJarPath );
10570
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
10671
{
10772
final String username = System.getenv( "MVNW_USERNAME" );
@@ -115,40 +80,11 @@ protected PasswordAuthentication getPasswordAuthentication()
11580
}
11681
} );
11782
}
118-
URL website = new URL( urlString );
119-
try ( InputStream inStream = website.openStream() ) {
120-
Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING );
121-
}
122-
log( " - Downloader complete" );
123-
}
124-
125-
private static void createDirectories(Path outputPath) throws IOException
126-
{
127-
if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) {
128-
Path createDirectories = Files.createDirectories( outputPath );
129-
log( " - Directories created: " + createDirectories );
130-
}
131-
}
132-
133-
private static String readWrapperUrl( Path mavenWrapperPropertyFile )
134-
{
135-
String url = DEFAULT_DOWNLOAD_URL;
136-
if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) )
83+
try ( InputStream inStream = wrapperUrl.openStream() )
13784
{
138-
log( " - Reading property file: " + mavenWrapperPropertyFile );
139-
try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) )
140-
{
141-
Properties mavenWrapperProperties = new Properties();
142-
mavenWrapperProperties.load( in );
143-
url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL );
144-
}
145-
catch ( IOException e )
146-
{
147-
System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" );
148-
}
85+
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
14986
}
150-
log( " - Downloading from: " + url );
151-
return url;
87+
log( " - Downloader complete" );
15288
}
15389

15490
private static void log( String msg )

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2010-2022 the original author or authors.
4+
Copyright 2010-2023 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -267,8 +267,8 @@
267267
<artifactId>nekohtml</artifactId>
268268
</exclusion>
269269
<exclusion>
270-
<groupId>junit</groupId>
271-
<artifactId>junit</artifactId>
270+
<groupId>junit</groupId>
271+
<artifactId>junit</artifactId>
272272
</exclusion>
273273
</exclusions>
274274
</dependency>

src/test/java/org/mybatis/spring/MyBatisSpringTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2022 the original author or authors.
2+
* Copyright 2010-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@
2323
import com.mockrunner.mock.jdbc.MockDataSource;
2424
import com.mockrunner.mock.jdbc.MockPreparedStatement;
2525

26+
import jakarta.transaction.UserTransaction;
27+
2628
import org.apache.ibatis.exceptions.PersistenceException;
2729
import org.apache.ibatis.mapping.Environment;
2830
import org.apache.ibatis.session.ExecutorType;
@@ -38,8 +40,6 @@
3840
import org.springframework.transaction.jta.JtaTransactionManager;
3941
import org.springframework.transaction.support.DefaultTransactionDefinition;
4042

41-
import jakarta.transaction.UserTransaction;
42-
4343
class MyBatisSpringTest extends AbstractMyBatisSpringTest {
4444

4545
private SqlSession session;

src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2022 the original author or authors.
2+
* Copyright 2010-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ class SampleSqlSessionTest {
3636
private BarService barService;
3737

3838
@Test
39-
final void testFooService() {
39+
void testFooService() {
4040
User user = this.barService.doSomeBusinessStuff("u1");
4141
assertThat(user).isNotNull();
4242
assertThat(user.getName()).isEqualTo("Pocoyo");

src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2022 the original author or authors.
2+
* Copyright 2010-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,15 +17,15 @@
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919

20+
import jakarta.transaction.UserTransaction;
21+
2022
import org.junit.jupiter.api.Disabled;
2123
import org.junit.jupiter.api.Test;
2224
import org.junit.jupiter.api.extension.ExtendWith;
2325
import org.springframework.beans.factory.annotation.Autowired;
2426
import org.springframework.test.context.junit.jupiter.SpringExtension;
2527
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2628

27-
import jakarta.transaction.UserTransaction;
28-
2929
@Disabled("Yet not found OSS implementation that supported Jakarta EE 9+ APIs")
3030
@ExtendWith(SpringExtension.class)
3131
@SpringJUnitConfig(locations = "classpath:org/mybatis/spring/submitted/xa/applicationContext.xml")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mock-maker-inline

0 commit comments

Comments
 (0)