man.setCookiePolicy(CookiePolicy.RFC_2109); URL url = new URL("http://order.now/sub1/moo.html"); man.addCookieFromHeader("test1=moo1;", url); man.addCookieFromHeader("test2=moo2;path=/sub1", url); man.addCookieFromHeader("test2=moo3;path=/", url); assertEquals(3,man.getCookieCount()); //assertEquals("/",man.get(0).getPath()); assertEquals("/sub1",man.get(1).getPath()); assertEquals("/",man.get(2).getPath()); String s = man.getCookieHeaderForURL(url); assertNotNull(s); org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url); assertEquals("/sub1",c[0].getPath()); assertFalse(c[0].isPathAttributeSpecified()); assertEquals("/sub1",c[1].getPath()); assertTrue(c[1].isPathAttributeSpecified()); assertEquals("/",c[2].getPath()); assertTrue(c[2].isPathAttributeSpecified()); assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
URL url = new URL("http://order.now/sub1/moo.html"); man.addCookieFromHeader("test1=moo1;", url); man.addCookieFromHeader("test2=moo2;path=/sub1", url); man.addCookieFromHeader("test2=moo3;path=/", url); assertEquals(3,man.getCookieCount()); assertEquals("/sub1",man.get(0).getPath()); // Defaults to caller URL assertEquals("/sub1",man.get(1).getPath()); assertEquals("/",man.get(2).getPath()); String s = man.getCookieHeaderForURL(url); assertNotNull(s); org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url); assertEquals("/sub1",c[0].getPath()); assertFalse(c[0].isPathAttributeSpecified()); assertEquals("/sub1",c[1].getPath()); assertTrue(c[1].isPathAttributeSpecified()); assertEquals("/",c[2].getPath()); assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
Method name: void testCookiePolicy2109() Method name: void testCookieOrdering2()
Number of AST nodes: 18 Number of AST nodes: 17
1
man.setCookiePolicy(CookiePolicy.RFC_2109);
2
            URL url = new URL("http://order.now/sub1/moo.html");
1
URL url = new URL("http://order.now/sub1/moo.html");
3
            man.addCookieFromHeader("test1=moo1;", url);
2
            man.addCookieFromHeader("test1=moo1;", url);
4
            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
3
            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
5
            man.addCookieFromHeader("test2=moo3;path=/", url);
4
            man.addCookieFromHeader("test2=moo3;path=/", url);
6
            assertEquals(3,man.getCookieCount());
5
            assertEquals(3,man.getCookieCount());
7
            //assertEquals("/",man.get(0).getPath());
6
            assertEquals("/sub1",man.get(0).getPath()); // Defaults to caller URL
8
            assertEquals("/sub1",man.get(1).getPath());
7
            assertEquals("/sub1",man.get(1).getPath());
9
            assertEquals("/",man.get(2).getPath());
8
            assertEquals("/",man.get(2).getPath());
10
            String s = man.getCookieHeaderForURL(url);
9
            String s = man.getCookieHeaderForURL(url);
11
            assertNotNull(s);
10
            assertNotNull(s);
12
            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
11
            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
13
            assertEquals("/sub1",c[0].getPath());
12
            assertEquals("/sub1",c[0].getPath());
14
            assertFalse(c[0].isPathAttributeSpecified());
13
            assertFalse(c[0].isPathAttributeSpecified());
15
            assertEquals("/sub1",c[1].getPath());
14
            assertEquals("/sub1",c[1].getPath());
16
            assertTrue(c[1].isPathAttributeSpecified());
15
            assertTrue(c[1].isPathAttributeSpecified());
17
            assertEquals("/",c[2].getPath());
16
            assertEquals("/",c[2].getPath());
18
            assertTrue(c[2].isPathAttributeSpecified());
17
            assert
19
            assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
18
Equals("test1=moo1; test2=moo2; test2=moo3", s);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are declared in the same class
Number of node comparisons273
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    man.setCookiePolicy(CookiePolicy.RFC_2109);
                                                                                                
    2
    URL url = new URL("http://order.now/sub1/moo.html");
    1
    URL url = new URL("http://order.now/sub1/moo.html");
    3
    man.addCookieFromHeader("test1=moo1;", url);
    2
    man.addCookieFromHeader("test1=moo1;", url);
    4
    man.addCookieFromHeader("test2=moo2;path=/sub1", url);
    3
    man.addCookieFromHeader("test2=moo2;path=/sub1", url);
    5
    man.addCookieFromHeader("test2=moo3;path=/", url);
    4
    man.addCookieFromHeader("test2=moo3;path=/", url);
    6
    assertEquals(3, man.getCookieCount());
    5
    assertEquals(3, man.getCookieCount());
    7
    assertEquals("/sub1", man.get(1).getPath());
    7
    assertEquals("/sub1", man.get(1).getPath());
    6
    assertEquals("/sub1", man.get(0).getPath());
    Differences
    Expression1Expression2Difference
    10LITERAL_VALUE_MISMATCH
    6
    assertEquals("/sub1", man.get(0).getPath());
    8
    assertEquals("/", man.get(2).getPath());
    8
    assertEquals("/", man.get(2).getPath());
    9
    String s = man.getCookieHeaderForURL(url);
    9
    String s = man.getCookieHeaderForURL(url);
    10
    assertNotNull(s);
    10
    assertNotNull(s);
    11
    org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
    11
    org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
    12
    assertEquals("/sub1", c[0].getPath());
    12
    assertEquals("/sub1", c[0].getPath());
    13
    assertFalse(c[0].isPathAttributeSpecified());
    13
    assertFalse(c[0].isPathAttributeSpecified());
    14
    assertEquals("/sub1", c[1].getPath());
    14
    assertEquals("/sub1", c[1].getPath());
    15
    assertTrue(c[1].isPathAttributeSpecified());
    15
    assertTrue(c[1].isPathAttributeSpecified());
    16
    assertEquals("/", c[2].getPath());
    16
    assertEquals("/", c[2].getPath());
    17
    assertTrue(c[2].isPathAttributeSpecified());
    17
    assertTrue(c[2].isPathAttributeSpecified());
    7
    assertEquals("/sub1", man.get(1).getPath());
    Differences
    Expression1Expression2Difference
    assertTrueassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(c[2].isPathAttributeSpecified())assertEquals("/sub1",man.get(1).getPath())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertTrue(c[2].isPathAttributeSpecified()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(c[2].isPathAttributeSpecified()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals("/sub1",man.get(1).getPath()) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(c[2].isPathAttributeSpecified()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(c[2].isPathAttributeSpecified()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals("/sub1",man.get(1).getPath()) is a void method call, and thus it cannot be parameterized
    7
    assertEquals("/sub1", man.get(1).getPath());
    18
    assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
    18
    assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
    17
    assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
    Differences
    Expression1Expression2Difference
    "$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/""test1=moo1; test2=moo2; test2=moo3"LITERAL_VALUE_MISMATCH
    17
    assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
    Precondition Violations (6)
    Row Violation
    1Expression assertTrue(c[2].isPathAttributeSpecified()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertTrue(c[2].isPathAttributeSpecified()) is a void method call, and thus it cannot be parameterized
    3Expression assertEquals("/sub1",man.get(1).getPath()) is a void method call, and thus it cannot be parameterized
    4Expression assertTrue(c[2].isPathAttributeSpecified()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression assertTrue(c[2].isPathAttributeSpecified()) is a void method call, and thus it cannot be parameterized
    6Expression assertEquals("/sub1",man.get(1).getPath()) is a void method call, and thus it cannot be parameterized