This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package se.uhr.nya.application; | |
/* | |
<repositories> | |
<repository> | |
<id>alfresco</id> | |
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url> | |
</repository> | |
<repository> | |
</repositories> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<dependency> | |
<groupId>postgresql</groupId> | |
<artifactId>postgresql</artifactId> | |
<version>9.1-901.jdbc4</version> | |
</dependency> | |
*/ | |
package se.uhr.nya.application; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.zip.ZipEntry; | |
import java.util.zip.ZipInputStream; | |
public class ExcelCompare { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void shouldThrow() | |
} | |
Exception exception = assertThrowsWithMessage(x -> statistikRest.excel(req)); | |
assertThat(exception.getMessage()).isEqualTo("the message from exception"); | |
} | |
private Exception assertThrowsWithMessage(Consumer<String> body) { | |
try { | |
body.accept("foo"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String fileOnClasspathContents(String filename) { | |
InputStream in = this.getClass().getClassLoader().getResourceAsStream(filename); | |
return toString(in); | |
} | |
static String toString(InputStream is) { | |
try (Scanner s = new Scanner(is)) { | |
s.useDelimiter("\\A"); | |
return s.hasNext() ? s.next() : ""; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(CdiRunner.class) | |
public class RepositoryJDBCTest extends RepositoryTest { | |
@Produces | |
DataSource createDataSource() { | |
JdbcDataSource dataSource = new JdbcDataSource(); | |
dataSource.setURL("jdbc:h2:mem:test;MODE=DB2;DB_CLOSE_DELAY=1;INIT=runscript from 'create.sql'"); | |
dataSource.setUser("sa"); | |
dataSource.setPassword("sa"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FunctionalInterface | |
interface SQLFunction<R> { | |
R apply(PreparedStatement t) throws SQLException; | |
} | |
public static Object runQuery(String sql, DataSource ds, SQLFunction f) { | |
logger.debug(sql); | |
Connection connection; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String hasTransaction() { | |
try { | |
TransactionSynchronizationRegistry tsr = | |
(TransactionSynchronizationRegistry) new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry"); | |
int status = tsr.getTransactionStatus(); | |
return (status == Status.STATUS_NO_TRANSACTION) ? "no" : "yes:" + status; | |
} catch (Exception ex) { | |
logger.info("Failed deciding transaction status", ex); | |
return "unknown"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.fest.assertions.Assertions.assertThat; | |
import java.nio.ByteBuffer; | |
import java.nio.CharBuffer; | |
import java.nio.charset.Charset; | |
import java.nio.charset.CharsetDecoder; | |
import java.nio.charset.CoderResult; | |
import java.nio.charset.CodingErrorAction; | |
import org.junit.Test; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)wait:(NSTimeInterval)timeout secondsOrUntil:(BOOL(^)())operationDone | |
{ | |
NSTimeInterval idle = 0.01; // Number of seconds to pause within loop | |
BOOL timedOut = NO; | |
NSDate *timeoutDate = [[NSDate alloc] initWithTimeIntervalSinceNow:timeout]; | |
while (!timedOut && !operationDone()) | |
{ | |
NSDate *tick = [[NSDate alloc] initWithTimeIntervalSinceNow:idle]; | |
[[NSRunLoop currentRunLoop] runUntilDate:tick]; |
NewerOlder