Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adding -XX:-UseSplitVerifier to surefire CLI args to try and coax cob…
…ertura into instrumenting Java7 better
  • Loading branch information
barmintor committed Apr 30, 2013
1 parent f1e5a41 commit 894861d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 17 deletions.
@@ -0,0 +1,58 @@
package org.fcrepo.messaging.legacy;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
import javax.jcr.observation.Event;

import javax.jms.JMSException;
import javax.jms.Message;

import org.apache.abdera.model.Category;
import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Person;
import org.apache.abdera.model.Text;
import org.fcrepo.utils.FedoraJcrTypes;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

public class LegacyMethodStaticTest {

@Before
public void setUp() throws RepositoryException {
}

@Test
public void testCanParse() throws JMSException {
// Should the static tests be broken out into a separate test class, so we can use PowerMock with better scope?
boolean result;
Message mockYes = mock(Message.class);
when(mockYes.getJMSType()).thenReturn(LegacyMethod.FORMAT);
when(mockYes.getStringProperty("methodName")).thenReturn("ingest");
result = LegacyMethod.canParse(mockYes);
assertEquals(true, result);
Message mockNoFormat = mock(Message.class);
when(mockNoFormat.getJMSType()).thenReturn("crazyType");
when(mockNoFormat.getStringProperty("methodName")).thenReturn("ingest");
result = LegacyMethod.canParse(mockNoFormat);
assertEquals(false, result);
Message mockNoMessage = mock(Message.class);
when(mockNoMessage.getJMSType()).thenReturn(LegacyMethod.FORMAT);
when(mockNoMessage.getStringProperty("methodName")).thenReturn("destroyEverything");
result = LegacyMethod.canParse(mockNoMessage);
assertEquals(false, result);
}
}
Expand Up @@ -3,6 +3,8 @@
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -77,23 +79,7 @@ public void setUp() throws RepositoryException {
// construct the test object
testObj = new LegacyMethod(mockEvent, mockSource);
}

public void testCanParse() throws JMSException {
// Should the static tests be broken out into a separate test class, so we can use PowerMock with better scope?
Message mockYes = mock(Message.class);
when(mockYes.getJMSType()).thenReturn(LegacyMethod.FORMAT);
when(mockYes.getStringProperty("methodName")).thenReturn("ingest");
assertEquals(true, LegacyMethod.canParse(mockYes));
Message mockNoFormat = mock(Message.class);
when(mockYes.getJMSType()).thenReturn("crazyType");
when(mockYes.getStringProperty("methodName")).thenReturn("ingest");
assertEquals(false, LegacyMethod.canParse(mockNoFormat));
Message mockNoMessage = mock(Message.class);
when(mockYes.getJMSType()).thenReturn(LegacyMethod.FORMAT);
when(mockYes.getStringProperty("methodName")).thenReturn("destroyEverything");
assertEquals(false, LegacyMethod.canParse(mockNoMessage));
}


@Test
public void testPidAccessors() {
String newPid = "newPid";
Expand Down Expand Up @@ -159,4 +145,11 @@ public void testSetContent() {
testObj.setContent("foo");
verify(mockDelegate).setContent("foo");
}

@Test
public void testWriteTo() throws IOException {
Writer mockWriter = mock(Writer.class);
testObj.writeTo(mockWriter);
verify(mockDelegate).writeTo(mockWriter);
}
}
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -616,6 +616,7 @@
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.14</version>
<configuration>
<argLine>-XX:-UseSplitVerifier</argLine>
<outputName>surefire-report</outputName>
<aggregate>true</aggregate>
<reportsDirectories>
Expand Down

0 comments on commit 894861d

Please sign in to comment.