2 new revisions:
Revision: cc7a1c394fcc
Branch: default
Author: Nick Tindall <
ntin...@aconex.com>
Date: Tue Apr 22 03:24:27 2014 UTC
Log: Make HashingIdentifierSource public
http://code.google.com/p/parfait/source/detail?r=cc7a1c394fcc
Revision: d415d0010b84
Branch: default
Author: Nick Tindall <
ntin...@aconex.com>
Date: Tue Apr 22 03:25:31 2014 UTC
Log: Make reset() set started flag to false in BasePcpWriter
http://code.google.com/p/parfait/source/detail?r=d415d0010b84
==============================================================================
Revision: cc7a1c394fcc
Branch: default
Author: Nick Tindall <
ntin...@aconex.com>
Date: Tue Apr 22 03:24:27 2014 UTC
Log: Make HashingIdentifierSource public
http://code.google.com/p/parfait/source/detail?r=cc7a1c394fcc
Modified:
/dxm/src/main/java/com/custardsource/parfait/dxm/HashingIdentifierSource.java
=======================================
---
/dxm/src/main/java/com/custardsource/parfait/dxm/HashingIdentifierSource.java
Tue Apr 13 02:07:34 2010 UTC
+++
/dxm/src/main/java/com/custardsource/parfait/dxm/HashingIdentifierSource.java
Tue Apr 22 03:24:27 2014 UTC
@@ -2,7 +2,7 @@
import java.util.Set;
-class HashingIdentifierSource implements IdentifierSource {
+public class HashingIdentifierSource implements IdentifierSource {
private final int allowedIdentifierCount;
public HashingIdentifierSource(int allowedIdentifierCount) {
==============================================================================
Revision: d415d0010b84
Branch: default
Author: Nick Tindall <
ntin...@aconex.com>
Date: Tue Apr 22 03:25:31 2014 UTC
Log: Make reset() set started flag to false in BasePcpWriter
http://code.google.com/p/parfait/source/detail?r=d415d0010b84
Modified:
/.hgignore
/dxm/pom.xml
/dxm/src/main/java/com/custardsource/parfait/dxm/BasePcpWriter.java
/dxm/src/test/java/com/custardsource/parfait/dxm/PcpMmvWriterTest.java
=======================================
--- /.hgignore Mon Feb 20 04:13:14 2012 UTC
+++ /.hgignore Tue Apr 22 03:25:31 2014 UTC
@@ -7,3 +7,5 @@
.*\.classpath
.*\.prefs
atlassian-ide-plugin.xml
+\.idea
+
=======================================
--- /dxm/pom.xml Mon Feb 20 04:18:18 2012 UTC
+++ /dxm/pom.xml Tue Apr 22 03:25:31 2014 UTC
@@ -44,6 +44,11 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<repositories>
<repository>
=======================================
--- /dxm/src/main/java/com/custardsource/parfait/dxm/BasePcpWriter.java Sat
Feb 18 02:51:18 2012 UTC
+++ /dxm/src/main/java/com/custardsource/parfait/dxm/BasePcpWriter.java Tue
Apr 22 03:25:31 2014 UTC
@@ -224,6 +224,7 @@
@Override
public void reset() {
+ started = false;
metricData.clear();
}
=======================================
--- /dxm/src/test/java/com/custardsource/parfait/dxm/PcpMmvWriterTest.java
Wed Dec 22 10:37:53 2010 UTC
+++ /dxm/src/test/java/com/custardsource/parfait/dxm/PcpMmvWriterTest.java
Tue Apr 22 03:25:31 2014 UTC
@@ -1,7 +1,21 @@
package com.custardsource.parfait.dxm;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.measure.unit.Unit;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import com.custardsource.parfait.dxm.semantics.Semantics;
+import com.custardsource.parfait.dxm.types.MmvMetricType;
+import com.custardsource.parfait.dxm.types.TypeHandler;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
public class PcpMmvWriterTest {
@@ -32,6 +46,36 @@
pcpMmvWriter.setClusterIdentifier(-1);
}
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void ensureUpdatesAreIgnoredAfterResetIsCalled() throws
IOException {
+ MetricName metricName = MetricName.parse("some.metric");
+ TypeHandler<CustomType> customTypeTypeHandler =
mock(TypeHandler.class);
+
when(customTypeTypeHandler.getMetricType()).thenReturn(MmvMetricType.DOUBLE);
+ pcpMmvWriter.registerType(CustomType.class, customTypeTypeHandler);
+ pcpMmvWriter.start();
+ pcpMmvWriter.reset();
+ Mockito.reset(customTypeTypeHandler);
+ pcpMmvWriter.addMetric(metricName, Semantics.COUNTER, Unit.ONE,
new CustomType());
+ pcpMmvWriter.updateMetric(metricName, new CustomType());
+ verify(customTypeTypeHandler,
never()).putBytes(any(ByteBuffer.class), any(CustomType.class));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void ensureSetPerMetricLockIsNotAllowedWhenWriterIsStarted()
throws IOException {
+ pcpMmvWriter.start();
+ pcpMmvWriter.setPerMetricLock(true);
+ }
+
+ @Test
+ public void ensureSetPerMetricLockIsAllowedAfterResetIsCalled() throws
IOException {
+ pcpMmvWriter.start();
+ pcpMmvWriter.reset();
+ pcpMmvWriter.setPerMetricLock(true);
+ }
+
+ class CustomType {}
}