2025 init
This commit is contained in:
54
code/tp3-balanced-strings/pom.xml
Normal file
54
code/tp3-balanced-strings/pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>fr.istic.vv</groupId>
|
||||
<artifactId>tp3-balanced-strings</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-junit5-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
private StringUtils() {}
|
||||
|
||||
public static boolean isBalanced(String str) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static fr.istic.vv.StringUtils.isBalanced;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class StringUtilsTest {
|
||||
|
||||
|
||||
}
|
||||
54
code/tp3-date/pom.xml
Normal file
54
code/tp3-date/pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>fr.istic.vv</groupId>
|
||||
<artifactId>tp3-date</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-junit5-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
17
code/tp3-date/src/main/java/fr/istic/vv/Date.java
Normal file
17
code/tp3-date/src/main/java/fr/istic/vv/Date.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
class Date implements Comparable<Date> {
|
||||
|
||||
public Date(int day, int month, int year) { }
|
||||
|
||||
public static boolean isValidDate(int day, int month, int year) { return false; }
|
||||
|
||||
public static boolean isLeapYear(int year) { return false; }
|
||||
|
||||
public Date nextDate() { return null; }
|
||||
|
||||
public Date previousDate() { return null; }
|
||||
|
||||
public int compareTo(Date other) { return 0; }
|
||||
|
||||
}
|
||||
10
code/tp3-date/src/test/java/fr/istic/vv/DateTest.java
Normal file
10
code/tp3-date/src/test/java/fr/istic/vv/DateTest.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DateTest {
|
||||
|
||||
|
||||
}
|
||||
54
code/tp3-heap/pom.xml
Normal file
54
code/tp3-heap/pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>fr.istic.vv</groupId>
|
||||
<artifactId>tp3-heap</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-junit5-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
17
code/tp3-heap/src/main/java/fr/istic/vv/BinaryHeap.java
Normal file
17
code/tp3-heap/src/main/java/fr/istic/vv/BinaryHeap.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class BinaryHeap<T> {
|
||||
|
||||
public BinaryHeap(Comparator<T> comparator) { }
|
||||
|
||||
public T pop() { return null; }
|
||||
|
||||
public T peek() { return null; }
|
||||
|
||||
public void push(T element) { }
|
||||
|
||||
public int count() { return 0; }
|
||||
|
||||
}
|
||||
10
code/tp3-heap/src/test/java/fr/istic/vv/BinaryHeapTest.java
Normal file
10
code/tp3-heap/src/test/java/fr/istic/vv/BinaryHeapTest.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class BinaryHeapTest {
|
||||
|
||||
|
||||
}
|
||||
61
code/tp3-ssl/pom.xml
Normal file
61
code/tp3-ssl/pom.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>fr.istic.vv</groupId>
|
||||
<artifactId>tp3-ssl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-junit5-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
11
code/tp3-ssl/src/main/java/fr/istic/vv/SSLSocket.java
Normal file
11
code/tp3-ssl/src/main/java/fr/istic/vv/SSLSocket.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
public interface SSLSocket {
|
||||
|
||||
public String[] getSupportedProtocols() ;
|
||||
|
||||
public String[] getEnabledProtocols();
|
||||
|
||||
public void setEnabledProtocols(String[] protocols);
|
||||
|
||||
}
|
||||
29
code/tp3-ssl/src/main/java/fr/istic/vv/TLSProtocol.java
Normal file
29
code/tp3-ssl/src/main/java/fr/istic/vv/TLSProtocol.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
/**
|
||||
* TLS protocols arranged in descending order of security preference in terms of
|
||||
* their ordinal numbers. See <a href=
|
||||
* "http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#jssenames"
|
||||
* >JSSE Standard Names</a>.
|
||||
*/
|
||||
public enum TLSProtocol {
|
||||
TLSv1_2("TLSv1.2"), // most secure/preferred
|
||||
TLSv1_1("TLSv1.1"),
|
||||
TLSv1("TLSv1"),
|
||||
TLS("TLS"), // least secure/preferred, but acceptable
|
||||
;
|
||||
private final String protocolName;
|
||||
|
||||
private TLSProtocol(String protocolName) {
|
||||
this.protocolName = protocolName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding TLS protocol name as per the <a href=
|
||||
* "http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#jssenames"
|
||||
* >JSSE Standard Names</a>
|
||||
*/
|
||||
String getProtocolName() {
|
||||
return protocolName;
|
||||
}
|
||||
}
|
||||
58
code/tp3-ssl/src/main/java/fr/istic/vv/TLSSocketFactory.java
Normal file
58
code/tp3-ssl/src/main/java/fr/istic/vv/TLSSocketFactory.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TLSSocketFactory {
|
||||
|
||||
|
||||
public void prepareSocket(SSLSocket socket) {
|
||||
|
||||
String[] supported = socket.getSupportedProtocols();
|
||||
String[] enabled = socket.getEnabledProtocols();
|
||||
|
||||
|
||||
List<String> target = new ArrayList<String>();
|
||||
if (supported != null) {
|
||||
// Append the preferred protocols in descending order of preference
|
||||
// but only do so if the protocols are supported
|
||||
TLSProtocol[] values = TLSProtocol.values();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
final String pname = values[i].getProtocolName();
|
||||
if (existsIn(pname, supported)) {
|
||||
target.add(pname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enabled != null) {
|
||||
// Append the rest of the already enabled protocols to the end
|
||||
// if not already included in the list
|
||||
for (String pname : enabled) {
|
||||
if (!target.contains(pname)) {
|
||||
target.add(pname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target.size() > 0) {
|
||||
String[] enabling = target.toArray(new String[target.size()]);
|
||||
socket.setEnabledProtocols(enabling);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given element exists in the given array; false otherwise.
|
||||
*/
|
||||
private boolean existsIn(String element, String[] a) {
|
||||
for (String s : a) {
|
||||
if (element.equals(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TLSSocketFactoryTest {
|
||||
|
||||
/**
|
||||
* Test when the edge case when the both supported and enabled protocols are null.
|
||||
*/
|
||||
@Test
|
||||
public void preparedSocket_NullProtocols() {
|
||||
TLSSocketFactory f = new TLSSocketFactory();
|
||||
f.prepareSocket(new SSLSocket() {
|
||||
|
||||
public String[] getSupportedProtocols() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] getEnabledProtocols() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEnabledProtocols(String[] protocols) {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typical() {
|
||||
TLSSocketFactory f = new TLSSocketFactory();
|
||||
f.prepareSocket(new SSLSocket() {
|
||||
@Override
|
||||
public String[] getSupportedProtocols() {
|
||||
return shuffle(new String[]{"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"});
|
||||
}
|
||||
@Override
|
||||
public String[] getEnabledProtocols() {
|
||||
return shuffle(new String[]{"SSLv3", "TLSv1"});
|
||||
}
|
||||
@Override
|
||||
public void setEnabledProtocols(String[] protocols) {
|
||||
assertTrue(Arrays.equals(protocols, new String[] {"TLSv1.2", "TLSv1.1", "TLSv1", "SSLv3" }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private String[] shuffle(String[] in) {
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(in));
|
||||
Collections.shuffle(list);
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.istic.vv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TLSSocketFactoryTestMocks {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user