Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Jul 27, 2012
1 parent 4d2dec5 commit dd20f83
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
4 changes: 3 additions & 1 deletion pom.xml
Expand Up @@ -9,14 +9,16 @@
<version>0.3.4</version>
<packaging>pom</packaging>

<name>Webcam Capture - Root POM</name>
<name>Webcam Capture - Drivers Root POM</name>
<description>This is Webcam Capture root POM</description>

<modules>
<module>webcam-capture</module>
<module>webcam-capture-driver-civil</module>
<module>webcam-capture-driver-jmf</module>
<module>webcam-capture-driver-openimaj</module>
<module>webcam-capture-driver-vlcj</module>
<module>webcam-capture-driver-javacv</module>
</modules>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion webcam-capture-driver-vlcj/pom.xml
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>webcam-capture-driver-vlcj</artifactId>
<name>Webcam Capture - vlcj Driver</name>
<name>Webcam Capture - VLCJ Driver</name>
<description>Webcam Capture driver using vlcj framework to grab frames from camera</description>

<repositories>
Expand Down
Expand Up @@ -22,11 +22,13 @@ public class Webcam {

private static final Logger LOG = LoggerFactory.getLogger(Webcam.class);

private static final List<String> DRIVERS_LIST = new ArrayList<String>(Arrays.asList(new String[] {
private static final String[] DRIVERS_DEFAULT = new String[] {
"com.github.sarxos.webcam.ds.openimaj.OpenImajDriver",
"com.github.sarxos.webcam.ds.civil.LtiCivilDriver",
"com.github.sarxos.webcam.ds.jmf.JmfDriver",
}));
};

private static final List<String> DRIVERS_LIST = new ArrayList<String>(Arrays.asList(DRIVERS_DEFAULT));

private static class ShutdownHook extends Thread {

Expand Down Expand Up @@ -324,7 +326,10 @@ public static void setDriver(Class<? extends WebcamDriver> driverClass) {
}

protected static void clearDriver() {
DRIVERS_LIST.clear();
DRIVERS_LIST.addAll(Arrays.asList(DRIVERS_DEFAULT));
driver = null;
webcams = null;
}

/**
Expand Down
Expand Up @@ -6,7 +6,8 @@

import junit.framework.Assert;

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

import com.github.sarxos.webcam.ds.test.DummyDriver;
Expand All @@ -19,11 +20,17 @@
*/
public class WebcamTest {

@BeforeClass
public static void setUp() {
@Before
public void prepare() {
Webcam.registerDriver(DummyDriver.class);
}

@After
public void cleanup() {
Webcam.clearDriver();
Webcam.clearWebcams();
}

@Test
public void test_getDevices() {

Expand All @@ -47,16 +54,13 @@ public void test_getDefault() {

@Test
public void test_open() {

Webcam webcam = Webcam.getDefault();
webcam.open();

Assert.assertTrue(webcam.isOpen());

webcam.open();

Assert.assertTrue(webcam.isOpen());

webcam = Webcam.getWebcams().get(1);
webcam.getImage();

Expand All @@ -70,13 +74,9 @@ public void test_close() {
webcam.open();

Assert.assertTrue(webcam.isOpen());

webcam.close();

Assert.assertFalse(webcam.isOpen());

webcam.close();

Assert.assertFalse(webcam.isOpen());
}

Expand Down Expand Up @@ -126,9 +126,10 @@ public void test_setDriver() throws InstantiationException {
@Test
public void test_registerDriver() {

Webcam.registerDriver(DummyDriver.class);
Webcam.clearDriver();
Webcam.clearWebcams();

Webcam.registerDriver(DummyDriver.class);
Webcam.getWebcams();
WebcamDriver driver = Webcam.getDriver();

Expand Down
Expand Up @@ -22,8 +22,6 @@ public class DummyDriver2 implements WebcamDriver {
public DummyDriver2() throws InstantiationException {
if (instance == null) {
instance = this;
} else {
throw new InstantiationException("Cannot be constructed twice");
}
}

Expand Down
Expand Up @@ -22,8 +22,6 @@ public class DummyDriver3 implements WebcamDriver {
public DummyDriver3() throws InstantiationException {
if (instance == null) {
instance = this;
} else {
throw new InstantiationException("Cannot be constructed twice");
}
}

Expand Down

0 comments on commit dd20f83

Please sign in to comment.