Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Dec 21, 2016
2 parents b509c23 + 423d0dc commit df9b300
Show file tree
Hide file tree
Showing 36 changed files with 884 additions and 234 deletions.
5 changes: 5 additions & 0 deletions case-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<artifactId>computation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.cases;

import org.junit.Test;

/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class CoverageTest {

@Test
public void testNothing() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class MemoryMapFileMock implements MemoryMappedFile {

@Override
public boolean exists() {
return false;
}

@Override
public ByteBuffer getBuffer(int size) throws IOException {
return ByteBuffer.allocate(size);
}

@Override
public void close() throws IOException {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface MemoryMappedFile extends AutoCloseable {

boolean exists();

ByteBuffer getBuffer(int size) throws IOException ;

@Override
void close() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import java.io.File;
import java.io.IOException;

/**
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface MemoryMappedFileFactory {

MemoryMappedFile create(File file) throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Objects;

/**
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class MemoryMappedFileImpl implements MemoryMappedFile {

private final File file;

private RandomAccessFile raf;

public MemoryMappedFileImpl(File file) throws IOException {
this.file = Objects.requireNonNull(file);
}

@Override
public boolean exists() {
return file.exists();
}

@Override
public ByteBuffer getBuffer(int size) throws IOException {
if (raf == null) {
raf = new RandomAccessFile(file, "rw");
}
return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size);
}

@Override
public void close() throws IOException {
if (raf != null) {
raf.close();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.nio.ByteBuffer;

import static org.junit.Assert.*;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class MemoryMapFileMockTest {

private MemoryMappedFile memoryMappedFile;

@Before
public void setUp() {
memoryMappedFile = new MemoryMapFileMock();
}

@After
public void tearDown() throws IOException {
memoryMappedFile.close();
}

@Test
public void exists() {
assertFalse(memoryMappedFile.exists());
}

@Test
public void getBuffer() throws IOException {
ByteBuffer buffer = memoryMappedFile.getBuffer(100);
assertNotNull(buffer);
assertEquals(buffer.remaining(), 100);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.commons.io.mmap;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import java.io.IOException;
import java.nio.ByteBuffer;

import static org.junit.Assert.*;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class MemoryMappedFileImplTest {

@Rule
public final TemporaryFolder folder = new TemporaryFolder();

private MemoryMappedFile memoryMappedFile;

@Before
public void setUp() throws IOException {
memoryMappedFile = new MemoryMappedFileImpl(folder.newFile());
}

@After
public void tearDown() throws IOException {
memoryMappedFile.close();
}

@Test
public void exists() {
assertTrue(memoryMappedFile.exists());
}

@Test
public void getBuffer() throws IOException {
ByteBuffer buffer = memoryMappedFile.getBuffer(100);
assertNotNull(buffer);
assertEquals(buffer.remaining(), 100);
}

}
5 changes: 5 additions & 0 deletions computation-local/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@
<artifactId>computation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.computation.local;

import org.junit.Test;

/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class CoverageTest {

@Test
public void testNothing() {
}
}
5 changes: 5 additions & 0 deletions computation-mpi-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<artifactId>iidm-network-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.computation.mpi.util;

import org.junit.Test;

/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class CoverageTest {

@Test
public void testNothing() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.computation;

import org.junit.Test;

/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class CoverageTest {

@Test
public void testNothing() {
}
}
5 changes: 5 additions & 0 deletions contingency-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<artifactId>iidm-network-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.contingency;

import org.junit.Test;

/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class CoverageTest {

@Test
public void testNothing() {
}
}
Loading

0 comments on commit df9b300

Please sign in to comment.