Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Elektron /
  • EMA /
avatar image
Question by daniel.lipofsky · May 03 at 08:49 PM · ema-apijavajunit

creating FieldEntry for unit tests

I'm using EMA Java 3.6.5.0 and I would like to write some unit tests. I see elsewhere descriptions on how to use replayers or mock providers, which are really more like integration tests, but I am wanting to write some simple unit tests that run with junit at compile time and do not require spinning up a separate process, so I want to create a FieldEntry and pass it to my methods. I tried the following

FieldEntry field = EmaFactory.createFieldEntry().real(1234, 999, OmmReal.MagnitudeType.EXPONENT_NEG_2);
System.out.println(field.toString());
System.out.println("id="+field.fieldId());
System.out.println("load="+field.load());
System.out.println("code="+field.code());

FieldEntry field = EmaFactory.createFieldEntry().codeReal(5678);
System.out.println(field.toString());
System.out.println("id="+field.fieldId());
System.out.println("load="+field.load());
System.out.println("code="+field.code());

But load() is null and code() throws NullPointerException and toString() returns "Decoding of just encoded object in the same application is not supported".

How can I do this?

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

7 Replies

  • Sort: 
avatar image
REFINITIV
Answer by umer.nalla · May 04 at 09:12 AM

Hi @daniel.lipofsky

As stated in the error message, EMA does not support the decoding of a just encoded message.

However, if you refer to the existing EMA C++ post below - this may help you achieve something similar in EMA Java

decode of just encoded object in EMA C++ - Forum | Refinitiv Developer Community

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
daniel.lipofsky · May 04 at 05:01 PM 0
Share

@umer.nalla that C++ example relies on the import of a StaticDecoder class. Is there an equivalent in Java? I don't see anything similarly named.

avatar image
REFINITIV
Answer by Jirapongse · May 05 at 02:03 AM

@daniel.lipofsky

I checked and found that the RTSDK Java package provides JUnitTestConnect.

You can see the examples in the Java\Ema\Core\src\test\java\com\refinitiv\ema\unittest directory, such as FieldListTests.java.

        // Decode FieldList with EMA.
        com.refinitiv.ema.access.FieldList fl = JUnitTestConnect.createFieldList();
        JUnitTestConnect.setRsslData(fl, buf, Codec.majorVersion(), Codec.minorVersion(), TestUtilities.getDataDictionary(), null);


Comment
umer.nalla

People who like this

1 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Answer by daniel.lipofsky · May 05 at 07:47 PM

@Jirapongse JUnitTestConnect is part of com.refinitiv.ema.ema.3.6.5.0 but TestUtilities is not. Is this included in another JAR?

@umer.nalla I do not see any Java equivalent to that C++ StaticDecoder class you linked to.

Comment

People who like this

0 Show 2 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Jirapongse ♦♦ · May 06 at 01:38 AM 0
Share

@daniel.lipofsky

The source code of TestUtilities is in the package.

RTSDK Java doesn't provide StaticDecoder. It uses JUnitTestConnect for unit tests.

avatar image
daniel.lipofsky Jirapongse ♦♦ · May 09 at 05:19 PM 0
Share

@Jirapongse I see TestUtilities in the SDK code but not in the JAR. I assume if I built the test JAR myself I would see it, but is there a reason you don't push the test jar to maven central (search.maven.org)? That would make it much more convenient. I am trying to build it myself, but I am running into cert issues, and since I don't normally use gradle I do not know how to troubleshoot.

avatar image
REFINITIV
Answer by Jirapongse · May 10 at 05:14 AM

@daniel.lipofsky

The TestUtilities class contains the code for our unit tests. It implements the encoding and decoding logic for test data used by the unit tests.

Typically, users need to implement their own encoding and decoding logic to test their specific data. I think this is why it wasn't included in the jar file.


Comment

People who like this

0 Show 3 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
daniel.lipofsky · May 10 at 04:27 PM 0
Share

Usually SDKs exist so that users don't have to implement their own encoding and decoding logic. That's a huge level of effort and a user shouldn't have to understand the underlying encoding/decoding details to implement a simple unit test.

avatar image
REFINITIV
Jirapongse ♦♦ daniel.lipofsky · May 11 at 03:07 AM 0
Share

@daniel.lipofsky

Yes, you are correct. However, EMA has a limitation that "Decoding of just encoded object in the same application is not supported".

Therefore, to create a field list for unit tests, we need ETA to encode the test data into a buffer. Then, use JUnitTestConnect to create a filed list and encode the buffer into the field list. Finally, use EMA to decode the field list.

avatar image
daniel.lipofsky Jirapongse ♦♦ · May 11 at 01:11 PM 0
Share

please then consider this a feature request: please add a utility to make it easy for your users to do this. It can be in a test jar, but it would be nice if that jar was published to maven central

avatar image
REFINITIV
Answer by wasin.w · May 12 at 11:04 AM

Hello @daniel.lipofsky

I found that you have submitted issues-197 on GitHub to the development team.

If you are using Maven, please be informed that you can build the code in Java/Ema/Core/src/test/ folder by adding the following dependencies in the pom.xml file

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.9.5</version>
</dependency>

Hope this helps.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Answer by daniel.lipofsky · May 12 at 03:47 PM

@wasin.w There is no pom.xml in the Real-Time-SDK project

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by wasin.w · May 17 at 04:23 AM

Hello @daniel.lipofsky

The RTSDK comes with Gradle build system/script by default. However, as the SDK libraries are available on the Maven central, so you can use the RTSDK with your Maven pom.xml as the following example:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>


    <groupId>com.refinitiv.ema</groupId>
    <artifactId>RTSDKJ_Maven</artifactId>
    <version>1.0</version>
    <name>RTSDKJ_Maven</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <rtsdk.version>3.6.5.0</rtsdk.version>
    </properties>


    <dependencies>
          
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.5</version>
        </dependency>


        <dependency>
            <groupId>com.refinitiv.ema</groupId>
            <artifactId>ema</artifactId>
            <version>${rtsdk.version}</version>
        </dependency>
    </dependencies>   
</project>

You can find more detail in the How to Set Up Refinitiv Real-Time SDK Java Application with Maven article.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

EMA Java client errored to connect using Elektron Connect

How to use RDMFieldDictionary using EMA java API ?

When would RSSL_ENCRYPTED channel be available in EMA Java?

How to configure EMA Java to use log4j as the underlying logging backend?​

EMA - How do I reset view to get all fields?

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • FX Venues
    • FX Trading – RFQ Maker
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • Yield Book Analytics
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges