Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo >> mail # dev >> Using powermock-api-mockito in tests?


Copy link to this message
-
Re: Using powermock-api-mockito in tests?
I do think that the tests that use the MiniDFSCluster (anything that uses AccumuloDFSBase) will fail on Windows. I had to use the following profile in the commons vfs package. Of course the test names will be different here...

<profile>
<id>hdfs</id>
<activation>
<activeByDefault>false</activeByDefault>
<os>
<family>Windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/HdfsFileProviderTest.java</exclude>
<exclude>**/HdfsFileProviderTestCase.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
----- Original Message -----
From: "Dave Marion" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Thursday, March 21, 2013 7:11:11 PM
Subject: RE: Using powermock-api-mockito in tests?
The Hadoop MiniDFSCluster won't work on Windoze. He'll have to exclude most of the new classloader tests from running on that platform.

-----Original Message-----
From: Josh Elser [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2013 6:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Using powermock-api-mockito in tests?

David is trying to build on Windows.

On 03/21/2013 06:40 PM, Dave Marion wrote:
> Out of curiosity, why do you say that " System.getenv() which breaks the tests in AccumuloVFSClassLoaderTest?" It's worked fine for a while. What is different now?
>
> -- Dave
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 21, 2013 5:12 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Using powermock-api-mockito in tests?
>
>
>
> We can do it with PowerMock, no need to add Mockito. This should work, going from memory here. I should be able to help when I get back to a computer if you have problems.
>
>
>
> //Mock the method
>
> PowerMock.mockStatic(System.class, System.class.getMethod("getenv"));
>
>
>
> //Invoke it
>
> Map<String, String> mockSystemProperties = new HashMap<String, String>();
> mockSystemProperties.put("ACCUMULO_HOME", System.getenv("HOME"));
> EasyMock.expect(System.getenv()).andReturn(mockSystemProperties);
>
>
>
> ----- Original Message -----
>
>
> From: "David Medinets" <[EMAIL PROTECTED]>
> To: "accumulo-dev" <[EMAIL PROTECTED]>
> Sent: Thursday, March 21, 2013 4:59:40 PM
> Subject: Using powermock-api-mockito in tests?
>
> Is there any reason why I should not add a dependency in start/pom.xml to powermock-api-mockito? With this library, we can mock the call to
> System.getenv() which breaks the tests in AccumuloVFSClassLoaderTest.
> The two tests need these four lines of setup in order to pass:
>
> Map<String, String> mockSystemProperties = new HashMap<String, String>();
> mockSystemProperties.put("ACCUMULO_HOME", System.getenv("HOME"));
>
> PowerMockito.mockStatic(System.class);
> Mockito.when(System.getenv()).thenReturn(mockSystemProperties);
>
> You'll notice that set ACCUMULO_HOME is set to the value of HOME to make the test cross-platform.
>

NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB